/* MIAO Design System · Cosmos / Sunset. All assets and fonts stay local. */
:root {
  color-scheme: dark;
  --app-bg: #0b1120; --sidebar-bg: #0e1728; --surface: #151f31;
  --surface-2: #1b293d; --surface-3: #25344b; --field-bg: #101a2b;
  --text: #f2eee7; --muted: #b1bccd; --soft: #97a6bd;
  --accent: #dfc498; --accent-soft: #2e2c2d; --primary-bg: #dfc498; --primary-text: #202330;
  --border: #34445b; --border-subtle: #29384d; --field-border: #73849d;
  --danger: #ffb5a9; --success: #a7d5c3; --focus: #f4d6a8;
  --hero-glow: #34313d; --orbit-line: #807355; --shadow: 0 16px 44px #03081230;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, monospace;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 20px;
  --sidebar-width: 248px; --titlebar-height: 44px;
  font-family: var(--font-ui); color: var(--text); background: var(--app-bg); font-size: 14px; line-height: 1.75;
}
:root[data-theme="sunset"] {
  color-scheme: light;
  --app-bg: #f3efe7; --sidebar-bg: #eee7dc; --surface: #fffcf7;
  --surface-2: #f5efe5; --surface-3: #e9dfd1; --field-bg: #fffdf9;
  --text: #3b3029; --muted: #6c5b4e; --soft: #726151;
  --accent: #835a2e; --accent-soft: #f0e2cd; --primary-bg: #885a2d; --primary-text: #fffaf3;
  --border: #cbbbA6; --border-subtle: #dfd5c7; --field-border: #a38d76;
  --danger: #9b3c34; --success: #37664f; --focus: #875924;
  --hero-glow: #ead8be; --orbit-line: #b79a6e; --shadow: 0 12px 40px #72533709;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; }
body { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button, input, textarea, select, .nav-link { transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 4px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; padding: 12px 20px; border-radius: 8px; background: var(--primary-bg); color: var(--primary-text); }
.skip-link:focus { top: 8px; }
.desktop-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: var(--titlebar-height) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.window-bar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 12px; position: relative; background: var(--sidebar-bg); border-bottom: 1px solid var(--border-subtle); font-size: 12px; user-select: none; }
.window-dots { position: absolute; left: 20px; display: flex; gap: 8px; }
.window-dots span { width: 11px; height: 11px; border-radius: 50%; border: 1px solid #00000015; }
.window-dots span:nth-child(1) { background: #e8877e; } .window-dots span:nth-child(2) { background: #dbbb70; } .window-dots span:nth-child(3) { background: #83b59d; }
.window-title { font-weight: 600; letter-spacing: .025em; color: var(--muted); }
.window-context { position: absolute; right: 24px; color: var(--soft); font-size: 11px; }
.sidebar { display: flex; flex-direction: column; min-height: 0; padding: 32px 16px 20px; background: var(--sidebar-bg); border-right: 1px solid var(--border-subtle); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 36px; }
.brand-orbit { position: relative; display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border: 1px solid var(--accent); border-radius: 15px; color: var(--accent); font-size: 30px; font-family: Georgia, serif; font-style: italic; line-height: 1; }
.brand-orbit::after { content: ''; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); right: -3px; top: 4px; box-shadow: 0 0 0 4px var(--sidebar-bg); }
.brand strong { display: block; font-size: 17px; line-height: 1.5; letter-spacing: .04em; }
.brand strong span { display: inline; margin-left: 5px; font-weight: 400; font-size: 12px; letter-spacing: 0; }
.brand p { margin: 4px 0 0; color: var(--soft); font-size: 11px; }
.sidebar-caption { color: var(--soft); font-size: 10px; letter-spacing: .13em; padding-left: 12px; margin: 0 0 12px; }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 13px 12px; border: 1px solid transparent; border-radius: var(--radius-md); text-decoration: none; color: var(--muted); }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current] { background: var(--accent-soft); border-color: var(--border); color: var(--accent); }
.nav-icon { width: 22px; text-align: center; font-size: 21px; flex-shrink: 0; line-height: 1.2; }
.nav-copy { flex: 1; font-weight: 500; font-size: 13px; }
.nav-copy small { display: block; font-size: 10px; color: var(--soft); font-weight: 400; margin-top: 1px; }
.nav-number { font: 10px var(--font-mono); color: var(--soft); }
.appearance { margin-top: auto; padding-top: 48px; }
.theme-switcher { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 4px; gap: 4px; background: var(--app-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.theme-switcher button { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 5px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font-size: 11px; }
.theme-switcher button[aria-pressed="true"] { background: var(--surface-3); border-color: var(--border); color: var(--text); box-shadow: var(--shadow); }
.theme-swatch { width: 13px; height: 13px; border-radius: 50%; border: 1px solid var(--field-border); }
.swatch-cosmos { background: linear-gradient(135deg, #101c31 58%, #d6bb8c 59%); }
.swatch-sunset { background: linear-gradient(135deg, #f7efdf 58%, #b98248 59%); }
.appearance-status { color: var(--soft); font-size: 10px; line-height: 1.5; min-height: 16px; padding: 4px 8px 0; margin: 0; }
.sidebar-footer { margin-top: 20px; padding: 20px 10px 0; border-top: 1px solid var(--border-subtle); display: flex; gap: 10px; align-items: center; }
.local-indicator { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.sidebar-footer strong { font-size: 11px; color: var(--muted); font-weight: 500; }
.sidebar-footer p { font-size: 10px; color: var(--soft); margin: 2px 0 0; }
.workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--app-bg); }
.workspace-toolbar { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; height: 60px; padding: 0 40px; border-bottom: 1px solid var(--border-subtle); }
.workspace-toolbar p { margin: 0; font-size: 12px; color: var(--muted); }
.workspace-toolbar strong { color: var(--text); font-weight: 500; }
.breadcrumb-separator { display: inline-block; margin: 0 14px; color: var(--soft); }
.mode-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 9px; font-weight: 600; letter-spacing: .12em; color: var(--muted); padding: 4px 10px; border: 1px solid var(--border); border-radius: 20px; }
.workspace-scroll { min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border) var(--app-bg); scrollbar-gutter: stable; }
.workspace-content { max-width: 1280px; margin: auto; padding: 0 40px; }
.workspace-intro { position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 295px; overflow: hidden; }
.intro-copy { position: relative; z-index: 1; padding: 36px 0; }
.eyebrow { font-size: 10px; font-weight: 600; color: var(--accent); letter-spacing: .18em; margin: 0 0 12px; }
h1 { font-size: clamp(27px, 2.5vw, 38px); font-weight: 500; line-height: 1.5; letter-spacing: .035em; margin: 0 0 14px; }
.intro-description { color: var(--muted); font-size: 12px; line-height: 1.9; margin: 0; }
.orbit-art { position: relative; width: 300px; height: 250px; flex-shrink: 0; background: radial-gradient(ellipse at center, var(--hero-glow), transparent 66%); }
.orbit { position: absolute; width: 220px; height: 130px; left: 40px; top: 45px; border: 1px solid var(--orbit-line); border-radius: 50%; opacity: .55; }
.orbit-one { transform: rotate(-32deg); } .orbit-two { transform: rotate(32deg); }
.orbit-core { position: absolute; width: 100px; height: 100px; left: 100px; top: 60px; border: 1px solid var(--orbit-line); border-radius: 50%; background: radial-gradient(circle at 30% 25%, var(--surface-3), var(--app-bg)); box-shadow: inset -12px -10px 30px #00000020; }
.orbit-star { position: absolute; right: 42px; top: 40px; color: var(--accent); font-size: 28px; }
.orbit-caption { position: absolute; bottom: 12px; width: 100%; text-align: center; color: var(--soft); font-size: 8px; letter-spacing: .25em; }
.workspace-notice { display: flex; align-items: flex-start; gap: 14px; padding: 18px 22px; margin-bottom: 28px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.notice-icon { color: var(--accent); font-size: 22px; line-height: 1.4; }
.workspace-notice strong { color: var(--text); font-size: 12px; font-weight: 500; }
.workspace-notice p { color: var(--muted); font-size: 11px; margin: 3px 0 0; }
.notice-tag { margin-left: auto; white-space: nowrap; color: var(--soft); font-size: 8px; letter-spacing: .12em; padding-top: 4px; }
.workspace-section { padding: 30px; margin: 0 0 28px; background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow); scroll-margin-top: 24px; min-width: 0; }
h2 { font-size: 23px; line-height: 1.4; font-weight: 550; letter-spacing: .025em; margin: 0 0 12px; }
h3 { font-size: 16px; font-weight: 550; margin: 28px 0 16px; }
h4 { font-size: 14px; font-weight: 600; margin: 16px 0 8px; }
h5 { font-size: 12px; font-weight: 600; margin: 16px 0 6px; }
p { margin: 10px 0; }
.workspace-section > p:not(.eyebrow) { color: var(--muted); }
.notice, .empty { padding: 16px 18px; background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
form { padding: 22px; margin-top: 22px; background: var(--field-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); min-width: 0; }
form h3 { margin-top: 0; }
label { display: block; margin: 14px 0; color: var(--muted); font-size: 12px; }
input:not([type="checkbox"]):not([type="radio"]), textarea, select { display: block; width: 100%; min-width: 0; max-width: 100%; padding: 10px 12px; margin-top: 7px; border: 1px solid var(--field-border); border-radius: var(--radius-sm); color: var(--text); background: var(--field-bg); line-height: 1.6; font-size: 13px; }
input::placeholder, textarea::placeholder { color: var(--soft); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0 6px 0 0; accent-color: var(--accent); vertical-align: middle; flex-shrink: 0; }
textarea { resize: vertical; min-height: 104px; }
textarea:read-only { background: var(--surface-2); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 2px; border-color: var(--accent); }
button { min-height: 38px; padding: 8px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: 12px; line-height: 1.5; font-weight: 500; }
button:hover:not(:disabled) { background: var(--surface-3); border-color: var(--field-border); }
button[type="submit"] { background: var(--primary-bg); color: var(--primary-text); border-color: var(--primary-bg); font-weight: 600; }
button[type="submit"]:hover:not(:disabled) { filter: brightness(1.08); background: var(--primary-bg); border-color: var(--primary-bg); }
button[aria-label^="刪除"] { color: var(--danger); }
button:disabled { opacity: .48; cursor: not-allowed; }
fieldset { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 16px 0; padding: 12px 16px; }
legend { color: var(--muted); font-size: 11px; padding: 0 6px; }
fieldset:disabled { opacity: .48; }
fieldset label { margin: 6px 0; }
.material-actions, .review-actions, .task-actions, .training-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 0; }
.material-card, .material-detail, .review-card, .review-detail, .task-card, .task-preview, .training-card { min-width: 0; padding: 18px; margin: 14px 0; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); overflow-wrap: anywhere; }
.material-card h4, .review-card h4, .task-card h4 { margin-top: 0; }
.material-card p, .review-card p, .task-card p { font-size: 11px; color: var(--muted); }
pre { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font: 12px/1.9 var(--font-ui); color: var(--text); }
details { margin: 14px 0; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--field-bg); }
summary { cursor: pointer; color: var(--accent); font-size: 12px; }
p[role="status"]:not(:empty) { padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; overflow-wrap: anywhere; }
p[role="status"]:empty { margin: 0; }
.material-error, .review-error, .task-error, .training-error { color: var(--danger) !important; }
.modules { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.module { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); min-width: 0; }
.module > label { display: flex; align-items: center; color: var(--text); font-weight: 550; margin: 0; font-size: 13px; }
.module fieldset { padding: 8px 10px; margin: 12px 0 0; }
.module fieldset label { font-size: 11px; }
.task-source { overflow-wrap: anywhere; }
.task-source small { display: block; margin-left: 24px; color: var(--soft); font-size: 10px; }
.material-filters, .review-filters, .training-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 14px 0; }
.training-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#material-form, #review-form, #task-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
#material-form > *, #review-form > *, #task-form > * { margin-top: 0; margin-bottom: 0; }
#material-form > h3, #material-form > label:has([name="title"]), #material-form > label:has(textarea), #material-form > fieldset, #material-form > .material-actions,
#review-form > h3, #review-form > p, #review-form > label:has([name="events"]), #review-form > label:has([name="insights"]), #review-form > .review-check, #review-form > .review-actions,
#task-form > :not(fieldset) { grid-column: 1 / -1; }
#material-list, #review-list, #task-list, #mock-results-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
#material-list > p, #review-list > p, #task-list > p, #mock-results-list > p { grid-column: 1 / -1; }
#material-list > article, #review-list > article, #task-list > article, #mock-results-list > article { margin: 0; }
#agent-preview-host, #mock-workspace { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.workspace-footer { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0 32px; color: var(--soft); font-size: 10px; letter-spacing: .08em; }
.sidebar .appearance-status:not(:empty) { padding: 8px; font-size: 10px; background: transparent; border: 0; }
@media (min-width: 1600px) { .workspace-content { padding-left: 60px; padding-right: 60px; } }
@media (max-width: 1050px) { :root { --sidebar-width: 220px; } .workspace-content { padding: 0 24px; } .workspace-toolbar { padding: 0 24px; } .workspace-section { padding: 24px; } .orbit-art { width: 230px; transform: scale(.85); transform-origin: right center; } .brand { padding-left: 0; gap: 8px; } .brand strong { font-size: 15px; } .brand strong span { font-size: 11px; } .nav-number { display: none; } .modules { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .desktop-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 36px auto minmax(0, 1fr); }
  .window-bar { grid-column: 1; font-size: 11px; } .window-context { display: none; } .window-dots { left: 14px; gap: 6px; } .window-dots span { width: 9px; height: 9px; }
  .sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 10px; padding: 14px; border-right: 0; border-bottom: 1px solid var(--border-subtle); overflow: visible; }
  .brand { padding: 0; gap: 8px; } .brand-orbit { width: 32px; height: 32px; flex-basis: 32px; font-size: 23px; border-radius: 11px; } .brand strong { font-size: 13px; } .brand strong span { display: block; margin: 0; font-size: 10px; } .brand p { display: none; }
  .sidebar-caption, .sidebar-footer { display: none; } .appearance { grid-column: 2; grid-row: 1; margin: 0; padding: 0; } .theme-switcher button { min-height: 30px; font-size: 10px; gap: 4px; } .theme-swatch { width: 10px; height: 10px; } .appearance-status { min-height: 0; }
  .sidebar nav { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; } .nav-link { padding: 8px 4px; justify-content: center; text-align: center; min-height: 46px; } .nav-icon, .nav-number, .nav-copy small { display: none; } .nav-copy { font-size: 11px; }
  .workspace-toolbar { height: 48px; padding: 0 16px; } .workspace-toolbar p { font-size: 10px; } .breadcrumb-separator { margin: 0 8px; } .mode-pill { font-size: 8px; padding: 3px 7px; }
  .workspace-content { padding: 0 14px; } .workspace-intro { min-height: 230px; } .intro-copy { padding: 28px 4px; } h1 { font-size: 28px; } .intro-description { font-size: 11px; } .orbit-art { position: absolute; right: -105px; opacity: .35; z-index: 0; } .notice-tag { display: none; }
  .workspace-notice { padding: 16px; gap: 10px; margin-bottom: 20px; } .workspace-section { padding: 20px 16px; border-radius: 16px; margin-bottom: 20px; } h2 { font-size: 21px; } form { padding: 16px; }
  #material-form, #review-form, #task-form, .modules, .material-filters, .review-filters, .training-filters, #material-list, #review-list, #task-list, #mock-results-list { grid-template-columns: minmax(0, 1fr); }
  #task-form > fieldset { grid-column: 1; } .workspace-footer { font-size: 8px; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
