
:root {
  --ground: #fbf7f8;
  --surface: #ffffff;
  --raised: #f5eff1;
  --active: #ede6e9;
  --border: #e9e1e4;
  --rule: #f3eef0;
  --control: #d3cbcf;
  --text: #17121a;
  --muted: #5f5860;
  --faint: #6b6469;
  --accent: #b8336a;
  --accent-soft: #fdf2f7;
  --accent-track: #f8dbe8;
  --accent-ink: #6b1d3e;
  --negative: #c4242a;
  --pill-positive-bg: #dcfce7; --pill-positive-ink: #14532d;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-neutral-bg: #f3eef0; --pill-neutral-ink: #3d3539;
  --pill-accent-bg: #fdf2f7; --pill-accent-ink: #6b1d3e;

  --radius-card: 8px;
  --radius-control: 6px;
  --sidebar-width: 236px;
  --gap: 24px;
  --pad: 32px;
  --card-pad: 24px;
  --control-height: 40px;
  --nav-row: 34px;

  --font: "DM Sans", "Noto Sans TC", system-ui, sans-serif;
  --fs-title: 32px;
  --fs-section: 18px;
  --fs-kpi: 24px;
  --fs-body: 14px;
  --fs-small: 12px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100svh;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
img, svg { display: block; }
.num { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- 品牌記號 ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand svg { width: 22px; height: 22px; color: var(--accent); }
.brand small { font-weight: 500; font-size: 13px; color: var(--muted); letter-spacing: 0; }

/* ---------- 按鈕與欄位 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control-height); padding: 0 16px;
  border-radius: var(--radius-control); border: 1px solid var(--control);
  background: var(--surface); font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: transform 120ms var(--ease-out);
}
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #a42c5d; border-color: #a42c5d; }
.btn.primary:active { background: #8f2651; }
.btn.text { border-color: transparent; background: transparent; padding: 0 4px; height: auto; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.btn.text:hover { color: var(--accent-ink); }
.btn.text:active { color: var(--accent); }
.btn svg { width: 16px; height: 16px; }

.field { display: grid; gap: 8px; }
.field + .field { margin-top: 16px; }
.field label { font-weight: 500; }
.field .hint { color: var(--muted); font-size: var(--fs-small); }
.field .error { color: var(--negative); font-size: var(--fs-small); }
.input {
  width: 100%; height: var(--control-height); padding: 0 12px;
  border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface);
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: #b9afb4; }
.input[aria-invalid="true"] { border-color: var(--negative); }
.input[readonly] { background: var(--raised); }
.joined { display: flex; }
.joined .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.joined .suffix {
  display: inline-flex; align-items: center; padding: 0 12px; height: var(--control-height);
  border: 1px solid var(--control); border-left: 0; border-radius: 0 var(--radius-control) var(--radius-control) 0;
  background: var(--raised); color: var(--muted); white-space: nowrap;
}
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 16px; height: 16px; margin-top: 3px; accent-color: var(--accent); flex: none; }
.check a { text-decoration: underline; text-underline-offset: 3px; }
.check a:hover { color: var(--accent-ink); }

.notice { padding: 12px 16px; border-radius: var(--radius-control); background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.notice.ok { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }

.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: var(--fs-small); font-weight: 500; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); white-space: nowrap; flex: none; }
.pill.accent { background: var(--pill-accent-bg); color: var(--pill-accent-ink); }

/* ---------- 登入、註冊：表單＋右側預覽 ---------- */
.auth { min-height: 100svh; display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 1fr); }
.auth-form { padding: 40px var(--pad) 40px; display: flex; flex-direction: column; gap: 40px; background: var(--surface); }
.auth-body { margin: auto 0; display: grid; gap: 40px; }
.auth-form h1 { font-size: var(--fs-title); line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.auth-form .lede { margin-top: 8px; color: var(--muted); font-size: 16px; }
.auth-form form { display: grid; }
.auth-form .actions { margin-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.auth-form .switch { color: var(--muted); }
.auth-aside { padding: 40px var(--pad) 56px; display: flex; flex-direction: column; justify-content: center; gap: 24px; }
.auth-aside h2 { font-size: var(--fs-section); font-weight: 600; }
.auth-aside p { color: var(--muted); max-width: 60ch; }

/* 學院預覽：講師邊打字，右邊的瀏覽器框邊換網址與學院名稱 */
.preview { border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); overflow: hidden; }
.preview-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--raised); }
.preview-dots { display: flex; gap: 6px; }
.preview-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--control); }
.preview-url { flex: 1; min-width: 0; height: 28px; display: flex; align-items: center; padding: 0 12px; border-radius: 999px; background: var(--surface); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.preview-url b { font-weight: 600; color: var(--accent-ink); }
.preview-body { padding: 32px 32px 40px; display: grid; gap: 20px; }
.preview-name { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; word-break: break-word; }
.preview-rows { display: grid; gap: 10px; }
.preview-rows span { display: block; height: 12px; border-radius: 6px; background: var(--raised); }
.preview-rows span:nth-child(1) { width: 72%; }
.preview-rows span:nth-child(2) { width: 54%; }
.preview-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.preview-cards span { aspect-ratio: 4 / 3; border-radius: 6px; background: var(--accent-soft); }
.preview-status { font-size: 13px; color: var(--muted); }
.preview-status.bad { color: var(--negative); }

/* ---------- 後台外框：側欄＋畫布 ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100svh; }
.sidebar { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; gap: 2px; padding: 20px 12px; overflow: auto; }
.sidebar .brand { padding: 0 8px; margin-bottom: 20px; }
.switcher { display: grid; gap: 2px; padding: 10px 8px; margin-bottom: 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.switcher span { font-size: var(--fs-small); color: var(--muted); }
.switcher strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item { display: flex; align-items: center; gap: 10px; height: var(--nav-row); padding: 0 8px; border-radius: 8px; color: var(--muted); }
.nav-item svg { width: 16px; height: 16px; flex: none; }
.nav-item:hover { background: var(--raised); color: var(--text); }
.nav-item:active { transform: translateY(1px); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
.nav-item[aria-current="page"] svg { color: var(--accent); }
.sidebar .bottom { margin-top: auto; display: grid; gap: 8px; padding: 12px 8px 0; }
.user-row { display: grid; }
.user-row strong { font-weight: 500; }
.user-row span { font-size: var(--fs-small); color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.sidebar form { display: contents; }
.sidebar .logout, .mobile-sheet .logout { justify-self: start; padding: 0; }

.mobile-bar { display: none; }

.canvas { min-width: 0; padding: 36px var(--pad) 64px; }
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 32px; flex-wrap: wrap; }
.title-row h1 { font-size: var(--fs-title); line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.title-row .sub { margin-top: 6px; color: var(--muted); font-size: 16px; }

/* 12 欄格線：欄寬由畫布決定，間距固定 24px（--gap），兩張卡片 8 + 4 欄、6 + 6 欄都落在同一組欄線上。 */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.span-8 { grid-column: span 8; } .span-4 { grid-column: span 4; } .span-12 { grid-column: 1 / -1; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); min-width: 0; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel h2 { font-size: var(--fs-section); line-height: 1.3; font-weight: 600; }
.panel .meta { color: var(--muted); font-size: var(--fs-small); }

/* 學院卡：網址是這個畫面最大的東西 */
.site-url { font-size: var(--fs-kpi); line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; word-break: break-all; }
.site-url a:hover { text-decoration: underline; text-underline-offset: 4px; }
.site-facts { display: grid; margin-top: 16px; }
.site-facts div { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding: 10px 0; }
.site-facts div + div { border-top: 1px solid var(--rule); }
.site-facts dt { color: var(--muted); }
.site-facts dd { font-weight: 500; }
.site-actions { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

/* 學員看到的首頁：直接嵌入學院網址，不是示意圖 */
.front-frame { display: block; width: 100%; height: 420px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.panel > header .btn.text { font-weight: 500; }

/* 開站進度 */
.progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.progress-figure { font-size: var(--fs-kpi); font-weight: 500; }
.progress-figure small { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.track { height: 8px; border-radius: 999px; background: var(--accent-track); margin: 12px 0 8px; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.steps { list-style: none; padding: 0; display: grid; }
.steps li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 0; }
.steps li + li { border-top: 1px solid var(--rule); }
.steps .done { color: var(--muted); }
.steps .done span:first-child { text-decoration: line-through; text-decoration-color: var(--control); }

/* 設定：左欄說明、右欄面板 */
.settings-section { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: var(--gap); padding: 32px 0; }
.settings-section + .settings-section { border-top: 1px solid var(--border); }
.settings-section:first-of-type { padding-top: 0; }
.settings-section h2 { font-size: 16px; font-weight: 600; }
.settings-section > div:first-child p { margin-top: 4px; color: var(--muted); max-width: 40ch; }
.settings-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); }
.settings-panel .actions { margin-top: 16px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; }
.kv dt { color: var(--muted); }


/* 課程管理 */
.area { height: auto; padding: 10px 12px; line-height: 1.7; resize: vertical; }
select.input { padding-right: 8px; }
.fit { width: auto; min-width: 180px; }
.file { font-size: var(--fs-small); }
.grow { flex: 1; }
.crumb { color: var(--muted); margin-bottom: 4px; }
.crumb a:hover { text-decoration: underline; text-underline-offset: 3px; }
.title-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline-form { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.inline-form .field + .field { margin-top: 0; }
.inline-form .grow { min-width: 240px; }
.empty { border: 1px dashed var(--control); border-radius: var(--radius-card); padding: 16px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { font-weight: 400; color: var(--muted); font-size: var(--fs-small); text-align: left; padding: 8px 12px 8px 0; white-space: nowrap; }
.table td { padding: 12px 12px 12px 0; border-top: 1px solid var(--rule); vertical-align: middle; }
.table th.num, .table td.num { text-align: right; padding-right: 0; padding-left: 12px; white-space: nowrap; }
.table td:first-child { width: 45%; }
.row-link { font-weight: 500; }
.row-link:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: 32px; overflow-x: auto; }
.tabs a { padding: 10px 0; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a:active { opacity: 0.7; }
.tabs a[aria-current="page"] { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px var(--gap); }
.form-grid .field + .field { margin-top: 0; }
.span-all { grid-column: 1 / -1; }
.form-row-end { display: flex; justify-content: flex-end; }
.field.checks { align-content: end; padding-bottom: 8px; }
.form-foot { display: flex; justify-content: flex-end; padding: 8px 0 32px; }
.choice, .swatches { border: 0; padding: 0; display: flex; gap: 20px; flex-wrap: wrap; }
.choice legend, .swatches legend { font-weight: 500; margin-bottom: 8px; padding: 0; }
.swatches { margin-top: 16px; }
.swatch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 32px; }
.swatch input { accent-color: var(--accent); }
.swatch i { width: 20px; height: 20px; border-radius: 50%; }
.upload-thumb { max-width: 240px; max-height: 135px; object-fit: cover; border-radius: var(--radius-control); }
.sub-title { font-size: 16px; font-weight: 600; margin: 24px 0 12px; }
.unit-list { display: grid; }
.unit + .unit { border-top: 1px solid var(--rule); }
.unit summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 0; cursor: pointer; }
.unit summary:hover .unit-title { color: var(--accent-ink); }
.unit-title { font-weight: 500; min-width: 0; }
.unit-side { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.unit-body { padding: 8px 0 24px; }
.unit-actions { display: flex; gap: 16px; margin-top: 12px; }
.btn.text[disabled] { color: var(--faint); text-decoration: none; cursor: not-allowed; }
.btn.danger { color: var(--negative); border-color: var(--control); }
.btn.danger:hover { background: var(--pill-negative-bg); }
.danger-text { color: var(--negative); }
.danger-zone { border-top: 1px solid var(--border); }

/* ---------- 平板與手機 ---------- */
@media (max-width: 1000px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { padding-top: 0; background: var(--surface); }
  .grid > * { grid-column: 1 / -1; }
  .settings-section { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}
@media (max-width: 860px) {
  :root { --pad: 16px; --fs-title: 24px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; height: 48px; padding: 0 var(--pad); background: var(--ground); position: sticky; top: 0; z-index: 10; }
  .mobile-bar details { position: relative; }
  .mobile-bar details:not([open]) .mobile-sheet { display: none; }
  .mobile-bar summary { list-style: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; cursor: pointer; border-radius: 8px; }
  .mobile-bar summary::-webkit-details-marker { display: none; }
  .mobile-bar summary:hover { background: var(--raised); }
  .mobile-bar summary svg { width: 20px; height: 20px; }
  .mobile-sheet { position: fixed; inset: 48px 0 0 0; background: var(--ground); padding: 16px var(--pad); display: flex; flex-direction: column; gap: 2px; }
  .mobile-sheet .nav-item { height: 44px; }
  .mobile-sheet .bottom { margin-top: 16px; display: grid; gap: 8px; padding: 0 8px; }
  .mobile-sheet form { display: contents; }
  .canvas { padding-top: 16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .inline-form { align-items: stretch; flex-direction: column; }
  .table td:first-child { width: auto; }
  .title-row { margin-bottom: 24px; }
  .auth-form, .auth-aside { padding-left: var(--pad); padding-right: var(--pad); }
  .auth-form { gap: 32px; padding-top: 24px; }
  .preview-body { padding: 24px 20px 28px; }
  .preview-name { font-size: 22px; }
  .front-frame { height: 360px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

.blk-wrap{display:flex;flex-direction:column;gap:16px;}
.blk{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-card);}
.blk-h{display:flex;align-items:center;gap:8px;padding:10px 16px;background:var(--raised);border-radius:var(--radius-card) var(--radius-card) 0 0;}
.blk-h .name{font-weight:600;flex:1;}
.blk-h button{width:32px;height:32px;border-radius:var(--radius-control);border:1px solid var(--control);background:var(--surface);cursor:pointer;color:var(--muted);transition:transform 120ms var(--ease-out);}
.blk-h button:hover{color:var(--text);background:var(--raised);}
.blk-h button:active{transform:translateY(1px);}
.blk-h button.del:hover{color:var(--negative);}
.blk-b{padding:16px;display:flex;flex-direction:column;gap:16px;}
.blk-b .field + .field{margin-top:0;}
.blk-item{border:1px solid var(--border);border-radius:var(--radius-control);padding:16px;display:flex;flex-direction:column;gap:12px;}
.blk-item-h{display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:var(--fs-small);}
.blk-item-h button{background:none;border:0;color:var(--negative);cursor:pointer;padding:2px 4px;}
.blk-item-h button:hover{text-decoration:underline;}
.blk-img{display:flex;align-items:center;gap:10px;}
.blk-img input[type=text]{flex:1;}
.blk-img .thumb{width:64px;height:48px;object-fit:cover;border-radius:var(--radius-control);}
.blk-add{display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding-top:16px;}
.blk-empty{border:1px dashed var(--control);border-radius:var(--radius-card);padding:32px;text-align:center;color:var(--muted);}
