:root {
  --bg: #07111f;
  --sidebar: #081522;
  --surface: #0d1b2a;
  --surface-2: #102235;
  --surface-3: #142a40;
  --line: rgba(153, 190, 216, .14);
  --line-strong: rgba(153, 190, 216, .24);
  --text: #edf5fa;
  --muted: #8fa8b9;
  --subtle: #61798b;
  --cyan: #55d8d0;
  --cyan-strong: #2abeb7;
  --cyan-soft: rgba(85, 216, 208, .12);
  --amber: #f1bc62;
  --amber-soft: rgba(241, 188, 98, .12);
  --danger: #ff8b91;
  --radius-lg: 22px;
  --radius-md: 15px;
  --shadow: 0 22px 60px rgba(0, 0, 0, .24);
  --sidebar-width: 264px;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; color: var(--text); background: radial-gradient(circle at 80% -10%, rgba(39, 151, 166, .16), transparent 34rem), var(--bg); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.skip-link { position: fixed; left: 12px; top: -80px; z-index: 999; padding: 10px 14px; border-radius: 9px; background: var(--cyan); color: #05201f; font-weight: 800; }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar-width); display: flex; flex-direction: column; padding: 26px 18px 20px; border-right: 1px solid var(--line); background: rgba(7, 20, 32, .96); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 27px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(85, 216, 208, .5); border-radius: 13px; color: var(--cyan); background: linear-gradient(145deg, rgba(85, 216, 208, .17), rgba(85, 216, 208, .04)); font-size: 13px; font-weight: 900; letter-spacing: .08em; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .02em; }
.brand small { margin-top: 3px; color: var(--subtle); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }

.nav-list { display: grid; gap: 5px; }
.nav-item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; width: 100%; min-height: 46px; padding: 8px 11px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; transition: .18s ease; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.035); }
.nav-item:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.nav-item.is-active { color: var(--text); border-color: rgba(85, 216, 208, .16); background: var(--cyan-soft); }
.nav-icon { display: grid; place-items: center; width: 22px; color: var(--cyan); font-weight: 800; }
.nav-state { padding: 3px 6px; border-radius: 999px; color: var(--subtle); background: rgba(255,255,255,.04); font-size: 9px; white-space: nowrap; }
.nav-item.is-active .nav-state { color: var(--cyan); background: rgba(85, 216, 208, .1); }
.sidebar-note { display: flex; gap: 10px; align-items: flex-start; margin-top: auto; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { margin-bottom: 3px; font-size: 12px; }
.sidebar-note small { color: var(--subtle); font-size: 10px; line-height: 1.45; }

.workspace { grid-column: 2; min-width: 0; max-width: 100%; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 12; display: flex; align-items: center; min-height: 76px; padding: 13px clamp(20px, 3vw, 46px); border-bottom: 1px solid var(--line); background: rgba(7, 17, 31, .84); backdrop-filter: blur(18px); }
.menu-button { display: none; width: 42px; height: 42px; margin-right: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.topbar-title { display: grid; gap: 2px; }
.topbar-title strong { font-size: 15px; }
.eyebrow, .section-kicker { color: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.connection-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.025); font-size: 11px; }
.status-dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--subtle); box-shadow: 0 0 0 4px rgba(255,255,255,.03); }
.status-dot--amber { background: var(--amber); box-shadow: 0 0 0 4px rgba(241,188,98,.1); }
.account-chip { display: flex; align-items: center; gap: 9px; padding: 5px 9px 5px 5px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); text-align: left; cursor: pointer; }
.account-chip:hover { border-color: var(--line-strong); }
.avatar { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 10px; color: var(--amber); background: var(--amber-soft); font-weight: 800; }
.account-chip strong, .account-chip small { display: block; }
.account-chip strong { font-size: 11px; }
.account-chip small { margin-top: 2px; color: var(--subtle); font-size: 9px; }

main { flex: 1; width: 100%; min-width: 0; max-width: 1560px; margin: 0 auto; padding: 34px clamp(20px, 3vw, 46px) 60px; }
.view { display: none; min-width: 0; max-width: 100%; animation: view-in .22s ease-out; }
.view.is-active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.panel { border: 1px solid var(--line); border-radius: var(--radius-lg); background: linear-gradient(145deg, rgba(16, 34, 53, .88), rgba(11, 26, 41, .94)); box-shadow: var(--shadow); }
.hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 350px); gap: 34px; overflow: hidden; padding: clamp(28px, 4vw, 54px); }
.hero::before { content: ""; position: absolute; width: 420px; height: 420px; right: -150px; top: -230px; border: 1px solid rgba(85,216,208,.18); border-radius: 50%; box-shadow: 0 0 90px rgba(85,216,208,.09); }
.hero::after { content: ""; position: absolute; right: 12%; bottom: -100px; width: 250px; height: 250px; background: radial-gradient(circle, rgba(85,216,208,.1), transparent 68%); }
.hero-copy { position: relative; z-index: 1; min-width: 0; max-width: 780px; }
.hero h1 { margin: 12px 0 16px; font-size: clamp(30px, 4.4vw, 58px); line-height: 1.09; letter-spacing: -.045em; }
.hero p { max-width: 670px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 27px; }
.milestone-card { position: relative; z-index: 1; align-self: stretch; display: flex; align-items: flex-end; gap: 16px; min-width: 0; min-height: 190px; padding: 24px; border: 1px solid rgba(85,216,208,.19); border-radius: 18px; background: linear-gradient(160deg, rgba(85,216,208,.12), rgba(4,16,26,.32)); }
.milestone-number { align-self: flex-start; color: rgba(85,216,208,.27); font-size: 66px; font-weight: 900; line-height: 1; letter-spacing: -.06em; }
.milestone-card small, .milestone-card strong { display: block; }
.milestone-card small { color: var(--cyan); font-size: 10px; letter-spacing: .12em; }
.milestone-card strong { margin: 5px 0 4px; font-size: 20px; }
.milestone-card p { font-size: 11px; line-height: 1.5; }

.button { min-height: 41px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface-2); font-size: 12px; font-weight: 750; cursor: pointer; transition: .17s ease; }
.button:hover { transform: translateY(-1px); border-color: rgba(85,216,208,.35); }
.button:focus-visible, .icon-button:focus-visible, .text-button:focus-visible, .account-chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.button--primary { border-color: var(--cyan); color: #031c1b; background: var(--cyan); }
.button--primary:hover { background: #6ae1da; }
.button--ghost { color: var(--text); background: rgba(255,255,255,.025); }
.button--small { min-height: 34px; padding-inline: 12px; font-size: 10px; }
.text-button, .icon-button { border: 0; color: var(--cyan); background: transparent; cursor: pointer; }
.text-button { padding: 6px; font-size: 10px; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); font-size: 18px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin: 15px 0; }
.metric-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card { min-height: 124px; padding: 21px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(14, 31, 48, .75); }
.metric-card span, .metric-card small { display: block; }
.metric-label { color: var(--muted); font-size: 11px; }
.metric-card strong { display: block; margin: 10px 0 5px; color: var(--text); font-size: 30px; line-height: 1; }
.metric-card small { color: var(--subtle); font-size: 9px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 15px; }
.dashboard-grid > .panel { padding: 24px; }
.span-7 { grid-column: span 7; }
.span-5 { grid-column: span 5; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 19px; }
.panel-heading h2, .panel-heading p { margin: 0; }
.panel-heading h2 { margin-top: 5px; font-size: 16px; }
.panel-heading p { margin-top: 5px; color: var(--muted); font-size: 11px; }
.badge { display: inline-flex; align-items: center; width: max-content; padding: 5px 8px; border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.045); font-size: 9px; white-space: nowrap; }
.badge--amber { color: var(--amber); background: var(--amber-soft); }
.badge--outline { border: 1px solid var(--line); background: transparent; }
.empty-state { display: flex; align-items: center; justify-content: center; gap: 13px; min-height: 180px; padding: 22px; color: var(--muted); text-align: left; }
.empty-state.compact { justify-content: flex-start; min-height: 88px; padding: 13px 0; }
.empty-state.large { min-height: 350px; text-align: center; }
.empty-state.large { flex-direction: column; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--text); font-size: 12px; }
.empty-state p { max-width: 560px; margin: 0; color: var(--subtle); font-size: 10px; line-height: 1.65; }
.empty-state .button { margin-top: 14px; }
.empty-icon { display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; border: 1px solid rgba(85,216,208,.16); border-radius: 13px; color: var(--cyan); background: var(--cyan-soft); font-weight: 800; }
.project-columns { display: grid; grid-template-columns: 1.25fr 1fr .7fr 1.2fr; gap: 10px; padding: 12px 13px; border-top: 1px solid var(--line); color: var(--subtle); font-size: 9px; }
.context-block { padding: 15px; border-left: 2px solid var(--cyan); border-radius: 0 11px 11px 0; background: rgba(85,216,208,.055); }
.context-block span { color: var(--cyan); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.context-block p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.option-list { display: grid; gap: 8px; margin-top: 13px; }
.option-list > div { display: flex; gap: 11px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; }
.option-list > div > span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: var(--cyan); background: var(--cyan-soft); font-size: 10px; font-weight: 900; }
.option-list p, .option-list strong, .option-list small { display: block; margin: 0; }
.option-list strong { font-size: 10px; }
.option-list small { margin-top: 3px; color: var(--subtle); font-size: 9px; }
.readiness-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.readiness-list li { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; }
.readiness-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--cyan); background: var(--cyan-soft); }
.readiness-list strong, .readiness-list small { display: block; }
.readiness-list strong { font-size: 10px; }
.readiness-list small { margin-top: 2px; color: var(--subtle); font-size: 8px; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin: 7px 0 7px; font-size: clamp(27px, 3vw, 40px); letter-spacing: -.035em; }
.page-heading p { max-width: 760px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.conversation-layout { display: grid; grid-template-columns: 275px minmax(0, 1fr); gap: 15px; min-height: 680px; }
.topic-panel, .chat-panel { padding: 20px; }
.topic-panel .empty-state { min-height: 490px; flex-direction: column; text-align: center; }
.chat-panel { display: flex; flex-direction: column; }
.chat-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.chat-heading > div { display: flex; align-items: center; gap: 10px; }
.chat-heading strong, .chat-heading small { display: block; }
.chat-heading strong { font-size: 11px; }
.chat-heading small { margin-top: 2px; color: var(--subtle); font-size: 9px; }
.chat-empty { display: grid; place-items: center; flex: 1; align-content: center; text-align: center; }
.chat-empty h2 { margin: 14px 0 6px; font-size: 18px; }
.chat-empty p { max-width: 440px; margin: 0; color: var(--subtle); font-size: 10px; line-height: 1.6; }
.chat-orb { display: grid; place-items: center; width: 72px; height: 72px; border: 1px solid rgba(85,216,208,.28); border-radius: 24px; color: var(--cyan); background: radial-gradient(circle at 35% 30%, rgba(85,216,208,.2), rgba(85,216,208,.04)); box-shadow: 0 0 45px rgba(85,216,208,.09); font-size: 16px; font-weight: 900; }
.prompt-context { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 10px; color: var(--subtle); font-size: 9px; }
.prompt-context strong { margin-right: 5px; color: var(--muted); }
.prompt-context span { padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; }
.composer { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(5,15,25,.4); }
.composer textarea { width: 100%; min-height: 52px; resize: none; padding: 10px; border: 0; outline: 0; color: var(--muted); background: transparent; }
.composer textarea::placeholder { color: var(--subtle); }
.send-button { width: 48px; height: 42px; border: 0; border-radius: 11px; color: var(--subtle); background: rgba(255,255,255,.055); font-size: 10px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 13px; margin-bottom: 15px; padding: 16px; }
.filter-bar label { display: grid; gap: 6px; min-width: 180px; color: var(--subtle); font-size: 9px; }
.filter-bar input, .filter-bar select { min-height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: rgba(5,15,25,.45); }
.table-panel { min-width: 0; max-width: 100%; overflow: hidden; }
.table-panel > .panel-heading { padding: 22px 22px 0; }
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 18px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--subtle); background: rgba(5,15,25,.22); font-size: 9px; font-weight: 700; letter-spacing: .04em; }
td { color: var(--muted); font-size: 10px; }
.empty-row td { padding: 38px 20px; border: 0; }
.empty-row .empty-state { min-height: 190px; }
.card-grid-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.feature-card, .node-card { min-height: 250px; padding: 25px; }
.feature-index { color: rgba(85,216,208,.34); font-size: 34px; font-weight: 900; }
.feature-card h2, .node-card h2 { margin: 24px 0 8px; font-size: 17px; }
.feature-card p, .node-card p { min-height: 53px; margin: 0 0 20px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.super-admin-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px; margin-bottom: 15px; padding: 24px; border-color: rgba(241,188,98,.23); background: linear-gradient(145deg, rgba(241,188,98,.09), rgba(14,31,48,.82)); }
.crown { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; color: var(--amber); background: var(--amber-soft); font-size: 18px; }
.super-admin-card h2 { margin: 5px 0; font-size: 20px; }
.super-admin-card p { margin: 0; color: var(--muted); font-size: 10px; }
.node-head { display: flex; align-items: center; justify-content: space-between; }
.node-icon { display: grid; place-items: center; width: 45px; height: 45px; border: 1px solid rgba(85,216,208,.19); border-radius: 14px; color: var(--cyan); background: var(--cyan-soft); font-size: 11px; font-weight: 900; }
.node-card dl { display: grid; gap: 8px; margin: 20px 0 0; }
.node-card dl div { display: flex; justify-content: space-between; gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 9px; }
.node-card dt { color: var(--subtle); }
.node-card dd { margin: 0; color: var(--muted); }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 18px clamp(20px, 3vw, 46px); border-top: 1px solid var(--line); color: var(--subtle); font-size: 9px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 60; max-width: min(390px, calc(100vw - 44px)); padding: 13px 16px; border: 1px solid rgba(241,188,98,.3); border-radius: 12px; color: var(--text); background: #172432; box-shadow: 0 18px 50px rgba(0,0,0,.35); font-size: 11px; line-height: 1.5; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: none; }
.sidebar-scrim { position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.55); }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-7, .span-5 { grid-column: span 12; }
  .card-grid-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: minmax(0, 1fr) 280px; }
}

@media (max-width: 860px) {
  :root { --sidebar-width: 278px; }
  .app-shell { display: block; }
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; box-shadow: 24px 0 65px rgba(0,0,0,.4); }
  .sidebar.is-open { transform: none; }
  .workspace { min-height: 100vh; }
  .menu-button { display: grid; place-items: center; }
  .connection-pill { display: none; }
  .hero { grid-template-columns: 1fr; }
  .milestone-card { min-height: 150px; }
  .conversation-layout { grid-template-columns: 1fr; min-height: auto; }
  .topic-panel .empty-state { min-height: 170px; }
  .chat-panel { min-height: 580px; }
  .super-admin-card { grid-template-columns: auto 1fr; }
  .super-admin-card > .badge { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  main { padding-top: 23px; }
  .topbar { min-height: 68px; padding-inline: 14px; }
  .topbar-title .eyebrow { display: none; }
  .account-chip { width: 38px; padding: 3px; border-radius: 12px; }
  .account-chip > span:last-child { display: none; }
  .avatar { width: 30px; height: 30px; }
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 31px; }
  .hero p { font-size: 12px; }
  .metric-grid, .metric-grid--three, .card-grid-three { grid-template-columns: 1fr; }
  .metric-card { min-height: 105px; }
  .dashboard-grid { display: block; }
  .dashboard-grid > .panel { margin-bottom: 13px; padding: 19px; }
  .project-columns { grid-template-columns: 1fr 1fr; }
  .project-columns span:nth-child(n+3) { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .filter-bar { display: grid; }
  .filter-bar label { min-width: 0; }
  .chat-panel { min-height: calc(100vh - 150px); padding: 14px; }
  .prompt-context strong { width: 100%; }
  .super-admin-card { grid-template-columns: 1fr; text-align: center; }
  .crown { margin: 0 auto; }
  .super-admin-card > .badge { justify-self: center; }
  footer { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
