:root {
  --ink: #0f3b2e; --teal: #3f8872; --teal-d: #2f6e5c; --mint: #e6f2ea; --orange: #f08a3e; --coral: #ec6e6e;
  --line: #dde7e0; --muted: #5b6f67; --bg: #f5f8f6;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Noto Sans", "Noto Sans TC", "Noto Sans SC", system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.55; }
h1, h2 { font-family: Montserrat, system-ui, sans-serif; line-height: 1.25; }
h1 { font-size: 1.7rem; margin: 0 0 .5em; } h2 { font-size: 1.2rem; margin: 1.8em 0 .5em; }
a { color: var(--teal-d); }
code { background: var(--mint); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
pre { background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
.muted { color: var(--muted); } .small { font-size: .88rem; }
.warn { color: #b4521a; font-weight: 600; font-size: .88rem; } .ok { color: var(--teal); font-size: .88rem; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer; font-family: inherit; }
.btn:hover { border-color: var(--teal); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-d); }
.btn-danger { color: #b53c35; } .btn-danger:hover { border-color: var(--coral); background: #fde7e5; }
.btn-sm { padding: 5px 12px; font-size: .85rem; }
.icon-btn { width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.link-btn { background: none; border: 0; color: #cfe3d9; cursor: pointer; padding: 0; font: inherit; text-decoration: underline; text-align: left; }

.alert { padding: 12px 16px; border-radius: 10px; background: var(--mint); border-left: 4px solid var(--teal); }
.alert-error { background: #fde7e5; border-color: var(--coral); color: #8e2c26; }
.alert-ok { background: var(--mint); }

/* auth */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #f9c894, #d7d4b2 45%, #a8d8c2); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 22px; padding: 36px 32px; box-shadow: 0 20px 50px -20px rgba(15,59,46,.4); }
.auth-logo { margin-bottom: 10px; }
.auth-card h1 { margin-bottom: 0; }
.stack { display: grid; gap: 14px; margin: 20px 0; }
.stack label { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; }
input, textarea, select { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; color: var(--ink); background: #fff; }
input:focus, textarea:focus, select:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px rgba(63,136,114,.18); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--teal); }
textarea { resize: vertical; min-height: 90px; }

/* layout */
.admin { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.admin-side { background: var(--ink); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.admin-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: Montserrat, sans-serif; font-weight: 800; line-height: 1.1; }
.admin-brand img { background: #fff; border-radius: 50%; padding: 3px; }
.admin-brand small { font-weight: 600; color: #f9c894; font-size: .75rem; }
.admin-side nav { display: grid; gap: 2px; }
.admin-side nav a { color: #d7e6de; text-decoration: none; padding: 9px 12px; border-radius: 10px; font-weight: 600; }
.admin-side nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-side nav a.is-active { background: var(--teal); color: #fff; }
.side-foot { margin-top: auto; display: grid; gap: 10px; font-size: .88rem; }
.side-foot a { color: #f9c894; }
.admin-main { padding: 32px 40px 80px; max-width: 1100px; width: 100%; }
@media (max-width: 820px) {
  .admin { grid-template-columns: 1fr; }
  .admin-side { position: static; height: auto; }
  .admin-side nav { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .admin-main { padding: 20px 16px 60px; }
  .hide-sm { display: none; }
}

.head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin: 20px 0; }
.dash-card { background: #fff; border: 1.5px solid var(--line); border-radius: 16px; padding: 18px; text-decoration: none; color: var(--ink); display: grid; }
.dash-card:hover { border-color: var(--teal); }
.dash-card strong { font-family: Montserrat, sans-serif; font-size: 2rem; color: var(--teal); }
.empty { color: var(--muted); padding: 24px; text-align: center; background: #fff; border-radius: 12px; }

table.list { width: 100%; border-collapse: collapse; background: #fff; border-radius: 14px; overflow: hidden; border: 1.5px solid var(--line); }
.list th, .list td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #fafcfb; }
.list tr:last-child td { border-bottom: 0; }
.list .thumb { width: 64px; }
.list .thumb img, .list .thumb span { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; display: block; background: linear-gradient(135deg, #f9c894, #a8d8c2); }
.list .actions { white-space: nowrap; text-align: right; }
.list .actions form { display: inline; }

/* forms */
.edit-form { background: #fff; border: 1.5px solid var(--line); border-radius: 16px; padding: 24px; }
.edit-form.narrow { max-width: 480px; }
.field { margin-bottom: 18px; }
.field-label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .92rem; }
.field-label em { color: var(--coral); font-style: normal; }
.help { display: block; color: var(--muted); margin-top: 5px; font-size: .84rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }
.ml-input { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.ml-tag { flex-shrink: 0; width: 34px; height: 34px; display: grid; place-items: center; background: var(--mint); color: var(--teal-d); border-radius: 8px; font-weight: 700; margin-top: 3px; }
.ml-input input, .ml-input textarea { flex: 1; }
/* tab switching: hide languages not selected */
[data-ml-form][data-lang-view="en"] .ml-input:not([data-lang="en"]),
[data-ml-form][data-lang-view="zh_hant"] .ml-input:not([data-lang="zh_hant"]),
[data-ml-form][data-lang-view="zh_hans"] .ml-input:not([data-lang="zh_hans"]) { display: none; }
.lang-tabs { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 0 14px; margin-bottom: 10px; background: #fff; border-bottom: 1px solid var(--line); }
.lang-tabs button { padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; font: inherit; font-weight: 600; }
.lang-tabs button[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.image-field { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.image-field img { width: 140px; height: 90px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.image-field input[type=file] { width: auto; flex: 1; min-width: 220px; }
.check { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.quiz-edit { border: 1.5px solid var(--line); border-radius: 14px; padding: 16px 18px 6px; margin: 0 0 16px; }
.quiz-edit legend { font-family: Montserrat, sans-serif; font-weight: 700; padding: 0 6px; }
.opt-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: start; }
.opt-row .field { margin-bottom: 10px; }
.correct-pick { display: flex; align-items: center; gap: 6px; font-size: .85rem; padding-top: 30px; color: var(--muted); }
.correct-pick:has(input:checked) { color: var(--teal-d); font-weight: 700; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; padding-top: 18px; border-top: 1px solid var(--line); }

/* interface text / SF-10 / branding */
.jump-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; }
.jump-links a { padding: 5px 12px; border-radius: 999px; background: #fff; border: 1.5px solid var(--line); text-decoration: none; font-weight: 600; font-size: .88rem; }
.jump-links a:hover { border-color: var(--teal); }
.edit-form h2 { scroll-margin-top: 70px; }
.string-row { border-left: 3px solid transparent; padding-left: 10px; margin-left: -13px; }
.string-row.is-edited { border-left-color: var(--orange); }
.string-row.is-edited .field-label::after, .badge { content: "edited"; display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 999px; background: #fdf0e1; color: #b4521a; font-size: .72rem; font-weight: 700; vertical-align: middle; }
.likert-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 14px; }
.likert-edit .field { margin-bottom: 10px; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; margin: 10px -24px -24px; padding: 14px 24px; border-radius: 0 0 16px 16px; box-shadow: 0 -6px 16px -10px rgba(15,59,46,.25); }
.reset-form { margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.brand-preview { display: flex; align-items: center; gap: 24px; padding: 16px; background: var(--bg); border-radius: 12px; margin-bottom: 18px; }
[data-lang-view^="zh"] .ml-field .field-label em { display: none; }

/* link picker */
.link-field select { max-width: 560px; }
.link-external { margin-top: 10px; max-width: 560px; }
.link-external[hidden] { display: none; }
.link-external .field-label { font-weight: 600; color: var(--muted); }

/* quiz editor */
.quiz-edit { position: relative; }
.quiz-edit-tools { position: absolute; top: -4px; right: 14px; display: flex; gap: 6px; background: #fff; padding: 0 6px; }
[data-q-add] { border-style: dashed; border-color: var(--teal); color: var(--teal-d); }

/* visual editor */
.ml-rich { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.ml-rich .tox-tinymce { flex: 1; min-width: 0; border-radius: 10px; border: 1.5px solid var(--line); }
.ml-rich textarea { flex: 1; }
[data-ml-form][data-lang-view="all"] .ml-rich { margin-bottom: 14px; }
/* media library */
.upload-box { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.upload-box .field-label { width: 100%; margin: 0; }
.upload-box input[type=file] { width: auto; flex: 1; min-width: 240px; }
.upload-box .help { width: 100%; margin: 0; }
.file-badge { width: 52px; height: 52px; border-radius: 8px; display: grid !important; place-items: center; font-size: .72rem; font-weight: 800; color: #fff; background: var(--teal) !important; }
.file-badge.file-pdf { background: var(--coral) !important; }
.file-badge.file-video, .file-badge.file-audio { background: var(--orange) !important; }
.media-list td:nth-child(2) { word-break: break-all; }

.btn-dashed { border-style: dashed; border-color: var(--teal); color: var(--teal-d); }
.quiz-edit-tools button:disabled { opacity: .35; cursor: default; }

/* questionnaire answers editor */
.answers-edit { margin-top: 6px; padding: 12px 14px; background: var(--bg); border-radius: 12px; }
.answers-edit > .field-label { margin-bottom: 8px; }
.answer-edit { background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px 2px; margin-bottom: 8px; }
.answer-edit .field { margin-bottom: 8px; }
.answer-edit .field-label { font-size: .82rem; color: var(--muted); }
.answer-edit-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.answer-num { font-family: Montserrat, sans-serif; font-weight: 700; font-size: .9rem; }
.answer-points { display: flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--teal-d); }
.answer-points input { width: 84px; padding: 5px 8px; }
.answer-tools { margin-left: auto; display: flex; gap: 4px; }
.answer-tools .icon-btn { width: 28px; height: 28px; }
.icon-danger { color: #b53c35; }
.answer-tools button:disabled { opacity: .35; cursor: default; }

/* quiz options editor */
.answers-edit .opt-row { background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px 2px; margin-bottom: 8px; grid-template-columns: 90px 1fr; }
.answers-edit .opt-row .correct-pick { padding-top: 6px; }
.answers-edit .opt-row .field { margin-bottom: 8px; }
.answers-edit .opt-row .field-label { font-size: .82rem; color: var(--muted); }
.opt-row:has(.correct-pick input:checked) { border-color: var(--teal); background: #f4faf6; }
