:root {
  color-scheme: light;
  font-family: 'Segoe UI', system-ui, sans-serif;
  --heading: Georgia, 'Times New Roman', serif;
  --paper: #f7f7f0;
  --surface: #fdfdf9;
  --rail: #edf0e5;
  --border: #d7ddcf;
  --ink: #222b24;
  --muted: #566359;
  --accent: #dce8cf;
  --hover: #e7ecdf;
  --primary: #254733;
  --primary-ink: #fff;
  --focus: #50734f;
  --danger: #8a3d2c;
  --warning: #a36728;
  --veil: #12241a99;
  background: var(--paper);
  color: var(--ink);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171c19;
  --surface: #202722;
  --rail: #1d241f;
  --border: #3a4940;
  --ink: #e8eee8;
  --muted: #b2c1b4;
  --accent: #314634;
  --hover: #28362b;
  --primary: #c0dbb1;
  --primary-ink: #171f18;
  --focus: #b4d5a8;
  --danger: #f0a48f;
  --warning: #e6b278;
  --veil: #0d130ec9;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1, h2 { font-family: var(--heading); font-weight: 500; letter-spacing: -.035em; }
h1 { font-size: clamp(2.45rem, 5vw, 4rem); line-height: 1.1; overflow-wrap: anywhere; }
h2 { font-size: clamp(1.38rem, 2.2vw, 1.72rem); line-height: 1.25; }
p { line-height: 1.58; }
.muted, small { color: var(--muted); }
.small, small { font-size: .875rem; }
.error { color: var(--danger); }
.preline { white-space: pre-wrap; overflow-wrap: anywhere; }
.icon { width: 21px; height: 21px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: fixed; background: var(--surface); padding: 12px; top: 8px; left: 8px; z-index: 10; transform: translateY(-140%); }
.skip:focus { transform: none; }

button, .button {
  display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: .53rem .85rem;
  text-decoration: none; line-height: 1.28; font-weight: 600; cursor: pointer;
  transition: background-color .14s ease, transform .12s ease;
}
button:hover, .button:hover { background: var(--hover); }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .56; cursor: default; }
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
button.primary:hover, .button.primary:hover { filter: brightness(.9); }
button.quiet, .button.quiet { background: transparent; border-color: transparent; }
button.quiet:hover, .button.quiet:hover { background: var(--hover); }
button.bordered, .button.bordered { border-color: var(--border); }
.icon-button { min-width: 44px; padding: 0; }

.shell { min-height: 100dvh; display: grid; grid-template-columns: 222px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; gap: 31px; position: sticky; top: 0; align-self: start; height: 100dvh;
  background: var(--rail); border-right: 1px solid var(--border); padding: 24px 16px 16px; overflow: auto; }
.brand { display: inline-flex; width: fit-content; align-items: center; gap: 9px; min-height: 44px; padding-left: 7px; text-decoration: none; }
.brand span { font-family: var(--heading); font-size: 1.67rem; letter-spacing: -.06em; white-space: nowrap; }
.brand.compact, #mobile { display: none; }
#nav { display: grid; gap: 3px; }
.side-bottom { margin-top: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 47px; border-radius: 8px; padding: 6px 10px;
  font-size: .94rem; font-weight: 550; text-decoration: none; }
.nav-item:hover { background: var(--hover); }
.nav-item[aria-current="page"] { background: var(--accent); font-weight: 650; }
.topbar { min-height: 68px; position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between;
  align-items: center; gap: 8px; background: var(--paper); border-bottom: 1px solid var(--border); padding: 0 clamp(16px, 4vw, 48px); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.location, .status-button { font-size: .87rem; color: var(--muted); }
.dot { width: 8px; height: 8px; background: var(--focus); border-radius: 50%; flex: none; }
.dot.pending { background: var(--warning); }
#main { max-width: 1040px; padding: 0 clamp(16px, 4vw, 48px) 48px; margin: 0 auto; outline: none; }
.view { display: grid; align-content: start; gap: 23px; padding-top: clamp(25px, 6vw, 58px); }
.view-title, .section-head, .calendar-tools { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.view-title p { margin-top: 9px; overflow-wrap: anywhere; }
.view-title > div:first-child { min-width: 0; }
.view-actions, .calendar-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.view-actions > * { min-width: 0; }
.empty-state { padding: 24px 0; border-block: 1px solid var(--border); }
.empty-state > p:first-child { font-weight: 600; }
.empty-state p + p { margin-top: 4px; }
.rows { display: grid; border-top: 1px solid var(--border); }
.row-button, .remote-event {
  display: flex; width: 100%; justify-content: flex-start; align-items: center; gap: 12px; min-height: 60px;
  background: transparent; text-align: left; padding: 10px 7px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
}
.row-button > .icon { width: 17px; color: var(--muted); }
.row-icon { display: grid; place-items: center; flex: none; min-width: 33px; min-height: 34px; border-radius: 7px; background: var(--rail); color: var(--muted); }
.row-title { display: grid; flex: 1; min-width: 0; gap: 4px; overflow-wrap: anywhere; }
.row-title strong { font-weight: 600; }
.row-title small { font-weight: 400; }
.row-title small:empty { display: none; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs a { text-decoration: none; min-height: 44px; display: flex; align-items: center; padding: 0 13px; border-bottom: 2px solid transparent; }
.tabs a[aria-current="page"] { font-weight: 650; border-color: var(--focus); }
.tabs a:hover { background: var(--hover); }
.project-section, .recordings, .recordings-list, .recovery { display: grid; gap: 15px; min-width: 0; }
.item-body { max-width: 72ch; min-width: 0; padding: 21px clamp(12px, 3vw, 26px); border: 1px solid var(--border);
  border-radius: 9px; background: var(--surface); font-size: 1.05rem; line-height: 1.75; }
.detail-link { align-self: start; justify-self: start; }
.recovery { padding: 12px 0; }
.recovery button { width: fit-content; }
.recordings { margin-top: 8px; }
.recording-card, .settings-panel, .comparison {
  min-width: 0; display: grid; gap: 11px; padding: clamp(13px, 3vw, 23px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.recording-card .section-head { align-items: center; }
.recording-card strong { overflow-wrap: anywhere; }
audio { display: block; width: 100%; min-width: 0; max-width: 620px; }
.recording-status { padding: 12px 0; font-weight: 650; color: var(--danger); }
.quick-task { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.task-list { border-top: 1px solid var(--border); }
.task-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.task-check { display: grid; place-items: center; min-width: 44px; min-height: 50px; cursor: pointer; }
.task-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.item-editor { display: grid; gap: 10px; }
.item-editor > button { justify-self: start; }
.editor-fields { display: flex; flex-wrap: wrap; gap: 10px; }
.editor-fields > label { flex: 1 1 145px; }
.editor-fields > label:first-child { flex-basis: 220px; }
.task-row.done input[name="title"] { text-decoration: line-through; }
.task-state { display: flex; align-items: center; gap: 8px; min-height: 44px; }
summary { cursor: pointer; padding: 10px 0; width: fit-content; }
.completed-tasks summary { min-height: 44px; }
.calendar-tools { align-items: center; padding-bottom: 13px; border-bottom: 1px solid var(--border); }
.calendar-tools > div:first-child { display: grid; gap: 4px; }
.calendar-controls input { max-width: 156px; }
.agenda-day { display: grid; gap: 9px; }
.calendar-state { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.event-information { padding: 6px 0; }
.remote-event { flex-wrap: wrap; }
.remote-event > .button { white-space: nowrap; font-size: .88rem; }
.settings-panel { gap: 15px; }
.settings-panel > label { width: min(100%, 310px); }
.add-options { display: grid; gap: 12px; }
.add-options button { width: 100%; justify-content: flex-start; min-height: 51px; }
.sync-entry { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.sync-entry > div { max-width: 100%; overflow-wrap: anywhere; }

label { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: .91rem; }
input:not([type=checkbox]), select, textarea {
  min-height: 44px; width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink); padding: .63rem .72rem;
}
input[type=checkbox] { accent-color: var(--primary); width: 19px; height: 19px; cursor: pointer; }
textarea { resize: vertical; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 22px; }
.login form { display: grid; gap: 14px; width: min(390px, 100%); padding: 25px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); }
dialog { width: min(520px, calc(100% - 24px)); max-height: 92dvh; padding: 0;
  background: var(--paper); color: var(--ink); border: 1px solid var(--border); border-radius: 12px; }
dialog.wide { width: min(760px, calc(100% - 24px)); }
dialog::backdrop { background: var(--veil); }
.dialog-content { display: grid; gap: 13px; padding: clamp(15px, 4vw, 25px); }
.dialog-head, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dialog-actions { justify-content: flex-end; }
#dialog-error:empty { display: none; }
.notice { position: fixed; right: 18px; bottom: 18px; z-index: 5; padding: 11px 15px; border-radius: 8px;
  background: var(--primary); color: var(--primary-ink); max-width: min(430px, calc(100vw - 30px)); }
.notice.is-error { color: var(--danger); background: var(--surface); border: 1px solid var(--danger); }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 183px minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar, .location { display: none; }
  .brand.compact { display: inline-flex; padding-left: 0; }
  .topbar { min-height: 59px; padding: 0 12px; }
  .topbar-actions { gap: 2px; }
  .status-button { min-width: 44px; padding: 6px; }
  .status-button .sync-label { display: none; }
  #main { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .view { gap: 18px; }
  #mobile { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; position: fixed; bottom: 0; inset-inline: 0;
    z-index: 2; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--paper); }
  #mobile .nav-item { min-width: 0; min-height: 50px; padding: 4px 1px; gap: 4px; flex-direction: column;
    justify-content: center; font-size: .7rem; }
  #mobile .icon { width: 18px; height: 18px; }
  .notice { bottom: 72px; right: 11px; }
}
@media (max-width: 425px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .view-title { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; }
}

