/* TalkTrail — clean & modern, auto light/dark */
:root {
  --bg: #f7f7f9;
  --card: #ffffff;
  --text: #1b1d23;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f766e;        /* teal trail */
  --accent-soft: #ccfbf1;
  --accent-text: #ffffff;
  --good: #15803d;
  --good-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --hi: #7c3aed;            /* Hindi explanation accent */
  --hi-soft: #f3e8ff;
  --gu: #0f766e;            /* Gujarati accent */
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 14px rgba(0,0,0,.05);
  --radius: 14px;
  --maxw: 880px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b22;
    --text: #e7e9ee;
    --muted: #9aa1ad;
    --line: #2a2f3a;
    --accent: #2dd4bf;
    --accent-soft: #134e4a;
    --accent-text: #06251f;
    --good: #4ade80;
    --good-soft: #14352177;
    --bad: #f87171;
    --bad-soft: #45151577;
    --warn: #fbbf24;
    --warn-soft: #43300c77;
    --hi: #c4b5fd;
    --hi-soft: #2e1f4d77;
    --gu: #2dd4bf;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
.gu-text { font-family: "Noto Sans Gujarati", "Shruti", "Segoe UI", sans-serif; }
.dev-text { font-family: "Noto Sans Devanagari", "Nirmala UI", "Mangal", "Segoe UI", sans-serif; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 16px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.topbar .inner {
  max-width: var(--maxw); margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.userchip img { width: 26px; height: 26px; border-radius: 50%; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin: 14px 0;
}
.card h2 { margin-top: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-text);
  border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.secondary { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Speak (TTS) button */
.tts {
  background: var(--accent-soft); color: var(--accent);
  border: none; border-radius: 50%;
  width: 32px; height: 32px; min-width: 32px;
  font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle;
}
.tts:hover { filter: brightness(1.05); }
.tts.playing { outline: 2px solid var(--accent); }

/* Phrase rows */
.phrase {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line);
  margin: 8px 0;
}
.phrase .texts { flex: 1; min-width: 0; }
.phrase .gu-line { font-size: 20px; font-weight: 600; color: var(--gu); }
.phrase .dev-line { font-size: 16px; color: var(--text); opacity: .92; }
.phrase .en-line { font-size: 14px; color: var(--muted); }
.phrase .note-line { font-size: 13px; color: var(--warn); margin-top: 2px; }
.phrase .actions { display: flex; flex-direction: column; gap: 6px; align-items: center; }

/* Bilingual explanation blocks */
.expl { margin: 10px 0; display: grid; gap: 8px; }
.expl .en-block, .expl .hi-block {
  padding: 10px 14px; border-radius: 10px; font-size: 15px;
}
.expl .en-block { background: var(--accent-soft); border-left: 4px solid var(--accent); }
.expl .hi-block { background: var(--hi-soft); border-left: 4px solid var(--hi); }
.expl .lang-tag { font-size: 11px; font-weight: 700; letter-spacing: .08em; opacity: .7; display: block; margin-bottom: 2px; }

/* Trap callout */
.trap {
  border: 1.5px solid var(--warn);
  background: var(--warn-soft);
  border-radius: var(--radius);
  padding: 14px 18px; margin: 14px 0;
}
.trap h3 { margin: 0 0 6px; color: var(--warn); }

/* Tables */
table.tt { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 15px; }
table.tt th, table.tt td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
table.tt th { background: var(--accent-soft); color: var(--text); }
table.tt td .small { font-size: 12px; color: var(--muted); }

/* Dialogue */
.dialogue .line { display: flex; gap: 10px; margin: 10px 0; align-items: flex-start; }
.dialogue .who {
  min-width: 74px; text-align: right; font-weight: 700; font-size: 13px;
  color: var(--muted); padding-top: 6px;
}
.dialogue .bubble {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 12px;
}
.dialogue .bubble .gu-line { font-size: 18px; font-weight: 600; color: var(--gu); }
.dialogue .bubble .dev-line { font-size: 14px; opacity: .9; }
.dialogue .bubble .en-line { font-size: 13px; color: var(--muted); }

/* Quiz */
.quiz-q { margin: 14px 0; }
.quiz-q .qtext { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.quiz-q .qtext-hi { font-size: 14px; color: var(--hi); margin-bottom: 8px; }
.quiz-options { display: grid; gap: 8px; }
.quiz-opt {
  text-align: left; background: var(--card); color: var(--text);
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: 16px; cursor: pointer;
}
.quiz-opt:hover { border-color: var(--accent); }
.quiz-opt.correct { border-color: var(--good); background: var(--good-soft); }
.quiz-opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.quiz-opt:disabled { cursor: default; }
.quiz-input {
  width: 100%; padding: 10px 14px; font-size: 17px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text);
}
.quiz-input:focus { outline: none; border-color: var(--accent); }
.feedback { border-radius: 10px; padding: 10px 14px; margin-top: 8px; font-size: 14px; }
.feedback.good { background: var(--good-soft); color: var(--good); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback.info { background: var(--accent-soft); color: var(--text); }
.feedback .explain { color: var(--text); opacity: .85; margin-top: 4px; }
.quiz-progress { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

/* Progress bars */
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

/* Unit list */
.unit-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; margin: 8px 0;
  color: var(--text); text-decoration: none;
}
.unit-row:hover { border-color: var(--accent); text-decoration: none; }
.unit-row .num {
  width: 34px; height: 34px; min-width: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px;
}
.unit-row.done .num { background: var(--good-soft); color: var(--good); }
.unit-row .meta { flex: 1; min-width: 0; }
.unit-row .meta .t { font-weight: 600; }
.unit-row .meta .s { font-size: 13px; color: var(--muted); }
.unit-row .score { font-size: 13px; font-weight: 700; color: var(--good); white-space: nowrap; }
.unit-row.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.unit-row .badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--accent); color: var(--accent-text); white-space: nowrap;
}

/* Chips & misc */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; padding: 4px 12px; border-radius: 99px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* Streak header */
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.stat {
  flex: 1; min-width: 130px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; text-align: center;
}
.stat .v { font-size: 26px; font-weight: 800; color: var(--accent); }
.stat .l { font-size: 12px; color: var(--muted); }

/* Notes */
.notebtn {
  background: none; border: none; cursor: pointer; font-size: 15px;
  opacity: .45; padding: 2px 4px;
}
.notebtn:hover, .notebtn.has-note { opacity: 1; }
.note-editor textarea {
  width: 100%; min-height: 70px; border: 1.5px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font: inherit;
  background: var(--card); color: var(--text);
}

/* Toast */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 20px; border-radius: 99px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 100; display: none;
  max-width: 90vw; text-align: center;
}
#toast.show { display: block; animation: toastin .25s ease; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 90; padding: 16px;
}
.modal {
  background: var(--card); border-radius: var(--radius);
  max-width: 480px; width: 100%; padding: 20px 22px;
  max-height: 85vh; overflow: auto;
}

/* Flashcards */
.fcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); min-height: 230px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; cursor: pointer; text-align: center;
  user-select: none;
}
.fcard .front-gu { font-size: 34px; font-weight: 700; color: var(--gu); }
.fcard .back-dev { font-size: 22px; }
.fcard .back-en { font-size: 17px; color: var(--muted); }

/* Sign-in hero */
.hero { text-align: center; padding: 40px 16px 24px; }
.hero h1 { font-size: 32px; margin: 12px 0 6px; }
.hero p { color: var(--muted); max-width: 520px; margin: 6px auto; }
.hero .logo-big { width: 76px; height: 76px; border-radius: 20px; box-shadow: var(--shadow); }

/* Course catalog card */
.course-card { display: flex; gap: 14px; align-items: center; }
.course-card .cicon { font-size: 40px; }
.course-card .cmeta { flex: 1; }
.course-card .cmeta h3 { margin: 0; }
.course-card .cmeta p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }

/* Print (cheatsheet) */
@media print {
  .topbar, .btn, .tts, .notebtn, #toast { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}
