/* Warm neutral surfaces with a restrained terracotta accent.
   Calendar colours, the red league seal, and semantic states stay distinct. */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --brand: #b4232a;
  --brand-dark: #931c22;
  --brand-soft: #fbedee;
  --seal: #b4232a;
  --on-seal: #ffffff;
  --accent: #d97757;
  --accent-ink: #9b3f27;
  --accent-soft: #f7e7de;
  --neutral-mid: #b0aea5;
  --ink: #141413;
  --ink-hover: #383832;
  --text: #262620;
  --text-2: #68675f;
  --text-3: #8d8b82;
  --text-3-strong: #737168;
  --line: #e8e6dc;
  --line-strong: #969387;
  --bg: #faf9f5;
  --card: #ffffff;
  --hover: #f2f0e7;
  --info: #9b3f27;
  --success: #1c7a52;
  --warning: #b87516;
  --warning-ink: #86600f;
  --danger: #bd382f;
  --tone-neutral-bg: #eeede6;
  --tone-neutral-ink: #626057;
  --tone-ok-bg: #e8f0e7;
  --tone-ok-ink: #34603e;
  --tone-warn-bg: #f5ebd2;
  --tone-warn-ink: #805c15;
  --tone-bad-bg: #f6e5e0;
  --tone-bad-ink: #993b33;
  --on-primary: #faf9f5;
  --on-brand: #ffffff;
  --on-success: #ffffff;
  --on-danger: #ffffff;
  --on-neutral: #ffffff;
  --shell-bg: #f6f5ef;
  --surface-subtle: #f2f0e8;
  --selected-bg: #eeebe2;
  --selected-border: #ccc6b8;
  --selection-bg: #ead8cc;
  --selection-ink: var(--ink);
  --focus-ring: rgba(20, 20, 19, .09);
  --loading-mask: rgba(250, 249, 245, .65);
  --event-outline: #79776d;
  --line-soft: var(--line);
  --radius: 8px;
  --radius-sm: 8px;
  --shadow: 0 4px 16px rgba(40, 34, 24, .08);
  --shadow-lg: 0 16px 48px rgba(40, 34, 24, .16);
  --mask: rgba(30, 27, 22, .34);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #f19a9f;
  --brand-dark: #fac0c4;
  --brand-soft: #3e2527;
  --seal: #b4232a;
  --on-seal: #ffffff;
  --accent: #d97757;
  --accent-ink: #e5a084;
  --accent-soft: #3a281f;
  --neutral-mid: #b0aea5;
  --ink: #faf9f5;
  --ink-hover: #e8e6dc;
  --text: #f0eee6;
  --text-2: #b0aea5;
  --text-3: #9d9a8f;
  --text-3-strong: #b0aea5;
  --line: #3b3a32;
  --line-strong: #726e61;
  --bg: #141413;
  --card: #1e1e1b;
  --hover: #2c2b25;
  --info: #e5a084;
  --success: #86c9a6;
  --warning: #d5b367;
  --warning-ink: #e7c682;
  --danger: #f0a09b;
  --tone-neutral-bg: #302f29;
  --tone-neutral-ink: #c7c3b8;
  --tone-ok-bg: #233327;
  --tone-ok-ink: #a8cfb0;
  --tone-warn-bg: #392f1e;
  --tone-warn-ink: #e7c681;
  --tone-bad-bg: #3b2723;
  --tone-bad-ink: #f0afa4;
  --on-primary: #141413;
  --on-brand: #32171b;
  --on-success: #14271b;
  --on-danger: #351714;
  --on-neutral: #1f1e1a;
  --shell-bg: #191917;
  --surface-subtle: #24241f;
  --selected-bg: #353128;
  --selected-border: #766d5b;
  --selection-bg: #6a4936;
  --selection-ink: #faf9f5;
  --focus-ring: rgba(232, 230, 220, .18);
  --loading-mask: rgba(20, 20, 19, .68);
  --event-outline: #b0aea5;
  --shadow: 0 4px 16px rgba(0, 0, 0, .24);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .42);
  --mask: rgba(5, 8, 12, .65);
}
body { font-family: "Segoe UI Variable Text", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif; letter-spacing: .1px; }
h1, h2, h3, h4 { color: var(--ink); }
button, input, select, textarea { font: inherit; }
a { text-underline-offset: 3px; }
:focus-visible { outline-color: var(--accent-ink); }
::selection { background: var(--selection-bg); color: var(--selection-ink); }
button, a, summary, input, select, textarea { -webkit-tap-highlight-color: transparent; }
.muted { color: var(--text-2); }

/* Shell */
.sidebar { background: var(--shell-bg); border-right-color: var(--line); height: 100dvh; }
.brand { min-height: 96px; gap: 12px; padding: 24px 16px; }
.brand-mark, .brand-mark.small { border-radius: 8px; color: var(--on-seal); background: var(--seal); }
.brand-text strong { font-size: 14px; line-height: 24px; font-weight: 650; }
.brand-text small { margin-top: 4px; font-size: 11px; line-height: 16px; }
.nav { padding: 8px 12px 16px; scrollbar-width: thin; }
.workbench-main-nav { gap: 4px; }
.nav-item { min-height: 44px; padding: 12px; gap: 12px; margin: 0; font-size: 14px; border-radius: 8px; }
.nav-item .icon { width: 18px; height: 18px; flex-basis: 18px; opacity: .85; }
.nav-item.active { background: var(--selected-bg); color: var(--ink); box-shadow: inset 2px 0 var(--accent); font-weight: 600; }
.workbench-management { margin-top: 24px; padding-top: 12px; }
.workbench-management > summary { padding: 12px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.sidebar-foot { padding: 16px; background: var(--shell-bg); }
.me-card { gap: 12px; }
.avatar { background: var(--selected-bg); color: var(--ink); border-radius: 8px; }
.me-info strong { font-size: 13px; line-height: 20px; }
.sidebar-foot .btn-row { gap: 8px; margin-top: 12px; }
.sidebar-foot .btn { font-size: 12px; }
.main { min-height: 100dvh; }
.topbar { min-height: 96px; padding: 16px 24px; gap: 16px; background: var(--bg); align-items: center; }
.topbar-title { flex: 1; }
.topbar-title h2 { font-size: 24px; line-height: 32px; font-weight: 650; letter-spacing: .3px; }
.topbar-title p { margin-top: 4px; font-size: 12px; line-height: 20px; }
.topbar-actions { gap: 8px; }
.page { max-width: 1440px; padding: 24px 24px 40px; }
.announce { max-width: 1392px; margin-top: 16px; }

/* Controls share one radius and one visual weight. */
.btn { min-height: 36px; padding: 8px 12px; border-radius: 8px; line-height: 20px; font-size: 13px; font-weight: 500; box-shadow: none; }
.btn:hover { border-color: var(--line-strong); text-decoration: none; }
.btn-primary, .btn-success { color: var(--on-primary); background: var(--ink); border-color: var(--ink); }
.btn-primary:hover, .btn-success:hover { color: var(--on-primary); background: var(--ink-hover); border-color: var(--ink-hover); filter: none; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 32px; padding: 4px 8px; font-size: 12px; }
.btn-block { min-height: 44px; }
.icon-btn { border-radius: 8px; }
input, select, textarea { border-radius: 8px; border-color: var(--line-strong); background-color: var(--card); color: var(--text); min-height: 40px; padding: 8px 12px; }
input::placeholder, textarea::placeholder { color: var(--text-3-strong); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 2px var(--focus-ring); outline: none; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ink); min-height: 0; padding: 0; box-shadow: none; }
.field { margin-bottom: 16px; min-width: 0; }
.field > span { font-size: 12px; line-height: 20px; margin-bottom: 8px; font-weight: 500; }
.form-grid { gap: 0 16px; }
.inline-form { gap: 12px; }
.tag, .chip, .badge { border-radius: 8px; }
.tag { padding: 2px 8px; font-size: 11px; line-height: 20px; font-weight: 500; }
.chip-row { gap: 8px; }
.chip { min-height: 32px; padding: 4px 12px; border-color: var(--line); background: var(--card); color: var(--text-2); }
.chip.on { background: var(--selected-bg); border-color: var(--selected-border); color: var(--ink); }
.workbench-tabs { gap: 4px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.workbench-tabs > .btn { background: transparent; border-color: transparent; color: var(--text-2); }
.workbench-tabs > .workbench-tab-current { color: var(--ink); background: var(--selected-bg); border-color: transparent; }
.workbench-more-menu { margin-left: auto; }
.workbench-more-menu > summary { list-style: none; min-height: 36px; padding: 8px 12px; color: var(--text-2); font-size: 13px; font-weight: 500; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.workbench-more-menu > summary::-webkit-details-marker { display: none; }
.workbench-more-menu > summary::after { content: '⌄'; margin-left: 12px; }
.workbench-more-menu[open] > .btn { position: absolute; top: calc(100% + 8px); right: 0; z-index: 35; width: 192px; padding: 12px; background: var(--card); border-color: var(--line); box-shadow: var(--shadow); text-align: left; }

/* Containers and readable lists */
.card, .quick { border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 24px; box-shadow: none; }
.card-head { align-items: center; gap: 8px 12px; margin-bottom: 16px; }
.card-head h3 { min-width: 0; font-size: 15px; line-height: 24px; font-weight: 600; }
.card-section { margin-top: 16px; padding-top: 16px; }
.card-brand { border-top: 1px solid var(--line); }
.grid { gap: 16px; }
.stat .v { font-size: 26px; line-height: 36px; letter-spacing: -.4px; }
.stat.accent .v { color: var(--ink); }
.stat .k, .stat .hint { font-size: 12px; line-height: 20px; }
.workbench-section { margin-bottom: 16px; }
.workbench-section > .workbench-tabs { margin-bottom: 0; }
.workbench-item { padding: 16px 0; gap: 16px; }
.workbench-item-main { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.workbench-item-main strong { flex: 0 0 100%; min-width: 0; font-size: 14px; line-height: 24px; font-weight: 550; }
.workbench-item-main > .muted { font-size: 12px; line-height: 20px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workbench-item-action { font-size: 12px; line-height: 20px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; }
.workbench-item:hover { color: var(--ink); text-decoration: none; }
.workbench-item:hover .workbench-item-action { background: var(--hover); border-color: var(--line-strong); }
.list-item { gap: 12px; padding: 16px 0; }
.li-meta { line-height: 20px; }
.empty { padding: 24px 16px; font-size: 13px; line-height: 24px; }
.task-summary-card, .activity-task-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.task-summary-card .card-head, .activity-task-card .card-head { align-items: flex-start; margin: 0; }
.task-summary-card .card-head h3, .activity-task-card .card-head h3 { flex: 1; font-size: 15px; line-height: 24px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.task-summary-card > .li-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 !important; }
.task-summary-card > .li-meta > span { margin-left: 0 !important; font-size: 12px; }
.task-summary-card > p, .activity-task-card > .activity-description { margin: 0 !important; color: var(--text-2); font-size: 13px; line-height: 24px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.task-summary-card > .chip-row { margin: 0 !important; }
.task-summary-card > .btn-row { margin-top: auto; padding-top: 4px; }
.activity-task-card > .btn { align-self: flex-start; margin-top: auto; }
.activity-task-card > p.muted { font-size: 12px; line-height: 20px; }
table.tb { font-size: 13px; }
table.tb th { background: var(--surface-subtle); color: var(--text-2); padding: 12px; font-size: 12px; font-weight: 500; }
table.tb td { padding: 12px; line-height: 24px; }
table.tb .btn-row { gap: 4px; }
.table-wrap { border-radius: 8px; }
.pager { padding-top: 16px; gap: 8px; }
.kv { gap: 8px 16px; line-height: 24px; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.alert { border-radius: 8px; padding: 12px 16px; line-height: 24px; }
.workbench-profile-summary { gap: 12px 24px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

/* Calendar: hierarchy comes from type, title and date, not extra colour. */
.activity-ui .btn, .activity-ui input, .activity-ui select { min-height: 36px; }
.activity-calendar-controls { padding: 16px; gap: 12px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.activity-calendar-controls .field { flex: 0 1 auto; }
.activity-calendar-controls .field > span { margin-bottom: 4px; }
.activity-calendar-controls .btn-row { gap: 8px; }
.activity-help { color: var(--text-2); font-size: 12px; line-height: 20px; margin: 12px 0; }
.activity-calendar-legend { margin: 0 0 16px; gap: 8px 16px; }
.activity-month-grid { border-radius: 8px; border-color: var(--line-strong); }
.activity-weekday { background: var(--surface-subtle); padding: 12px 8px; font-size: 12px; }
.activity-day { min-height: 116px; padding: 8px; }
.activity-day[aria-hidden="true"] { background: var(--surface-subtle); }
.activity-day-number { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin: 0 0 8px; font-size: 12px; line-height: 24px; }
.activity-today .activity-day-number { color: var(--on-primary); background: var(--ink); border-radius: 8px; font-weight: 600; }
.activity-event { gap: 4px; padding: 8px; margin: 4px 0 8px; border-color: var(--line); border-radius: 8px; background: var(--card); box-shadow: none; }
.activity-event:hover { border-color: var(--line-strong); background: var(--surface-subtle); text-decoration: none; }
.activity-event-kind { display: block; font-size: 12px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-event-title { font-size: 13px; font-weight: 550; line-height: 20px; }
.activity-event-title > span:last-child { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.activity-event-title .activity-status-mark { margin-top: 6px; }
.activity-event-date-label { color: var(--text-2); font-size: 12px; line-height: 18px; }
.activity-event > .activity-main-context { margin: 0; font-size: 12px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-event > .muted:not(.activity-main-context):not(.activity-event-date-label) { font-size: 12px; line-height: 18px; }
.activity-pending-row { display: grid; grid-template-columns: minmax(0, 1fr) 128px 136px auto; gap: 8px 16px; padding: 12px 0; }
.activity-pending-link { min-height: 36px; font-size: 13px; line-height: 24px; padding: 4px 0; overflow-wrap: anywhere; }
.activity-pending-row > .muted { font-size: 12px; line-height: 20px; }
.activity-detail-head h3 { font-size: 20px; line-height: 32px; }
.activity-node { padding: 16px 0; }
.activity-node h3 { font-size: 14px; line-height: 24px; }
.activity-node .btn-row { gap: 8px; }
.activity-subnodes { margin-top: 12px; margin-left: 16px; padding-left: 16px; }
.activity-member-choices { border-radius: 8px; padding: 8px 12px; }
.activity-choice { gap: 12px; }
.activity-proof-list .att { border-radius: 8px; }

/* Dialogs are the only elevated surfaces. */
.modal-root { padding: 24px; }
.modal, .modal.wide { border-radius: 8px; border-color: var(--line); }
.modal { max-width: 640px; max-height: min(88dvh, 960px); }
.modal.wide { max-width: 960px; }
.modal-head { padding: 16px 24px; gap: 12px; background: var(--card); }
.modal-head h3 { font-size: 17px; line-height: 24px; }
.modal-body { padding: 24px; overscroll-behavior: contain; }
.modal-foot { gap: 8px; padding: 16px 24px; background: var(--shell-bg); }
.modal-body .form-grid:last-child .field { margin-bottom: 0; }
.modal-body .workbench-more > summary, .modal-body .workbench-advanced > summary { color: var(--text-2); font-size: 13px; }
.login-card { max-width: 416px; padding: 24px; border-radius: 8px; }
.login-brand { gap: 16px; margin-bottom: 24px; }
.login-brand h1 { font-size: 21px; line-height: 32px; }
.login-brand p { margin-top: 4px; font-size: 12px; line-height: 20px; }
.login-foot { margin-top: 16px; }

@media (min-width: 1180px) {
  .page[data-page="home"] { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
  .page[data-page="home"] > .workbench-section { margin: 0; }
  .page[data-page="home"] > .workbench-section:first-of-type { grid-row: span 2; }
  .page[data-page="home"] > .alert { grid-column: 1 / -1; }
}
@media (min-width: 768px) and (max-width: 1100px) {
  .activity-pending-row { grid-template-columns: minmax(0, 1fr) auto; }
  .activity-event { padding: 8px 4px; }
  .activity-day { padding: 4px; }
}
@media (max-width: 767px) {
  :root { --sidebar-w: 280px; }
  .brand { min-height: 88px; padding: 24px 16px; }
  .sidebar-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .topbar { min-height: 72px; padding: 12px 16px; gap: 8px; }
  .topbar-title h2 { font-size: 20px; line-height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-actions { flex-shrink: 0; }
  .topbar-actions > input { width: 90px !important; min-width: 0; }
  .page { padding: 16px 16px 24px; }
  .announce { width: auto; margin: 12px 16px 0; }
  .btn, .activity-ui .btn { min-height: 44px; padding: 10px 12px; font-size: 14px; }
  .btn-sm { min-height: 36px; padding: 6px 8px; font-size: 12px; }
  input, select, textarea, .activity-ui input, .activity-ui select { min-height: 44px; font-size: 16px; }
  .card, .quick { padding: 16px; }
  .workbench-tabs { gap: 4px; margin-bottom: 16px; padding-bottom: 12px; }
  .workbench-tabs > .btn { min-height: 40px; font-size: 13px; padding: 8px 12px; }
  .workbench-more-menu > summary { min-height: 40px; padding: 10px 12px; }
  .workbench-section { margin-bottom: 16px; }
  .workbench-item { gap: 12px; padding: 16px 0; }
  .workbench-item-main strong { font-size: 14px; }
  .workbench-item-action { padding: 4px; border: 0; }
  .workbench-profile-summary { gap: 4px; padding: 16px 0; }
  .workbench-profile-summary dd { margin-bottom: 12px; }
  .chip { min-height: 36px; padding: 6px 12px; }
  .activity-calendar-controls { padding: 12px; gap: 12px; }
  .activity-calendar-controls > .field { flex-basis: 100%; }
  .activity-calendar-controls .btn-row .btn { min-width: 0; }
  .activity-calendar-legend { font-size: 12px; margin-bottom: 12px; }
  .activity-agenda-date { padding: 16px; margin-bottom: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
  .activity-agenda-date h3 { margin-bottom: 12px; font-size: 14px; }
  .activity-event { gap: 4px; padding: 12px; margin: 8px 0 0; }
  .activity-event-kind, .activity-event-date-label, .activity-event > .activity-main-context, .activity-event > .muted:not(.activity-main-context):not(.activity-event-date-label) { font-size: 12px; line-height: 20px; }
  .activity-event-title { font-size: 14px; line-height: 24px; }
  .activity-event-title .activity-status-mark { margin-top: 8px; }
  .activity-pending-row { display: flex; align-items: flex-start; gap: 8px 12px; }
  .activity-pending-link { flex-basis: 100%; min-height: 44px; font-size: 14px; }
  .activity-subnodes { margin-left: 8px; padding-left: 12px; }
  .activity-detail-head h3 { font-size: 18px; line-height: 28px; }
  table.tb tr { padding: 16px; margin-bottom: 12px; border-radius: 8px; }
  table.tb td { padding: 4px 0; line-height: 24px; min-width: 0; }
  table.tb td:first-child { padding-bottom: 8px; }
  table.tb .col-name, table.tb .col-text, table.tb .col-tags { max-width: none; white-space: normal; }
  table.tb .col-tight { white-space: normal; overflow-wrap: anywhere; }
  table.tb td::before { flex-basis: 72px; font-size: 12px; }
  .tabbar-inner { padding-top: 8px; background: var(--card); border-top-color: var(--line); }
  .tab-item.active { color: var(--ink); }
  .modal-root { padding: 12px; align-items: center; }
  .modal, .modal.wide { max-height: calc(100dvh - 24px); border-radius: 8px; border: 1px solid var(--line); }
  .modal-head { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { flex-wrap: wrap; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }
  .login-wrap { padding: 16px; }
  .login-card { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
