/* =========================================================
   2026 新版外觀：所有頁面最後載入，統一顏色、圓角和動畫。
   想回到舊版外觀，只要在 HTML 拿走 theme.css 這一行。
   ========================================================= */
:root {
  --t-ink: #1f1d47;
  --t-muted: #6a6c8c;
  --t-line: #e3e1f2;
  --t-soft: #f5f4fd;
  --t-bg: #f7f6fc;
  --t-primary: #5b4ff0;
  --t-primary-dark: #4337c9;
  --t-primary-soft: #eeecff;
  --t-coral: #ff7a59;
  --t-mint: #12b886;
  --t-mint-dark: #0b8f68;
  --t-sun: #ffb020;
  --t-red: #e5484d;
  --t-radius: 18px;
  --t-shadow: 0 10px 30px rgba(47, 39, 140, 0.08);
  --t-shadow-lift: 0 18px 44px rgba(47, 39, 140, 0.14);
  --t-font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Heiti TC", system-ui, sans-serif;

  /* 舊樣式表的變數，一併換成新顏色 */
  --bg: var(--t-bg);
  --surface: var(--t-soft);
  --surface-strong: #e4e0ff;
  --panel: #fff;
  --text: var(--t-ink);
  --muted: var(--t-muted);
  --border: var(--t-line);
  --teal: var(--t-primary);
  --teal-dark: var(--t-primary-dark);
  --coral: var(--t-red);
  --amber: #d48806;
  --green: var(--t-mint-dark);
  --shadow: var(--t-shadow);
  --shadow-strong: 0 30px 80px rgba(31, 29, 71, 0.22);
  --radius: var(--t-radius);
  --ink: var(--t-ink);
  --line: var(--t-line);
  --soft: var(--t-soft);
  --blue: var(--t-primary);
  --blue-dark: var(--t-primary-dark);
  --red: var(--t-red);
  --f-ink: var(--t-ink);
  --f-muted: var(--t-muted);
  --f-line: var(--t-line);
  --f-soft: var(--t-soft);
  --f-bg: var(--t-bg);
  --f-blue: var(--t-primary);
  --f-blue-dark: var(--t-primary-dark);
  --f-blue-soft: var(--t-primary-soft);
  --f-red: var(--t-red);
  --f-font: var(--t-font);
}

body {
  font-family: var(--t-font);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(91, 79, 240, 0.09), transparent 70%),
    radial-gradient(700px 380px at -10% 0%, rgba(255, 122, 89, 0.08), transparent 70%),
    var(--t-bg);
  background-attachment: fixed;
}

body.flow-practice,
body.flow-choose,
body.portal-body { background:
    radial-gradient(900px 420px at 100% -10%, rgba(91, 79, 240, 0.09), transparent 70%),
    radial-gradient(700px 380px at -10% 0%, rgba(255, 122, 89, 0.07), transparent 70%),
    var(--t-bg); background-attachment: fixed; }

::selection { background: rgba(91, 79, 240, 0.2); }

/* ---------- 頂部列 ---------- */
.portal-header,
.practice-bar {
  border-bottom: 1px solid rgba(227, 225, 242, 0.9);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(1.4) blur(14px);
}

.portal-mark {
  border-radius: 14px;
  background: linear-gradient(145deg, #7b6ff7, var(--t-primary-dark));
  box-shadow: 0 8px 20px rgba(91, 79, 240, 0.3);
  transform: rotate(-4deg);
  transition: transform 200ms ease;
}

.portal-brand:hover .portal-mark { transform: rotate(4deg) scale(1.05); }
.teacher-mark { background: linear-gradient(145deg, #2fd3a1, var(--t-mint-dark)); box-shadow: 0 8px 20px rgba(18, 184, 134, 0.3); }

.portal-nav a,
.portal-nav button { border-radius: 999px; color: var(--t-muted); }
.portal-nav a:hover,
.portal-nav button:hover,
.portal-nav .is-active { color: var(--t-primary); background: var(--t-primary-soft); }
.teacher-body .portal-nav .is-active,
.teacher-body .portal-nav button:hover { color: var(--t-mint-dark); background: #e3f8f0; }

/* ---------- 按鈕 ---------- */
.portal-button,
.command,
.start-button,
.back-link { border-radius: 999px; transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, color 140ms ease; }

.portal-button.primary,
.command.primary,
.start-button {
  color: #fff;
  background: linear-gradient(135deg, #7366f6, var(--t-primary));
  box-shadow: 0 6px 0 var(--t-primary-dark), 0 12px 24px rgba(91, 79, 240, 0.25);
}

.portal-button.primary:hover,
.command.primary:hover,
.start-button:hover { background: linear-gradient(135deg, #6a5cf4, var(--t-primary-dark)); transform: translateY(-1px); }
.portal-button.primary:active,
.command.primary:active,
.start-button:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--t-primary-dark), 0 4px 10px rgba(91, 79, 240, 0.2); }

.teacher-body .portal-button.primary {
  background: linear-gradient(135deg, #2bcf9c, var(--t-mint));
  box-shadow: 0 5px 0 var(--t-mint-dark), 0 10px 22px rgba(18, 184, 134, 0.22);
}

.portal-button.ghost,
.command.ghost,
.back-link { border: 1px solid var(--t-line); background: #fff; }
.portal-button.ghost:hover,
.command.ghost:hover,
.back-link:hover { border-color: #cbc6f5; background: var(--t-soft); }

.start-button { min-height: 58px; padding: 0 34px; font-size: 19px; }

/* ---------- 卡片 ---------- */
.portal-card,
.metric-card,
.teacher-sidebar,
.stat-strip,
.practice-sheet,
.custom-block,
.article-card,
.choose-task {
  border-color: var(--t-line);
  border-radius: var(--t-radius);
  box-shadow: var(--t-shadow);
}

.article-card { transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease; }
.article-card:hover { transform: translateY(-3px); box-shadow: var(--t-shadow-lift); }

.welcome-card {
  border-radius: 24px;
  background: linear-gradient(120deg, #2d2591 0%, var(--t-primary) 55%, #8f7bff 100%);
}

.teacher-body .welcome-card { background: linear-gradient(120deg, #0b5e4a 0%, #11a57a 55%, #3dd6a5 100%); }

.welcome-card::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  left: 45%;
  bottom: -120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.metric-card { transition: transform 160ms ease; }
.metric-card:hover { transform: translateY(-2px); }
.metric-card > strong { font-variant-numeric: tabular-nums; }

.form-field input,
.form-field select,
.form-field textarea { border-radius: 12px; border-color: #dcd9ef; }

.teacher-sidebar button { border-radius: 12px; }
.teacher-sidebar button:hover,
.teacher-sidebar button.is-active { color: var(--t-mint-dark); background: #e3f8f0; }

.table-wrap { border-radius: 14px; border-color: var(--t-line); }
.portal-table th { background: var(--t-soft); }

/* ---------- 打字頁 ---------- */
.stat-strip { background: #fff; }
.stat-time strong { color: var(--t-primary); }
.stat-time strong.is-low { color: var(--t-red); animation: fx-tick 1s ease-in-out infinite; }

.strip-progress { height: 6px; background: #ece9fb; }
.strip-progress i {
  background: linear-gradient(90deg, var(--t-primary), #9b7bff, var(--t-coral), var(--t-primary));
  background-size: 300% 100%;
  animation: fx-flow 3s linear infinite;
  border-radius: 0 6px 6px 0;
}

.flow-practice .passage {
  background:
    linear-gradient(90deg, rgba(91, 79, 240, 0.05) 0, rgba(91, 79, 240, 0) 46px),
    #fff;
}

.char.correct { color: #0f7a57; background: rgba(18, 184, 134, 0.12); }
.char.wrong { color: #c42b31; background: rgba(229, 72, 77, 0.14); box-shadow: inset 0 -2px 0 rgba(229, 72, 77, 0.6); }
.char.current {
  background: rgba(91, 79, 240, 0.14);
  box-shadow: inset 0 -3px 0 var(--t-primary);
  animation: fx-caret 1.1s ease-in-out infinite;
}

.input-zone { background: var(--t-soft); }
.typing-input { border-radius: 14px; }
.start-overlay { background: rgba(245, 244, 253, 0.88); backdrop-filter: blur(3px); }
.start-overlay .start-button { animation: fx-breathe 2.4s ease-in-out infinite; }
.input-zone.is-counting .start-overlay { display: none; }

.result-dialog { border-radius: 24px; animation: fx-rise 360ms cubic-bezier(.2, .9, .3, 1.2); }

/* ---------- 打字動畫 ---------- */
/* 沒有拼音時，字是 inline，要改成 inline-block 才能做動畫；
   有拼音時每格已是 inline-flex（上拼音、下字），不可改，否則拼音會擠到字的旁邊 */
.char.fx-pop:not(.cell),
.char.fx-shake:not(.cell) { display: inline-block; }
.char.fx-pop { animation: fx-pop 260ms cubic-bezier(.3, 1.6, .5, 1); }
.char.fx-shake { animation: fx-shake 320ms ease; }
.passage .cell.fx-pop .hz { animation: fx-glow 420ms ease; }

.fx-combo {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--t-primary);
  background: var(--t-primary-soft);
  font-weight: 900;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 180ms ease, transform 180ms ease, background 200ms ease, color 200ms ease;
}

.fx-combo.is-on { opacity: 1; transform: scale(1); }
.fx-combo b { font-size: 20px; font-variant-numeric: tabular-nums; }
.fx-combo-label { font-size: 12px; }
.fx-combo.is-hot { color: #b45309; background: #fff1d6; }
.fx-combo.is-fire { color: #fff; background: linear-gradient(135deg, var(--t-coral), #ff4d6d); }
.fx-combo.is-fire .fx-combo-label::before { content: "🔥 "; }
.fx-combo.is-bump { animation: fx-bump 240ms ease; }
.fx-combo.is-broke { animation: fx-shake 360ms ease; }

.practice-sheet { position: relative; }
.fx-burst {
  position: absolute;
  left: 50%;
  top: 38%;
  z-index: 5;
  padding: 10px 22px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--t-primary), var(--t-coral));
  box-shadow: 0 16px 40px rgba(91, 79, 240, 0.35);
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
  animation: fx-burst 1.4s cubic-bezier(.2, .9, .3, 1) forwards;
}

.fx-countdown {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: rgba(245, 244, 253, 0.92);
  pointer-events: none;
}

.fx-count {
  color: var(--t-primary);
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  animation: fx-count 600ms cubic-bezier(.2, .9, .3, 1.3);
}

.fx-count.go { color: var(--t-mint); font-size: 52px; }

.kb-key.is-pressed { animation: fx-key 260ms ease; }

.fx-confetti { position: fixed; inset: 0; z-index: 60; overflow: hidden; pointer-events: none; }
.fx-confetti i {
  position: absolute;
  top: -20px;
  display: block;
  animation-name: fx-fall;
  animation-timing-function: cubic-bezier(.25, .6, .4, 1);
  animation-fill-mode: forwards;
}

@keyframes fx-pop { 0% { transform: scale(1.45) translateY(-3px); } 100% { transform: none; } }
@keyframes fx-glow { 0% { text-shadow: 0 0 14px rgba(18, 184, 134, 0.8); } 100% { text-shadow: none; } }
@keyframes fx-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes fx-caret { 0%, 100% { box-shadow: inset 0 -3px 0 var(--t-primary); } 50% { box-shadow: inset 0 -3px 0 rgba(91, 79, 240, 0.25); } }
@keyframes fx-bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes fx-burst { 0% { opacity: 0; transform: translate(-50%, 20px) scale(0.6); } 18% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 30% { transform: translate(-50%, 0) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50px) scale(0.95); } }
@keyframes fx-count { 0% { opacity: 0; transform: scale(2.2); } 100% { opacity: 1; transform: scale(1); } }
@keyframes fx-key { 0% { transform: translateY(2px) scale(0.92); filter: brightness(0.9); box-shadow: 0 0 0 3px rgba(91, 79, 240, 0.45); } 100% { transform: none; } }
@keyframes fx-fall { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--drift), 105vh) rotate(var(--spin)); opacity: 0.9; } }
@keyframes fx-flow { from { background-position: 0 0; } to { background-position: 300% 0; } }
@keyframes fx-tick { 0%, 100% { transform: none; } 50% { transform: scale(1.08); } }
@keyframes fx-breathe { 0%, 100% { transform: none; } 50% { transform: translateY(-2px) scale(1.03); } }
@keyframes fx-rise { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }

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

/* =========================================================
   老師後台：練習代碼
   ========================================================= */
.code-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 26px clamp(20px, 3vw, 34px);
  border-radius: 24px;
  color: #fff;
  background: linear-gradient(120deg, #2d2591, var(--t-primary) 60%, #8f7bff);
  box-shadow: var(--t-shadow-lift);
  overflow: hidden;
  position: relative;
}

.code-hero[hidden] { display: none; }
.code-hero .eyebrow { color: rgba(255, 255, 255, 0.75); }
.code-hero h2 { margin: 4px 0 6px; font-size: 22px; }
.code-hero p { margin: 0; color: rgba(255, 255, 255, 0.82); font-weight: 700; word-break: break-all; }
.code-hero .code-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.code-hero .portal-button { color: var(--t-primary-dark); background: #fff; box-shadow: none; border: 0; }
.code-hero .portal-button.ghost { color: #fff; background: rgba(255, 255, 255, 0.16); }

.code-big {
  display: flex;
  gap: 8px;
  font-family: "Consolas", "SFMono-Regular", "Menlo", monospace;
}

.code-big span {
  width: 58px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--t-ink);
  background: #fff;
  box-shadow: 0 6px 0 rgba(31, 29, 71, 0.25);
  font-size: 40px;
  font-weight: 900;
  animation: fx-flip 520ms cubic-bezier(.2, .9, .3, 1.3) both;
}

.code-big span:nth-child(2) { animation-delay: 60ms; }
.code-big span:nth-child(3) { animation-delay: 120ms; }
.code-big span:nth-child(4) { animation-delay: 180ms; }
.code-big span:nth-child(5) { animation-delay: 240ms; }
.code-big span:nth-child(6) { animation-delay: 300ms; }

@keyframes fx-flip { from { opacity: 0; transform: rotateX(90deg) translateY(-10px); } to { opacity: 1; transform: none; } }

.source-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--t-soft);
  grid-column: 1 / -1;
  justify-self: start;
}

.source-switch button {
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  color: var(--t-muted);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
}

.source-switch button.is-active { color: #fff; background: var(--t-mint); box-shadow: 0 4px 12px rgba(18, 184, 134, 0.3); }

.code-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 10px;
  color: var(--t-primary-dark);
  background: var(--t-primary-soft);
  font-family: "Consolas", "SFMono-Regular", "Menlo", monospace;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.code-chip.is-off { color: #9a9ab0; background: #f0f0f5; text-decoration: line-through; }

/* 投影用：全螢幕顯示代碼 */
.code-projector {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 28px;
  padding: 24px;
  color: #fff;
  background: radial-gradient(circle at 30% 20%, #6d5ff5, #241d7a 70%);
  text-align: center;
}

.code-projector[hidden] { display: none; }
.code-projector h2 { margin: 0; font-size: clamp(22px, 3vw, 36px); }
.code-projector p { margin: 0; color: rgba(255, 255, 255, 0.82); font-size: clamp(16px, 2vw, 24px); font-weight: 700; word-break: break-all; }
.code-projector .code-big span { width: clamp(64px, 11vw, 150px); height: clamp(84px, 14vw, 190px); font-size: clamp(48px, 9vw, 120px); border-radius: 22px; }
.code-projector .portal-button { position: absolute; top: 20px; right: 20px; color: #fff; background: rgba(255, 255, 255, 0.16); border: 0; }

@media (max-width: 680px) {
  .code-hero { grid-template-columns: 1fr; }
  .code-big span { width: 44px; height: 56px; font-size: 30px; }
}

/* =========================================================
   輸入法切換（拼音／速成／倉頡）、聲效、考試模式
   ========================================================= */
.method-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--t-soft);
  border: 1px solid var(--t-line);
}

.method-switch[hidden] { display: none; }
.method-switch button {
  min-width: 50px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  color: var(--t-muted);
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.method-switch button[aria-checked="true"] { color: #fff; background: var(--t-primary); box-shadow: 0 3px 10px rgba(91, 79, 240, 0.3); }
.method-switch button:focus-visible { outline: 3px solid rgba(91, 79, 240, 0.35); outline-offset: 1px; }
.view-toggles[hidden] { display: none; }

.sound-toggle {
  width: 40px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--t-line);
  border-radius: 999px;
  color: var(--t-primary-dark);
  background: #fff;
  cursor: pointer;
}

.sound-toggle svg { width: 20px; height: 20px; fill: currentColor; }
.sound-toggle .snd-off { display: none; }
.sound-toggle[aria-pressed="false"] { color: var(--t-muted); }
.sound-toggle[aria-pressed="false"] .snd-on { display: none; }
.sound-toggle[aria-pressed="false"] .snd-off { display: block; }

/* 字上面顯示速成／倉頡字根 */
.passage.has-codes .cell .py {
  color: #8a7fd0;
  font-family: var(--t-font);
  font-size: 0.38em;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.passage.is-cangjie .cell.han { width: 1.9em; }
.passage.is-cangjie .cell .py { font-size: 0.34em; }

/* 指法提示：字根＋字母 */
.key-chip.has-radical { min-width: 40px; height: 40px; padding: 0 6px; gap: 0; line-height: 1; }
.key-chip.has-radical b { font-family: var(--t-font); font-size: 17px; }
.key-chip.has-radical small { font-size: 10px; opacity: 0.85; }
.kb-key.has-radical { height: 30px; align-content: center; gap: 1px; line-height: 1; }
.kb-key.has-radical b { font-family: var(--t-font); font-size: 12px; font-weight: 800; }
.kb-key.has-radical small { font-size: 8px; opacity: 0.75; }

/* 考試模式 */
.is-exam .practice-bar { box-shadow: inset 0 -3px 0 var(--t-coral); }
.is-exam .practice-heading p::before {
  content: "考試中";
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--t-coral);
  font-size: 12px;
}

/* 老師後台：用途 */
.purpose-pick {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}
.purpose-pick legend { margin-bottom: 7px; color: #4e5f73; font-size: 13px; font-weight: 900; }
.purpose-pick label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 2px solid var(--t-line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.purpose-pick label:has(input:checked) { border-color: var(--t-mint); background: #effbf6; }
.purpose-pick label:has(input[value="exam"]:checked) { border-color: var(--t-coral); background: #fff4f0; }
.purpose-pick input { margin-top: 3px; accent-color: var(--t-mint); }
.purpose-pick b, .purpose-pick small { display: block; }
.purpose-pick small { margin-top: 2px; color: var(--t-muted); font-weight: 600; }
.purpose-chip { display: inline-block; padding: 2px 9px; border-radius: 999px; color: var(--t-mint-dark); background: #e3f8f0; font-size: 12px; font-weight: 900; }
.purpose-chip.is-exam { color: #fff; background: var(--t-coral); }

@media (max-width: 820px) {
  .method-switch button { min-width: 0; padding: 0 9px; }
}
@media (max-width: 680px) {
  .purpose-pick { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .method-switch button { height: 30px; padding: 0 7px; font-size: 12px; }
  .sound-toggle { width: 34px; height: 34px; }
}
@media (max-width: 600px) {
  .practice-tools .font-tool { display: none; }
}
@media (max-width: 600px) {
  .practice-bar { flex-wrap: wrap; row-gap: 6px; }
  .practice-tools { order: 3; width: 100%; justify-content: space-between; }
}

/* ---------- 選文章：分類欄（分組、自動換行，不再橫向捲動） ---------- */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px 26px;
  overflow: visible;
  padding: 16px 18px;
  border: 1px solid var(--t-line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--t-shadow);
}

.cat-group { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.cat-group-label {
  padding-left: 4px;
  color: var(--t-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.cat-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--t-soft);
}

.category-tab {
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  color: var(--t-ink);
  background: transparent;
  font-size: 15px;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.category-tab:hover { background: #fff; box-shadow: 0 2px 8px rgba(47, 39, 140, 0.08); }

.category-tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, #7366f6, var(--t-primary));
  box-shadow: 0 6px 16px rgba(91, 79, 240, 0.32);
}

.category-tab:focus-visible { outline: 3px solid rgba(91, 79, 240, 0.35); outline-offset: 2px; }

.tab-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--t-muted);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.category-tab:hover .tab-count { background: var(--t-soft); }
.category-tab.is-active .tab-count { color: #fff; background: rgba(255, 255, 255, 0.22); }

@media (max-width: 600px) {
  .category-tabs { gap: 8px; padding: 10px; border-radius: 18px; }
  .cat-group { display: grid; grid-template-columns: 3.4em 1fr; align-items: center; gap: 6px; width: 100%; }
  .cat-group-label { padding-left: 2px; font-size: 11px; letter-spacing: 0.02em; line-height: 1.25; }
  .cat-group-chips { gap: 2px; padding: 3px; border-radius: 12px; }
  .category-tab { gap: 5px; min-height: 34px; padding: 0 9px; border-radius: 9px; font-size: 14px; }
  .tab-count { min-width: 18px; padding: 0 5px; font-size: 11px; }
}

/* 手機上可以左右滑的列：滑得動，但不顯示捲動條 */
.time-options,
.portal-nav,
.teacher-sidebar { scrollbar-width: none; }
.time-options::-webkit-scrollbar,
.portal-nav::-webkit-scrollbar,
.teacher-sidebar::-webkit-scrollbar { display: none; }

/* ---------- 老師：我的文章 ---------- */
.share-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.share-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--t-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
}

.share-steps b {
  display: grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(145deg, #2fd3a1, var(--t-mint-dark));
  font-size: 15px;
}

.share-steps span { display: grid; gap: 3px; }
.share-steps strong { color: var(--t-ink); font-size: 15px; }
.share-steps small { color: var(--t-muted); font-size: 13px; line-height: 1.45; }

.article-editor .card-heading { flex-wrap: wrap; }
.editor-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.file-button { position: relative; cursor: pointer; }
.file-button:focus-within { outline: 3px solid rgba(18, 184, 134, 0.35); outline-offset: 2px; }

.template-select {
  max-width: 260px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--t-line);
  border-radius: 999px;
  color: var(--t-ink);
  background: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.form-field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.article-editor textarea { min-height: 200px; line-height: 1.7; }

.list-count { margin-left: 6px; color: var(--t-muted); font-size: 14px; font-weight: 700; }

.article-search input {
  width: 240px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--t-line);
  border-radius: 999px;
  background: var(--t-soft);
  font: inherit;
  font-size: 14px;
}

.article-search input:focus { border-color: var(--t-mint); outline: none; background: #fff; }

.my-article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.my-article-grid > .empty-state { grid-column: 1 / -1; }

.my-article {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--t-line);
  border-radius: 16px;
  background: #fff;
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.my-article:hover { transform: translateY(-2px); box-shadow: var(--t-shadow-lift); }
.my-article.is-off { background: var(--t-soft); opacity: 0.75; }
.my-article-top { display: flex; align-items: center; gap: 6px; }
.my-article-len { margin-left: auto; color: var(--t-muted); font-size: 13px; font-weight: 800; }
.my-article h3 { margin: 0; overflow: hidden; color: var(--t-ink); font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }

.my-article-preview {
  display: -webkit-box;
  min-height: 2.9em;
  margin: 0;
  overflow: hidden;
  color: var(--t-muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.my-article-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; color: var(--t-muted); font-size: 12px; }
.my-article .table-actions { margin-top: auto; padding-top: 4px; }

.off-chip,
.shared-chip { display: inline-flex; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.off-chip { color: #8a5a07; background: #fff3d9; }
.shared-chip { color: var(--t-primary-dark); background: var(--t-primary-soft); }

#codeForm.is-flash { animation: fx-form-flash 1.4s ease; border-radius: 14px; }
@keyframes fx-form-flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(18, 184, 134, 0.35); } 100% { box-shadow: 0 0 0 4px rgba(18, 184, 134, 0); } }

@media (max-width: 820px) {
  .share-steps { grid-template-columns: 1fr; gap: 8px; }
  .share-steps li { padding: 10px 12px; }
  .article-search, .article-search input { width: 100%; }
  .template-select { max-width: 100%; }
}

@media (max-width: 600px) {
  .form-field-pair { grid-template-columns: 1fr; }
  .my-article-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  #codeForm.is-flash { animation: none; }
  .my-article:hover { transform: none; }
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#codeForm,
#articleEditor { scroll-margin-top: 96px; }

.form-actions { flex-wrap: wrap; align-items: center; }
.form-actions .portal-button { white-space: nowrap; }
.count-badge { align-self: center; white-space: nowrap; }

@media (max-width: 600px) {
  .article-editor .form-actions .count-badge { margin-right: auto; }
  .article-editor .form-actions button[data-after="share"] { flex: 1 1 100%; justify-content: center; }
}
.list-heading { flex-wrap: wrap; }
.list-heading h2 { white-space: nowrap; }
@media (max-width: 600px) { .list-heading .article-search { flex: 1 1 100%; } }

/* ---------- 開始前試打（確認中英文、繁簡輸入法） ---------- */
.input-zone.is-idle.has-ime-check .input-box { min-height: 206px; }
.ime-check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  max-width: 600px;
  padding: 0 12px;
}
.ime-check[hidden] { display: none; }
.ime-check label { color: var(--t-ink); font-size: 15px; font-weight: 700; }
.ime-check input {
  width: 180px;
  height: 42px;
  padding: 0 12px;
  border: 2px solid #d6d2f6;
  border-radius: 12px;
  background: #fff;
  color: var(--t-ink);
  font: inherit;
  font-size: 20px;
  text-align: center;
}
.ime-check input:focus { border-color: var(--t-primary); outline: none; box-shadow: 0 0 0 4px rgba(91, 79, 240, 0.16); }
.start-overlay .ime-check-status { flex-basis: 100%; min-height: 20px; color: var(--t-muted); font-size: 14px; text-align: center; }
.start-overlay .ime-check-status[data-tone="ok"] { color: var(--t-mint-dark); }
.start-overlay .ime-check-status[data-tone="warn"] { color: #c42b31; }
.ime-check:has([data-tone="ok"]) input { border-color: var(--t-mint); }
.ime-check:has([data-tone="warn"]) input { border-color: var(--t-red); }

/* 按了開始、等第一個字：輸入框發亮提示 */
.input-zone.is-armed .typing-input {
  border-color: var(--t-primary);
  box-shadow: 0 0 0 4px rgba(91, 79, 240, 0.16);
  animation: fx-armed 1.6s ease-in-out infinite;
}
.input-zone.is-armed .typing-input::placeholder { color: var(--t-primary); font-weight: 700; opacity: 0.8; }
@keyframes fx-armed {
  0%, 100% { box-shadow: 0 0 0 4px rgba(91, 79, 240, 0.12); }
  50% { box-shadow: 0 0 0 6px rgba(91, 79, 240, 0.24); }
}
@media (prefers-reduced-motion: reduce) {
  .input-zone.is-armed .typing-input { animation: none; }
}

@media (max-width: 820px) {
  .input-zone.is-idle.has-ime-check .input-box { min-height: 188px; }
  .ime-check { gap: 4px 8px; padding: 0 4px; }
  .ime-check label { flex-basis: 100%; text-align: center; font-size: 14px; }
  .ime-check input { width: 160px; height: 38px; font-size: 18px; }
  .start-overlay .ime-check-status { font-size: 13px; min-height: 18px; }
}
