/*
  AI Tutors. Look taken from the student's two references:
  - the study app (studyable): soft lavender page, indigo/violet accent, big friendly rounded cards,
    a gradient hero with one search field;
  - the career search (BigFuture): a grid of colored category tiles with an icon, name and a
    one-line description, pill filters, a profile page per item.
  Each tutor carries its own color (--tc) through tiles, avatars, bubbles and buttons.
*/
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("./fonts/inter-400-600-latin.woff2") format("woff2");
}

:root {
  --accent: #4F46E5;
  --accent-2: #7C5CF6;
  --accent-ink: #ffffff;
  --bg: #F5F5FC;
  --surface: #ffffff;
  --surface-2: #EEEDFB;
  --ink: #16163A;
  --ink-2: #5C5E7A;
  --line: #E3E3F1;
  --good: #11845B;
  --bad: #C2392F;
  --sun: #FFC857;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(22 22 58 / 5%), 0 8px 24px rgb(22 22 58 / 6%);
  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font);
  --max: 1040px;
  --tc: var(--accent);
  color-scheme: light;
}

body { letter-spacing: -0.005em; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.big { width: 44px; height: 44px; margin: 0 auto; stroke-width: 1.4; color: var(--accent); }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 600; color: var(--tc); margin-bottom: 6px; }
.spacer { flex: 1; }
.small { font-size: .875rem; }

/* ---------- Header + tab bar ---------- */
.app-header .brand { text-decoration: none; color: var(--ink); }
.mode-pill {
  min-height: 34px; padding: 0 12px 0 26px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; position: relative;
}
.mode-pill::before { content: ""; position: absolute; left: 11px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--sun); }
.mode-pill[data-mode="remote"]::before { background: var(--good); }
.tabbar .tab-icon { display: grid; place-items: center; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); background: var(--surface-2); }
body[data-route="chat"] .tabbar { display: none; }

/* ---------- Buttons ---------- */
.btn.primary { background: var(--accent); }
.btn.tinted { background: var(--tc); color: #fff; }
.btn.tinted-outline { color: var(--tc); border-color: color-mix(in srgb, var(--tc) 40%, transparent); }
.btn.danger-fill { background: var(--bad); color: #fff; border-color: transparent; }
.btn .icon { width: 18px; height: 18px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- Avatars ---------- */
.avatar {
  --size: 48px;
  width: var(--size); height: var(--size); flex: none; display: grid; place-items: center;
  border-radius: 32%; color: var(--tc);
  background: color-mix(in srgb, var(--tc) 13%, white);
}
.avatar .icon { width: 55%; height: 55%; }
.avatar.xs { --size: 26px; }
.avatar.sm { --size: 36px; }
.avatar.xl { --size: 88px; }

/* ---------- Subjects ---------- */
.hero {
  position: relative; overflow: hidden;
  margin: 4px 0 8px; padding: 28px 24px 24px; border-radius: 28px; color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgb(255 200 87 / 35%) 0 18%, transparent 42%),
    linear-gradient(135deg, var(--accent-2), var(--accent) 55%, #3A2FC0);
}
.hero .eyebrow { color: rgb(255 255 255 / 80%); }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); max-width: 18ch; margin-bottom: 8px; }
.hero-sub { color: rgb(255 255 255 / 85%); max-width: 52ch; }
.ask {
  display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 0 16px;
  background: var(--surface); color: var(--ink-2); border-radius: 999px; box-shadow: 0 6px 20px rgb(22 22 58 / 18%);
}
.ask input { border: 0; background: none; padding: 14px 0; min-height: 52px; color: var(--ink); }
.ask input:focus { outline: none; }
.ask:focus-within { outline: 3px solid rgb(255 255 255 / 55%); }
.ask.slim { box-shadow: var(--shadow); margin: 0 0 16px; }
.ask.slim:focus-within { outline-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.match {
  display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 14px;
  background: var(--surface); color: var(--ink); border-radius: 18px;
}
.match-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
@media (max-width: 520px) { .match { flex-wrap: wrap; } .match .btn { width: 100%; } }

.section-title { flex-wrap: wrap; margin-top: 26px; }
.level-chips { padding-bottom: 0; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.tile {
  display: flex; flex-direction: column; gap: 12px; padding: 18px; text-align: left;
  background: var(--surface); color: var(--ink); text-decoration: none; font: inherit;
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer;
  position: relative; overflow: hidden; transition: transform .12s ease, border-color .12s ease;
}
.tile::after { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--tc); }
.tile:active { transform: scale(.98); }
.tile:hover { border-color: color-mix(in srgb, var(--tc) 40%, var(--line)); }
.tile-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; color: var(--tc); background: color-mix(in srgb, var(--tc) 13%, white); }
.tile-icon .icon { width: 26px; height: 26px; }
.tile-text { display: flex; flex-direction: column; gap: 2px; }
.tile-text strong { font-size: 1.08rem; }
.tile-tutor { font-size: .85rem; color: var(--tc); font-weight: 600; }
.tile-tag { font-size: .9rem; color: var(--ink-2); }
.tile-meta { margin-top: auto; font-size: .75rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.tile-more { --tc: var(--ink); background: var(--surface-2); border-style: dashed; box-shadow: none; }
.tile-more::after { display: none; }
.tile-more .tile-icon { background: var(--surface); }

.continue { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.continue-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 64px;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); color: var(--ink); text-decoration: none;
  border-left: 4px solid var(--tc);
}
.continue-card > span { display: flex; flex-direction: column; min-width: 0; }
.continue-card strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Tutor profile ---------- */
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.profile {
  padding: 24px; border-radius: 28px; background: color-mix(in srgb, var(--tc) 9%, white);
  border: 1px solid color-mix(in srgb, var(--tc) 18%, white);
}
.profile-head { display: flex; gap: 18px; align-items: center; margin-bottom: 14px; }
.profile-head h1 { font-size: 2rem; margin-bottom: 2px; }
.profile-head .avatar { background: var(--tc); color: #fff; }
@media (max-width: 520px) { .profile-head { flex-direction: column; align-items: flex-start; } .profile-head .avatar { --size: 64px; } }
body[data-route="chat"] .app-header { background: var(--bg); }
.profile-tag { color: var(--ink-2); margin-bottom: 8px; }
.profile .badge { background: var(--surface); color: var(--tc); }
.profile-progress { margin: 12px 0 0; }
.topics { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.topic {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 64px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; font: inherit; color: var(--ink); cursor: pointer;
}
.topic > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; gap: 2px; }
.topic > .icon { color: var(--ink-2); width: 18px; }
.topic-dot { width: 26px; height: 26px; border-radius: 50%; flex: none; border: 2px solid var(--line); display: grid; place-items: center; }
.topic-dot.seen { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 15%, white); }
.topic-dot.mastered { border-color: var(--tc); background: var(--tc); color: #fff; }
.topic-dot .icon { width: 16px; height: 16px; stroke-width: 2.6; }
.how { margin-top: 20px; }
.how summary { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; min-height: 44px; list-style: none; }
.how summary::-webkit-details-marker { display: none; }
.prompt {
  margin: 10px 0; padding: 14px 16px; border-left: 4px solid var(--tc); background: var(--surface-2);
  border-radius: 0 12px 12px 0; font-family: var(--font-mono); font-size: .85rem; line-height: 1.55;
}

/* ---------- Chat ---------- */
body[data-route="chat"] .app-main { padding-bottom: calc(190px + var(--safe-bottom)); max-width: 820px; }
.chat-bar {
  position: sticky; top: var(--header-h, 57px); z-index: 10; display: flex; align-items: center; gap: 8px;
  margin: -16px -16px 12px; padding: 8px 12px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.chat-who { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: 44px; }
.chat-who > span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; }
.msg.student { flex-direction: column; align-items: flex-end; gap: 2px; }
.msg.tutor { align-items: flex-start; }
.msg-body { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 0; max-width: min(640px, 86%); }
.bubble { padding: 12px 16px; border-radius: 20px; line-height: 1.5; overflow-wrap: anywhere; }
.bubble p { margin: 0; white-space: pre-line; }
.bubble p + p { margin-top: .7em; }
.student .bubble { max-width: min(560px, 86%); background: var(--tc); color: #fff; border-bottom-right-radius: 6px; white-space: pre-line; }
.tutor .bubble { background: var(--surface); box-shadow: var(--shadow); border-top-left-radius: 6px; border: 1px solid color-mix(in srgb, var(--tc) 14%, var(--line)); }
.bubble-title { font-size: 1.05rem; color: var(--tc); margin: 0 0 6px; }
.msg-meta { padding-left: 4px; }
.msg-action {
  display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 8px; border: 0; background: none;
  color: var(--ink-2); font: inherit; font-size: .8rem; cursor: pointer; border-radius: 8px;
}
.msg-action .icon { width: 15px; height: 15px; }
.typing .bubble { display: flex; gap: 5px; padding: 16px; }
.typing .bubble span { width: 8px; height: 8px; border-radius: 50%; background: var(--tc); opacity: .35; animation: blink 1s infinite; }
.typing .bubble span:nth-child(2) { animation-delay: .15s; }
.typing .bubble span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: 1; } }

.check { display: grid; gap: 8px; margin-top: 12px; }
.option {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); font: inherit; color: var(--ink); cursor: pointer;
}
.option:not(:disabled):active { border-color: var(--tc); }
.option-letter { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); font-weight: 600; font-size: .85rem; }
.option.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, white); }
.option.right .option-letter { background: var(--good); color: #fff; }
.option.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, white); }
.option.wrong .option-letter { background: var(--bad); color: #fff; }
.option:disabled { cursor: default; opacity: 1; }
.bubble .check-result { white-space: normal; margin: 4px 0 0; padding: 10px 12px; border-radius: 12px; font-size: .92rem; }
.check-result.good { background: color-mix(in srgb, var(--good) 12%, white); }
.check-result.bad { background: color-mix(in srgb, var(--bad) 10%, white); }

.composer-wrap {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 10px calc(12px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(12px + var(--safe-left));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.composer-wrap > * { max-width: 796px; margin-left: auto; margin-right: auto; }
.composer-wrap .chips { margin-bottom: 8px; }
.starters .chip, .followups .chip { border-color: color-mix(in srgb, var(--tc) 35%, var(--line)); color: var(--ink); }
.followups .chip .icon { width: 16px; height: 16px; color: var(--tc); }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  min-height: 48px; max-height: 160px; resize: none; border-radius: 24px; padding: 12px 18px; line-height: 1.4;
  background: var(--surface); border: 1.5px solid var(--line);
}
.composer textarea:focus { outline: none; border-color: var(--tc); }
.composer .btn { width: 48px; height: 48px; min-height: 48px; border-radius: 50%; flex: none; }

/* ---------- Lists: chats, doubts ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 14px; }
.page-head h1 { margin: 0; font-size: 1.9rem; }
.chats > li { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 14px; }
.chat-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 6px 0; color: var(--ink); text-decoration: none; }
.chat-row-text { display: flex; flex-direction: column; min-width: 0; }
.chat-row-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doubt-form .field { margin-bottom: 10px; }
.doubt-form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.doubt-form-row .field { flex: 1 1 220px; margin: 0; }
.form-error { color: var(--bad); font-weight: 600; margin: 10px 0 0; }
.doubt-filter { margin: 18px 0 12px; }
.doubts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.doubt { border-left: 4px solid var(--tc); }
.doubt + .doubt { margin-top: 0; }
.doubt-head { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.doubt-head .badge { margin-left: auto; }
.badge.good { background: color-mix(in srgb, var(--good) 14%, white); color: var(--good); }
.doubt-text { font-size: 1.05rem; margin: 10px 0 12px; }
.doubt.resolved .doubt-text { color: var(--ink-2); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink-2) 50%, transparent); }

/* ---------- Progress ---------- */
.level-card {
  display: flex; align-items: center; gap: 22px; padding: 22px; border-radius: 28px; color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent) 60%, #3A2FC0);
}
.level-card .eyebrow { color: var(--sun); }
.level-card p { margin: 0 0 4px; }
.xp { font-size: 1.1rem; }
.xp strong { font-size: 2.2rem; letter-spacing: -0.03em; }
.xp-legend { opacity: .8; margin-top: 8px !important; }
.ring {
  --pct: 0; width: 116px; height: 116px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--sun) calc(var(--pct) * 1%), rgb(255 255 255 / 22%) 0);
}
.ring span { width: 92px; height: 92px; border-radius: 50%; background: #3F36D0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.ring small { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.ring strong { font-size: 2.2rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
@media (max-width: 600px) { .stats { grid-template-columns: repeat(2, 1fr); } .level-card { flex-direction: column; text-align: center; } }
.stat { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stat .icon { color: var(--accent); }
.stat strong { font-size: 1.5rem; }
.stat span { color: var(--ink-2); font-size: .85rem; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 150px; align-items: end; }
.bar { height: 100%; display: grid; grid-template-rows: 18px 1fr 20px; justify-items: center; align-items: end; }
.bar-fill { width: 100%; max-width: 38px; min-height: 4px; border-radius: 8px 8px 4px 4px; background: color-mix(in srgb, var(--accent) 35%, white); }
.bar.today .bar-fill { background: var(--accent); }
.bar-n { font-size: .75rem; font-weight: 600; color: var(--ink-2); }
.bar-label { font-size: .75rem; color: var(--ink-2); }
.bar.today .bar-label { color: var(--accent); font-weight: 600; }
.sp-row { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.sp-text { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.meter { position: relative; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: color-mix(in srgb, var(--tc) 40%, white); }
.meter > .meter-mastered { background: var(--tc); }
.toggle { margin: 12px 0; min-height: 44px; }

@media (prefers-reduced-motion: reduce) { .typing .bubble span { animation: none; opacity: .6; } }
