:root {
  --paper: #f5f3eb;
  --white: #fffefa;
  --ink: #10211b;
  --muted: #63716b;
  --line: rgba(16, 33, 27, .13);
  --lime: #c9f25e;
  --blue: #315cdd;
  --guide: #ff8d79;
  --guide-soft: #f5d9cf;
  --sans: "Avenir Next", Avenir, "SF Pro Display", "PingFang HK", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, textarea, input { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 3px solid rgba(49,92,221,.28); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 1000; top: 8px; left: 8px; padding: 10px 14px; color: #fff; background: var(--ink); border-radius: 8px; transform: translateY(-150%); }
.skip-link:focus { transform: none; }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }

.practice-body.theme-mallow { --guide: #9d78ca; --guide-soft: #e9def4; }
.practice-body.theme-orbit { --guide: #315cdd; --guide-soft: #d8e3f6; }
.practice-body.theme-fern { --guide: #5f9f61; --guide-soft: #dfebd7; }
.practice-header { position: relative; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 74px; padding: 0 clamp(18px, 4vw, 60px); border-bottom: 1px solid var(--line); background: rgba(245,243,235,.9); backdrop-filter: blur(18px); }
.practice-wordmark { display: inline-flex; align-items: center; width: fit-content; color: var(--ink); text-decoration: none; font-size: 21px; letter-spacing: -.05em; }
.practice-wordmark > span { display: grid; place-items: center; width: 29px; height: 29px; margin-right: 8px; color: var(--lime); background: var(--ink); border-radius: 50% 50% 50% 10px; font-size: 13px; font-weight: 900; }
.practice-wordmark b { font-weight: 800; }
.practice-wordmark i { color: var(--blue); font-style: normal; font-weight: 800; }
.practice-trust { display: flex; align-items: center; gap: 20px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.practice-trust span { display: flex; align-items: center; gap: 7px; }
.practice-trust i { width: 7px; height: 7px; background: #69a75f; border-radius: 50%; box-shadow: 0 0 0 4px rgba(105,167,95,.12); }
.home-link { justify-self: end; color: var(--ink); font-size: 11px; font-weight: 750; text-underline-offset: 4px; }

.practice-main { min-height: calc(100vh - 74px); }
.setup-view { width: min(1320px, 100%); margin: 0 auto; padding: clamp(54px, 7vw, 96px) clamp(20px, 5vw, 72px) 100px; }
.setup-intro { display: grid; grid-template-columns: 1fr .58fr; gap: 70px; align-items: end; margin-bottom: 60px; }
.setup-kicker { grid-column: 1 / -1; margin: 0 0 -38px !important; color: var(--blue) !important; font-size: 10px !important; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.setup-intro h1 { margin: 0; font-size: clamp(58px, 7.5vw, 104px); font-weight: 570; letter-spacing: -.075em; line-height: .88; }
.setup-intro h1 em { color: var(--blue); font-family: Georgia, serif; font-weight: 400; }
.setup-intro > p:last-child { margin: 0 0 6px; color: var(--muted); font-size: 16px; line-height: 1.7; }
.experience-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.experience-switch button { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 15px; align-items: center; min-height: 94px; padding: 14px 20px; border: 1px solid var(--line); border-radius: 23px; background: rgba(255,254,250,.6); text-align: left; cursor: pointer; transition: transform .2s ease, background .2s ease, border-color .2s ease; }
.experience-switch button:hover { transform: translateY(-2px); border-color: var(--ink); }
.experience-switch button.selected { background: var(--ink); border-color: var(--ink); color: #fff; }
.experience-switch .switch-icon { display: grid; place-items: center; width: 55px; height: 55px; background: #fff; border-radius: 18px; color: var(--ink); font-size: 25px; }
.experience-switch button:last-child .switch-icon { background: var(--lime); }
.experience-switch button > span:nth-child(2) { display: grid; gap: 4px; }
.experience-switch b { font-size: 15px; letter-spacing: -.02em; }
.experience-switch small { color: var(--muted); font-size: 10px; }
.experience-switch button.selected small { color: #aebbb5; }
.experience-switch button > i { color: #93a29a; font-family: Georgia, serif; font-size: 15px; font-style: italic; }
.setup-panel { overflow: hidden; background: var(--white); border: 1px solid var(--line); border-radius: 32px; box-shadow: 0 28px 70px rgba(32,51,43,.08); }
.setup-step { display: grid; grid-template-columns: 270px 1fr; gap: clamp(30px, 5vw, 80px); padding: 38px clamp(25px, 4vw, 52px); border-bottom: 1px solid var(--line); }
.step-title { display: flex; gap: 14px; align-items: flex-start; }
.step-title > span { flex: 0 0 27px; display: grid; place-items: center; width: 27px; height: 27px; color: #fff; background: var(--ink); border-radius: 50%; font-size: 11px; font-weight: 800; }
.step-title h2 { margin: 2px 0 4px; font-size: 18px; letter-spacing: -.025em; }
.step-title p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.grade-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-self: center; }
.grade-picker button { min-height: 57px; border: 1px solid var(--line); border-radius: 16px; background: transparent; font-size: 13px; font-weight: 800; cursor: pointer; transition: .18s ease; }
.grade-picker button:hover { border-color: var(--blue); transform: translateY(-2px); }
.grade-picker button.selected { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 9px 20px rgba(49,92,221,.2); }
.guide-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; }
.mood-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.mood-card { position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; min-height: 74px; padding: 10px 12px; background: #faf9f4; border: 1px solid var(--line); border-radius: 17px; text-align: left; cursor: pointer; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.mood-card:hover { transform: translateY(-2px); border-color: var(--guide); }
.mood-card.selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.mood-card > span { grid-row: 1 / 3; display: grid; place-items: center; width: 43px; height: 43px; background: #fff; border-radius: 14px; font-size: 24px; }
.mood-card b { align-self: end; font-size: 12px; }
.mood-card small { align-self: start; color: var(--muted); font-size: 8px; }
.mood-card i { position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 18px; height: 18px; color: #fff; background: var(--ink); border-radius: 50%; font-size: 8px; font-style: normal; opacity: 0; transform: scale(.7); transition: .18s ease; }
.mood-card.selected i { opacity: 1; transform: none; }
.guide-card { position: relative; min-width: 0; padding: 0 0 14px; overflow: hidden; background: #f8efe9; border: 1px solid transparent; border-radius: 20px; text-align: left; cursor: pointer; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.guide-card:nth-child(2) { background: #f0e9f7; }
.guide-card:nth-child(3) { background: #e8eef8; }
.guide-card:nth-child(4) { background: #edf2e7; }
.guide-card:hover { transform: translateY(-3px); }
.guide-card.selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.guide-card > i { position: absolute; top: 9px; right: 9px; display: grid; place-items: center; width: 22px; height: 22px; color: #fff; background: var(--ink); border-radius: 50%; font-size: 10px; font-style: normal; opacity: 0; transform: scale(.7); transition: .18s ease; }
.guide-card.selected > i { opacity: 1; transform: none; }
/* Must stay square. The sprite is a 2x2 sheet drawn with background-size:200%
   200%, which is a percentage of THIS box, so a 1.25 box stretched each
   character 25% wider than tall — the same distortion the homepage cards had.
   The card is simply taller now. */
.guide-art { display: block; width: 100%; aspect-ratio: 1; }
.guide-info { display: block; padding: 0 14px; }
.guide-info b, .guide-info small { display: block; }
.guide-info b { font-size: 15px; letter-spacing: -.02em; }
.guide-info small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.companion-sprite { background-image: url("../images/alphafy-companions-sheet.png"); background-repeat: no-repeat; background-size: 200% 200%; }
.companion-sol { background-position: 0 0; }
.companion-mallow { background-position: 100% 0; }
.companion-orbit { background-position: 0 100%; }
.companion-fern { background-position: 100% 100%; }
.topic-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.scene-picker { grid-template-columns: repeat(3, 1fr); }
.topic-picker button { display: flex; flex-direction: column; align-items: flex-start; min-height: 116px; padding: 15px; border: 1px solid var(--line); border-radius: 18px; background: transparent; text-align: left; cursor: pointer; transition: .18s ease; }
.topic-picker button:hover { background: var(--paper); transform: translateY(-2px); }
.topic-picker button.selected { background: var(--lime); border-color: var(--lime); box-shadow: 0 9px 20px rgba(169,219,45,.2); }
.topic-picker button > span { margin-bottom: auto; color: var(--blue); font-size: 18px; }
.topic-picker button b { font-size: 12px; }
.topic-picker button small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.setup-footer { display: flex; justify-content: space-between; align-items: center; gap: 30px; padding: 26px clamp(25px, 4vw, 52px); }
.setup-footer p { display: flex; gap: 9px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.setup-footer p span { color: #529553; font-weight: 900; }
.start-practice { display: flex; align-items: center; justify-content: space-between; gap: 28px; min-height: 53px; padding: 0 13px 0 21px; color: #fff; background: var(--ink); border: 0; border-radius: 999px; font-size: 12px; font-weight: 750; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.start-practice:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(16,33,27,.17); }
.start-practice span { display: grid; place-items: center; width: 32px; height: 32px; color: var(--ink); background: var(--lime); border-radius: 50%; }

/* Chat */
.chat-view { height: calc(100vh - 74px); min-height: 560px; display: grid; grid-template-rows: auto auto 1fr auto; background: #e9eee9; }
.chat-header { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 13px; min-height: 82px; padding: 12px clamp(14px, 3vw, 36px); background: rgba(255,254,250,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.icon-button { display: grid; place-items: center; width: 39px; height: 39px; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; }
.chat-guide-avatar { width: 52px; height: 52px; background-color: var(--guide-soft); border-radius: 18px; }
.chat-guide-avatar.emoji-avatar, .message-avatar.emoji-avatar { display: grid; place-items: center; background-image: none; background-color: var(--guide-soft); font-size: 27px; }
.chat-guide-info { min-width: 0; }
.chat-guide-info > div { display: flex; align-items: center; gap: 7px; }
.chat-guide-info h1 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.online-dot { width: 6px; height: 6px; background: #63a45b; border-radius: 50%; }
.chat-guide-info small { color: var(--muted); font-size: 9px; }
.chat-guide-info p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.new-chat { min-height: 38px; padding: 0 14px; background: transparent; border: 1px solid var(--line); border-radius: 999px; font-size: 10px; font-weight: 750; cursor: pointer; }
.service-notice { padding: 10px 18px; color: #6f5211; background: #fff3c9; border-bottom: 1px solid #ead69b; text-align: center; font-size: 11px; line-height: 1.4; }
.service-notice.error { color: #8a3b35; background: #ffe6df; border-color: #f3c1b7; }
.messages { min-height: 0; overflow-y: auto; padding: 34px max(22px, calc((100vw - 830px) / 2)); scroll-behavior: smooth; }
.message { display: flex; align-items: flex-end; gap: 10px; width: 100%; margin: 0 auto 18px; }
.message.user { justify-content: flex-end; }
.message-avatar { flex: 0 0 36px; width: 36px; height: 36px; background-color: var(--guide-soft); border-radius: 13px; }
.message-bubble { position: relative; max-width: min(640px, 78%); padding: 13px 16px; background: var(--white); border: 1px solid rgba(16,33,27,.08); border-radius: 20px 20px 20px 5px; box-shadow: 0 4px 12px rgba(27,46,38,.04); font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .message-bubble { color: #fff; background: var(--ink); border-color: var(--ink); border-radius: 20px 20px 5px 20px; }
.message-tools { display: flex; justify-content: flex-end; margin-top: 7px; }
.speak-reply { padding: 3px 6px; color: var(--muted); background: transparent; border: 0; font-size: 9px; cursor: pointer; }
.typing-bubble { display: flex; gap: 5px; width: 62px; }
.typing-bubble i { width: 6px; height: 6px; background: #9cad9f; border-radius: 50%; animation: typing 1.2s infinite ease-in-out; }
.typing-bubble i:nth-child(2) { animation-delay: .15s; }
.typing-bubble i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
.composer-area { padding: 0 max(18px, calc((100vw - 830px) / 2)) 16px; background: linear-gradient(to top, #e9eee9 85%, rgba(233,238,233,0)); }
.starter-wrap { display: flex; gap: 11px; align-items: center; padding: 10px 2px; overflow: hidden; }
.starter-wrap > span { flex: 0 0 auto; color: var(--guide); font-size: 9px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.starters { display: flex; gap: 7px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.starters::-webkit-scrollbar { display: none; }
.starters button { flex: 0 0 auto; padding: 7px 10px; color: #4f6058; background: rgba(255,255,255,.65); border: 1px solid var(--line); border-radius: 999px; font-size: 9px; cursor: pointer; }
.starters button:hover { color: var(--ink); background: #fff; }
.composer { position: relative; display: grid; grid-template-columns: 1fr auto; min-height: 62px; padding: 9px 9px 9px 19px; background: var(--white); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 12px 36px rgba(28,49,39,.1); }
.composer:focus-within { border-color: var(--guide); box-shadow: 0 0 0 3px color-mix(in srgb, var(--guide) 15%, transparent), 0 12px 36px rgba(28,49,39,.1); }
.composer textarea { align-self: center; width: 100%; min-height: 38px; max-height: 118px; padding: 8px 0; resize: none; overflow-y: auto; field-sizing: content; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 14px; line-height: 1.45; }
.composer textarea::placeholder { color: #9aa49f; }
.composer-actions { display: flex; align-items: flex-end; gap: 8px; }
.composer-actions > span { align-self: center; color: #9aa49f; font-size: 8px; }
.blank-button { align-self: center; min-height: 32px; padding: 0 10px; color: var(--guide); background: var(--guide-soft); border: 0; border-radius: 999px; font-size: 8px; font-weight: 800; cursor: pointer; }
.voice-button, .send-button { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 50%; cursor: pointer; }
.voice-button { color: var(--guide); background: var(--guide-soft); border: 0; font-size: 14px; }
.voice-button.listening { color: #fff; background: #cf544a; animation: pulse 1.2s infinite; }
.send-button { color: #fff; background: var(--ink); border: 0; font-size: 18px; font-weight: 800; }
.send-button:disabled { color: #8d9892; background: #dce0dd; cursor: wait; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(207,84,74,.13); } }
.composer-note { margin: 8px 0 0; color: #839088; text-align: center; font-size: 8px; line-height: 1.4; }

@media (max-width: 920px) {
  .setup-intro { grid-template-columns: 1fr; gap: 29px; }
  .setup-kicker { margin-bottom: -10px !important; }
  .setup-intro > p:last-child { max-width: 620px; }
  .setup-step { grid-template-columns: 1fr; }
  .step-title { max-width: 480px; }
  .scene-picker { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 680px) {
  .practice-header { grid-template-columns: 1fr auto; min-height: 66px; padding: 0 15px; }
  .practice-main { min-height: calc(100vh - 66px); }
  .practice-trust { display: none; }
  .home-link { font-size: 9px; }
  .setup-view { padding-top: 45px; padding-bottom: 65px; }
  .setup-intro { margin-bottom: 38px; }
  .setup-intro h1 { font-size: clamp(54px, 16vw, 82px); }
  .experience-switch { grid-template-columns: 1fr; }
  .experience-switch button { min-height: 82px; }
  .setup-panel { border-radius: 24px; }
  .setup-step { padding: 28px 20px; gap: 22px; }
  .grade-picker { grid-template-columns: repeat(3, 1fr); }
  .guide-picker { grid-template-columns: 1fr 1fr; }
  .mood-picker { grid-template-columns: 1fr 1fr; }
  .topic-picker, .scene-picker { grid-template-columns: 1fr 1fr; }
  .setup-footer { align-items: stretch; flex-direction: column; padding: 24px 20px; }
  .start-practice { width: 100%; }
  .chat-view { height: calc(100dvh - 66px); min-height: 460px; }
  .chat-header { grid-template-columns: auto auto 1fr; min-height: 72px; gap: 9px; padding: 9px 12px; }
  .chat-guide-avatar { width: 46px; height: 46px; border-radius: 15px; }
  .new-chat { display: none; }
  .chat-guide-info small { display: none; }
  .messages { padding: 23px 13px; }
  .message-bubble { max-width: 83%; padding: 11px 13px; font-size: 13px; }
  .composer-area { padding: 0 11px 10px; }
  .starter-wrap { padding-left: 2px; }
  .composer { min-height: 58px; padding-left: 14px; border-radius: 19px; }
  .composer-actions > span { display: none; }
  .voice-button, .send-button { width: 39px; height: 39px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
