/* Calendula — calm, paper-like calendar UI. Tokens first; dark mode by media query or [data-theme]. */
:root {
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --surface-2: #F2F0EB;
  --surface-3: #EAE7E0;
  --line: #E6E2DA;
  --line-strong: #D6D1C7;
  --text: #1C1B19;
  --text-2: #4A4741;
  --muted: #8A857B;
  --accent: #E8590C;
  --accent-strong: #C94A06;
  --accent-soft: rgba(232, 89, 12, .10);
  --accent-ink: #FFFFFF;
  --danger: #D93025;
  --danger-soft: rgba(217, 48, 37, .10);
  --warn: #B86E00;
  --warn-soft: rgba(230, 150, 0, .14);
  --ok: #2F9E5B;
  --shadow-sm: 0 1px 2px rgba(28, 27, 25, .06);
  --shadow: 0 1px 2px rgba(28, 27, 25, .05), 0 4px 16px rgba(28, 27, 25, .07);
  --shadow-lg: 0 12px 40px rgba(28, 27, 25, .18), 0 2px 6px rgba(28, 27, 25, .08);
  --radius: 10px;
  --radius-sm: 7px;
  --hour: 52px;
  --sidebar: 296px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #141311; --surface: #1C1B19; --surface-2: #232220; --surface-3: #2C2A27; --line: #2E2C29; --line-strong: #3B3834;
  --text: #EDEAE4; --text-2: #C9C4BA; --muted: #8F897F; --accent: #FF7A33; --accent-strong: #FF9257;
  --accent-soft: rgba(255, 122, 51, .14); --accent-ink: #1A0E05; --danger: #FF6B5E; --danger-soft: rgba(255, 107, 94, .14);
  --warn: #F2B544; --warn-soft: rgba(242, 181, 68, .14); --ok: #4CC38A;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141311; --surface: #1C1B19; --surface-2: #232220; --surface-3: #2C2A27; --line: #2E2C29; --line-strong: #3B3834;
    --text: #EDEAE4; --text-2: #C9C4BA; --muted: #8F897F; --accent: #FF7A33; --accent-strong: #FF9257;
    --accent-soft: rgba(255, 122, 51, .14); --accent-ink: #1A0E05; --danger: #FF6B5E; --danger-soft: rgba(255, 107, 94, .14);
    --warn: #F2B544; --warn-soft: rgba(242, 181, 68, .14); --ok: #4CC38A;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* boot */
.boot { min-height: 100%; display: grid; place-items: center; }
.boot-mark, .brand-mark { background: url("/static/favicon.svg") center/contain no-repeat; }
.boot-mark { width: 44px; height: 44px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.94); } }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.icon { width: 34px; padding: 0; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span, .label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.title-input { height: 44px; font-size: 18px; font-weight: 600; border-color: transparent; padding: 0 2px; background: transparent; }
.input.title-input:focus { box-shadow: none; border-color: transparent; border-bottom: 2px solid var(--accent); border-radius: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font-weight: 550; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- auth screens ---------- */
.auth {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 400px at 110% 110%, rgba(79, 107, 237, .08), transparent 60%), var(--bg);
}
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.auth-card .brand { justify-content: center; margin-bottom: 6px; font-size: 22px; }
.auth-card .brand-mark { width: 34px; height: 34px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.auth-card .btn.primary { height: 40px; margin-top: 4px; }
.auth-sub { text-align: center; color: var(--muted); margin: 0; }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; }

/* ---------- app shell ---------- */
.app { height: 100%; display: grid; grid-template-columns: var(--sidebar) 1fr; grid-template-rows: 100%; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; flex: none; }

.sidebar {
  display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 0 16px; flex: none; }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 12px 16px; display: flex; flex-direction: column; gap: 18px; }
.section-title {
  display: flex; align-items: center; justify-content: space-between; margin: 0 4px 8px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0; }

/* mini month */
.mini { padding: 4px; }
.mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.mini-head strong { font-size: 13px; padding-left: 6px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; }
.mini-grid .dow { font-size: 10px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.mini-grid button {
  height: 30px; border: 0; background: transparent; border-radius: 50%; font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--text); position: relative; aspect-ratio: 1; width: 30px; margin: 0 auto; padding: 0;
}
.mini-grid button:hover { background: var(--surface-2); }
.mini-grid button.out { color: var(--muted); opacity: .6; }
.mini-grid button.in-range { background: var(--surface-2); border-radius: 6px; }
.mini-grid button.today { background: var(--accent); color: var(--accent-ink); font-weight: 700; border-radius: 50%; }
.mini-grid button.has::after { content: ""; position: absolute; bottom: 3px; left: 50%; width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: var(--muted); }
.mini-grid button.today.has::after { background: var(--accent-ink); }

/* inbox (unplaced tasks) */
.inbox { border-radius: 12px; transition: background .12s, box-shadow .12s; padding: 2px; }
.inbox.drop-hover { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.quick-add { display: flex; gap: 6px; margin-bottom: 8px; }
.quick-add .input { height: 34px; }
.task-list { display: flex; flex-direction: column; gap: 6px; }
.task-card {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); cursor: grab; user-select: none; touch-action: pan-y;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.task-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.task-card .cal-bar { width: 3px; align-self: stretch; border-radius: 2px; flex: none; }
.task-card .t-title { font-weight: 550; line-height: 1.3; word-break: break-word; }
.task-card .t-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip svg.i { width: 12px; height: 12px; }
.chip.overdue { background: var(--danger-soft); color: var(--danger); }
.chip.soon { background: var(--warn-soft); color: var(--warn); }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 8px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 4px 0; }

.cal-list { display: flex; flex-direction: column; gap: 2px; }
.cal-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; user-select: none; }
.cal-item:hover { background: var(--surface-2); }
.cal-swatch { width: 14px; height: 14px; border-radius: 4px; border: 2px solid; flex: none; }
.cal-item.off .cal-swatch { background: transparent !important; }
.cal-item.off span { color: var(--muted); }

/* main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 8px; height: 60px; padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; background: var(--bg); }
.toolbar h1 { margin: 0 6px; font-size: 19px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar h1 .yr { color: var(--muted); font-weight: 500; }
.toolbar .spacer { flex: 1; }
.menu-btn { display: none; }
.search { position: relative; }
.search .input { width: 220px; padding-left: 32px; height: 34px; }
.search svg.i { position: absolute; left: 9px; top: 8px; color: var(--muted); width: 16px; height: 16px; }
.search-results { position: absolute; right: 0; top: 40px; width: 360px; max-height: 420px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 40; padding: 6px; }
.search-results button { display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; border: 0; background: transparent; border-radius: 8px; padding: 8px; }
.search-results button:hover { background: var(--surface-2); }
.search-results .when { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.view { flex: 1; min-height: 0; position: relative; }

/* ---------- month ---------- */
.month { height: 100%; display: flex; flex-direction: column; }
.month-dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); flex: none; }
.month-dow div { padding: 8px 10px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.month-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; min-height: 0; }
.day {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 4px 2px; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px; background: var(--surface); transition: background .1s, box-shadow .1s;
}
.day:nth-child(7n) { border-right: 0; }
.day.out { background: var(--bg); }
.day.out .day-num { color: var(--muted); }
.day.weekend:not(.out) { background: color-mix(in srgb, var(--surface) 70%, var(--bg)); }
.day.drop-hover { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.day-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 2px; }
.day-num { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; border: 0; background: transparent; }
.day-num:hover { background: var(--surface-2); }
.day.today .day-num { background: var(--accent); color: var(--accent-ink); }
.day-items { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden; flex: 1; }
.more { border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; padding: 1px 6px; border-radius: 5px; }
.more:hover { background: var(--surface-2); color: var(--text); }

.ev {
  display: flex; align-items: center; gap: 6px; min-height: 22px; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; cursor: pointer; user-select: none; border: 0; background: transparent; text-align: left; width: 100%; flex: none;
}
.ev:hover { background: var(--surface-2); }
.ev .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ev .tm { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-size: 12px; }
.ev .tt { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ev.allday { color: #fff; font-weight: 600; }
.ev.allday:hover { filter: brightness(.95); }
.ev.task .box { width: 13px; height: 13px; border-radius: 50%; border: 1.8px solid currentColor; flex: none; display: grid; place-items: center; }
.ev.task { font-weight: 550; }
.ev.task.done .tt { text-decoration: line-through; color: var(--muted); }
.ev.task.done .box { background: currentColor; }
.ev.task.done .box::after { content: ""; width: 5px; height: 3px; border: solid var(--surface); border-width: 0 0 1.6px 1.6px; transform: rotate(-45deg) translate(1px, -1px); }
.ev.task.late { box-shadow: inset 2px 0 0 var(--danger); }
.ev.deadline { color: var(--danger); font-weight: 600; font-size: 12px; }
.ev.deadline svg.i { width: 13px; height: 13px; }
.ev.dragging-src { opacity: .35; }

/* ---------- week / day ---------- */
.week { height: 100%; display: flex; flex-direction: column; }
.week-head { display: grid; border-bottom: 1px solid var(--line); flex: none; background: var(--surface); }
.week-head .gutter { border-right: 1px solid var(--line); }
.wh-day { padding: 8px 6px 6px; text-align: center; border-right: 1px solid var(--line); }
.wh-day:last-child { border-right: 0; }
.wh-day .dw { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.wh-day .dn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 19px; font-weight: 650; margin-top: 2px; border: 0; background: transparent; font-variant-numeric: tabular-nums; }
.wh-day .dn:hover { background: var(--surface-2); }
.wh-day.today .dn { background: var(--accent); color: var(--accent-ink); }
.allday-row { display: grid; border-bottom: 1px solid var(--line-strong); flex: none; background: var(--surface); max-height: 140px; overflow-y: auto; }
.allday-row .gutter { font-size: 10px; color: var(--muted); padding: 6px 6px 0 0; text-align: right; border-right: 1px solid var(--line); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.allday-cell { border-right: 1px solid var(--line); padding: 3px; min-height: 30px; display: flex; flex-direction: column; gap: 2px; transition: background .1s; }
.allday-cell:last-child { border-right: 0; }
.allday-cell.drop-hover { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.week-scroll { flex: 1; overflow-y: auto; min-height: 0; position: relative; background: var(--surface); }
.week-body { display: grid; position: relative; }
.hours { border-right: 1px solid var(--line); }
.hours div { height: var(--hour); position: relative; }
.hours div span { position: absolute; top: -8px; right: 8px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--surface); padding: 0 2px; }
.hours div:first-child span { display: none; }
.col { position: relative; border-right: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour)); }
.col:last-child { border-right: 0; }
.col.today { background-color: color-mix(in srgb, var(--accent) 3%, transparent); }
.col.drop-hover { background-color: var(--accent-soft); }
.drop-ghost { position: absolute; left: 3px; right: 3px; border-radius: 7px; border: 2px dashed var(--accent); background: var(--accent-soft); pointer-events: none; z-index: 3; font-size: 11px; font-weight: 700; color: var(--accent); padding: 2px 6px; }
.tev {
  position: absolute; border-radius: 7px; padding: 3px 7px; font-size: 12px; line-height: 1.25; overflow: hidden; cursor: pointer;
  user-select: none; border: 0; text-align: left; box-shadow: 0 0 0 1px var(--surface); display: flex; flex-direction: column; z-index: 2;
}
.tev .tt { font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.tev .tm { opacity: .85; font-variant-numeric: tabular-nums; font-size: 11px; }
.tev.task { border-left: 3px solid; }
.tev.task.done .tt { text-decoration: line-through; opacity: .7; }
.tev.dragging-src { opacity: .35; }
.tev .resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* ---------- agenda ---------- */
.agenda { height: 100%; overflow-y: auto; padding: 8px 0 40px; }
.ag-day { display: grid; grid-template-columns: 120px 1fr; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.ag-date { display: flex; align-items: baseline; gap: 8px; }
.ag-date .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.ag-date .w { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.ag-day.today .ag-date .n { color: var(--accent); }
.ag-items { display: flex; flex-direction: column; gap: 4px; }
.ag-items .ev { min-height: 30px; font-size: 14px; padding: 4px 8px; }
.ag-items .ev .tm { min-width: 96px; font-size: 13px; }

/* ---------- drag ghost ---------- */
.drag-ghost {
  position: fixed; z-index: 1000; pointer-events: none; padding: 7px 11px; border-radius: 9px; background: var(--surface);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); font-weight: 600; font-size: 13px; max-width: 260px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transform: rotate(-1.5deg); display: flex; align-items: center; gap: 8px;
}
.drag-ghost .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none !important; }

/* ---------- modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 19, 17, .38); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 540px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: pop .16s cubic-bezier(.2, .9, .3, 1.2);
}
.modal.wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 14px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dt { display: grid; grid-template-columns: 1fr 110px; gap: 6px; }
.dt.date-only { grid-template-columns: 1fr; }
.weekdays { display: flex; gap: 4px; }
.weekdays button { width: 34px; height: 30px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 12px; font-weight: 650; }
.weekdays button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.placed-box { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }
.placed-box .grow { font-weight: 550; }
.note { color: var(--muted); font-size: 12.5px; }
.warn-note { color: var(--warn); font-size: 12.5px; font-weight: 600; }

/* settings */
.tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { height: 40px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .sub { color: var(--muted); font-size: 12px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; word-break: break-all; user-select: all; }
pre.secret { white-space: pre-wrap; margin: 0; }
.qr { width: 180px; height: 180px; border-radius: 8px; background: #fff; padding: 4px; }
input[type="color"].input { padding: 2px; width: 44px; height: 32px; }

/* toast */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: #23211E; color: #F4F1EB; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .16s ease-out; max-width: calc(100vw - 32px); }
.toast.error { background: #8E1F17; }
.toast button { border: 0; background: transparent; color: #FFB27A; font-weight: 700; padding: 0; }

/* fab (mobile) */
.fab { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .search .input { width: 160px; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(88vw, 340px); z-index: 60; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app.drawer-open .sidebar { transform: none; }
  .app.drawer-open::after { content: ""; position: fixed; inset: 0; background: rgba(20, 19, 17, .35); z-index: 50; }
  .menu-btn { display: inline-flex; }
  .toolbar { padding: 0 10px; gap: 4px; }
  .toolbar h1 { font-size: 17px; margin: 0 2px; }
  .hide-sm { display: none !important; }
  .search .input { width: 34px; padding: 0; color: transparent; cursor: pointer; }
  .search .input:focus { width: min(60vw, 240px); padding-left: 32px; color: inherit; position: relative; z-index: 2; }
  .search-results { width: min(92vw, 360px); right: -40px; }
  .month-dow div { padding: 6px 4px; text-align: center; letter-spacing: .02em; }
  .day { padding: 2px 1px; }
  .day-head { justify-content: center; }
  .day-num { min-width: 24px; height: 24px; font-size: 12px; }
  .ev { font-size: 11px; padding: 0 3px; min-height: 17px; gap: 3px; border-radius: 4px; }
  .ev .tm { display: none; }
  .ev .dot { width: 6px; height: 6px; }
  .ev.task .box { width: 10px; height: 10px; border-width: 1.5px; }
  .ag-day { grid-template-columns: 72px 1fr; padding: 12px 14px; gap: 10px; }
  .ag-items .ev .tm { display: inline; min-width: 70px; }
  .fab { display: inline-flex; position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30; width: 54px; height: 54px; border-radius: 16px; box-shadow: var(--shadow-lg); }
  .fab svg.i { width: 24px; height: 24px; }
  .two { grid-template-columns: 1fr; }
  :root { --hour: 46px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- calendar colors (set per element as --c) ---------- */
.ev, .tev, .task-card { --c: var(--accent); }
.ev.task { color: color-mix(in srgb, var(--c) 72%, var(--text)); }
.ev.task .tt { color: var(--text); }
.ev.task.done .tt { color: var(--muted); }
.ev.allday { background: var(--c); }
.ev.allday svg.i { width: 12px; height: 12px; stroke: #fff; }
.ev svg.i { width: 12px; height: 12px; flex: none; color: var(--muted); }
.task-card .cal-bar { background: var(--c); }
.tev { background: color-mix(in srgb, var(--c) 17%, var(--surface)); color: color-mix(in srgb, var(--c) 45%, var(--text)); border-left: 3px solid var(--c); }
.tev:hover { background: color-mix(in srgb, var(--c) 26%, var(--surface)); }
.tev.task { background: var(--surface); border: 1px dashed color-mix(in srgb, var(--c) 60%, var(--line)); border-left: 3px solid var(--c); }

/* ---------- polish ---------- */
p.note, p.hint, p.warn-note, p.auth-sub { margin: 0; }
.dt { grid-template-columns: 1fr 132px; }
.day.out { background: var(--surface-2); }
.day.out .day-num { color: var(--muted); font-weight: 500; }
.day.out .ev { opacity: .75; }
@media (max-width: 900px) {
  .toolbar > .btn:not(.icon):not(.primary) { padding: 0 9px; }
  .toolbar h1 { font-size: 16px; min-width: 0; flex: 1; }
  .toolbar h1 .yr { display: none; }
  .toolbar .spacer { display: none; }
  .search .input::placeholder { color: transparent; }
  .search .input:focus::placeholder { color: var(--muted); }
  .toolbar select.input { width: auto; height: 34px; padding: 0 6px; }
  .day.out { background: var(--bg); }
}
