/* Eigo Dojo — no external fonts, no external assets, no third-party CSS.
   System font stacks only, so nothing needs to be licensed or downloaded. */

:root {
  --bg: #0b0e14;
  --bg-soft: #121722;
  --card: #161c28;
  --card-2: #1c2432;
  --line: #27303f;
  --text: #e6ebf2;
  --text-dim: #93a0b4;
  --text-faint: #64708a;
  --accent: #e2574c;
  --accent-2: #f0a03c;
  --good: #4ec9a0;
  --info: #5aa9f0;
  --purple: #a77bf0;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  --font: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo,
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa;
    --bg-soft: #eaeef5;
    --card: #ffffff;
    --card-2: #f2f5fa;
    --line: #dde3ec;
    --text: #161d2b;
    --text-dim: #5b6779;
    --text-faint: #8b95a6;
    --shadow: 0 6px 20px rgba(20, 30, 50, 0.08);
  }
}

* {
  box-sizing: border-box;
}

/* Views set their own display, which would otherwise beat the UA rule for
   [hidden]. Keep the attribute authoritative. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--info);
}

/* ------------------------------- top bar ------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px clamp(12px, 3vw, 28px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 4px;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--accent), #b3372f);
  color: #fff;
  font-weight: 700;
  font-size: 19px;
  flex: none;
}

.brand-text strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.brand-text small {
  display: block;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.hud {
  display: flex;
  gap: clamp(8px, 2vw, 20px);
}

.hud-item {
  text-align: right;
  line-height: 1.15;
}

.hud-value {
  display: block;
  font-weight: 700;
  font-size: clamp(12px, 2.6vw, 14px);
  white-space: nowrap;
}

.hud-label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.rankbar {
  position: sticky;
  top: 57px;
  z-index: 29;
  height: 3px;
  background: var(--line);
}

.rankbar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.6s cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* ------------------------------- layout ------------------------------- */

#main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 20px) 40px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.grid-2 {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(14px, 3vw, 20px);
}

.card-title {
  margin: 0 0 12px;
  font-size: 14px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.card-title small {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-faint);
}

/* ------------------------------- buttons ------------------------------- */

.btn {
  border: 1px solid var(--line);
  background: var(--card-2);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.12);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(140deg, var(--accent), #c2433a);
  border-color: transparent;
  color: #fff;
}

.btn-accent {
  background: linear-gradient(140deg, var(--accent-2), #d8842a);
  border-color: transparent;
  color: #241503;
}

.btn-ghost {
  background: transparent;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}

.btn-icon {
  padding: 9px 11px;
  font-size: 17px;
  line-height: 1;
}

.btn-icon.listening {
  background: var(--accent);
  border-color: transparent;
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    filter: brightness(1.45);
  }
}

.linklike {
  background: none;
  border: 0;
  color: var(--text-dim);
  text-decoration: underline;
  cursor: pointer;
  font-size: 12px;
  padding: 4px;
}

.linklike.danger {
  color: var(--accent);
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}

/* ------------------------------- daily ------------------------------- */

.daily {
  background: linear-gradient(150deg, var(--card), var(--card-2));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

.daily-tag {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent-2);
  font-weight: 700;
  text-transform: uppercase;
}

.daily-title {
  margin: 8px 0 2px;
  font-size: clamp(20px, 4.4vw, 27px);
  line-height: 1.3;
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.daily-emoji {
  font-size: 1.1em;
}

.daily-en {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.daily-goal {
  margin: 12px 0 16px;
  padding: 10px 13px;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text-dim);
}

.daily-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.daily-note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--good);
}

/* ------------------------------- quests ------------------------------- */

.quests {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quest {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.quest.done {
  border-color: color-mix(in srgb, var(--good) 45%, transparent);
}

.quest-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 12px;
  flex: none;
}

.quest.done .quest-check {
  background: var(--good);
  border-color: var(--good);
  color: #05201a;
}

.quest-body {
  flex: 1;
  min-width: 0;
}

.quest-title {
  font-weight: 600;
  font-size: 13px;
}

.quest.done .quest-title {
  text-decoration: line-through;
  color: var(--text-dim);
}

.quest-hint {
  font-size: 11px;
  color: var(--text-faint);
}

.quest-xp {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-2);
  flex: none;
}

/* ------------------------------- chart ------------------------------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 96px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.chart-bar {
  flex: 1;
  min-width: 3px;
  background: linear-gradient(to top, var(--accent), var(--accent-2));
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}

.chart-empty {
  color: var(--text-faint);
  font-size: 12px;
  align-self: center;
  margin: auto;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 17px;
  font-weight: 700;
}

.stat-label {
  display: block;
  font-size: 10px;
  color: var(--text-faint);
}

/* ------------------------------- ranks ------------------------------- */

.ranklist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 190px;
  overflow-y: auto;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.rank-row.reached {
  background: var(--bg-soft);
}

.rank-row.current {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-soft));
  font-weight: 700;
}

.rank-row.locked {
  opacity: 0.42;
}

.rank-xp {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
}

/* ------------------------------- badges ------------------------------- */

.badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.badge {
  text-align: center;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid transparent;
}

.badge.locked {
  opacity: 0.33;
  filter: grayscale(1);
}

.badge.earned {
  border-color: color-mix(in srgb, var(--accent-2) 45%, transparent);
}

.badge-emoji {
  font-size: 22px;
  display: block;
}

.badge-name {
  font-size: 11px;
  font-weight: 600;
  display: block;
  margin-top: 2px;
}

.badge-desc {
  font-size: 10px;
  color: var(--text-faint);
  display: block;
  line-height: 1.35;
}

/* ------------------------------- history ------------------------------- */

.history {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.history-when {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11px;
  flex: none;
}

.history-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-score {
  font-weight: 700;
  flex: none;
}

.empty {
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: center;
  padding: 18px 0;
}

/* ------------------------------- setup ------------------------------- */

.partners,
.levels,
.scenarios {
  display: grid;
  gap: 8px;
}

.partners {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.levels {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.scenarios {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}

.choice {
  text-align: left;
  background: var(--bg-soft);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.choice:hover:not(:disabled) {
  background: var(--card-2);
}

.choice.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-soft));
}

.choice:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.choice-title {
  font-weight: 700;
  font-size: 13.5px;
  display: flex;
  gap: 7px;
  align-items: center;
}

.choice-sub {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.45;
}

.choice-lock {
  font-size: 10.5px;
  color: var(--accent-2);
}

.choice-flag {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 0.08em;
}

/* ------------------------------- chat ------------------------------- */

.view-chat {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 140px);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.chat-who {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--card-2);
  font-size: 20px;
  flex: none;
}

.chat-who strong {
  display: block;
  font-size: 14px;
}

.chat-who small {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--text-dim);
  white-space: nowrap;
}

.mission {
  margin: 10px 0;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-2);
}

.log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 2px 12px;
  min-height: 200px;
}

.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: rise 0.22s ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.msg.partner {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}

.msg.me {
  align-self: flex-end;
  background: linear-gradient(140deg, var(--accent), #bf4139);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-faint);
  font-size: 12px;
  max-width: 100%;
  text-align: center;
  padding: 4px;
}

.msg-speak {
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.5;
  padding: 0 0 0 6px;
}

.msg-speak:hover {
  opacity: 1;
}

.typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 13px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 5px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: blink 1.3s infinite;
}

.typing span:nth-child(2) {
  animation-delay: 0.18s;
}

.typing span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes blink {
  0%,
  60%,
  100% {
    opacity: 0.25;
  }
  30% {
    opacity: 1;
  }
}

.assist {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 8px;
  background: var(--card);
}

.assist-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}

.assist-option {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  margin-bottom: 6px;
  cursor: pointer;
}

.assist-option:hover {
  border-color: var(--accent);
}

.assist-en {
  font-size: 13.5px;
  font-weight: 600;
}

.assist-ja {
  font-size: 11.5px;
  color: var(--text-faint);
}

.composer {
  display: flex;
  gap: 7px;
  align-items: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  line-height: 1.5;
  font-size: 15px;
}

.composer textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: -1px;
}

.chat-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  flex-wrap: wrap;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}

/* ------------------------------- report ------------------------------- */

.report-hero {
  display: flex;
  align-items: center;
  gap: clamp(14px, 4vw, 28px);
  flex-wrap: wrap;
  background: linear-gradient(150deg, var(--card), var(--card-2));
}

.cefr {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--info), var(--purple));
  color: #fff;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex: none;
}

.report-number {
  font-size: 46px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.report-label {
  font-size: 11px;
  color: var(--text-faint);
}

.xp-gain {
  margin-left: auto;
  text-align: right;
  font-size: 12px;
  color: var(--text-dim);
}

.xp-gain strong {
  display: block;
  font-size: 21px;
  color: var(--accent-2);
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: 96px 1fr 34px;
  align-items: center;
  gap: 9px;
  font-size: 12px;
}

.bar-track {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0;
  transition: width 0.8s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.bar-value {
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
}

.summary {
  margin: 14px 0 0;
  padding: 11px 13px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.unlocks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.unlock {
  padding: 8px 13px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-2) 20%, var(--bg-soft));
  border: 1px solid color-mix(in srgb, var(--accent-2) 45%, transparent);
  font-size: 12.5px;
  font-weight: 600;
}

.plain {
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.plain .ja {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
}

.fixes {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.fix {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}

.fix-you {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent);
}

.fix-better {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--good);
  margin-top: 3px;
}

.fix-why {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 5px;
}

/* ------------------------------- misc ------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 60;
  max-width: min(92vw, 460px);
  text-align: center;
  animation: rise 0.2s ease-out;
}

.footer {
  border-top: 1px solid var(--line);
  padding: 18px clamp(12px, 3vw, 28px) 34px;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.7;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.footer p {
  margin: 0 0 8px;
}

.footer-privacy strong {
  color: var(--text-dim);
}

.footer-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
