/* OffiZcan UI: tokens, base, layout, components, utilities, print (UI design plan). */

/* ---------- tokens ---------- */
:root {
  --font-ui: "OffiZcan Sans", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "OffiZcan Mono", "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-base: 1rem;
  --text-lg: clamp(1.125rem, 1.05rem + 0.25vw, 1.25rem);
  --text-xl: clamp(1.5rem, 1.35rem + 0.5vw, 2rem);
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem; --space-5: 1.25rem;
  --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem; --space-16: 4rem;
  --radius-sm: 4px; --radius: 6px; --radius-lg: 10px;
  --sidebar: 15rem; --topbar: 3.5rem; --tabbar: 3.75rem; --touch: 2.25rem;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}
:root, [data-theme="light"] {
  color-scheme: light;
  --color-bg: #f5f6f4; --color-surface: #ffffff; --color-surface-raised: #fbfcfa; --color-surface-muted: #ecefeb; --color-surface-selected: #dcecea;
  --color-text: #202522; --color-text-muted: #5c6660; --color-text-faint: #747e78; --color-text-inverse: #ffffff;
  --color-border: #ced4d0; --color-divider: #dde2de;
  --color-primary: #086c68; --color-primary-hover: #075955; --color-primary-active: #064642; --color-primary-soft: #d7ebe8;
  --color-success: #397229; --color-success-soft: #dfedd9; --color-warning: #8a5a00; --color-warning-soft: #f4e8c9;
  --color-error: #a52b3a; --color-error-soft: #f4dadd; --color-info: #275f8c; --color-info-soft: #dce8f1;
  --shadow-sm: 0 1px 2px rgb(25 35 29 / 0.06), 0 2px 6px rgb(25 35 29 / 0.04);
  --shadow-md: 0 4px 12px rgb(25 35 29 / 0.08), 0 12px 28px rgb(25 35 29 / 0.05);
}
[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #141715; --color-surface: #1b1f1c; --color-surface-raised: #212622; --color-surface-muted: #292f2b; --color-surface-selected: #243b38;
  --color-text: #e1e6e2; --color-text-muted: #adb7b0; --color-text-faint: #8c9790; --color-text-inverse: #12201e;
  --color-border: #3b443e; --color-divider: #303732;
  --color-primary: #72bbb5; --color-primary-hover: #8bcac5; --color-primary-active: #a0d7d2; --color-primary-soft: #263e3b;
  --color-success: #8bc375; --color-success-soft: #293c25; --color-warning: #e0b45e; --color-warning-soft: #433821;
  --color-error: #e3828d; --color-error-soft: #47292e; --color-info: #83b2d5; --color-info-soft: #273947;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.24), 0 2px 8px rgb(0 0 0 / 0.16);
  --shadow-md: 0 6px 18px rgb(0 0 0 / 0.28), 0 16px 36px rgb(0 0 0 / 0.18);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font: var(--text-base)/1.5 var(--font-ui); background: var(--color-bg); color: var(--color-text); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; font-weight: 600; }
h1 { font-size: var(--text-xl); } h2 { font-size: var(--text-lg); } h3 { font-size: var(--text-base); } h4 { font-size: var(--text-sm); }
p { margin: 0 0 var(--space-2); }
a { color: var(--color-primary); text-underline-offset: 2px; }
a:hover { color: var(--color-primary-hover); }
small, .small-text { font-size: var(--text-sm); }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.9em; }
kbd { border: 1px solid var(--color-border); border-bottom-width: 2px; border-radius: var(--radius-sm); padding: 0 0.3em; color: var(--color-text-muted); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
::selection { background: var(--color-primary-soft); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--space-2); top: -3rem; z-index: 100; background: var(--color-surface); padding: var(--space-2) var(--space-3); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.skip:focus { top: var(--space-2); }

/* ---------- forms ---------- */
label { display: block; font-size: var(--text-sm); font-weight: 500; color: var(--color-text); }
input, textarea, select {
  display: block; width: 100%; margin-top: var(--space-1); padding: 0.5rem 0.625rem; min-height: var(--touch);
  font: var(--text-base)/1.4 var(--font-ui); color: var(--color-text); background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius); transition: border-color 150ms var(--ease);
}
textarea { resize: vertical; min-height: 5rem; }
input:hover, textarea:hover, select:hover { border-color: var(--color-text-faint); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 0; border-color: var(--color-primary); }
input[type="checkbox"], input[type="radio"] { display: inline-block; width: 1.1rem; height: 1.1rem; min-height: 0; margin: 0; accent-color: var(--color-primary); vertical-align: middle; }
input[type="color"] { width: 3rem; padding: 0.15rem; }
fieldset { border: 1px solid var(--color-divider); border-radius: var(--radius); margin: 0 0 var(--space-3); padding: var(--space-3); }
legend { font-size: var(--text-sm); font-weight: 600; padding: 0 var(--space-1); }
.field { margin-bottom: var(--space-3); }
.field-help { font-size: var(--text-xs); color: var(--color-text-muted); margin: var(--space-1) 0 0; }
.field-error { font-size: var(--text-sm); color: var(--color-error); margin: var(--space-1) 0 0; }
.req { color: var(--color-error); }
.choice { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 400; min-height: var(--touch); cursor: pointer; }
.choice input { margin: 0; }
.fields { display: grid; gap: 0 var(--space-3); grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: var(--space-3); }
.error-summary { border: 1px solid var(--color-error); background: var(--color-error-soft); color: var(--color-text); border-radius: var(--radius); padding: var(--space-3); margin-bottom: var(--space-3); }

/* ---------- buttons ---------- */
button { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--touch); padding: 0.4rem 0.875rem;
  border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); color: var(--color-text);
  font-size: var(--text-sm); font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.btn:hover { background: var(--color-surface-muted); color: var(--color-text); }
.btn:active { background: var(--color-surface-selected); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-text-inverse); }
.btn.primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn.primary:active { background: var(--color-primary-active); }
.btn.danger { color: var(--color-error); border-color: var(--color-error); }
.btn.danger.solid { background: var(--color-error); color: var(--color-text-inverse); }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.quiet:hover { background: var(--color-surface-muted); }
.btn.sm { min-height: 1.875rem; padding: 0.2rem 0.6rem; font-size: var(--text-xs); }
.btn.on, .btn[aria-pressed="true"] { background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-text); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; position: relative; min-width: var(--touch); min-height: var(--touch); padding: 0 var(--space-2); border: 0; border-radius: var(--radius); background: transparent; color: var(--color-text); cursor: pointer; text-decoration: none; font-size: 1.05rem; gap: var(--space-2); }
.icon-btn:hover { background: var(--color-surface-muted); color: var(--color-text); }
.icon { display: inline-block; width: 1.25em; text-align: center; flex: none; font-style: normal; line-height: 1; }
.linkish { border: 0; background: none; padding: 0; color: var(--color-primary); cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 2px; font: inherit; }
.segmented { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; }
.segmented .btn { border: 0; border-radius: 0; border-right: 1px solid var(--color-border); }
.segmented .btn:last-child { border-right: 0; }

/* ---------- badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 0.05rem 0.5rem; border-radius: 999px; font-size: var(--text-xs); font-weight: 500; background: var(--color-surface-muted); color: var(--color-text-muted); white-space: nowrap; border: 1px solid transparent; }
.badge.ok { background: var(--color-success-soft); color: var(--color-success); }
.badge.warn { background: var(--color-warning-soft); color: var(--color-warning); }
.badge.err { background: var(--color-error-soft); color: var(--color-error); }
.badge.info { background: var(--color-info-soft); color: var(--color-info); }
.badge.accent { background: var(--color-primary-soft); color: var(--color-primary); }
.badge.outline { background: transparent; border-color: var(--color-border); }
.count { display: inline-block; min-width: 1.25rem; padding: 0 0.35rem; border-radius: 999px; background: var(--color-error); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 1.25rem; text-align: center; }
.icon-btn .count { position: absolute; top: 0.1rem; right: 0.05rem; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 2rem; padding: 0.2rem 0.75rem; border-radius: 999px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); font-size: var(--text-sm); cursor: pointer; }
.chip:hover { background: var(--color-surface-muted); }
.chip[aria-pressed="true"] { background: var(--color-primary-soft); border-color: var(--color-primary); }
.chip .x { border: 0; background: none; cursor: pointer; padding: 0 0.15rem; color: var(--color-text-muted); }
.label-tag { display: inline-block; padding: 0 0.45rem; border-radius: var(--radius-sm); background: var(--color-info-soft); color: var(--color-info); font-size: var(--text-xs); }

/* ---------- app shell ---------- */
body.app { display: grid; min-height: 100vh; min-height: 100dvh; grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-rows: var(--topbar) 1fr auto; grid-template-areas: "top top" "side main" "side status"; }
.topbar { grid-area: top; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4); background: var(--color-surface); border-bottom: 1px solid var(--color-divider); }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 700; font-size: var(--text-lg); color: var(--color-text); text-decoration: none; min-width: calc(var(--sidebar) - var(--space-8)); }
.brand svg { width: 1.5rem; height: 1.5rem; color: var(--color-primary); }
.top-title { display: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger { flex: 0 1 26rem; display: flex; align-items: center; gap: var(--space-2); min-height: var(--touch); padding: 0 var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-bg); color: var(--color-text-muted); cursor: text; font-size: var(--text-sm); }
.search-trigger:hover { border-color: var(--color-text-faint); }
.search-trigger kbd { margin-left: auto; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-1); }
.user-btn { font-size: var(--text-sm); max-width: 12rem; }
.user-btn span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar { grid-area: side; position: sticky; top: var(--topbar); align-self: start; height: calc(100vh - var(--topbar)); height: calc(100dvh - var(--topbar)); overflow-y: auto; padding: var(--space-3) var(--space-2); background: var(--color-surface); border-right: 1px solid var(--color-divider); display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: var(--space-3); min-height: 2.5rem; padding: 0 var(--space-3); border-radius: var(--radius); color: var(--color-text); text-decoration: none; font-size: var(--text-sm); font-weight: 500; }
.nav-link:hover { background: var(--color-surface-muted); color: var(--color-text); }
.nav-link[aria-current="page"] { background: var(--color-surface-selected); color: var(--color-text); box-shadow: inset 3px 0 0 var(--color-primary); }
.nav-link .nav-badge { margin-left: auto; font-size: var(--text-xs); color: var(--color-text-muted); }
.nav-link .nav-badge.alert { color: var(--color-error); font-weight: 600; }
.nav-link .nav-badge.warn { color: var(--color-warning); }
.nav-sep { height: 1px; background: var(--color-divider); margin: var(--space-2) var(--space-2); }
.workspace { grid-area: main; min-width: 0; padding: var(--space-6) var(--space-8) var(--space-8); outline: none; }
.statusbar { grid-area: status; display: flex; gap: var(--space-3); align-items: center; padding: var(--space-1) var(--space-8); font-size: var(--text-xs); color: var(--color-text-muted); border-top: 1px solid var(--color-divider); background: var(--color-surface); }
.statusbar .dot { color: var(--color-success); }
.statusbar.offline .dot { color: var(--color-error); }
.tabbar { display: none; }
.fab { display: none; }

/* ---------- page ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.page-head h1 { display: flex; align-items: center; gap: var(--space-2); }
.page-head .sub { color: var(--color-text-muted); font-size: var(--text-sm); }
.page-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.back { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); margin-bottom: var(--space-3); text-decoration: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-4); }
.toolbar .grow { flex: 1 1 14rem; }
.toolbar input, .toolbar select { margin-top: 0; width: auto; }
.toolbar .grow input { width: 100%; }
.panel { background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); min-width: 0; }
.panel + .panel { margin-top: var(--space-4); }
.panel-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.panel-head h2, .panel > h2 { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-base); }
.panel-head .more { margin-left: auto; font-size: var(--text-sm); }
.with-aside { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr) 20rem; align-items: start; }
.with-nav { display: grid; gap: var(--space-4); grid-template-columns: 15rem minmax(0, 1fr); align-items: start; }
.stack > * + * { margin-top: var(--space-4); }
.muted { color: var(--color-text-muted); }
.faint { color: var(--color-text-faint); }
.message { color: var(--color-error); min-height: 1.25em; font-size: var(--text-sm); }
.message:empty { min-height: 0; margin: 0; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.spread { display: flex; gap: var(--space-2); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.done-text { text-decoration: line-through; color: var(--color-text-muted); }
.late { color: var(--color-error); font-weight: 500; }
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-1) var(--space-3); margin: 0; font-size: var(--text-sm); }
.dl dt { color: var(--color-text-muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
details.disclose > summary { cursor: pointer; font-weight: 600; font-size: var(--text-sm); min-height: var(--touch); display: flex; align-items: center; gap: var(--space-2); list-style: none; }
details.disclose > summary::before { content: "→"; transition: transform 160ms var(--ease); }
details.disclose[open] > summary::before { transform: rotate(90deg); }
details.disclose > summary::-webkit-details-marker { display: none; }

/* ---------- lists ---------- */
.items { list-style: none; margin: 0; padding: 0; }
.items > li { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) 0; border-bottom: 1px solid var(--color-divider); }
.items > li:last-child { border-bottom: 0; }
.items.compact > li { padding: var(--space-2) 0; }
.item-icon { flex: none; width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border-radius: var(--radius); background: var(--color-surface-muted); font-size: 0.95rem; }
.item-icon.warn { background: var(--color-warning-soft); color: var(--color-warning); }
.item-icon.err { background: var(--color-error-soft); color: var(--color-error); }
.item-icon.accent { background: var(--color-primary-soft); color: var(--color-primary); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 500; overflow-wrap: anywhere; }
.item-title a { color: var(--color-text); text-decoration: none; }
.item-title a:hover { color: var(--color-primary); text-decoration: underline; }
.item-meta { font-size: var(--text-sm); color: var(--color-text-muted); display: flex; flex-wrap: wrap; gap: 0 var(--space-3); }
.item-side { flex: none; display: flex; gap: var(--space-1); align-items: center; }
.items > li.unread .item-title { font-weight: 700; }
.items > li.unread::before { content: ""; flex: none; width: 0.5rem; height: 0.5rem; margin-top: 0.6rem; border-radius: 50%; background: var(--color-primary); }
.items > li.selected { background: var(--color-surface-selected); margin: 0 calc(-1 * var(--space-3)); padding-left: var(--space-3); padding-right: var(--space-3); border-radius: var(--radius); }
.excerpt { color: var(--color-text-muted); font-size: var(--text-sm); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: var(--space-1) 0 0; }
.pager { display: flex; gap: var(--space-2); align-items: center; justify-content: flex-end; margin-top: var(--space-4); font-size: var(--text-sm); color: var(--color-text-muted); }
.card-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); list-style: none; padding: 0; margin: 0; }
.card-grid > li { background: var(--color-surface-raised); border: 1px solid var(--color-divider); border-radius: var(--radius-lg); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.card-grid > li:hover { border-color: var(--color-border); box-shadow: var(--shadow-sm); }

/* ---------- tree ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree button { display: flex; width: 100%; align-items: center; gap: var(--space-2); min-height: 2.25rem; padding: 0 var(--space-2); border: 0; border-radius: var(--radius); background: none; cursor: pointer; text-align: left; font-size: var(--text-sm); color: var(--color-text); }
.tree button:hover { background: var(--color-surface-muted); }
.tree button[aria-current="true"] { background: var(--color-surface-selected); font-weight: 600; }
.tree .n { margin-left: auto; color: var(--color-text-faint); font-size: var(--text-xs); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-divider); border-radius: var(--radius-lg); background: var(--color-surface); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
table.data caption { text-align: left; padding: var(--space-3); color: var(--color-text-muted); caption-side: bottom; }
table.data th, table.data td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-divider); text-align: left; vertical-align: top; }
table.data thead th { position: sticky; top: 0; background: var(--color-surface-raised); font-weight: 600; color: var(--color-text-muted); white-space: nowrap; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; }
table.data tbody tr:hover { background: var(--color-surface-raised); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .title-cell a { font-weight: 500; color: var(--color-text); text-decoration: none; }
table.data .title-cell a:hover { color: var(--color-primary); text-decoration: underline; }
table.data .id { font-family: var(--font-mono); color: var(--color-text-faint); font-size: var(--text-xs); }
.sel-bar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); border-radius: var(--radius); background: var(--color-primary-soft); font-size: var(--text-sm); }
.sel-bar select { width: auto; margin: 0; }

/* ---------- status ---------- */
.st { display: inline-flex; align-items: center; gap: 0.3rem; font-size: var(--text-xs); font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; white-space: nowrap; background: var(--color-surface-muted); color: var(--color-text-muted); }
.st-open { background: var(--color-info-soft); color: var(--color-info); }
.st-in_progress { background: var(--color-primary-soft); color: var(--color-primary); }
.st-blocked { background: var(--color-warning-soft); color: var(--color-warning); }
.st-completed { background: var(--color-success-soft); color: var(--color-success); }
.st-cancelled { background: var(--color-surface-muted); color: var(--color-text-faint); }

/* ---------- states ---------- */
.state { text-align: center; padding: var(--space-12) var(--space-4); color: var(--color-text-muted); }
.state .glyph { font-size: 2rem; display: block; margin-bottom: var(--space-3); }
.state h2 { color: var(--color-text); margin-bottom: var(--space-2); font-size: var(--text-lg); }
.state p { max-width: 32rem; margin: 0 auto var(--space-4); }
.state.small { padding: var(--space-6) var(--space-2); }
.state.small .glyph { font-size: 1.4rem; margin-bottom: var(--space-2); }
.notice { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3); border-radius: var(--radius); background: var(--color-info-soft); color: var(--color-text); font-size: var(--text-sm); margin-bottom: var(--space-3); }
.notice.warn { background: var(--color-warning-soft); }
.notice.err { background: var(--color-error-soft); }
.notice.ok { background: var(--color-success-soft); }
.skeleton { display: block; height: 1rem; margin: var(--space-3) 0; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--color-surface-muted), var(--color-surface-raised), var(--color-surface-muted)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton.w60 { width: 60%; } .skeleton.w80 { width: 80%; } .skeleton.w40 { width: 40%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- dashboard ---------- */
.dash { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "attention attention" "today tasks" "activity quick"; }
.dash .a-attention { grid-area: attention; } .dash .a-today { grid-area: today; } .dash .a-tasks { grid-area: tasks; }
.dash .a-activity { grid-area: activity; } .dash .a-quick { grid-area: quick; align-self: start; }
.attention-ok { display: flex; gap: var(--space-2); align-items: center; color: var(--color-success); font-size: var(--text-sm); }
.quick { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.quick .btn { justify-content: flex-start; }
.when { flex: none; min-width: 4.5rem; font-variant-numeric: tabular-nums; font-size: var(--text-sm); color: var(--color-text-muted); }

/* ---------- detail ---------- */
.detail-title { font-size: var(--text-xl); font-weight: 600; }
.title-input { font-size: var(--text-lg); font-weight: 600; }
.dirty { color: var(--color-warning); font-size: var(--text-sm); }
.comment { padding: var(--space-3) 0; border-bottom: 1px solid var(--color-divider); }
.comment:last-child { border-bottom: 0; }
.comment .body { margin: var(--space-1) 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.files-list { list-style: none; padding: 0; margin: 0 0 var(--space-2); }
.files-list li { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding: var(--space-2) 0; border-bottom: 1px solid var(--color-divider); font-size: var(--text-sm); }
.files-list li:last-child { border-bottom: 0; }
.gone { text-decoration: line-through; color: var(--color-text-muted); }
.sticky-action { display: none; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: var(--text-sm); }
.timeline li { padding: var(--space-2) 0 var(--space-2) var(--space-4); border-left: 2px solid var(--color-divider); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 0.85rem; width: 8px; height: 8px; border-radius: 50%; background: var(--color-border); }

/* ---------- inbox ---------- */
.split-view { display: grid; gap: var(--space-4); grid-template-columns: minmax(18rem, 2fr) minmax(0, 3fr); align-items: start; }
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-divider); margin-bottom: var(--space-4); overflow-x: auto; }
.tabs a, .tabs button { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 2.5rem; padding: 0 var(--space-3); border: 0; border-bottom: 2px solid transparent; background: none; color: var(--color-text-muted); text-decoration: none; font-size: var(--text-sm); font-weight: 500; cursor: pointer; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--color-text); }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--color-text); border-bottom-color: var(--color-primary); }

/* ---------- calendar ---------- */
.cal-bar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-3); }
.cal-bar .range { font-weight: 600; min-width: 12rem; }
.cal-layout { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr) 18rem; align-items: start; }
.cal-layout.no-side { grid-template-columns: minmax(0, 1fr); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--color-divider); border: 1px solid var(--color-divider); border-radius: var(--radius-lg); overflow: hidden; }
.cal-head { background: var(--color-surface-raised); padding: var(--space-1) var(--space-2); font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cal-day { background: var(--color-surface); min-height: 6.5rem; padding: var(--space-1); min-width: 0; }
.cal-week .cal-day { min-height: 18rem; }
.cal-day.other { background: var(--color-surface-raised); color: var(--color-text-faint); }
.cal-day.today .cal-date { background: var(--color-primary); color: var(--color-text-inverse); }
.cal-date { display: inline-grid; place-items: center; min-width: 1.75rem; height: 1.75rem; border: 0; border-radius: 999px; background: none; cursor: pointer; font-size: var(--text-xs); font-weight: 600; color: inherit; }
.cal-date:hover { background: var(--color-surface-muted); }
.cal-item { display: block; width: 100%; margin: 2px 0; padding: 0.1rem 0.35rem; border: 0; border-left: 3px solid var(--color-primary); border-radius: var(--radius-sm); background: var(--color-primary-soft); color: var(--color-text); font-size: var(--text-xs); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-item:hover { filter: brightness(0.97); }
.cal-item.src-task { border-left-color: var(--color-warning); background: var(--color-warning-soft); }
.cal-item.src-external { border-left-style: dashed; background: var(--color-surface-muted); }
.cal-item.done { text-decoration: line-through; color: var(--color-text-muted); }
.agenda-day { padding: var(--space-3) 0; border-bottom: 1px solid var(--color-divider); }
.agenda-day:last-child { border-bottom: 0; }
.agenda-day h3 { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-2); }
.agenda-day.today h3 { color: var(--color-primary); }
.agenda-item { display: flex; gap: var(--space-3); align-items: baseline; width: 100%; padding: var(--space-2); border: 0; border-left: 3px solid var(--color-primary); border-radius: var(--radius-sm); background: none; color: var(--color-text); text-align: left; cursor: pointer; font-size: var(--text-sm); }
.agenda-item:hover { background: var(--color-surface-muted); }
.agenda-item.src-task { border-left-color: var(--color-warning); }
.agenda-item.src-external { border-left-style: dashed; }
.swatch { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 3px; background: var(--color-primary); flex: none; }
.secret { font-family: var(--font-mono); font-size: var(--text-sm); }

/* ---------- admin ---------- */
.health { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }
.health > div { border: 1px solid var(--color-divider); border-radius: var(--radius); padding: var(--space-3); background: var(--color-surface-raised); }
.health .k { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.health .v { font-size: var(--text-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.admin-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.admin-grid .full { grid-column: 1 / -1; }

/* ---------- menus, dialogs, toasts ---------- */
.menu { position: fixed; z-index: 60; min-width: 13rem; padding: var(--space-1); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.menu a, .menu button { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 2.5rem; padding: 0 var(--space-3); border: 0; border-radius: var(--radius); background: none; color: var(--color-text); text-decoration: none; font-size: var(--text-sm); cursor: pointer; text-align: left; }
.menu a:hover, .menu button:hover, .menu a:focus-visible, .menu button:focus-visible { background: var(--color-surface-muted); }
.menu .menu-head { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); color: var(--color-text-muted); border-bottom: 1px solid var(--color-divider); margin-bottom: var(--space-1); }
dialog { padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-md); width: min(34rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); }
dialog::backdrop { background: rgb(10 14 12 / 0.45); }
dialog[open] { animation: pop 200ms var(--ease); }
dialog.sheet { margin: 0 0 0 auto; height: 100vh; height: 100dvh; max-height: none; width: min(38rem, 100vw); border-radius: 0; border-width: 0 0 0 1px; }
dialog.sheet[open] { animation: slide 220ms var(--ease); }
.dlg { display: flex; flex-direction: column; max-height: inherit; height: 100%; }
.dlg-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-divider); }
.dlg-head h2 { flex: 1; }
.dlg-body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.dlg-foot { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-divider); background: var(--color-surface-raised); }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes slide { from { transform: translateX(2rem); opacity: 0; } to { transform: none; opacity: 1; } }
.toasts { position: fixed; z-index: 80; right: var(--space-4); bottom: var(--space-8); display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none; }
.toast { pointer-events: auto; max-width: 24rem; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--color-text); color: var(--color-bg); box-shadow: var(--shadow-md); font-size: var(--text-sm); animation: pop 180ms var(--ease); }
.toast.err { background: var(--color-error); color: #fff; }
.search-results h2 { font-size: var(--text-sm); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: var(--space-4) 0 var(--space-2); }
.search-big { font-size: var(--text-lg); }

/* ---------- standalone pages (login, attach, viewer) ---------- */
.center { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: var(--space-4); }
.card { background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow-sm); }
.narrow { width: min(24rem, 100%); }
.narrow h1 { margin-bottom: var(--space-4); display: flex; align-items: center; gap: var(--space-2); }
.narrow label { margin-bottom: var(--space-3); }
.narrow button[type="submit"], .card .row button { display: inline-flex; align-items: center; justify-content: center; min-height: var(--touch); padding: 0.4rem 1rem; border: 1px solid var(--color-primary); border-radius: var(--radius); background: var(--color-primary); color: var(--color-text-inverse); cursor: pointer; font-weight: 500; }
.narrow button[type="submit"] { width: 100%; margin-top: var(--space-4); }
.card .row button.ghost { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.login-foot { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-4); font-size: var(--text-xs); color: var(--color-text-muted); }
.bar { display: flex; gap: var(--space-3); align-items: center; min-height: var(--topbar); padding: 0 var(--space-4); background: var(--color-surface); border-bottom: 1px solid var(--color-divider); }
.bar .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.viewer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; min-height: calc(100vh - var(--topbar)); }
.viewer { padding: var(--space-4); display: grid; gap: var(--space-4); justify-items: center; align-content: start; background: var(--color-bg); overflow: auto; }
.viewer .page { max-width: 100%; height: auto; box-shadow: var(--shadow-md); background: #fff; }
.viewer pre { white-space: pre-wrap; word-break: break-word; background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-lg); padding: var(--space-4); width: min(960px, 100%); margin: 0; font-family: var(--font-mono); font-size: var(--text-sm); }
.viewer pre.nowrap { white-space: pre; }
.viewer img { max-width: 100%; }
.viewer-meta { border-left: 1px solid var(--color-divider); background: var(--color-surface); padding: var(--space-5); }
.viewer-meta summary { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1279px) {
  .with-aside { grid-template-columns: minmax(0, 1fr) 17rem; }
  .cal-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1023px) {
  :root { --sidebar: 4.25rem; }
  .brand { min-width: 0; }
  .brand span { display: none; }
  .sidebar { padding: var(--space-2); align-items: center; }
  .nav-link { width: 3.25rem; justify-content: center; padding: 0; position: relative; font-size: 1.1rem; }
  .nav-link .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .nav-link .nav-badge { position: absolute; top: 0.1rem; right: 0.1rem; margin: 0; font-size: 0.65rem; }
  .workspace { padding: var(--space-5); }
  .statusbar { padding: var(--space-1) var(--space-5); }
  .with-aside, .split-view, .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .with-nav { grid-template-columns: 12rem minmax(0, 1fr); }
  .viewer-layout { grid-template-columns: minmax(0, 1fr); }
  .viewer-meta { border-left: 0; border-top: 1px solid var(--color-divider); }
  .pdf-mode .viewer-layout { grid-template-rows: minmax(0, 1fr) auto; }
  .pdf-mode .viewer-meta { max-height: 40vh; }
}
/* ---------- markdown preview ---------- */
.md { overflow-wrap: anywhere; line-height: 1.6; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: var(--space-5) 0 var(--space-2); }
.md h1 { font-size: 1.6rem; } .md h2 { font-size: 1.3rem; } .md h3 { font-size: 1.1rem; } .md h4, .md h5, .md h6 { font-size: 1rem; }
.md p, .md ul, .md ol, .md pre, .md blockquote, .md table, .md figure { margin: 0 0 var(--space-3); }
.md ul, .md ol { padding-left: 1.5rem; }
.md li > ul, .md li > ol { margin: 0; }
.md li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.4rem; }
.md li > input[type="checkbox"] { margin-right: var(--space-2); }
.md blockquote { padding: var(--space-1) var(--space-4); border-left: 3px solid var(--color-primary); color: var(--color-text-muted); background: var(--color-surface-raised); }
.md code { padding: 0.1em 0.3em; border-radius: var(--radius-sm); background: var(--color-surface-muted); }
.md pre { padding: var(--space-3); overflow: auto; border-radius: var(--radius); background: var(--color-surface-muted); }
.md pre code { padding: 0; background: none; font-size: 0.875rem; }
.md hr { border: 0; border-top: 1px solid var(--color-divider); margin: var(--space-4) 0; }
.md table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.md th, .md td { padding: var(--space-1) var(--space-3); border: 1px solid var(--color-border); text-align: left; vertical-align: top; min-width: 3rem; }
.md th { background: var(--color-surface-muted); font-weight: 600; }
.md tr:nth-child(even) td { background: var(--color-surface-raised); }
.md img, .md video { display: block; max-width: 100%; height: auto; border-radius: var(--radius); }
.md video { max-height: 70vh; background: #000; }
.md audio { display: block; width: min(100%, 28rem); }
.doc .doc-head { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.doc .doc-head:has(.chips:empty) { justify-content: flex-end; }
.doc .doc-head h2 { display: flex; gap: var(--space-2); align-items: center; }

/* ---------- markdown editor (EasyMDE, native Markdown in a monospace font) ---------- */
.EasyMDEContainer { margin-top: var(--space-1); }
.EasyMDEContainer .CodeMirror { font-family: var(--editor-font, var(--font-mono)); font-size: var(--editor-size, 14px); line-height: 1.5; color: var(--color-text); background: var(--color-surface); border-color: var(--color-border); border-radius: 0 0 var(--radius) var(--radius); }
.EasyMDEContainer .CodeMirror-focused { border-color: var(--color-primary); }
.EasyMDEContainer .CodeMirror-cursor { border-left-color: var(--color-text); }
.EasyMDEContainer .CodeMirror-selected, .EasyMDEContainer .CodeMirror-focused .CodeMirror-selected, .EasyMDEContainer .CodeMirror-line::selection, .EasyMDEContainer .CodeMirror-line > span::selection, .EasyMDEContainer .CodeMirror-line > span > span::selection { background: var(--color-primary-soft); }
.EasyMDEContainer .cm-s-easymde .cm-header-1 { font-size: 1.3em; } .EasyMDEContainer .cm-s-easymde .cm-header-2 { font-size: 1.15em; } .EasyMDEContainer .cm-s-easymde .cm-header-3 { font-size: 1.05em; }
.EasyMDEContainer .cm-s-easymde .cm-link, .EasyMDEContainer .cm-s-easymde .cm-url { color: var(--color-primary); }
.EasyMDEContainer .cm-s-easymde .cm-comment { background: var(--color-surface-muted); color: var(--color-text); }
.EasyMDEContainer .cm-s-easymde .cm-quote { color: var(--color-text-muted); }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: var(--space-1); border-color: var(--color-border); border-radius: var(--radius) var(--radius) 0 0; background: var(--color-surface-raised); opacity: 1; }
.editor-toolbar:hover, .editor-toolbar.disabled-for-preview { opacity: 1; }
.editor-toolbar button { display: inline-grid; place-items: center; min-width: 2rem; width: auto; height: 2rem; padding: 0 0.4rem; margin: 0; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--color-text); font: 600 0.9rem/1 var(--font-ui); }
.editor-toolbar button:hover, .editor-toolbar button.active { background: var(--color-surface-muted); border-color: var(--color-border); }
.editor-toolbar button.active { background: var(--color-primary-soft); color: var(--color-primary); }
.editor-toolbar.disabled-for-preview button:not(.no-disable) { opacity: 0.4; }
.editor-toolbar i.separator { width: 0; height: 1.4rem; margin: 0 var(--space-1); border-left: 1px solid var(--color-divider); border-right: 0; color: transparent; overflow: hidden; }
.editor-toolbar.fullscreen { z-index: 70; background: var(--color-surface-raised); }
.EasyMDEContainer .CodeMirror-fullscreen, .editor-preview-side { z-index: 70; }
.editor-preview, .editor-preview-side { font: var(--text-base)/1.6 var(--font-ui); color: var(--color-text); background: var(--color-surface); padding: var(--space-3) var(--space-4); }
.editor-preview-side { border-color: var(--color-border); }
/* EasyMDE sets an inline height on the side preview; size it to the editor instead. */
.EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side { height: auto !important; align-self: stretch; contain: size; }
.EasyMDEContainer .editor-toolbar:not(.fullscreen) { position: sticky; top: var(--topbar); z-index: 5; }
dialog .EasyMDEContainer .editor-toolbar:not(.fullscreen) { top: 0; }
.md td, .md th { height: 2em; }
.editor-statusbar { color: var(--color-text-faint); font-size: var(--text-xs); }
.media-pick .files-list li { align-items: center; }
.media-pick .thumb { width: 3rem; height: 3rem; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--color-divider); }

/* ---------- notification popup ---------- */
.notif-pop { position: fixed; z-index: 60; width: min(26rem, calc(100vw - 1rem)); max-height: min(75vh, 40rem); display: flex; flex-direction: column; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.notif-pop::before { content: ""; position: absolute; top: -7px; right: var(--caret, 1rem); width: 12px; height: 12px; background: var(--color-surface); border-left: 1px solid var(--color-border); border-top: 1px solid var(--color-border); transform: rotate(45deg); }
.notif-pop .np-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-2) var(--space-1) var(--space-4); }
.notif-pop .np-head h2 { display: flex; gap: var(--space-2); align-items: center; font-size: var(--text-base); }
.notif-pop .np-bar { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-4); }
.notif-pop .np-bar select { width: auto; margin: 0 0 0 auto; min-height: 1.875rem; padding: 0.15rem 0.4rem; font-size: var(--text-xs); }
.notif-pop .np-bar .grow { font-size: var(--text-xs); }
.notif-pop .np-list { flex: 1 1 auto; min-height: 6rem; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--color-divider); border-bottom: 1px solid var(--color-divider); padding: 0 var(--space-4); }
.notif-pop .items > li { gap: var(--space-2); padding: var(--space-2) 0; }
.notif-pop .items > li:not(.unread):not(.np-more):not(.np-empty)::before { content: ""; flex: none; width: 0.5rem; }
.notif-pop .item-title { font-size: var(--text-sm); }
.notif-pop .item-title a { color: var(--color-text); text-decoration: none; }
.notif-pop .item-title a:hover { color: var(--color-primary); text-decoration: underline; }
.notif-pop .np-body { font-size: var(--text-xs); color: var(--color-text-muted); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-pop .item-meta { font-size: var(--text-xs); }
.notif-pop .np-tools { display: flex; flex: none; gap: 2px; opacity: 0.55; }
.notif-pop li:hover .np-tools, .notif-pop .np-tools:focus-within { opacity: 1; }
.notif-pop .icon-btn.sm { min-width: 1.875rem; min-height: 1.875rem; font-size: var(--text-sm); }
.notif-pop .np-more, .notif-pop .np-empty { justify-content: center; border-bottom: 0; }
.notif-pop .np-empty .state { padding: var(--space-4) 0; }
.notif-pop .np-foot { padding: var(--space-2) var(--space-4); text-align: right; font-size: var(--text-sm); }

/* ---------- PDF viewer ---------- */
.pdf-mode .viewer-layout { height: calc(100vh - var(--topbar)); height: calc(100dvh - var(--topbar)); min-height: 0; }
.pdf-mode .viewer { display: flex; flex-direction: column; padding: 0; gap: 0; overflow: hidden; min-height: 0; }
.pdf-mode .viewer-meta { overflow: auto; }
.pdfbar { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; justify-content: center; padding: var(--space-2) var(--space-3); background: var(--color-surface); border-bottom: 1px solid var(--color-divider); width: 100%; }
.pdfbar[hidden] { display: none; }
.pdfbar .grp { display: flex; align-items: center; gap: var(--space-1); }
.pdfbar .pdf-no { width: 4.5rem; text-align: right; }
.pdfbar select { width: auto; }
.pdfbar .icon-btn[aria-pressed="true"] { background: var(--color-primary); color: var(--color-text-inverse); }
.pdf-mode #pages { flex: 1; min-height: 0; width: 100%; overflow: auto; overscroll-behavior: contain; }
.pdf-sheet { width: max-content; min-width: 100%; padding: var(--space-4); box-sizing: border-box; }
.pdf-page { position: relative; margin: 0 auto var(--space-4); background: #fff; box-shadow: var(--shadow-md); --user-unit: 1; --scale-round-x: 1px; --scale-round-y: 1px; }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
#pages.hand { cursor: grab; touch-action: none; }
#pages.hand.grabbing { cursor: grabbing; }
#pages.hand .textLayer, #pages.hand .textLayer span { cursor: inherit; user-select: none; -webkit-user-select: none; }
/* PDF.js text layer (from pdfjs-dist web/pdf_viewer.css, Apache-2.0) */
.textLayer { position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1; text-size-adjust: none; -webkit-text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 0;
  --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size)); }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height)); --scale-x: 1; --rotate: 0deg; transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); }
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { user-select: none; cursor: default; }
.textLayer ::selection { background: rgb(0 0 255 / 0.25); background: color-mix(in srgb, AccentColor, transparent 75%); }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }
/* ---------- mention suggestions ---------- */
.mention-pop { position: fixed; z-index: 1000; min-width: 12rem; max-width: 20rem; max-height: 14rem; overflow: auto; margin: 0; padding: var(--space-1); list-style: none; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-lg, var(--shadow-md)); }
.mention-pop li { display: flex; gap: var(--space-2); align-items: baseline; padding: var(--space-1) var(--space-2); border-radius: var(--radius); cursor: pointer; white-space: nowrap; }
.mention-pop li span { color: var(--color-text-muted); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; }
.mention-pop li.on, .mention-pop li:hover { background: var(--color-primary); color: var(--color-text-inverse); }
.mention-pop li.on span, .mention-pop li:hover span { color: inherit; }
@media (max-width: 767px) {
  .notif-pop { left: 0.5rem; right: 0.5rem !important; width: auto; max-height: calc(100dvh - var(--topbar) - var(--tabbar) - 1.5rem); }
  .notif-pop .np-tools { opacity: 1; }
  .editor-toolbar button { min-width: 2.5rem; height: 2.5rem; }
  .toolbar > .chip { flex: 0 0 auto; }
  .cards-on-mobile caption { display: block; text-align: left; padding: 0 0 var(--space-2); }
  body:has(.sticky-action) .fab { display: none; }
  :root { --touch: 2.75rem; --topbar: 3.25rem; }
  body.app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--topbar) 1fr auto; grid-template-areas: "top" "main" "tabs"; }
  .sidebar, .statusbar, .search-trigger, .user-btn, .create-btn { display: none; }
  .top-title { display: block; flex: 1; text-align: center; }
  .brand { font-size: var(--text-base); }
  .brand span { display: inline; }
  .topbar { gap: var(--space-2); padding: 0 var(--space-2) 0 var(--space-3); }
  .top-actions { margin-left: 0; }
  .workspace { padding: var(--space-4) var(--space-3) calc(var(--tabbar) + var(--space-16)); }
  .tabbar { grid-area: tabs; display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--color-surface); border-top: 1px solid var(--color-divider); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 44px; border: 0; background: none; color: var(--color-text-muted); text-decoration: none; font-size: 0.7rem; position: relative; cursor: pointer; }
  .tabbar .icon { font-size: 1.15rem; width: auto; }
  .tabbar [aria-current="page"] { color: var(--color-primary); font-weight: 600; }
  .tabbar .count { position: absolute; top: 0.3rem; left: calc(50% + 0.4rem); }
  .fab { display: grid; place-items: center; position: fixed; right: var(--space-4); bottom: calc(var(--tabbar) + var(--space-4) + env(safe-area-inset-bottom)); z-index: 35; width: 3.5rem; height: 3.5rem; border: 0; border-radius: 50%; background: var(--color-primary); color: var(--color-text-inverse); font-size: 1.5rem; box-shadow: var(--shadow-md); cursor: pointer; }
  .page-head { margin-bottom: var(--space-4); }
  .page-head .actions .btn.primary { display: none; }
  .panel { padding: var(--space-4); border-radius: var(--radius); }
  .dash { grid-template-columns: minmax(0, 1fr); grid-template-areas: "attention" "today" "tasks" "quick" "activity"; }
  .with-nav { grid-template-columns: minmax(0, 1fr); }
  .folder-panel:not([open]) .tree-body { display: none; }
  .toolbar input, .toolbar select { width: 100%; }
  .toolbar > * { flex: 1 1 100%; }
  .toolbar .segmented, .toolbar .chips { flex-basis: 100%; }
  /* task table becomes task cards */
  .table-wrap.cards-on-mobile { border: 0; background: none; overflow: visible; }
  .cards-on-mobile table.data, .cards-on-mobile tbody { display: block; }
  .cards-on-mobile thead { display: none; }
  .cards-on-mobile tbody tr { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-1) var(--space-2); padding: var(--space-3); margin-bottom: var(--space-2); background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-lg); }
  .cards-on-mobile table.data td { display: block; padding: 0; border: 0; }
  .cards-on-mobile td.c-sel { grid-row: 1; grid-column: 1; }
  .cards-on-mobile td.c-status { grid-row: 1; grid-column: 2; }
  .cards-on-mobile td.c-id { grid-row: 1; grid-column: 3; text-align: right; }
  .cards-on-mobile td.c-title { grid-column: 1 / -1; font-size: var(--text-base); }
  .cards-on-mobile td.c-who, .cards-on-mobile td.c-due { grid-column: 1 / -1; color: var(--color-text-muted); }
  .cards-on-mobile td.c-who::before { content: "👤 "; }
  .cards-on-mobile td.c-due::before { content: "📅 "; }
  .cards-on-mobile td.c-desc { display: none; }
  .sticky-action { display: flex; position: sticky; bottom: calc(var(--tabbar) + var(--space-2)); z-index: 20; margin-top: var(--space-4); }
  .sticky-action .btn { flex: 1; box-shadow: var(--shadow-md); }
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  dialog.sheet { width: 100vw; border: 0; }
  .split-view.has-detail > .list-pane { display: none; }
  .split-view:not(.has-detail) > .detail-pane { display: none; }
  .cal-grid.cal-month .cal-day { min-height: 3.25rem; }
  .cal-grid.cal-month .cal-item { font-size: 0; height: 0.4rem; padding: 0; border-left-width: 0; }
  .cal-grid.cal-week { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .cal-grid.cal-week .cal-head { display: none; }
  .cal-grid.cal-week .cal-day { flex: 0 0 85%; scroll-snap-align: start; min-height: 12rem; }
  .cal-day .wd { display: inline; }
  .toasts { left: var(--space-3); right: var(--space-3); bottom: calc(var(--tabbar) + var(--space-4)); }
  .viewer-meta { position: sticky; bottom: 0; padding: var(--space-3) var(--space-4); }
  .viewer-meta summary { display: flex; }
  .viewer-meta:not([open]) .meta-body { display: none; }
}
.cal-day .wd { display: none; font-size: var(--text-xs); color: var(--color-text-muted); margin-left: var(--space-1); }
@media (pointer: coarse) {
  :root { --touch: 2.75rem; }
  .btn.sm { min-height: 2.75rem; }
  .tree button { min-height: 2.75rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
@media (forced-colors: active) {
  .nav-link[aria-current="page"], .tabs [aria-selected="true"] { outline: 2px solid CanvasText; }
  .count, .st, .badge { border: 1px solid CanvasText; }
}

/* ---------- print ---------- */
@media print {
  body.app { display: block; background: #fff; color: #000; }
  .topbar, .sidebar, .statusbar, .tabbar, .fab, .toasts, .actions, .toolbar, .pager, .sel-bar, .btn, .icon-btn, .sticky-action, form.comment-form, .no-print { display: none !important; }
  .workspace { padding: 0; }
  .panel { box-shadow: none; border-color: #999; break-inside: avoid; }
  .with-aside, .split-view, .dash, .cal-layout { display: block; }
  a { color: #000; text-decoration: none; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
