:root {
  --font: "Noto Sans TC", "Noto Sans CJK TC", "Noto Sans CJK HK", "PingFang HK", "PingFang TC", "Hiragino Sans CNS", "Microsoft JhengHei", sans-serif;
  --bg: #f4efe6;
  --bg-2: #ebe4d8;
  --card: #fffcf7;
  --ink: #1d3330;
  --muted: #5d706c;
  --line: #ddd4c6;
  --teal: #2c7a73;
  --teal-dark: #1c5853;
  --teal-soft: #d8efe9;
  --danger: #8f3535;
  --danger-bg: #f8ecec;
  --warn: #8a5a12;
  --warn-bg: #f7efd8;
  --ok: #246247;
  --ok-bg: #e5f3eb;
  --shadow: 0 12px 32px rgba(29, 51, 48, 0.07);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, #e7f3ef 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
}

html, body, #app { min-height: 100vh; }

a { color: var(--teal-dark); }

.hidden { display: none; }

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

/* ===== Login / password (風格 A) ===== */
.login-page,
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 32px 16px;
}

.login-card,
.login-wrap .card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
}

.login-card .brand,
.login-wrap .brand {
  margin-bottom: 16px;
}

.login-card .brand strong,
.login-wrap .brand strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.login-card .brand span,
.login-wrap .brand span,
.muted, .hint {
  color: var(--muted);
  font-size: 14.5px;
}

.login-card h1,
.login-wrap h1,
.password-card h1 {
  margin: 16px 0 14px;
  font-size: 23px;
  font-weight: 700;
}

.login-card label,
.login-wrap label,
.password-card label,
.a-label, label {
  display: block;
  font-size: 13.5px;
  color: var(--muted);
  margin: 0 0 6px;
}

.login-card input,
.login-wrap input,
.password-card input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  margin-bottom: 14px;
}

.login-card button[type="submit"],
.login-wrap form .actions button[type="submit"],
.login-card .login-submit {
  width: 100%;
  border: 0;
  background: var(--teal);
  color: #fff;
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
}

.login-wrap .actions { margin-top: 0; }
.login-wrap .actions button { width: 100%; }

.password-card .hint { margin: 0 0 12px; }

/* ===== 青綠側欄 shell ===== */
.a {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  align-items: stretch;
}

.a-side {
  width: 248px;
  flex: none;
  background: #1c5853;
  color: #e7f3ef;
  display: flex;
  flex-direction: column;
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.a-logo {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 8px 28px;
}

.a-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #2c7a73;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.ico { width: 18px; height: 18px; flex: none; }

.a-logo b { display: block; font-size: 15px; color: #fff; font-weight: 700; }
.a-logo span { display: block; font-size: 12px; color: #b7d6d1; }

.a-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.a-nav a,
.a-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  color: #d8efe9;
  text-decoration: none;
  font-weight: 600;
  font-size: 14.5px;
  background: transparent;
  border: 0;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.a-nav a.active,
.a-nav button.active {
  background: #2c7a73;
  color: #fff;
}

.a-user {
  padding: 16px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
  color: #b7d6d1;
}

.a-user b { display: block; color: #fff; margin-bottom: 8px; font-size: 14px; }
.a-user a { color: #d8efe9; text-decoration: none; font-weight: 600; }

.a-main {
  flex: 1;
  padding: 36px 40px 28px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.a-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}

.a-head h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.a-head p { margin: 0; color: var(--muted); font-size: 14.5px; }

.a-cta,
button,
.btn {
  appearance: none;
  background: var(--teal);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

a.btn {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.a-btn-sec,
button.secondary,
.btn.secondary {
  background: transparent;
  color: var(--teal-dark);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
}

button:disabled, .btn:disabled, .a-cta:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.danger { background: var(--danger); color: #fff; }

button.secondary-danger,
.btn.secondary-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.a-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

.a-foot {
  margin-top: auto;
  color: var(--muted);
  font-size: 13px;
  padding-top: 24px;
}

/* Overview */
.a-child { margin-bottom: 22px; }
.a-child-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.a-child-h h2 { margin: 0; font-size: 18px; font-weight: 700; }

.av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex: none;
}
.av-0 { background: #f3d7b5; color: #6a3b16; }
.av-1 { background: #cfe8e2; color: #1c5853; }
.av-2 { background: #e4d7f3; color: #4a3a6a; }
.av-3 { background: #f3d4d4; color: #6a2a2a; }

.a-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}

.a-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 16px 14px;
  min-height: 148px;
  box-shadow: 0 8px 24px rgba(29, 51, 48, 0.05);
  border-top: 4px solid var(--line);
}

.a-card.zh { border-top-color: #2c7a73; }
.a-card.en { border-top-color: #7c6ea5; }
.a-card.math { border-top-color: #c4922a; }
.a-card.science { border-top-color: #278c5c; }
.a-card.humanities { border-top-color: #9c5a3e; }

.a-card .k {
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.pill {
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 8px;
  flex: none;
}
.pill-on { background: #d8efe9; color: #1c5853; }
.pill-off { background: #ebe4d8; color: #5d706c; }

.a-card .meta { color: var(--muted); font-size: 13.5px; }
.a-card .meta b { color: var(--ink); }
.a-card .title { color: var(--ink); font-weight: 650; margin: 2px 0 6px; font-size: 14.5px; }
.a-empty { color: #8a7d70; font-size: 13.5px; padding-top: 8px; }

/* Forms */
.a-form,
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.a-select,
select,
input[type="text"],
input[type="password"] {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
}

select, input[type="text"], input[type="password"] { margin-bottom: 0; }

.a-select:invalid,
select:invalid {
  color: var(--muted);
}

input:focus, select:focus, .a-drop:focus-within, .photo-drop:focus-within, .drop:focus-within {
  outline: 2px solid var(--teal-soft);
  border-color: var(--teal);
}

.a-drop, .drop {
  background: #fbf8f2;
  border: 1.5px dashed #c9bfb0;
  border-radius: 16px;
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  margin-bottom: 16px;
  cursor: pointer;
}

.a-drop b, .drop b { display: block; color: var(--ink); margin-top: 8px; }
.a-drop.drag, .drop.drag, .photo-drop.drag {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.drop input, .a-drop input, .photo-drop input { display: none; }
.file-name { margin-top: 8px; color: var(--ink); font-weight: 600; }

.a-box, .card, .template-box, .admin-create, .family-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(29, 51, 48, 0.05);
}

.a-box, .card { padding: 16px 18px; }
.card { border-radius: 16px; padding: 20px 22px; }

.a-box h3, .a-box h2, .template-box h2, .admin-create h2, .family-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.a-box p { margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }

.a-pre, .template-pre {
  margin: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #3d4f4c;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
  font-family: ui-monospace, "Noto Sans TC", monospace;
  line-height: 1.5;
}

/* Notices */
.notice, .error, .warn, .ok, .okline {
  border-radius: 12px;
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 14.5px;
}

.error { background: var(--danger-bg); color: var(--danger); }
.warn { background: var(--warn-bg); color: var(--warn); }
.ok, .okline { background: var(--ok-bg); color: var(--ok); }
.okline { font-weight: 700; margin: 0 0 14px; }
.notice { background: #eef4f3; color: var(--teal-dark); }

/* Steps */
.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 14px;
}

.steps span {
  padding: 6px 12px;
  border-radius: 999px;
  background: #ebe4d8;
}

.steps span.on { background: #d8efe9; color: #1c5853; }
.steps i { font-style: normal; color: #b7aaa0; font-weight: 600; }

/* Photo upload */
.photo-drop {
  border: 1.5px dashed #c9bfb0;
  background: #fbf8f2;
  border-radius: 16px;
  padding: 22px;
  display: flex;
  gap: 22px;
  align-items: center;
  margin-bottom: 16px;
  cursor: pointer;
}

.pdf-thumb {
  width: 168px;
  height: 220px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #f4efe6, #e8dfd0);
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #5c4f43;
  text-align: center;
  padding: 12px;
  box-sizing: border-box;
}
.pdf-thumb b {
  display: block;
  font-size: 22px;
  letter-spacing: 0.04em;
  color: #8b2e2e;
}
.pdf-thumb span { font-size: 13px; font-weight: 600; }
.wait-card .pdf-thumb, .pdf-thumb.compact { }
.wait-card .pdf-thumb {
  width: 200px;
  height: 262px;
}

.photo-drop img {
  width: 168px;
  height: 220px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  flex: none;
}

.photo-meta b { display: block; font-size: 16px; margin-bottom: 4px; color: var(--ink); }
.photo-meta p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }

.chip {
  display: inline-block;
  background: #d8efe9;
  color: #1c5853;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 6px;
}

/* Waiting */
.wait-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0 24px;
}

.wait-card {
  width: min(720px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  gap: 24px;
  align-items: center;
}

.wait-card img, .photo-thumb {
  width: 200px;
  height: 262px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  flex: none;
}

.wait-card h1, .wait-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
}

.wait-card p { margin: 0 0 16px; color: var(--muted); }

.wait-bar, .bar {
  height: 8px;
  background: #ebe4d8;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 8px;
}

.wait-bar i, .bar > i {
  display: block;
  height: 100%;
  width: 36%;
  background: #2c7a73;
  border-radius: inherit;
  animation: wait-slide 1.4s ease-in-out infinite;
}

@keyframes wait-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

/* Preview questions */
.detect, .detect-line {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 8px;
}

.detect b, .detect-line b { color: var(--ink); }

.qgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 16px;
}

.qitem {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px 9px;
}

.qitem .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.qno { font-size: 11px; font-weight: 800; color: #1c5853; }
.qtype {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  background: #ebe4d8;
  border-radius: 999px;
  padding: 1px 7px;
}
.qtext { font-size: 13px; margin: 0 0 2px; line-height: 1.4; white-space: pre-wrap; }
.qans { font-size: 12px; color: #1c5853; font-weight: 700; margin: 0; }
.qans b { color: #1c5853; }

/* Markdown preview questions */
.preview q, .q {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.q .prompt { white-space: pre-wrap; margin-bottom: 8px; }
.q ol { margin: 0; padding-left: 1.3em; color: var(--muted); }

/* Count picker */
.count-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin: 8px 0 16px;
}

.count-card {
  appearance: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 12px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(29, 51, 48, 0.05);
  cursor: pointer;
  color: var(--ink);
  font: inherit;
}

.count-card b {
  display: block;
  font-size: 36px;
  letter-spacing: -0.03em;
  font-weight: 700;
  color: var(--ink);
}

.count-card span { color: var(--muted); font-size: 13px; font-weight: 500; }

.count-card.pick,
.count-card[aria-pressed="true"] {
  border: 2px solid #2c7a73;
  background: #eef7f5;
}

.count-card.pick span,
.count-card[aria-pressed="true"] span {
  color: var(--teal-dark);
  font-weight: 650;
}

/* Publish */
.pub-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 8px 24px rgba(29, 51, 48, 0.05);
}

.stat, .counts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}

.stat span, .counts span {
  background: #ebe4d8;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13.5px;
}

.publish-target {
  margin: 0 0 12px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--teal);
  background: var(--teal-soft);
}

.publish-target .kicker {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--teal-dark);
  font-weight: 700;
  margin-bottom: 4px;
}

.publish-target .who {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
}

.confirm-box {
  margin-top: 16px;
  padding: 16px 18px;
  border: 2px solid var(--danger);
  background: var(--danger-bg);
  border-radius: 16px;
}

.confirm-box h2 { margin: 0 0 8px; color: var(--danger); font-size: 1.05rem; }
.confirm-box p { margin: 0 0 8px; color: var(--ink); }

/* Templates */
.template-box { padding: 16px 18px; margin: 4px 0 18px; }
.template-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.template-head h2 { margin: 0 0 4px; }
.template-label {
  font-size: 0.88rem;
  color: var(--teal-dark);
  font-weight: 650;
  margin: 8px 0;
}
.template-optional {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.template-optional summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--teal-dark);
  list-style: none;
}
.template-optional summary::-webkit-details-marker { display: none; }
.template-optional summary::before { content: "▸ "; }
.template-optional[open] summary::before { content: "▾ "; }
.template-optional .hint { margin: 8px 0 0; }

/* Family admin */
.admin-create { padding: 16px 18px; margin: 8px 0 22px; }
.family-list { display: grid; gap: 16px; }
.family-card { padding: 16px 18px; }
.family-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.family-head h3 { margin: 0 0 6px; font-size: 18px; }
.family-card h4 { margin: 8px 0 8px; font-size: 0.95rem; }
.child-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 8px;
}
.child-row .rename-form,
.add-child-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.child-row input,
.add-child-form input { margin: 0; }
.family-actions { justify-content: flex-end; }
.family-card .confirm-box { margin-top: 10px; }
.family-card .child-row .confirm-box { flex-basis: 100%; }
.child-row { display: block; }
.child-row .rename-form { margin-bottom: 0; }

h1, h2, h3 { margin: 0 0 12px; font-weight: 700; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }


/* ===== App 主題 ===== */
.theme-kids {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 20px;
}
.theme-kid {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 10px 14px;
  min-width: 200px;
  flex: 1;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.theme-kid.on {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(44, 122, 115, 0.18);
}
.theme-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--teal-soft);
  flex: none;
}
.theme-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
}
.theme-kid .nm {
  display: block;
  font-weight: 700;
  font-size: 15px;
}
.theme-kid .use {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 1px;
}
.theme-sec {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
}
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.theme-card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}
.theme-card.using { border-color: var(--teal); }
.theme-hero {
  height: 168px;
  border-radius: 14px;
  background: var(--bg);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}
.theme-hero img {
  height: 160px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(29, 51, 48, 0.12));
}
.theme-card h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}
.theme-meta {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.theme-thumbs { display: flex; gap: 8px; }
.theme-thumb {
  flex: 1;
  background: var(--bg);
  border-radius: 10px;
  padding: 6px 4px 4px;
  text-align: center;
  color: var(--muted);
}
.theme-thumb img {
  height: 64px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}
.theme-thumb span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
}
.theme-apply {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.theme-apply.idle { background: var(--teal); color: #fff; }
.theme-apply.on { background: var(--teal-soft); color: var(--teal-dark); cursor: default; }
.theme-hero.photo { align-items: center; background: #fff; }
.theme-hero.photo img {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(29, 51, 48, 0.12));
}
.theme-av.photo img { object-fit: contain; }
.theme-thumb-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.theme-thumb-grid img,
.theme-saved-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 8px;
  display: block;
  background: #fff;
}
.theme-saved-thumb {
  position: relative;
}
.theme-saved-thumb .rm {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(28, 88, 83, 0.88);
  color: #fff;
  font-size: 13px;
  line-height: 20px;
  padding: 0;
  cursor: pointer;
}
.theme-manage {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.theme-manage button {
  flex: 1 1 auto;
  padding: 8px 10px;
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  border-radius: 12px;
  cursor: pointer;
}
.theme-card .confirm-box { margin-top: 4px; }
.theme-thumb-more {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--teal-dark);
}
.theme-add-card {
  border-style: dashed;
  border-color: #c8bfb0;
  background: rgba(255, 252, 247, 0.6);
  min-height: 280px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 8px;
  color: var(--teal-dark);
  font: inherit;
  text-align: center;
  box-shadow: none;
}
.theme-add-card:hover {
  border-color: var(--teal);
  background: var(--card);
}
.theme-add-plus {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.theme-add-card b { display: block; font-size: 16px; font-weight: 800; }
.theme-add-card span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  max-width: 200px;
  line-height: 1.4;
}
.theme-panel {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.theme-panel.hidden { display: none !important; }
.theme-panel h2 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 4px;
}
.theme-panel .hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 14px;
  line-height: 1.45;
}
.theme-fname {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  margin-bottom: 14px;
}
.theme-flabel {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 6px;
}
.theme-slots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.theme-slot {
  border: 1.5px dashed #c8bfb0;
  background: var(--bg);
  border-radius: 12px;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  text-align: center;
  padding: 6px;
  font: inherit;
  color: inherit;
}
.theme-slot.has {
  border-style: solid;
  border-color: var(--teal);
  padding: 0;
  cursor: default;
}
.theme-slot.add-more { border-style: dashed; }
.theme-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.theme-slot .lab { font-size: 11px; font-weight: 800; color: var(--teal-dark); }
.theme-slot .sub { font-size: 10px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.theme-slot .rm {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(28, 88, 83, 0.88);
  color: #fff;
  font-size: 13px;
  line-height: 20px;
  padding: 0;
  cursor: pointer;
}
.theme-count-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}
.theme-video-slot {
  width: 100%;
  aspect-ratio: auto;
  height: 168px;
  margin-bottom: 14px;
}
.theme-video-slot video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #1d3330;
  display: block;
}
.theme-home-video {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.theme-home-video-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.45;
}
.theme-home-video .theme-flabel { margin: 0; }
.theme-home-video .theme-video-slot {
  height: 140px;
  margin-bottom: 0;
}
.theme-home-video .theme-replace-video {
  align-self: stretch;
  padding: 8px 10px;
  font-size: 13px;
}
.theme-actions-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
/* Mobile */
@media (max-width: 900px) {
  .a { flex-direction: column; }
  .a-side {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 16px;
    gap: 8px;
  }
  .a-logo { padding: 0 12px 0 0; }
  .a-nav {
    flex-direction: row;
    flex: 1;
    flex-wrap: wrap;
  }
  .a-nav a, .a-nav button { width: auto; padding: 8px 12px; }
  .a-user {
    border-top: 0;
    padding: 0 0 0 8px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .a-user b { margin: 0; }
  .a-main { padding: 20px 16px 24px; min-height: 0; }
  .a-head { flex-direction: column; align-items: stretch; }
  .a-head h1 { font-size: 24px; }
  .a-form, .row, .qgrid, .a-grid, .subjects, .theme-grid { grid-template-columns: 1fr; }
  .theme-slots { grid-template-columns: repeat(3, 1fr); }
  .count-grid { grid-template-columns: 1fr 1fr; }
  .photo-drop, .wait-card { flex-direction: column; align-items: stretch; width: 100%; }
  .photo-drop img, .wait-card img, .photo-thumb, .pdf-thumb, .wait-card .pdf-thumb {
    width: 100%;
    height: 200px;
  }
  .template-head, .family-head, .child-row .rename-form, .add-child-form {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 560px) {
  .count-grid { grid-template-columns: 1fr; }
}

.qimg, .q .qimg {
  display: block;
  max-width: 100%;
  max-height: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 8px 0 10px;
  padding: 6px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(29, 51, 48, 0.05);
}
