/* 閱讀小老師・學生端 — 潑墨宣紙＋屏東山海；滿版背景，上疊半透明宣紙卡 */
:root {
  --paper: #f6f1e7;
  --paper-a: rgba(246, 241, 231, .88);
  --ink: #1f2a2e;
  --ink-2: #5b6468;
  --seal: #c8452c;
  --sea: #2f7a83;
  --leaf: #4f7d4a;
  --sun: #e8a93a;
  --line: rgba(31, 42, 46, .14);
  --f-title: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --f-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --r: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--f-body);
  font-size: 18px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); margin: 0; }

/* ── 滿版背景：圖在上、漸層墊底（圖缺時仍好看） ── */
.view {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--paper);
  background-size: cover;
  background-position: center;
  background-attachment: scroll;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bg-home {
  background-image:
    url("img/bg-home.webp"),
    radial-gradient(ellipse 70% 40% at 15% 100%, rgba(79, 125, 74, .45), transparent 70%),
    radial-gradient(ellipse 60% 35% at 90% 95%, rgba(47, 122, 131, .40), transparent 70%),
    radial-gradient(ellipse 50% 30% at 80% 12%, rgba(232, 169, 58, .30), transparent 70%),
    radial-gradient(ellipse 80% 50% at 30% 30%, rgba(31, 42, 46, .07), transparent 70%),
    linear-gradient(180deg, #f9f5ec 0%, #efe7d6 100%);
}
.bg-chat {
  background-image:
    url("img/bg-chat.webp"),
    radial-gradient(ellipse 60% 30% at 0% 100%, rgba(79, 125, 74, .18), transparent 70%),
    radial-gradient(ellipse 60% 30% at 100% 0%, rgba(47, 122, 131, .16), transparent 70%),
    linear-gradient(180deg, #f8f4eb 0%, #f1eadc 100%);
}

/* ── 宣紙卡：半透明＋墨暈邊 ── */
.card {
  background: var(--paper-a);
  border-radius: var(--r);
  padding: 20px;
  box-shadow:
    0 0 0 1.5px rgba(31, 42, 46, .22),
    0 0 18px 2px rgba(31, 42, 46, .10),
    0 10px 30px -12px rgba(31, 42, 46, .35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* ── 頂列 ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  max-width: 980px; margin: 0 auto;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  padding-bottom: 10px;
}
.brand-mark {
  font-family: var(--f-title); font-weight: 900; font-size: 20px; letter-spacing: .08em;
  background: var(--paper-a); padding: 4px 14px; border-radius: 999px;
  box-shadow: 0 0 0 1.5px rgba(31, 42, 46, .2);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; margin-left: auto; }
.who-chip {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 700; font-size: 17px; padding: 6px 14px; border-radius: 999px;
  background: var(--paper); color: var(--ink); box-shadow: 0 0 0 2px var(--seal);
}
.chat-title {
  flex: 1; min-width: 0; text-align: center; font-family: var(--f-title); font-weight: 900; font-size: 18px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); text-shadow: 0 0 6px var(--paper), 0 0 2px var(--paper);
}
.btn-text {
  flex: none; min-height: 48px; padding: 0 16px; border: 0; border-radius: 999px;
  background: var(--paper-a); font-weight: 700; color: var(--ink);
  box-shadow: 0 0 0 1.5px rgba(31, 42, 46, .2);
}

/* ── Q 版頭像容器（圖缺時顯示朱印「屏」） ── */
.tutor-big, .tutor-mid, .tutor-sm, .avatar {
  position: relative; flex: none; display: grid; place-items: center;
}
.tutor-big { width: min(240px, 60vw); aspect-ratio: 1; }
.tutor-mid { width: 108px; aspect-ratio: 1; }
.tutor-sm  { width: 84px; aspect-ratio: 1; }
.avatar    { width: 56px; aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: var(--paper); box-shadow: 0 0 0 2px rgba(200, 69, 44, .55); }
.avatar img { transform: scale(1.9); transform-origin: 50% 24%; }
.tutor-big img, .tutor-mid img, .tutor-sm img, .avatar img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
.tutor-fallback {
  width: 78%; aspect-ratio: 1; display: grid; place-items: center;
  border-radius: 50%; background: var(--seal); color: var(--paper);
  font-family: var(--f-title); font-weight: 900; font-size: calc(1em * 1);
  box-shadow: inset 0 0 0 4px rgba(246, 241, 231, .5), 0 0 12px rgba(200, 69, 44, .35);
}
.tutor-big .tutor-fallback { font-size: 88px; }
.tutor-mid .tutor-fallback { font-size: 42px; }
.tutor-sm  .tutor-fallback { font-size: 32px; }
.avatar    .tutor-fallback { font-size: 20px; box-shadow: inset 0 0 0 2px rgba(246, 241, 231, .5); }
img:not([hidden]) ~ .tutor-fallback, .tutor-fallback:has(+ img:not([hidden])) { visibility: hidden; }

/* ── 登入畫面 ── */
.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding-block: 24px; text-align: center;
}
.login-card { max-width: 520px; width: 100%; padding: 28px 22px; }
.brand { margin: 0 0 6px; font-family: var(--f-title); font-weight: 600; color: var(--seal); letter-spacing: .3em; }
.login-notice { margin: 4px 0 12px; font-weight: 700; }
.pw-form { margin-top: 18px; padding-top: 16px; border-top: 2px dashed rgba(31, 42, 46, .2); display: grid; gap: 12px; }
.pw-or { margin: 0; font-weight: 700; color: var(--ink-2); }
.pw-field { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 700; }
.pw-field span { width: 3em; flex: none; }
.pw-field input { flex: 1; min-width: 0; font-size: 30px; letter-spacing: .2em; padding: 10px 14px; border: 2px solid var(--ink-2); border-radius: 14px; background: #fff; text-align: center; }
.pw-field input:focus { outline: 3px solid var(--seal); border-color: var(--seal); }
.pw-btn { font-size: 24px; font-weight: 900; padding: 14px; border: 0; border-radius: 16px; background: var(--seal); color: #fff; cursor: pointer; }
.pw-btn:disabled { opacity: .6; }
.guide-link { display: inline-block; margin-top: 14px; text-decoration: none; }
a.btn-text { text-decoration: none; display: inline-flex; align-items: center; }
.confirm-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.confirm-btns button { min-height: 72px; font-size: 26px; padding: 0 10px; white-space: nowrap; letter-spacing: .05em; }
.login-title {
  margin: 0 0 12px; font-family: var(--f-title); font-weight: 900;
  font-size: clamp(30px, 7vw, 44px); line-height: 1.3; text-wrap: balance;
}

/* ── 首頁 ── */
.home-main {
  max-width: 980px; margin: 0 auto; display: grid; gap: 18px;
  padding-block: 8px 32px;
}
.hello-card { display: flex; align-items: center; gap: 14px; }
.hello-text { min-width: 0; }
.hello-title {
  margin: 0; font-family: var(--f-title); font-weight: 900;
  font-size: clamp(28px, 6vw, 40px); line-height: 1.25; overflow-wrap: anywhere;
}
.btn-continue {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 92px; padding: 16px 20px; border: 0; border-radius: var(--r);
  background: radial-gradient(120% 140% at 0% 0%, #d65b40, var(--seal) 55%, #a33620); color: var(--paper);
  box-shadow: 0 8px 20px -10px rgba(31, 42, 46, .6), inset 0 -4px 0 rgba(0, 0, 0, .15);
}
.btn-continue .btn-ico { font-size: 30px; width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: rgba(246, 241, 231, .22); flex: none; }
.continue-text { flex: 1; min-width: 0; }
.home-main > * { min-width: 0; }
.btn-continue b { display: block; font-family: var(--f-title); font-weight: 900; font-size: 26px; line-height: 1.25; }
.btn-continue small { display: block; font-size: 17px; opacity: .95; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.btn-big {
  display: flex; align-items: center; gap: 14px; text-align: left;
  min-height: 96px; padding: 16px 20px; border: 0; border-radius: var(--r);
  color: var(--paper); box-shadow: 0 8px 20px -10px rgba(31, 42, 46, .6), inset 0 -4px 0 rgba(0, 0, 0, .15);
  transition: transform .12s ease;
}
.btn-big:active { transform: translateY(2px) scale(.99); }
.btn-big b { display: block; font-family: var(--f-title); font-weight: 900; font-size: 26px; line-height: 1.25; }
.btn-big small { display: block; font-size: 16px; opacity: .9; }
.btn-ico { font-size: 40px; line-height: 1; }
.btn-sea  { background: radial-gradient(120% 140% at 0% 0%, #3c8e97, var(--sea) 55%, #23606a); }
.btn-leaf { background: radial-gradient(120% 140% at 0% 0%, #5f9159, var(--leaf) 55%, #3d6439); }

.section-title { margin: 0 0 10px; font-family: var(--f-title); font-weight: 900; font-size: 24px; }
.session-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.session-item {
  width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center;
  text-align: left; min-height: 64px; padding: 12px 14px; border: 0; border-radius: 14px;
  background: rgba(255, 255, 255, .55); box-shadow: 0 0 0 1.5px var(--line);
}
.session-item:hover { background: rgba(255, 255, 255, .8); }
.mode-tag {
  grid-row: span 2; font-family: var(--f-title); font-weight: 900; font-size: 16px;
  color: var(--seal); border: 2px solid var(--seal); border-radius: 8px; padding: 2px 6px;
  writing-mode: vertical-rl; letter-spacing: .1em; transform: rotate(-3deg);
}
.mode-tag.ask { color: var(--leaf); border-color: var(--leaf); }
.s-title { font-weight: 700; min-width: 0; display: grid; }
.s-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--ink-2); font-size: 16px; min-width: 0; }
.stamps { display: inline-flex; gap: 4px; }
.stamp {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px;
  font-family: var(--f-title); font-weight: 900; font-size: 15px;
  color: rgba(31, 42, 46, .3); border: 1.5px dashed rgba(31, 42, 46, .25);
}
.stamp.on { color: var(--paper); background: var(--seal); border: 0; transform: rotate(-4deg); box-shadow: 0 0 6px rgba(200, 69, 44, .4); }
.stamp.now { color: var(--seal); border: 2px solid var(--seal); }
.s-when { font-weight: 700; color: var(--sea); font-size: 15px; }
.nw { white-space: nowrap; }
.btn-more {
  display: block; width: 100%; margin-top: 10px; min-height: 52px; border-radius: 14px;
  border: 2px dashed rgba(31, 42, 46, .3); background: rgba(255, 255, 255, .5); font-weight: 700; color: var(--sea);
}
.done-badge { color: var(--seal); font-weight: 700; }
.empty { display: flex; align-items: center; gap: 12px; color: var(--ink-2); }
.empty p { margin: 0; }

/* ── 開新練習 ── */
.new-main { max-width: 820px; margin: 0 auto; padding-block: 8px 32px; }
.new-card { display: grid; gap: 14px; }
.new-card .section-title { margin: 0; }
.brand-tag { margin: 0; font-family: var(--f-title); font-weight: 900; color: var(--seal); letter-spacing: .15em; font-size: 16px; }
.count-line { margin: 0; font-size: 17px; color: var(--ink-2); }
.count-line b { color: var(--seal); font-size: 22px; }
.tip { margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 17px; background: rgba(47, 122, 131, .12); border: 1.5px solid rgba(47, 122, 131, .45); }
.big-input, .chat-input {
  width: 100%; min-width: 0; border: 2px solid rgba(31, 42, 46, .25); border-radius: 14px;
  background: rgba(255, 255, 255, .85); padding: 12px 14px; font-size: 20px; line-height: 1.6; resize: vertical;
}
.big-input:focus, .chat-input:focus { outline: none; border-color: var(--sea); box-shadow: 0 0 0 3px rgba(47, 122, 131, .2); }
.photo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.btn-photo {
  display: inline-flex; align-items: center; min-height: 56px; padding: 0 20px; border-radius: 999px;
  background: rgba(255, 255, 255, .8); border: 2px dashed var(--sea); color: var(--sea); font-weight: 700; cursor: pointer;
}
.photo-preview { position: relative; width: 120px; }
.photo-preview img { display: block; width: 120px; height: 90px; object-fit: cover; border-radius: 10px; box-shadow: 0 0 0 2px var(--line); }
.photo-preview.small, .photo-preview.small img { width: 80px; height: 60px; }
.btn-x {
  position: absolute; top: -10px; right: -10px; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: var(--ink); color: var(--paper); font-size: 16px;
}
.btn-primary {
  min-height: 56px; padding: 0 28px; border: 0; border-radius: 999px;
  background: var(--sea); color: var(--paper); font-family: var(--f-title); font-weight: 900; font-size: 22px; letter-spacing: .1em;
  box-shadow: 0 6px 16px -8px rgba(31, 42, 46, .7), inset 0 -3px 0 rgba(0, 0, 0, .15);
}
.btn-primary.seal { background: var(--seal); }
.btn-primary:disabled, .btn-send:disabled { opacity: .5; cursor: default; }
.btn-ghost {
  min-height: 56px; padding: 0 24px; border-radius: 999px; border: 2px solid rgba(31, 42, 46, .3);
  background: transparent; font-weight: 700; font-size: 20px;
}
.notice {
  margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 18px;
  background: rgba(232, 169, 58, .18); border: 1.5px solid rgba(232, 169, 58, .6); color: var(--ink);
}

/* ── 對話頁 ── */
.chat-view {
  height: 100vh; height: 100dvh; min-height: 0;
  display: flex; flex-direction: column; padding-bottom: 0;
}
.chat-view > * { width: 100%; max-width: 980px; margin-left: auto; margin-right: auto; }
.stepwrap { flex: none; margin: 0 auto 8px; }
.stepbar {
  list-style: none; margin: 0; padding: 6px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: var(--paper-a); border-radius: 16px; box-shadow: 0 0 0 1.5px var(--line);
}
.stepbar li { min-width: 0; }
.stepbar button {
  width: 100%; height: 100%; display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 4px 8px;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font-weight: 700; font-size: 16px;
  line-height: 1.3; text-align: left;
}
.stepbar i {
  font-style: normal; font-family: var(--f-title); font-weight: 900; font-size: 18px;
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; flex: none;
  border: 1.5px dashed rgba(31, 42, 46, .3);
}
.stepbar li.done i { background: var(--seal); color: var(--paper); border: 0; transform: rotate(-5deg); }
.stepbar li.now button { background: rgba(200, 69, 44, .12); color: var(--seal); }
.stepbar li.now i { border: 2px solid var(--seal); color: var(--seal); }
.stepbar li.open button { box-shadow: inset 0 0 0 2px var(--sea); }
.step-help {
  margin: 6px 0 0; padding: 10px 14px; border-radius: 14px; font-size: 17px; line-height: 1.6;
  background: var(--paper); box-shadow: 0 0 0 1.5px rgba(47, 122, 131, .5);
}
.step-help b { display: block; color: var(--sea); font-family: var(--f-title); }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 2px 12px; -webkit-overflow-scrolling: touch; }
.chat-list { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; }
.msg.tutor { align-self: flex-start; padding-right: 8%; }
.msg.student { align-self: flex-end; justify-content: flex-end; padding-left: 14%; }
.bubble {
  min-width: 0; padding: 12px 16px; border-radius: 20px; font-size: 19px; line-height: 1.75;
  overflow-wrap: anywhere; white-space: normal;
}
.msg.tutor .bubble {
  background: rgba(255, 255, 255, .92); border-bottom-left-radius: 6px;
  box-shadow: 0 0 0 1.5px rgba(31, 42, 46, .18), 0 0 14px rgba(31, 42, 46, .08);
}
.msg.tutor .bubble strong { color: var(--seal); }
.rich p { margin: 0 0 .6em; }
.rich p:last-child, .rich ul:last-child, .rich ol:last-child { margin-bottom: 0; }
.rich ul, .rich ol { margin: 0 0 .6em; padding-left: 1.5em; }
.rich li { margin: .2em 0; padding-left: .1em; }
.rich ul li::marker { color: var(--sea); }
.rich ol li::marker { color: var(--sea); font-weight: 700; }
.failed-chip { display: block; margin-top: 6px; font-size: 14px; opacity: .9; }
.msg.student .bubble {
  background: var(--sea); color: var(--paper); border-bottom-right-radius: 6px;
  box-shadow: 0 6px 14px -8px rgba(31, 42, 46, .6);
}
.msg .who { display: block; font-family: var(--f-title); font-weight: 900; font-size: 15px; color: var(--seal); margin-bottom: 2px; }
.photo-chip { display: inline-block; margin-top: 6px; font-size: 15px; opacity: .85; }
.thinking { align-items: center; }
.thinking .avatar { width: 84px; border-radius: 0; overflow: visible; background: none; box-shadow: none; }
.thinking .avatar img { transform: none; animation: bob 1.2s ease-in-out infinite; }
.thinking .avatar .tutor-fallback { font-size: 30px; animation: bob 1.2s ease-in-out infinite; }
.thinking .bubble { color: var(--ink-2); font-family: var(--f-title); font-weight: 600; }
.dots span { display: inline-block; animation: blink 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

.cheer {
  margin: 16px auto 6px; max-width: 560px; display: grid; gap: 10px;
  background: var(--paper); border-radius: var(--r); padding: 14px 16px;
  box-shadow: 0 0 0 2px var(--seal), 0 0 24px rgba(200, 69, 44, .2);
}
.cheer-head { display: flex; align-items: center; gap: 12px; }
.tutor-cheer { position: relative; flex: none; width: 88px; aspect-ratio: 1; display: grid; place-items: center; animation: pop .6s ease-out; }
.tutor-cheer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tutor-cheer .tutor-fallback { font-size: 34px; }
.cheer-title { margin: 0; font-family: var(--f-title); font-weight: 900; font-size: 24px; color: var(--seal); line-height: 1.3; }
.cheer .muted { font-size: 16px; }
.final-box { background: #fffdf7; border-radius: 14px; padding: 12px 16px 14px; border: 2px dashed rgba(200, 69, 44, .5); }
.final-label { margin: 0 0 4px; font-family: var(--f-title); font-weight: 900; font-size: 18px; color: var(--sea); }
.final-text { margin: 0; font-family: var(--f-title); font-weight: 600; font-size: 26px; line-height: 1.6; overflow-wrap: anywhere; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }

.chat-foot { flex: none; display: grid; gap: 8px; padding: 8px 0 max(12px, env(safe-area-inset-bottom, 0px)); }
.done-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.done-actions button { min-height: 60px; background-color: var(--paper); }
.done-actions .btn-primary { background: var(--seal); }
.composer { display: grid; gap: 6px; }
.frames { display: grid; gap: 4px; }
.frame-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.frame-btn { border: 2px dashed var(--sea); background: var(--paper-a); color: var(--ink); border-radius: 999px; padding: 8px 14px; font-size: 18px; font-weight: 700; cursor: pointer; }
.frame-btn:active { transform: scale(.97); }
.mic-tip { margin: 0; padding: 2px 12px; font-size: 15px; color: var(--ink-2); background: var(--paper-a); border-radius: 999px; justify-self: start; }
.composer .count-line { padding: 2px 14px; background: var(--paper-a); border-radius: 999px; justify-self: start; }
.composer-row {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px; border-radius: 22px;
  background: var(--paper-a); box-shadow: 0 0 0 1.5px rgba(31, 42, 46, .22), 0 -6px 20px -12px rgba(31, 42, 46, .4);
}
.chat-input { flex: 1; resize: none; min-height: 64px; max-height: 30vh; }
.btn-cam {
  flex: none; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%;
  background: rgba(255, 255, 255, .85); border: 2px solid rgba(47, 122, 131, .5); font-size: 26px; cursor: pointer;
}
.btn-send {
  flex: none; min-width: 104px; height: 64px; padding: 0 18px; border: 0; border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--seal); color: var(--paper); font-family: var(--f-title); font-weight: 900; font-size: 22px; letter-spacing: .1em;
  box-shadow: 0 6px 14px -6px rgba(200, 69, 44, .8), inset 0 -3px 0 rgba(0, 0, 0, .18);
}
.send-arrow { font-size: 18px; letter-spacing: 0; }
.btn-send.locked { background: var(--ink-2); }

/* ── 自製對話框 ── */
.dialog-mask {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(31, 42, 46, .45); padding: 16px;
}
.dialog { max-width: 400px; width: 100%; text-align: center; display: grid; gap: 10px; background: var(--paper); }
.dialog-title { margin: 0; font-family: var(--f-title); font-weight: 900; font-size: 26px; }
.dialog-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

/* ── RWD ── */
@media (max-width: 560px) {
  .big-actions { grid-template-columns: 1fr; }
  .btn-big { min-height: 84px; }
  .hello-card { padding: 16px; }
  .tutor-mid { width: 84px; }
  .stepbar { display: flex; gap: 4px; padding: 5px; }
  .stepbar li { flex: none; }
  .stepbar li.now { flex: 1; }
  .stepbar li:not(.now) span { display: none; }
  .stepbar button { min-height: 44px; padding: 4px 6px; font-size: 15px; gap: 4px; }
  .stepbar i { width: 26px; height: 26px; font-size: 16px; }
  .stepbar li:not(.now) button { justify-content: center; }
  .msg.tutor .avatar { display: none; }
  .msg.tutor .who { display: flex; align-items: center; gap: 6px; }
  .msg.tutor .who::before {
    content: ""; width: 30px; height: 30px; border-radius: 50%; flex: none;
    background: var(--seal) url("img/tutor-wave.webp") 50% 18% / 190% auto no-repeat;
    background-color: var(--paper); box-shadow: 0 0 0 1.5px rgba(200, 69, 44, .55);
  }
  .bubble { font-size: 18px; line-height: 1.8; padding: 12px 14px; }
  .chat-title { display: none; }
  .who-chip { font-size: 16px; padding: 5px 10px; }
  .btn-text { padding: 0 12px; }
  .btn-continue b { font-size: 23px; }
  .final-text { font-size: 22px; }
  .tutor-cheer { width: 72px; }
  .cheer-title { font-size: 21px; }
  .composer-row { padding: 6px; gap: 6px; }
  .btn-cam { width: 48px; height: 48px; font-size: 22px; }
  .msg.student { padding-left: 8%; }
  .msg.tutor { padding-right: 2%; }
  .avatar { width: 44px; }
  .thinking .avatar { width: 64px; }
  .btn-send { min-width: 84px; padding: 0 10px; font-size: 20px; letter-spacing: .04em; }
  .brand-mark { font-size: 17px; padding: 4px 10px; }
  .msg.thinking .avatar { display: grid; }
}
@media (min-width: 1100px) {
  body { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
