/* muzix 家長 App styles. Role accent = 家長 amber gold (Master Bible §16.4),
   driven by --parent-* tokens (Dev Bible §2 — no hardcoded brand hex). Semantic
   colours (success green / error red) keep their own meaning; the amber accent is
   brand/emphasis ONLY and must never read as a warning. */

:root {
  --bg: #f8f9fa;
  --ink: #0a0a0f;
  --muted: #4b4b57;
  --faint: #9a9aa6;
  --line: #e9e9ef;

  /* 家長 role accent */
  --parent-accent: #fca92f;   /* 琥珀金 */
  --parent-panel:   #fff5e6;  /* 12% overlay — tinted chips/panels */
  --parent-surface: #fffdfa;  /* 2.5% overlay — card surfaces */
  --parent-grad: linear-gradient(135deg, color-mix(in srgb, var(--parent-accent) 86%, #fff), var(--parent-accent));
  --parent-ring: color-mix(in srgb, var(--parent-accent) 30%, transparent);

  --card: var(--parent-surface);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* sections are toggled with .active */
#login, #app { display: none; min-height: 100vh; }
#login.active { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
#app.active { display: block; }

.login-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.login-brand .logo { height: 22px; width: auto; display: block; }
.role-tag {
  font-size: 12px; font-weight: 600; color: var(--parent-accent);
  background: var(--parent-panel); border-radius: 999px; padding: 3px 9px;
}

.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: 22px; padding: 28px;
  box-shadow: 0 2px 10px rgba(10, 10, 15, .04);
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card .sub { font-size: 14px; line-height: 1.6; color: var(--muted); margin: 0 0 20px; }

form label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
form input {
  width: 100%; font: inherit; font-size: 15px; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--parent-surface); outline: none;
}
form input:focus { border-color: var(--parent-accent); box-shadow: 0 0 0 3px var(--parent-ring); }

.btn {
  display: inline-block; width: 100%; margin-top: 14px; font: inherit;
  font-weight: 700; font-size: 15px; padding: 14px; border-radius: 999px;
  border: 0; cursor: pointer;
}
.btn-primary { background: var(--parent-accent); color: var(--ink); } /* dark text — amber is light, white fails contrast */
.btn-primary:disabled { opacity: .6; cursor: default; }

.flash { font-size: 14px; line-height: 1.5; margin-top: 14px; display: none; }
.flash.show { display: block; }
.flash.ok { color: #2e9e7a; }   /* semantic success — unchanged */
.flash.err { color: #c8503e; }  /* semantic error — unchanged */

.note { font-size: 12px; line-height: 1.6; color: var(--faint); margin: 18px 0 0; }

/* app bar */
.app-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line); background: var(--parent-surface);
}
.linkbtn { background: none; border: 0; color: var(--parent-accent); font: inherit; font-weight: 600; cursor: pointer; }
.app-body { padding: 18px 16px 32px; max-width: 480px; margin: 0 auto; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }

/* wallet */
.wallet-card {
  display: flex; align-items: baseline; justify-content: space-between;
  background: var(--parent-accent); background: var(--parent-grad); /* flat fallback, then gradient */
  color: var(--ink); border-radius: 18px; padding: 18px 20px; margin-bottom: 22px;
}
.wallet-lb { font-size: 13px; opacity: .7; font-weight: 600; }
.wallet-amt { font-size: 24px; font-weight: 700; letter-spacing: .01em; }

/* section title */
.sec-title { font-size: 14px; font-weight: 700; color: var(--muted); margin: 0 2px 12px; display: flex; align-items: center; gap: 7px; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--parent-panel); color: var(--parent-accent); font-size: 12px; }

/* child cards */
.kid-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 14px; box-shadow: 0 2px 10px rgba(10,10,15,.04); }
.kid-top { display: flex; align-items: center; gap: 12px; }
.kid-av { width: 42px; height: 42px; border-radius: 12px; background: var(--parent-accent); background: var(--parent-grad); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.kid-name { font-size: 16px; font-weight: 700; }
.kid-grade { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kid-prog { margin: 16px 0 10px; }
.kp-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kp-pct { font-weight: 700; color: var(--parent-accent); }
.kp-bar { height: 8px; border-radius: 999px; background: #eef0f4; overflow: hidden; }
.kp-bar i { display: block; height: 100%; border-radius: 999px; background: var(--parent-accent); transition: width .4s ease; }
.kid-tutor { font-size: 13px; color: var(--muted); }
.kid-card.tap { cursor: pointer; transition: box-shadow .15s ease, transform .05s ease; }
.kid-card.tap:active { transform: scale(.995); }
.kid-arr { margin-left: auto; color: var(--faint); font-size: 22px; line-height: 1; }

.spin { text-align: center; color: var(--faint); font-size: 14px; padding: 28px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.empty { text-align: center; color: var(--faint); font-size: 14px; padding: 10px 0; }

/* child detail view (S2/S3) */
#child-view { display: none; position: fixed; inset: 0; background: var(--bg); z-index: 20; overflow-y: auto; }
#child-view.active { display: block; }
.cv-bar { position: sticky; top: 0; display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--parent-surface); border-bottom: 1px solid var(--line); }
.cv-bar .back { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--ink); cursor: pointer; padding: 0 4px; }
.cv-title { font-size: 17px; font-weight: 700; }
.cv-body { padding: 18px 16px 32px; max-width: 480px; margin: 0 auto; }

.lesson-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.lc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.lc-when { font-size: 14px; font-weight: 700; }
.lc-status { font-size: 12px; font-weight: 600; color: var(--parent-accent); background: var(--parent-panel); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.lc-sum { font-size: 14px; line-height: 1.6; color: var(--ink); white-space: pre-wrap; }
.lc-cmt { font-size: 13px; line-height: 1.6; color: var(--muted); margin-top: 8px; }
.lc-cmt span { display: block; font-weight: 700; color: var(--faint); font-size: 11px; margin-bottom: 2px; }
.lc-foot { font-size: 12px; color: var(--faint); margin-top: 10px; }
.lc-noins { font-size: 13px; color: var(--faint); }

/* S4 flip card (front = student basics / back = DREAMT radar) */
.flip-card { position: relative; }
.flip-inner { transition: transform .17s ease; transform-origin: center; will-change: transform; }
.flip-front { display: flex; flex-direction: column; }
.flip-back { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.flip-card:not(.flipped) .flip-back { display: none; }
.flip-card.flipped .flip-front { display: none; }
.stu-front, .stu-back { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 2px 10px rgba(10,10,15,.04); }
.stu-front .kid-tutor { margin-top: 4px; }
.flip-ico { margin-top: 14px; align-self: center; border: 1px solid var(--line); background: var(--parent-panel); color: var(--parent-accent); font: inherit; font-weight: 700; font-size: 13px; padding: 7px 16px; border-radius: 999px; cursor: pointer; }
.flip-ico.back-ico { margin-top: 12px; }

/* DREAMT radar */
.radar-svg { width: 100%; max-width: 200px; height: auto; display: block; }
.radar-empty { font-size: 13.5px; color: var(--faint); padding: 34px 14px; line-height: 1.6; }
.rg-ring, .rg-spoke { fill: none; stroke: var(--line); stroke-width: 1; }
.rg-req { fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 6 4; stroke-linejoin: round; stroke-linecap: round; }
.rg-area { fill: color-mix(in srgb, var(--parent-accent) 22%, transparent); stroke: var(--parent-accent); stroke-width: 1.9; stroke-linejoin: round; }
.rg-dot { fill: var(--parent-accent); }
.rg-lb { fill: var(--muted); font-size: 9px; }
.radar-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.radar-legend .rl { display: inline-flex; align-items: center; gap: 5px; }
.rl-sw { flex: none; }
.rd-caption { font-size: 10.5px; color: var(--faint); margin-top: 8px; line-height: 1.4; }

/* homework (S3) */
.hw-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.hw-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.hw-name { font-size: 15px; font-weight: 700; }
.hw-status { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.hw-skill { font-size: 13px; color: var(--parent-accent); margin-top: 8px; }
.hw-instr { font-size: 14px; line-height: 1.6; color: var(--muted); margin-top: 8px; white-space: pre-wrap; }
