:root {
  --bg: #f7f8fa;
  --surface: #fff;
  --text: #172b40;
  --muted: #586b7e;
  --line: #e0e6ec;
  --strong: #23486e;
  --accent: #4e82b2;
  --pale: #eaf1f8;
  --radius: 15px;
  --shadow: 0 1px 2px #172b4008;
  --top-height: 66px;
  --sidebar-width: 210px;
  font: 14px/1.55 Inter, "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p, dl, dd { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
a { color: var(--strong); }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
:focus-visible { scroll-margin-block: 82px 16px; }
h1 { font-size: clamp(31px, 4vw, 43px); font-weight: 780; line-height: 1.2; letter-spacing: -.045em; }
h2 { font-size: 18px; font-weight: 750; letter-spacing: -.015em; }
h3 { font-size: 14px; }
h1[tabindex="-1"], main[tabindex="-1"] { outline: none; }
svg { flex: none; }
.break-any { overflow-wrap: anywhere; }
.visually-hidden, .skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip:focus { position: fixed; top: 6px; left: 6px; z-index: 20; padding: 8px 12px; background: #fff; }

.top {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--top-height);
  padding: 0 30px;
  gap: 14px;
  background: #fffffff4;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand, .top-actions, .brand-home { display: flex; align-items: center; gap: 11px; }
.brand-home { min-width: 0; border: 0; background: transparent; color: var(--text); padding: 0; text-align: left; }
.brand-name { font-size: 15px; font-weight: 780; white-space: nowrap; letter-spacing: .015em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #203d5b; color: #f0f5fa; }
.brand-mark svg { width: 21px; height: 21px; }
.sync { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.sync svg { width: 16px; height: 16px; color: #3c7665; }
.sync.dirty, .sync.dirty svg { color: #8b561b; }

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 9px;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.button { min-height: 40px; padding: 0 13px; gap: 7px; color: #fff; background: var(--strong); font-weight: 700; text-decoration: none; white-space: nowrap; }
.button svg { width: 16px; height: 16px; }
.button:hover:not(:disabled) { background: #17395c; }
.button.secondary, .button.login { background: #fff; color: var(--strong); border-color: #d5e0ea; }
.button.secondary:hover:not(:disabled), .button.login:hover:not(:disabled) { background: #eff4f9; border-color: #c5d6e5; }
.button.ghost { background: #edf3f8; color: var(--strong); }
.button.ghost:hover:not(:disabled) { background: #e4edf6; }
.button.danger { background: #fce9e6; color: #952e2b; }
.button.danger:hover:not(:disabled) { background: #f7dad4; }
.icon-button { min-width: 36px; min-height: 36px; padding: 0; background: transparent; color: #4c657d; }
.icon-button svg { width: 19px; height: 19px; }
.icon-button:hover:not(:disabled) { background: #eaf1f8; color: #1c456d; }
.mobile-nav, .nav-shade { display: none; }

.layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: calc(100dvh - var(--top-height)); }
.sidebar {
  position: sticky;
  top: var(--top-height);
  height: calc(100dvh - var(--top-height));
  display: flex;
  flex-direction: column;
  padding: 26px 15px 19px;
  border-right: 1px solid var(--line);
  background: #f9fafb;
  overflow-y: auto;
}
.sidebar-title { margin: 4px 12px 10px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .14em; }
.sidebar nav { display: grid; gap: 4px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  gap: 10px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #42586d;
  font-weight: 680;
  text-align: left;
  transition: background-color 150ms ease, color 150ms ease;
}
.nav-item:hover:not(:disabled) { background: #eff3f7; }
.nav-item[aria-current="page"] { background: #e8eff6; border-color: #dce7f1; color: #1e4266; font-weight: 750; }
.nav-item[aria-current="page"]::before { position: absolute; content: ""; top: 10px; bottom: 10px; left: -1px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item svg { width: 18px; height: 18px; }
.side-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 15px 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.tiny-mark { display: inline-flex; align-items: center; }
.tiny-mark svg { width: 16px; height: 16px; }

main { width: 100%; min-width: 0; padding: 34px clamp(22px, 4vw, 52px) 60px; }
#screen { max-width: 1180px; margin: 0 auto; }
.view-layer { min-width: 0; }
.eyebrow { margin: 0 0 10px; color: #496d8e; font-size: 11px; font-weight: 770; letter-spacing: .15em; }
.eyebrow:empty { display: none; }
.subpage { margin: 0 0 21px; }
.subpage p { margin-top: 7px; color: var(--muted); }
.schedule-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.panel-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.panel { min-width: 0; padding: 19px 21px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 15px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.panel-head p { margin-top: 4px; font-size: 12px; }
.panel-head p, .muted { color: var(--muted); line-height: 1.6; }

.overview-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(175px, .46fr);
  gap: 24px;
  align-items: end;
  padding: clamp(25px, 4vw, 43px);
  background: linear-gradient(112deg, #fff, #f3f7fb 100%);
  border: 1px solid #dfe7ef;
  border-radius: 17px;
}
.overview-copy h1 { font-size: clamp(37px, 5vw, 57px); }
.overview-copy p { margin-top: 11px; color: #4c6178; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.overview-identity { display: grid; gap: 8px; align-self: end; padding-left: 18px; border-left: 1px solid #dce6ef; }
.overview-identity p, .overview-local { display: flex; align-items: flex-start; gap: 8px; color: #405972; overflow-wrap: anywhere; }
.overview-identity svg, .overview-local svg { width: 16px; height: 16px; margin-top: 3px; }
.overview-identity time { color: var(--text); font-weight: 750; }
.overview-local { margin-top: 10px; color: var(--muted); font-size: 12px; }
.overview-section { margin-top: 28px; }
.overview-section h2 { margin-bottom: 11px; }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.overview-task {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 90px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.overview-task:hover { border-color: #acc5dc; background: #fbfdff; }
.overview-task-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 10px; color: #355e82; background: #edf3f8; }
.overview-task svg { width: 20px; height: 20px; }
.overview-task > svg { color: #6b8298; transition: transform 150ms ease, color 150ms ease; }
.overview-task:hover > svg { transform: translateX(3px); color: #285981; }
.overview-task-copy { display: grid; gap: 3px; min-width: 0; }
.overview-task-copy strong { font-size: 16px; }
.overview-task-copy span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.overview-staff { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 25px; margin-top: 24px; padding: 15px 0; border-top: 1px solid var(--line); }
.overview-staff h2 { color: #405b75; font-size: 14px; }
.overview-staff dl { display: flex; align-items: center; gap: 20px; }
.overview-metric { display: flex; align-items: baseline; gap: 7px; }
.overview-metric dt, .overview-metric dd { color: var(--muted); font-size: 12px; }
.overview-metric strong { color: var(--text); font-size: 18px; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.segmented { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid #e5ebf1; border-radius: 9px; background: #f3f6f9; }
.segmented button { min-height: 34px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #486078; font-weight: 650; }
.segmented button[aria-pressed="true"] { background: #fff; color: #23496f; border-color: #dbe5ef; box-shadow: 0 1px 2px #172b400a; }
.search { display: flex; align-items: center; gap: 8px; width: min(100%, 245px); min-height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; color: #536c83; background: #fff; }
.search:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.search svg { width: 16px; height: 16px; }
.search input { width: 100%; min-width: 0; border: 0; outline: none !important; background: transparent; color: var(--text); }
.timeline { padding-block: 15px 9px; }
.timeline-count { margin: 12px 0 7px; color: var(--muted); font-size: 12px; }
.timeline-table table { width: 100%; border-collapse: collapse; text-align: left; }
.timeline-table th { padding: 7px 9px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 670; white-space: nowrap; }
.timeline-table td { padding: 9px 9px; border-bottom: 1px solid #ebeff3; vertical-align: top; }
.timeline-table tbody tr:last-child td { border-bottom: 0; }
.timeline-table .clock { width: 133px; padding-top: 14px; color: #365571; font-weight: 760; font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline-table .timeline-status { width: 76px; padding-top: 13px; }
.timeline-table .timeline-edit { width: 43px; padding: 6px 0 5px 5px; text-align: right; }
.timeline-item summary, .row-plain { display: flex; align-items: center; gap: 7px; min-height: 31px; }
.timeline-item summary { width: fit-content; max-width: 100%; list-style: none; cursor: pointer; border-radius: 5px; }
.timeline-item summary::-webkit-details-marker { display: none; }
.timeline-item summary:hover .title-line { color: #275e8d; }
.timeline-item summary > svg { width: 15px; height: 15px; color: #59758e; transition: transform 160ms ease; }
.timeline-item details[open] summary > svg { transform: rotate(90deg); }
.title-line { color: var(--text); font-weight: 740; }
.row-detail { display: grid; gap: 5px; padding: 8px 12px; margin: 5px 0 3px 21px; border-left: 2px solid #dce7f1; background: #f7f9fb; color: #415a73; font-size: 12px; }
.row-detail > div { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; }
.row-detail dt { color: #516c86; font-weight: 740; }
.row-detail dd { white-space: pre-wrap; overflow-wrap: anywhere; }
.tag { display: inline-flex; align-items: center; padding: 2px 6px; border-radius: 5px; color: #445e76; background: #eff3f7; font-size: 11px; font-weight: 720; white-space: nowrap; }
.tag.am, .tag.pm, .tag.all { background: #edf2f7; color: #496680; font-size: 10px; }
.tag.planned { background: #f7f0e3; color: #765523; }
.tag.confirmed { background: #e9f0f8; color: #305b80; }
.tag.done { background: #e7f2eb; color: #38694e; }
.empty { padding: 23px 12px; color: var(--muted); text-align: center; }

.notes-grid, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; align-items: start; }
.notes-grid .panel, .settings-grid .panel { margin: 0; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; color: #3e556d; line-height: 1.7; }
.settings-line { padding: 8px 0; border-top: 1px solid var(--line); line-height: 1.6; overflow-wrap: anywhere; }
.settings-line b { display: block; color: #45627e; font-size: 12px; }
.settings-line .button { margin-top: 4px; min-height: 32px; }
.draft-line { margin-top: 17px; padding-top: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.notice { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 9px; margin-bottom: 16px; padding: 11px 13px; border: 1px solid #ecdcb5; border-radius: 9px; background: #fbf5e8; color: #765521; }
.notice svg { width: 17px; height: 17px; margin-top: 2px; }
.notice button { min-height: 33px; }
.notice p { margin-top: 3px; }
.notice ul { margin: 5px 0 0; padding-left: 20px; }

.feature-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 11px; background: #ebf2f8; color: #355e82; }
.feature-icon svg { width: 22px; height: 22px; }
.gate { max-width: 530px; margin: 7vh auto; padding: 37px 30px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.gate .feature-icon { margin: 0 auto 15px; }
.gate h1 { font-size: 31px; }
.gate p { margin-top: 10px; color: var(--muted); line-height: 1.65; }
.gate .actions { justify-content: center; margin-top: 17px; }

dialog { width: min(570px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: #fff; box-shadow: 0 24px 70px #162d4245; }
dialog::backdrop { background: #162b4169; }
.dialog-head, .dialog-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 19px; }
.dialog-head { border-bottom: 1px solid var(--line); }
.dialog-actions { justify-content: flex-end; border-top: 1px solid var(--line); }
.dialog-actions .danger { margin-right: auto; }
.dialog-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 13px; padding: 16px 19px; }
.field { display: grid; gap: 5px; color: #374f67; font-weight: 660; }
.dialog-body .wide, .form-error { grid-column: 1 / -1; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; min-height: 39px; padding: 7px 9px; border: 1px solid #cbd7e3; border-radius: 7px; background: #fff; color: var(--text); }
.field textarea { min-height: 72px; resize: vertical; }
.field textarea.prompt-output { min-height: 150px; background: #f7f9fc; font-weight: 450; line-height: 1.55; }
.form-error { color: #9a2722; }
.toast { position: fixed; z-index: 11; right: 18px; bottom: 19px; max-width: min(390px, calc(100vw - 36px)); padding: 10px 14px; border-radius: 9px; background: #203b56; color: #fff; line-height: 1.55; box-shadow: 0 5px 16px #1a2b4d38; }

@media (prefers-reduced-motion: no-preference) {
  .view-enter { animation: view-arrive 200ms cubic-bezier(.2,.65,.35,1) both; }
  .timeline-item details[open] .row-detail { animation: detail-arrive 150ms ease-out both; }
  dialog[open] { animation: dialog-arrive 170ms cubic-bezier(.2,.65,.35,1) both; }
  .toast:not([hidden]) { animation: detail-arrive 140ms ease-out both; }
  @keyframes view-arrive { from { opacity: .55; transform: translateY(5px); } }
  @keyframes detail-arrive { from { opacity: .42; transform: translateY(-2px); } }
  @keyframes dialog-arrive { from { opacity: .6; transform: translateY(5px) scale(.995); } }
}

@media (max-width: 1050px) {
  :root { --sidebar-width: 177px; }
  .top { padding: 0 19px; }
  .sidebar { padding-inline: 11px; }
}
@media (max-width: 760px) {
  :root { --top-height: 60px; }
  .top { padding: 0 10px; gap: 5px; }
  .top-actions, .brand, .brand-home { gap: 6px; }
  .brand-mark { width: 31px; height: 31px; }
  .brand-mark svg { width: 19px; height: 19px; }
  .brand-name { font-size: 13px; }
  .mobile-nav { display: inline-flex; width: 37px; min-width: 37px; min-height: 39px; }
  .layout { display: block; }
  .sidebar {
    position: fixed;
    z-index: 7;
    top: var(--top-height);
    left: 0;
    width: min(255px, 80vw);
    padding: 20px 12px 16px;
    background: #fff;
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 170ms ease, visibility 0s linear 170ms;
  }
  .sidebar.open { visibility: visible; transform: translateX(0); transition-delay: 0s; }
  .nav-shade { display: block; position: fixed; inset: var(--top-height) 0 0; z-index: 6; padding: 0; border: 0; background: #243b553f; }
  main { padding: 21px 14px 47px; }
  .button.top-save, .button.login { min-height: 34px; padding: 0 7px; font-size: 12px; }
  .panel { padding: 14px; }
  .subpage { margin-bottom: 15px; }
  .subpage p { font-size: 13px; }
  .schedule-head { align-items: flex-start; flex-wrap: wrap; gap: 11px; }
  .notes-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .overview-head { grid-template-columns: minmax(0, 1fr); gap: 17px; }
  .overview-identity { border-left: 0; border-top: 1px solid #dce6ef; padding: 10px 0 0; }
  .overview-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .overview-task { min-height: 72px; padding: 12px; }
  .overview-section { margin-top: 22px; }
  .overview-staff { margin-top: 19px; }
  .toolbar .search { flex: 1; min-width: min(100%, 155px); }
  .timeline-table table, .timeline-table tbody { display: block; }
  .timeline-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .timeline-table tr { display: grid; grid-template-columns: minmax(0, 1fr) max-content 34px; align-items: center; gap: 1px 6px; padding: 6px 0 8px; border-bottom: 1px solid #ebeff3; }
  .timeline-table tbody tr:last-child { border-bottom: 0; }
  .timeline-table td { min-width: 0; padding: 0; border: 0; }
  .timeline-table .clock { width: auto; padding-top: 0; font-size: 12px; }
  .timeline-item { grid-area: 2 / 1 / 3 / 4; }
  .timeline-table .timeline-status { grid-area: 1 / 2 / 2 / 3; width: auto; padding: 0; }
  .timeline-table .timeline-edit { grid-area: 1 / 3 / 2 / 4; width: auto; padding: 0; }
  .timeline-table .timeline-edit .icon-button { min-width: 34px; min-height: 31px; }
  .timeline-table .timeline-edit .icon-button svg { width: 16px; height: 16px; }
  .timeline-item summary { min-height: 30px; }
}
@media (max-width: 460px) {
  .sync span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .top-actions > .sync svg { width: 14px; height: 14px; }
  .top-save svg, .button.login svg { width: 13px; height: 13px; }
  .segmented button { min-height: 31px; padding: 0 9px; font-size: 12px; }
  .panel-actions .button { min-height: 34px; padding: 0 9px; font-size: 12px; }
  .panel-head h2 { font-size: 16px; }
}
@media (max-width: 350px) {
  .brand-mark { display: none; }
  .brand-name { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .nav-item, .button, .icon-button, .overview-task, .overview-task > svg, .timeline-item summary > svg { transition: none; }
  .overview-task:hover > svg { transform: none; }
}
@media print {
  .top, .sidebar, .toolbar, .notice, .panel-head button, .timeline-edit, .toast { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  .panel { box-shadow: none; }
  tr, .panel { break-inside: avoid; }
}
