/* Shelf: warm black and paper, brass accent. Follows the phone's light or dark unless a theme is chosen.
   No inline styles anywhere: dynamic values use data-css, applied through the style API. */

@font-face { font-family: "Space Grotesk"; src: url(../fonts/space-grotesk-latin-wght-normal.woff2) format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/ibm-plex-sans-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/ibm-plex-sans-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(../fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(../fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(../fonts/ibm-plex-mono-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #0B0A09; --bg1: #131110; --bg2: #1A1715; --bg3: #241F1C;
  --line: #2E2926; --line2: #403933;
  --hi: #F6F1EA; --mid: #B3A99F; --lo: #8F847A;
  --accent: #E9B949; --accent-ink: #141413; --link: #F0C766;
  --bad: #FF6B4F; --ok: #8DBF6B; --warn: #F5892B;
  --shadow: 0 10px 34px rgba(0, 0, 0, .42);
  --disp: "Space Grotesk", system-ui, sans-serif;
  --text: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --pad: clamp(16px, 4vw, 34px);
  --r: 14px; --r-lg: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F6F1EA; --bg1: #FFFCF7; --bg2: #EFE7DB; --bg3: #E3D8C8;
  --line: #DDD2C2; --line2: #C8BAA6;
  --hi: #141413; --mid: #4F463E; --lo: #6E6359;
  --accent: #E9B949; --accent-ink: #141413; --link: #8A5A00;
  --bad: #C0311C; --ok: #3F7A24; --warn: #B8590B;
  --shadow: 0 10px 30px rgba(60, 40, 20, .12);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #F6F1EA; --bg1: #FFFCF7; --bg2: #EFE7DB; --bg3: #E3D8C8;
    --line: #DDD2C2; --line2: #C8BAA6;
    --hi: #141413; --mid: #4F463E; --lo: #6E6359;
    --accent: #E9B949; --accent-ink: #141413; --link: #8A5A00;
    --bad: #C0311C; --ok: #3F7A24; --warn: #B8590B;
    --shadow: 0 10px 30px rgba(60, 40, 20, .12);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--hi); font: 400 16px/1.5 var(--text); min-height: 100vh; min-height: 100dvh; padding-bottom: calc(76px + var(--safe-b)); overscroll-behavior-y: none; }
h1, h2, h3 { font-family: var(--disp); line-height: 1.15; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(26px, 5vw, 38px); font-weight: 700; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
a { color: var(--link); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
.dim { color: var(--mid); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.eyebrow { font: 600 12px/1 var(--mono); letter-spacing: .09em; text-transform: uppercase; color: var(--lo); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 0; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 8px; }

/* ---------- top island ---------- */
.island { position: sticky; top: calc(8px + var(--safe-t)); z-index: 30; margin: calc(8px + var(--safe-t)) auto 0; width: min(1120px, calc(100% - 20px)); display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--bg1) 82%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--shadow); }
.ibrand { display: flex; align-items: center; gap: 8px; color: var(--hi); text-decoration: none; font: 700 18px var(--disp); }
.mark svg { width: 22px; height: 22px; display: block; }
.iback { display: flex; align-items: center; gap: 2px; color: var(--hi); text-decoration: none; font-weight: 500; padding: 6px 10px 6px 4px; border-radius: 999px; }
.iback svg, .tabbar svg, .dock svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ipills { display: none; gap: 2px; margin-left: 10px; }
.ipill { color: var(--mid); text-decoration: none; padding: 7px 13px; border-radius: 999px; font-weight: 500; font-size: 15px; }
.ipill:hover { color: var(--hi); background: var(--bg2); }
.ipill[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.iright { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.itheme { width: 38px; height: 38px; border: 1px solid var(--line); background: transparent; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--hi); }
.itheme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.itheme .sun { display: none; }
:root[data-theme="light"] .itheme .moon { display: none; }
:root[data-theme="light"] .itheme .sun { display: block; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .itheme .moon { display: none; } :root:not([data-theme="dark"]) .itheme .sun { display: block; } }
.net { display: flex; align-items: center; gap: 6px; font: 500 12px var(--mono); color: var(--mid); }
.net-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lo); }
.net[data-state="ok"] .net-dot { background: var(--ok); }
.net[data-state="busy"] .net-dot { background: var(--accent); animation: pulse 1s infinite; }
.net[data-state="off"] .net-dot, .net[data-state="warn"] .net-dot { background: var(--warn); }
.net[data-state="bad"] .net-dot { background: var(--bad); }
.net-label { display: none; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- bottom bars ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(6, 1fr); padding: 6px 4px calc(6px + var(--safe-b)); background: color-mix(in srgb, var(--bg1) 90%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px; font-weight: 500; color: var(--lo); text-decoration: none; border-radius: 12px; }
.tabbar a[aria-current="page"] { color: var(--hi); }
.tabbar a[aria-current="page"] svg { stroke: var(--accent); }
.dock { display: none; }

@media (min-width: 900px) {
  body { padding-bottom: 110px; }
  .ipills { display: flex; }
  .tabbar { display: none; }
  .net-label { display: inline; }
  .dock { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30; display: flex; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--bg1) 86%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--shadow); }
  .dock button { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--hi); padding: 9px 16px; border-radius: 999px; cursor: pointer; font-weight: 500; }
  .dock button:hover { background: var(--accent); color: var(--accent-ink); }
  .dock svg { width: 18px; height: 18px; }
}

/* ---------- page ---------- */
main { width: min(1120px, 100%); margin: 0 auto; padding: 22px var(--pad) 30px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--mid); margin-top: 4px; }
.card { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.card.flat { background: transparent; }
.card h2 + * { margin-top: 10px; }
.empty { text-align: center; color: var(--mid); padding: 34px 16px; border: 1px dashed var(--line2); border-radius: var(--r-lg); }
.empty h3 { color: var(--hi); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }
.notice { padding: 12px 14px; border-radius: var(--r); background: var(--bg2); border: 1px solid var(--line); font-size: 14px; color: var(--mid); }
.notice.warn { border-color: var(--warn); color: var(--hi); }
.notice.bad { border-color: var(--bad); color: var(--hi); }
.notice b { color: var(--hi); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line2); background: var(--bg2); color: var(--hi); font-weight: 600; cursor: pointer; text-decoration: none; font-size: 15px; transition: transform .15s var(--ease), background .15s; }
.btn:hover { background: var(--bg3); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 5px 13px; font-size: 14px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg2); display: inline-grid; place-items: center; cursor: pointer; font-size: 20px; line-height: 1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label { font-size: 13px; font-weight: 600; color: var(--mid); }
input[type=text], input[type=password], input[type=search], input[type=email], input[type=url], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea { width: 100%; min-height: 44px; padding: 10px 14px; background: var(--bg1); border: 1px solid var(--line2); border-radius: 12px; color: var(--hi); font-size: 16px; }
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[aria-invalid="true"] { border-color: var(--bad); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: center; min-height: 40px; cursor: pointer; }
.hint { font-size: 13px; color: var(--lo); }
.err { font-size: 14px; color: var(--bad); min-height: 20px; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button, .seg a { border: 0; background: transparent; color: var(--mid); padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.seg [aria-pressed="true"], .seg [aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: 12.5px; color: var(--mid); white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--h, var(--accent)); display: inline-block; }
.meter { display: block; height: 6px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- welcome ---------- */
.welcome { max-width: 460px; margin: 6vh auto 0; display: flex; flex-direction: column; gap: 18px; }
.welcome .brand-big { display: flex; align-items: center; gap: 12px; font: 700 34px var(--disp); }
.welcome .brand-big svg { width: 38px; height: 38px; }
.recovery { font: 600 20px/1.7 var(--mono); letter-spacing: .06em; text-align: center; padding: 18px; border: 1px dashed var(--accent); border-radius: var(--r-lg); background: var(--bg1); user-select: all; word-spacing: .4em; }

/* ---------- home bento ---------- */
.bento { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .bento { grid-template-columns: repeat(6, 1fr); } .bento .t-read { grid-column: span 4; } .bento .t-rem { grid-column: span 2; } .bento .t-today { grid-column: span 3; } .bento .t-diary { grid-column: span 3; } .bento .t-recent { grid-column: span 6; } }
.tile { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tile > header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.tile.accent { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 22%, var(--bg1)), var(--bg1) 70%); }
.greet { margin-bottom: 18px; }
.greet p { color: var(--mid); margin-top: 4px; }
.resume { display: flex; gap: 16px; align-items: center; text-decoration: none; color: inherit; }
.resume .cover { width: 84px; flex: none; }
.resume h3 { font-size: 19px; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.li:first-child { border-top: 0; }
.li .when { font: 500 13px var(--mono); color: var(--mid); min-width: 74px; }
.li .grow b { font-weight: 600; }

/* ---------- library ---------- */
.lib-tools { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.lib-tools input[type=search] { max-width: 320px; }
.shelf-block { margin-bottom: 26px; }
.shelf-block > header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.shelf-block > header .swatch { width: 10px; height: 22px; border-radius: 3px; background: var(--h, var(--accent)); }
.shelf-block > header .count { color: var(--lo); font: 500 13px var(--mono); }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 16px 14px; }
@media (min-width: 700px) { .books { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.hrow { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.hrow .book { flex: 0 0 128px; scroll-snap-align: start; }
.book { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; min-width: 0; }
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 6px 10px 10px 6px; overflow: hidden; background: var(--bg3); box-shadow: 0 6px 16px rgba(0, 0, 0, .35), inset 3px 0 0 rgba(255, 255, 255, .12); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover.fallback { background: linear-gradient(155deg, var(--h, #7A6F65), color-mix(in srgb, var(--h, #7A6F65) 55%, #000)); color: #fff; padding: 30px 10px 12px 14px; display: flex; flex-direction: column; justify-content: space-between; }
.cover.fallback b { font: 700 15px/1.15 var(--disp); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.cover.fallback i { font: 500 11px var(--text); font-style: normal; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cover .fmt { position: absolute; top: 6px; right: 6px; font: 600 10px var(--mono); background: rgba(0, 0, 0, .6); color: #fff; padding: 2px 6px; border-radius: 99px; letter-spacing: .05em; }
.cover .pbar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, .45); }
.cover .pbar span { display: block; height: 100%; background: var(--accent); }
.book .btitle { font-weight: 600; font-size: 14px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.book .bsub { font-size: 12.5px; color: var(--mid); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book .off { color: var(--warn); }
.book-hero { display: grid; gap: 22px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .book-hero { grid-template-columns: 220px 1fr; } }
.book-hero .cover { max-width: 220px; }
.corrections { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .corrections { grid-template-columns: 1fr 1fr; } }
.dropzone { border: 2px dashed var(--line2); border-radius: var(--r-lg); padding: 22px; text-align: center; color: var(--mid); }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.upload-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.upload-row:first-child { border-top: 0; }
.kw { font: 400 13px/1.5 var(--mono); }

/* ---------- reader ---------- */
body.reading { padding-bottom: 0; }
body.reading .tabbar, body.reading .dock { display: none; }
.reader { display: flex; flex-direction: column; }
.reader-bar { position: sticky; top: calc(66px + var(--safe-t)); z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 10px; background: color-mix(in srgb, var(--bg1) 90%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 999px; }
.reader-bar .title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 0; min-width: 0; color: var(--hi); text-decoration: none; }
.reader-bar .where { font: 500 12.5px var(--mono); color: var(--mid); white-space: nowrap; }
.pdf-pages { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; margin: 0 auto; }
.pdf-page { width: 100%; background: #fff; border-radius: 4px; box-shadow: 0 4px 18px rgba(0, 0, 0, .35); overflow: hidden; }
.pdf-page canvas { width: 100%; height: auto; display: block; }
.epub-wrap { max-width: 680px; margin: 0 auto; width: 100%; }
.epub-text { font: 400 var(--epub-size, 19px)/1.7 "IBM Plex Sans", Georgia, serif; padding: 8px 4px 40px; overflow-wrap: anywhere; }
.epub-text h1, .epub-text h2, .epub-text h3 { margin: 1.4em 0 .6em; }
.epub-text p { margin: 0 0 1em; }
.epub-text img { max-width: 100%; height: auto; border-radius: 4px; }
.epub-text blockquote { margin: 1em 0; padding-left: 14px; border-left: 3px solid var(--line2); color: var(--mid); }
.epub-text a { color: var(--link); }
.epub-nav { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0 30px; }
.toc-list { display: flex; flex-direction: column; max-height: 60vh; overflow: auto; }
.toc-list button { text-align: left; background: transparent; border: 0; padding: 10px 6px; border-top: 1px solid var(--line); cursor: pointer; font-size: 15px; }
.toc-list button:first-child { border-top: 0; }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-head h1 { font-size: clamp(22px, 4vw, 30px); flex: 1 1 auto; min-width: 150px; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.month .dow { background: var(--bg1); padding: 8px 4px; text-align: center; font: 600 11px var(--mono); color: var(--lo); text-transform: uppercase; letter-spacing: .06em; }
.cell { background: var(--bg1); min-height: 58px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; border: 0; color: inherit; text-align: center; }
.cell:hover { background: var(--bg2); }
.cell .n { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-weight: 500; font-size: 14px; }
.cell.other { color: var(--lo); background: color-mix(in srgb, var(--bg1) 60%, var(--bg)); }
.cell.today .n { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.cell.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; min-height: 7px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.dots i.ics { background: #5B8DEF; }
.dots i.diary { background: #B58BE8; border-radius: 2px; }
@media (min-width: 700px) {
  .cell { min-height: 92px; align-items: stretch; padding: 6px; text-align: left; }
  .cell .n { align-self: flex-start; }
  .cell .ev-pill { display: block; font-size: 11.5px; background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 4px; padding: 1px 5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cell .dots { display: none; }
}
.ev-pill { display: none; }
.agenda { margin-top: 18px; }
.week { display: grid; grid-template-columns: 44px repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--bg1); }
.week .wh { padding: 8px 2px; text-align: center; font: 600 11px var(--mono); color: var(--lo); border-bottom: 1px solid var(--line); background: var(--bg1); }
.week .wh.today { color: var(--accent); }
.week .wh b { display: block; font: 700 16px var(--disp); color: var(--hi); }
.tl { position: relative; border-left: 1px solid var(--line); height: 960px; }
.tl.hours { border-left: 0; }
.tl .hr { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); font: 500 10px var(--mono); color: var(--lo); padding: 2px 4px; }
.tl .evb { position: absolute; border-radius: 8px; padding: 3px 6px; font-size: 12px; line-height: 1.25; overflow: hidden; background: color-mix(in srgb, var(--accent) 28%, var(--bg1)); border-left: 3px solid var(--accent); cursor: pointer; color: var(--hi); text-align: left; border-top: 0; border-right: 0; border-bottom: 0; }
.tl .evb.ics { background: color-mix(in srgb, #5B8DEF 26%, var(--bg1)); border-left-color: #5B8DEF; }
.tl .now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 2; }
.allday { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.day-wrap { display: grid; grid-template-columns: 44px 1fr; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--bg1); }
.ev-row { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; color: inherit; text-align: left; width: 100%; }
.ev-row:first-child { border-top: 0; }
.ev-row .bar { width: 4px; border-radius: 4px; background: var(--accent); flex: none; }
.ev-row.ics .bar { background: #5B8DEF; }
.dow-picks { display: flex; gap: 6px; flex-wrap: wrap; }
.dow-picks label { display: inline-flex; }
.dow-picks input { position: absolute; opacity: 0; pointer-events: none; }
.dow-picks span { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line2); font-size: 14px; font-weight: 600; cursor: pointer; }
.dow-picks input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.dow-picks input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- reminders, alarms, timers ---------- */
.rem { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.rem:first-child { border-top: 0; }
.rem .grow b { font-weight: 600; display: block; }
.rem.overdue .when { color: var(--bad); }
.rem.done { opacity: .55; }
.rem .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.check-circle { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line2); background: transparent; cursor: pointer; flex: none; display: grid; place-items: center; color: var(--accent-ink); }
.check-circle:hover { border-color: var(--accent); }
.check-circle[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.digits { font: 600 clamp(44px, 12vw, 72px)/1 var(--mono); letter-spacing: -.02em; }
.timer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.timer:first-child { border-top: 0; }
.timer .t-digits { font: 600 30px var(--mono); }
.quick-timers { display: flex; gap: 8px; flex-wrap: wrap; }
.alarm-time { font: 600 34px var(--mono); letter-spacing: -.02em; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--bg3); border: 1px solid var(--line2); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--hi); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--accent-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.clock-chip { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); z-index: 40; background: var(--accent); color: var(--accent-ink); font: 600 14px var(--mono); padding: 9px 16px; border-radius: 999px; text-decoration: none; box-shadow: var(--shadow); }
.clock-chip.paused { background: var(--bg3); color: var(--hi); }
.ring-screen { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); overflow: auto; }
.ring-card { width: min(440px, 100%); text-align: center; background: var(--bg1); border: 1px solid var(--line2); border-radius: 28px; padding: 30px 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); animation: ringin .35s var(--ease); }
@keyframes ringin { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.ring-card h1 { font-size: clamp(30px, 8vw, 44px); overflow-wrap: anywhere; }
.ring-label { font-size: 18px; color: var(--hi); }
.ring-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.ring-actions .btn { flex: 1 1 140px; min-height: 52px; font-size: 17px; }
.snooze-menu { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.pick-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pick-row input { flex: 1 1 200px; }

/* ---------- diary ---------- */
.entry { display: block; padding: 16px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.entry:first-child { border-top: 0; }
.entry .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font: 500 12.5px var(--mono); color: var(--mid); margin-bottom: 4px; }
.entry p { color: var(--mid); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.entry h3 { margin-bottom: 2px; }
.entry mark { background: color-mix(in srgb, var(--accent) 40%, transparent); color: inherit; border-radius: 3px; }
.diary-editor textarea { min-height: 46vh; font-size: 17px; }
.moods { display: flex; gap: 8px; flex-wrap: wrap; }
.moods button { border: 1px solid var(--line2); background: var(--bg1); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.moods button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tagrow { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- more / settings ---------- */
.menu { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .menu { grid-template-columns: 1fr 1fr; } }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; }
.setting .grow small { display: block; color: var(--mid); font-size: 13px; }
.device { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.device:first-child { border-top: 0; }
.shelf-edit { border-top: 1px solid var(--line); padding: 14px 0; display: grid; gap: 10px; }
.shelf-edit:first-child { border-top: 0; }
.quota { display: flex; flex-direction: column; gap: 6px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); }
.table th { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--lo); border-top: 0; }
.invite-code { font: 600 18px var(--mono); letter-spacing: .04em; user-select: all; word-break: break-all; }

/* ---------- dialogs and toasts ---------- */
dialog.dlg { border: 1px solid var(--line2); border-radius: 24px; padding: 22px; background: var(--bg1); color: var(--hi); width: min(480px, calc(100% - 28px)); max-height: calc(100dvh - 40px); box-shadow: var(--shadow); }
dialog.dlg.wide { width: min(640px, calc(100% - 28px)); }
dialog.dlg::backdrop { background: rgba(0, 0, 0, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog.dlg h2 { margin-bottom: 12px; }
dialog.dlg form { display: flex; flex-direction: column; gap: 14px; }
.dlg-body { display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 12px); opacity: 0; z-index: 120; background: var(--hi); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; max-width: calc(100% - 32px); transition: opacity .25s, transform .25s var(--ease); box-shadow: var(--shadow); text-align: center; }
.toast.in { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
.splash { display: grid; place-items: center; min-height: 50vh; color: var(--mid); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

body.signedout .tabbar, body.signedout .dock, body.signedout .ipills, body.signedout .itheme + * { display: none !important; }
body.signedout { padding-bottom: 20px; }

.week-list { display: block; }
.week-grid { display: none; }
@media (min-width: 760px) { .week-grid { display: block; } .week-list { display: none; } }
.ev-row .diary-bar { background: #B58BE8; }
.agenda h2, .agenda h3 { margin-bottom: 6px; }
.scroll-x { overflow: auto; }
