/* Stone + Eucalyptus design system */
:root {
  --ivory: #F4EFE8; --stone: #D9D1C7; --eucalyptus: #BCC8B5; --sage: #8E9F8A; --mineral: #5B5F58;
  --accent: #8E9F8A;
  --accent-soft: color-mix(in srgb, var(--accent) 22%, var(--card));
  --ink: #343A34; --muted: #7d8078; --line: #E6E1D8; --line-soft: #EFEBE4;
  --page: #F4EFE8; --card: #FFFEFA; --fill: #F3F1EA; --side: #575F55; --side-ink: #EEF0E9;
  --danger: #A2584E; --warn: #B08B3E; --ok: #6F8A6B;
  --shadow: 0 9px 25px #3b483a0d; --radius: 14px;
  --serif: Fraunces, Georgia, 'Times New Roman', serif;
  --sans: Manrope, system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  color-scheme: light;
}
[data-paper=cream] { --page: #F2EAD9; --card: #FFFBF1; --fill: #F2ECDf; }
[data-paper=linen] { --page: #ECE7DF; --card: #FAF7F1; --fill: #EFEBE3; }
[data-paper=crisp] { --page: #F6F6F3; --card: #FFFFFF; --fill: #F2F3EF; --line: #E4E5E0; }
[data-theme=dark] {
  --ink: #E9E7E0; --muted: #A4A79E; --line: #3B4039; --line-soft: #33372F;
  --page: #1F221E; --card: #282C27; --fill: #30352F; --side: #171A16; --side-ink: #DDE2D7;
  --shadow: 0 9px 25px #0000002e; color-scheme: dark;
}
[data-theme=dark][data-paper=cream] { --page: #221F1A; --card: #2C2924; }
[data-theme=dark][data-paper=linen] { --page: #20201E; --card: #2A2A27; }
[data-theme=dark][data-paper=crisp] { --page: #1B1C1B; --card: #252625; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 500 14px/1.45 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1, h2, .serif { font-family: var(--serif); font-weight: 500; letter-spacing: -.02em; }
h1 { font-size: clamp(28px, 3.4vw, 38px); line-height: 1.1; }
h2 { font-size: 22px; }
h3 { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--card); padding: 8px 12px; z-index: 99; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--side); color: var(--side-ink); padding: 24px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 10px; }
.brand .mark { font-size: 24px; color: var(--eucalyptus); }
.brand strong { font: 500 20px var(--serif); display: block; }
.brand small { font-size: 9px; letter-spacing: .2em; opacity: .7; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; font-size: 13px; font-weight: 600; color: color-mix(in srgb, var(--side-ink) 86%, transparent); }
#nav a:hover { background: #ffffff14; }
#nav a.active { background: #ffffff24; color: #fff; }
#nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sidefoot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid #ffffff22; font-size: 11px; opacity: .85; }
.syncstatus::before { content: '●'; margin-right: 6px; color: var(--eucalyptus); }
.syncstatus.offline::before { color: #d9b26b; }
.syncstatus.error::before { color: #e09a8f; }
.column { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 12px clamp(16px, 3vw, 40px); background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line-soft); }
.searchwrap { position: relative; flex: 1; max-width: 420px; }
#search { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 12px; }
.searchresults { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; z-index: 30; }
.sr { display: flex; gap: 10px; align-items: flex-start; width: 100%; border: 0; background: none; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.sr:hover, .sr:focus { background: var(--fill); outline: none; }
.sr small { display: block; color: var(--muted); font-size: 11px; }
.topactions { margin-left: auto; display: flex; align-items: center; gap: 8px; position: relative; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; font: 500 17px var(--serif); }
.menubtn { display: none; }
main { padding: 22px clamp(16px, 3vw, 40px) 60px; outline: none; max-width: 1500px; width: 100%; }
.loading { color: var(--muted); padding: 40px 0; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.headactions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.eyebrow { font-size: 10px; text-transform: uppercase; letter-spacing: .22em; color: var(--accent); font-weight: 800; margin-bottom: 6px; }
[data-theme=dark] .eyebrow { color: color-mix(in srgb, var(--accent) 70%, #fff); }
.subtle { color: var(--muted); font-size: 12px; }
.grow { flex: 1; }

/* ---------- controls ---------- */
.btn, .iconbtn { border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 8px 13px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.btn:hover, .iconbtn:hover { background: var(--fill); }
.btn.primary { background: var(--mineral); border-color: var(--mineral); color: #fff; }
[data-theme=dark] .btn.primary { background: var(--accent); border-color: var(--accent); color: #1b1d1a; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.on, .tabs .on { background: var(--mineral); color: #fff; border-color: var(--mineral); }
[data-theme=dark] .btn.on, [data-theme=dark] .tabs .on { background: var(--accent); color: #1b1d1a; }
.iconbtn { padding: 7px 10px; line-height: 1; }
.iconbtn.ghost, .linkbtn { border: 0; background: none; }
.linkbtn { color: color-mix(in srgb, var(--accent) 80%, var(--ink)); font-weight: 800; font-size: 12px; padding: 3px 4px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.x { border: 0; background: none; color: var(--muted); padding: 2px 6px; font-size: 14px; border-radius: 6px; opacity: .7; }
.x:hover { opacity: 1; background: var(--fill); }
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { border: 1px solid var(--line); background: var(--card); border-radius: 9px; padding: 8px 10px; min-width: 0; }
textarea { width: 100%; resize: vertical; }
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; flex-shrink: 0; cursor: pointer; }
input[type=range] { accent-color: var(--accent); width: 100%; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button, .tabs a { border-radius: 9px; border: 1px solid var(--line); background: var(--card); padding: 7px 12px; font-weight: 700; font-size: 12px; text-decoration: none; }
.datebar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.datebar .label { font: 500 20px var(--serif); margin: 0 6px; }
.addrow { display: flex; gap: 6px; margin-top: 10px; }
.addrow input { flex: 1; }
.tag { display: inline-block; background: var(--accent-soft); border-radius: 7px; padding: 3px 7px; font-size: 10px; font-weight: 800; color: color-mix(in srgb, var(--accent) 60%, var(--ink)); white-space: nowrap; }
.cdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stack { display: grid; gap: 16px; }
.empty { color: var(--muted); font-size: 12px; padding: 10px 0; }
.empty .btn { margin-top: 8px; }
.stat .num { font: 500 30px var(--serif); line-height: 1.1; }
.stat.dark { background: var(--mineral); color: #fff; border: 0; }
.stat.dark .eyebrow { color: var(--eucalyptus); }

/* dashboard */
.dashhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.summary { color: var(--muted); margin-top: 6px; }
.dashgrid { columns: 3 300px; column-gap: 16px; }
.dashgrid > .card { break-inside: avoid; margin-bottom: 16px; display: block; }

/* lists */
.row { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); min-height: 38px; }
.row:last-child { border-bottom: 0; }
.row .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row .txt small { display: block; color: var(--muted); font-size: 11px; }
.row.done .txt > span, .done-text { text-decoration: line-through; color: var(--muted); }
.row .grip { cursor: grab; color: var(--muted); padding: 0 2px; user-select: none; touch-action: none; }
.dragging { opacity: .6; background: var(--fill); }
.from { font-size: 10px; color: var(--warn); font-weight: 700; }
.section-label { font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 14px 0 4px; }
.prio { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.prio:last-child { border: 0; }
.prio .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); font-size: 11px; font-weight: 800; flex-shrink: 0; }
.prio input[type=text] { flex: 1; border: 0 !important; background: transparent !important; padding: 4px 0 !important; border-bottom: 1px dashed transparent !important; border-radius: 0 !important; }
.prio input[type=text]:focus { border-bottom-color: var(--line) !important; outline: none; }
.prio.done input[type=text] { text-decoration: line-through; color: var(--muted); }

/* schedule timeline */
.timeline { position: relative; }
.hour { display: grid; grid-template-columns: 44px 1fr; height: 44px; border-top: 1px solid var(--line-soft); font-size: 10px; color: var(--muted); }
.hour span { transform: translateY(-7px); background: var(--card); width: max-content; padding-right: 4px; }
.block { position: absolute; left: 50px; right: 2px; border-left: 3px solid var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 16%, var(--card)); border-radius: 6px; padding: 3px 8px; font-size: 11px; overflow: hidden; cursor: pointer; text-align: left; border-top: 0; border-right: 0; border-bottom: 0; }
.block b { font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block.done b { text-decoration: line-through; }
.nowline { position: absolute; left: 44px; right: 0; height: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.nowline::before { content: attr(data-t); position: absolute; left: -44px; top: -8px; background: var(--danger); color: #fff; font-size: 9px; font-weight: 800; padding: 1px 4px; border-radius: 4px; }
.allday { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 7px; padding: 4px 8px; font-size: 11px; font-weight: 600; background: color-mix(in srgb, var(--c, var(--accent)) 18%, var(--card)); text-align: left; }
.onnow { font-size: 12px; margin-bottom: 8px; }
.onnow b { color: var(--danger); }
.slist .row { cursor: pointer; }
.slist .time { width: 92px; flex-shrink: 0; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* habits mini */
.hab { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.hab:last-child { border: 0; }
.tick { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--stone); background: var(--fill); display: grid; place-items: center; padding: 0; color: #fff; font-size: 13px; flex-shrink: 0; }
.tick.on { background: var(--accent); border-color: var(--accent); }
.tick:disabled { opacity: .35; cursor: not-allowed; }
.streak { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* check-in */
.faces { display: flex; gap: 6px; }
.face { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--fill); font-size: 18px; padding: 0; }
.face.on { border: 2px solid var(--accent); background: var(--accent-soft); }
.drops { display: flex; gap: 4px; flex-wrap: wrap; }
.drop { width: 22px; height: 26px; border: 0; background: none; padding: 0; color: var(--stone); }
.drop svg { width: 100%; height: 100%; fill: transparent; stroke: currentColor; stroke-width: 1.6; }
.drop.on { color: var(--accent); }
.drop.on svg { fill: currentColor; }
.meter { height: 7px; border-radius: 9px; background: var(--fill); overflow: hidden; }
.meter > div { height: 100%; background: var(--accent); border-radius: 9px; }
.kv { display: grid; grid-template-columns: 70px 1fr; gap: 6px 10px; align-items: center; }
.kv > span:nth-child(odd) { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }

/* meals */
.meal { display: grid; grid-template-columns: 82px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); align-items: baseline; }
.meal:last-child { border: 0; }
.meal span:first-child { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }

/* planner: week */
.weekgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.weekday { background: var(--card); border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px; min-height: 280px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.weekday.today { border: 2px solid var(--accent); }
.weekday header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line-soft); padding-bottom: 6px; }
.weekday header a { text-decoration: none; }
.weekday header b { font: 500 20px var(--serif); margin-left: 4px; }
.weekday .row { padding: 4px 0; min-height: 0; font-size: 12px; border: 0; }
.weekday .chip { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.miniadd { display: flex; gap: 4px; margin-top: auto; }
.miniadd input { flex: 1; width: 100%; font-size: 12px; padding: 5px 7px !important; }
.weekday .drops .drop { width: 13px; height: 16px; }
.weekday .faces .face { width: 24px; height: 24px; font-size: 12px; }
.carry { background: color-mix(in srgb, var(--warn) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--card)); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }

/* planner: month */
.monthgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.monthgrid .dh { text-align: center; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 4px 0; }
.mday { min-height: 104px; border: 1px solid var(--line-soft); border-radius: 10px; padding: 6px; background: var(--fill); display: flex; flex-direction: column; gap: 2px; text-align: left; font-size: 11px; overflow: hidden; color: inherit; text-decoration: none; }
.mday.out { opacity: .4; }
.mday.today { border: 2px solid var(--accent); }
.mday .dn { font-weight: 800; font-size: 12px; }
.mday .it { display: flex; gap: 4px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mday .count { margin-top: auto; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mday:hover { border-color: var(--accent); }

/* planner: year */
.yeargrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ymonth { background: var(--fill); border-radius: 12px; padding: 10px; }
.ymonth h4 { margin: 0 0 6px; font: 500 15px var(--serif); }
.ymonth h4 a { text-decoration: none; }
.ydays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; font-size: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.ydays a, .ydays span { padding: 3px 0; border-radius: 5px; text-decoration: none; position: relative; }
.ydays a:hover { background: var(--accent-soft); }
.ydays .imp { font-weight: 800; }
.ydays .imp::after { content: ''; position: absolute; bottom: 0; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--c, var(--accent)); }
.ydays .td { background: var(--accent); color: #fff; }
.ydays .hd { color: var(--muted); font-weight: 700; }
.vision { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.vision figure { margin: 0; position: relative; }
.vision img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; }
.vision figcaption { font-size: 11px; text-align: center; margin-top: 4px; }
.vision .x { position: absolute; top: 4px; right: 4px; background: var(--card); }

/* forms in modals */
dialog.modal { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--card); color: var(--ink); box-shadow: 0 30px 80px #0000003a; max-height: calc(100vh - 24px); }
dialog.modal.wide { width: min(900px, calc(100vw - 24px)); }
dialog::backdrop { background: #2a2e2a66; backdrop-filter: blur(2px); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
dialog header { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 22px 8px; }
.modal-body { padding: 8px 22px 12px; overflow-y: auto; display: grid; gap: 12px; }
dialog footer { display: flex; gap: 8px; padding: 12px 22px 18px; border-top: 1px solid var(--line-soft); }
.form-error { color: var(--danger); padding: 0 22px 14px; font-weight: 600; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.field small { color: var(--muted); font-size: 11px; }
.field input, .field select { width: 100%; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
.choicegrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: block; text-align: center; padding: 14px 6px; border: 1px solid var(--line); border-radius: 12px; font-weight: 700; cursor: pointer; }
.choice input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); }
.daypick { display: flex; gap: 10px; flex-wrap: wrap; }
.daypick label { display: flex; gap: 4px; align-items: center; font-size: 12px; }

/* popover / toast */
.popover { position: absolute; top: calc(100% + 8px); right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); width: 270px; z-index: 40; }
.timerrow { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 10px; }
.timerdisplay { font: 500 36px var(--serif); font-variant-numeric: tabular-nums; }
.timerbar { height: 4px; background: var(--fill); border-radius: 4px; overflow: hidden; margin-bottom: 10px; }
.timerbar div { height: 100%; background: var(--accent); width: 0; }
.timerpresets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
#timerBadge { font-size: 11px; font-variant-numeric: tabular-nums; margin-left: 2px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); opacity: 0; padding: 11px 18px; border-radius: 12px; background: var(--ink); color: var(--page); box-shadow: var(--shadow); z-index: 100; pointer-events: none; transition: .2s; font-weight: 600; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* stars */
.stars { display: inline-flex; }
.star { border: 0; background: none; padding: 0 1px; color: var(--stone); font-size: 15px; }
.star.on { color: var(--warn); }

/* tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); padding: 6px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px; border-bottom: 1px solid var(--line-soft); }
.tbl input:not([type=checkbox]) { width: 100%; }
.scrollx { overflow-x: auto; }

/* ---------- responsive ---------- */
@media (max-width: 1250px) {
  .dashgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .weekgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .yeargrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-105%); transition: transform .2s; height: 100%; }
  .navopen .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; background: #0005; z-index: 45; display: none; }
  .navopen .scrim { display: block; }
  .menubtn { display: inline-block; }
  .avatar, #printBtn { display: none; }
  .dashgrid, .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .dashgrid .span2 { grid-column: auto; }
  .weekgrid { grid-template-columns: minmax(0, 1fr); }
  .weekday { min-height: 0; }
  .yeargrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mday { min-height: 62px; padding: 4px; }
  .mday .it span:last-child, .mday .more { display: none; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .choicegrid { grid-template-columns: repeat(2, 1fr); }
  .quickadd-label { display: none; }
}
@media (max-width: 520px) {
  .topbar { gap: 6px; padding: 10px 12px; }
  main { padding: 16px 16px 60px; }
  #quickAddBtn { padding: 8px 10px; }
  .monthgrid { gap: 3px; }
  .mday { min-height: 48px; font-size: 9px; }
  .mday .it { display: none; }
  .mday .dot-row { display: flex; gap: 2px; flex-wrap: wrap; }
}
.dot-row { display: none; }

/* ---------- print ---------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .sidebar, .topbar, .scrim, .noprint, .headactions, .addrow, .miniadd, .x, .grip, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .card, .weekday { box-shadow: none; break-inside: avoid; }
  .sidebar, .linkbtn, .carry { display: none !important; }
  .dashgrid { columns: 3; }
  .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .weekgrid { grid-template-columns: repeat(7, minmax(0, 1fr)) !important; gap: 4px; }
  .weekday { padding: 6px; min-height: 240px; }
  .weekday .drops .drop { width: 9px; height: 12px; }
  .weekday .faces .face { width: 16px; height: 16px; font-size: 9px; }
  .weekday .chip, .weekday .row { font-size: 9px; }
  .monthgrid { grid-template-columns: repeat(7, minmax(0, 1fr)) !important; }
  .yeargrid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .mday { min-height: 80px; }
  .mday .it span:last-child, .mday .more { display: inline !important; }
  .mday .dot-row { display: none !important; }
  textarea { resize: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* habit tracker */
table.tracker { border-collapse: separate; border-spacing: 3px; font-size: 10px; }
.tracker th { font-weight: 700; color: var(--muted); text-align: center; min-width: 22px; }
.tracker th.td { color: var(--danger); }
.tracker tbody th { text-align: left; color: var(--ink); font-size: 12px; font-weight: 600; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.tracker td { padding: 0; }
.sq { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--stone); background: var(--fill); padding: 0; display: block; }
.sq.on { background: var(--accent); border-color: var(--accent); }
.sq.rest:not(.on) { border-style: dashed; opacity: .45; }
.sq.td { box-shadow: 0 0 0 2px var(--danger); }
.sq:disabled { opacity: .3; cursor: not-allowed; }
.tracker .streak { color: var(--danger); padding-left: 8px; }

/* charts */
svg.bars { width: 100%; height: 70px; margin-top: 8px; display: block; }
.bars rect { fill: color-mix(in srgb, var(--accent) 75%, var(--card)); }
.bars rect.last { fill: var(--mineral); }
[data-theme=dark] .bars rect.last { fill: var(--eucalyptus); }
.bars rect.gap { fill: var(--stone); }
.linechart { width: 100%; height: 180px; display: block; }
.linechart .axis { stroke: var(--line); stroke-width: 1; }
.linechart text { fill: var(--muted); font-size: 10px; font-family: var(--sans); }
.linechart .ln { fill: none; stroke: var(--accent); stroke-width: 2; }
.linechart .pt { fill: var(--card); stroke: var(--accent); stroke-width: 2; }
.linechart .pr { fill: var(--mineral); }

/* food */
.mealtbl th { white-space: nowrap; }
.mealtbl .tdh { color: var(--danger); }
.mealtbl td { min-width: 120px; }
.mealcell { display: flex; align-items: center; gap: 2px; }
.mealcell input { width: 100%; background: var(--fill) !important; border-color: transparent !important; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.segb { border: 0; background: var(--card); padding: 5px 10px; font-size: 12px; font-weight: 700; border-right: 1px solid var(--line); }
.segb:last-child { border-right: 0; }
.segb.on.in { background: var(--accent); color: #fff; }
.segb.on.low { background: color-mix(in srgb, var(--warn) 70%, var(--card)); color: #fff; }
.segb.on.out { background: color-mix(in srgb, var(--danger) 75%, var(--card)); color: #fff; }

/* training */
.titleinput { font-size: 24px; border: 0 !important; background: transparent !important; padding: 0 !important; margin-bottom: 6px; width: 100%; max-width: 420px; }
.exercise { border-top: 1px solid var(--line); padding: 14px 0 10px; }
.exname { font-weight: 700; min-width: 200px; }
.compare { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12px; background: var(--fill); border-radius: 9px; padding: 7px 10px; margin-bottom: 6px; }
.sets td:first-child { width: 40px; color: var(--muted); font-weight: 700; }
.sets input[type=number] { width: 100%; max-width: 110px; }
.setdone td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.histrow { border-bottom: 1px solid var(--line-soft); padding: 10px 0; }
.tpl input, .tpl select { width: 100%; min-width: 60px; }
.tpl td:first-child input { min-width: 160px; }

/* lifestyle */
.colgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.colcard { text-decoration: none; display: flex; flex-direction: column; gap: 4px; min-height: 160px; transition: transform .15s; }
.colcard:hover { transform: translateY(-2px); border-color: var(--accent); }
.colicon { font-size: 22px; }
.colcard h2 { font-size: 19px; }
.tagline { margin-top: auto; font-size: 11px; color: color-mix(in srgb, var(--accent) 70%, var(--ink)); font-weight: 700; letter-spacing: .04em; }

/* notebook */
.paper { min-height: 420px; width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; line-height: 28px; font-size: 15px; background-color: var(--card); resize: vertical; background-attachment: local; }
.paper.lined { background-image: linear-gradient(transparent 27px, var(--line) 27px); background-size: 100% 28px; background-position: 0 13px; }
.paper.dot { background-image: radial-gradient(circle, var(--stone) 1.2px, transparent 1.4px); background-size: 22px 22px; }
.paper.grid { background-image: linear-gradient(var(--line-soft) 1px, transparent 1px), linear-gradient(90deg, var(--line-soft) 1px, transparent 1px); background-size: 22px 22px; }

/* settings */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 6px; font-size: 11px; font-weight: 700; width: 82px; }
.swatch span { width: 100%; height: 26px; border-radius: 6px; }
.swatch.on { border: 2px solid var(--ink); }
.swatches.small { gap: 4px; flex: 1; }
.dotbtn { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.dotbtn.on { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--card); }
code { font-size: 12px; background: var(--fill); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.syncstatus a { color: inherit; }
.autosave { display: block; font-size: 11px; margin-top: 4px; min-height: 14px; }
.row3.macrogrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 520px) { .row3.macrogrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
