/* Pila: design tokens --------------------------------------------------- */
:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #f8fafa;
  --ink: #13232a;
  --ink-2: #33464e;
  --muted: #61727a;
  --line: #e2e7e9;
  --line-strong: #cdd5d8;

  --side: #0f2a2e;
  --side-ink: #e2eeed;
  --side-muted: #8fb0ae;
  --side-line: #1f4045;
  --side-active: #1a4247;

  --accent: #0e7c74;
  --accent-hover: #0b6760;
  --accent-soft: #e2f2f0;
  --accent-ink: #ffffff;

  --good: #17784c;  --good-soft: #e5f4ec;
  --warn: #935b00;  --warn-soft: #fff3dc;
  --bad: #be3329;   --bad-soft: #fdecea;
  --next: #b9770e;  --next-soft: #fff7e8;

  --pb-threads: #39424b;
  --pb-instagram: #b44a7c;
  --pb-facebook: #3a62c2;
  --pb-x: #1f2a33;

  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 7px;
  --shadow: 0 1px 2px rgba(15, 42, 46, .06), 0 1px 1px rgba(15, 42, 46, .04);
  --shadow-pop: 0 24px 60px rgba(9, 25, 28, .22), 0 4px 14px rgba(9, 25, 28, .08);

  font-family: "Geist", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0c1416;
    --surface: #131e21;
    --surface-2: #172427;
    --ink: #e4edef;
    --ink-2: #c3d0d4;
    --muted: #8ea2a8;
    --line: #22333a;
    --line-strong: #2e434b;
    --side: #091114;
    --side-ink: #dbe8e7;
    --side-muted: #7f9c9b;
    --side-line: #18282c;
    --side-active: #16302f;
    --accent: #3fbdb1;
    --accent-hover: #5ccbc0;
    --accent-soft: #123532;
    --accent-ink: #032220;
    --good: #67cd91;  --good-soft: #13301f;
    --warn: #e5ad52;  --warn-soft: #33260e;
    --bad: #f2877e;   --bad-soft: #3a1a18;
    --next: #e9b058;  --next-soft: #2f240f;
    --pb-threads: #56606a;
    --pb-x: #45525d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-pop: 0 24px 60px rgba(0, 0, 0, .55);
  }
}

/* Base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); }
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 18px; height: 18px; flex: none; }

/* Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1; text-decoration: none; cursor: pointer;
  height: 38px; padding: 0 .95rem; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  transition: background-color .12s, border-color .12s;
}
.btn:hover { border-color: var(--muted); }
.btn .i { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.small { height: 32px; padding: 0 .7rem; font-size: .84rem; }
.btn.wide { width: 100%; height: 42px; }
.btn.is-disabled { pointer-events: none; opacity: .5; }
.btn.danger-text { color: var(--bad); }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: var(--r-sm); border: 1px solid transparent; background: none;
  color: var(--muted); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.icon-btn.bordered { border-color: var(--line-strong); background: var(--surface); }
.icon-btn.danger:hover { color: var(--bad); background: var(--bad-soft); border-color: transparent; }

/* Forms ----------------------------------------------------------------- */
.field { display: grid; gap: .4rem; }
.label { font-size: .84rem; font-weight: 600; color: var(--ink-2); padding: 0; }
.opt { font-weight: 400; color: var(--muted); }
.input {
  font: inherit; color: var(--ink); width: 100%;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: .6rem .75rem; transition: border-color .12s, box-shadow .12s;
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 9.5rem; line-height: 1.55; }
.input-icon { position: relative; display: block; }
.input-icon .i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.input-icon .input { padding-left: 2.2rem; }

.alert { padding: .65rem .8rem; border-radius: var(--r-sm); font-size: .9rem; margin-bottom: 1rem; }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-ok { background: var(--good-soft); color: var(--good); }

/* Platform badge: neutral monogram, not a logo -------------------------- */
.pb {
  display: inline-grid; place-items: center; flex: none;
  width: 20px; height: 20px; border-radius: 6px;
  font-size: .62rem; font-weight: 700; letter-spacing: -.01em; color: #fff;
}
.pb-threads { background: var(--pb-threads); }
.pb-instagram { background: var(--pb-instagram); }
.pb-facebook { background: var(--pb-facebook); }
.pb-x { background: var(--pb-x); }

/* Brand ----------------------------------------------------------------- */
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: inherit; font-weight: 700; font-size: 1.2rem; letter-spacing: -.02em; }
.logo-mark { width: 26px; height: 26px; color: var(--accent); }
.brand-lg { font-size: 1.45rem; margin-bottom: 1.75rem; }
.brand-lg .logo-mark { width: 32px; height: 32px; }

/* Login ----------------------------------------------------------------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.login-card {
  width: min(400px, 100%); display: grid; gap: 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 2.25rem 2rem; box-shadow: var(--shadow);
}
.login-card .brand-lg { margin-bottom: .5rem; }
.login-title { font-size: 1.35rem; letter-spacing: -.02em; }
.login-sub { color: var(--muted); margin-top: -.6rem; margin-bottom: .25rem; }
.login-card .alert { margin: 0; }

/* App shell ------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.25rem;
  padding: 1.25rem 1rem; background: var(--side); color: var(--side-ink);
}
.sidebar .brand { padding: .25rem .5rem; color: var(--side-ink); }
.sidebar .logo-mark { color: #5fd0c4; }
.new-btn { width: 100%; height: 40px; }

.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: .7rem; height: 38px; padding: 0 .65rem;
  border-radius: var(--r-sm); color: var(--side-muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { color: var(--side-ink); background: rgba(255, 255, 255, .04); }
.nav a[aria-current="page"] { background: var(--side-active); color: var(--side-ink); }
.nav-count { margin-left: auto; font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--side-muted); }
.nav-count.is-alert { background: #e5574d; color: #fff; border-radius: 999px; padding: .05rem .45rem; font-weight: 600; }

.side-title { font-size: .76rem; font-weight: 600; color: var(--side-muted); padding: 0 .65rem; margin-bottom: .4rem; }
.accounts { border-top: 1px solid var(--side-line); padding-top: 1.1rem; }
.accounts ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.accounts a { display: flex; align-items: center; gap: .6rem; padding: .35rem .65rem; font-size: .88rem; color: var(--side-ink); text-decoration: none; border-radius: var(--r-sm); }
.accounts a:hover { background: rgba(255, 255, 255, .05); }
.accounts a.is-off { color: var(--side-muted); }
.accounts a.is-off .pb { opacity: .5; }
.acct-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.accounts .pb, .nav .pb { box-shadow: 0 0 0 1px rgba(255, 255, 255, .18); }
.acct-state { margin-left: auto; font-size: .72rem; color: var(--side-muted); }
.accounts a:not(.is-off) .acct-state { color: #6fd39a; }
.accounts a.is-off .acct-state { color: #7fd3c9; font-weight: 600; }
.nav-gap { height: .6rem; }

.side-foot {
  margin-top: auto; display: flex; align-items: center; gap: .6rem;
  border-top: 1px solid var(--side-line); padding: 1rem .35rem 0;
}
.side-foot .who { font-size: .88rem; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot form { margin-left: auto; }
.side-foot .icon-btn { color: var(--side-muted); }
.side-foot .icon-btn:hover { background: var(--side-active); color: var(--side-ink); border-color: transparent; }

.avatar {
  display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: .78rem; font-weight: 700;
}

.main { padding: 2rem clamp(1rem, 3.5vw, 2.75rem) 5rem; max-width: 1180px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -.025em; }
.page-sub { color: var(--muted); margin-top: .2rem; }
.week-nav { display: flex; gap: .4rem; align-items: center; }

/* Stats ----------------------------------------------------------------- */
.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); margin-bottom: 2rem; overflow: hidden;
}
.stat { display: grid; align-content: start; gap: .2rem; padding: 1rem 1.2rem; color: inherit; text-decoration: none; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-value.is-text { font-size: 1.15rem; padding-top: .3rem; }
.stat-foot { font-size: .8rem; color: var(--muted); }
a.stat:hover { background: var(--surface-2); }
.stat.is-alert .stat-value, .stat.is-alert .stat-foot { color: var(--bad); }

/* Day groups + rows ----------------------------------------------------- */
.day { margin-bottom: 2rem; }
.day-head { display: flex; align-items: baseline; gap: .6rem; margin: 0 0 .7rem; font-size: 1rem; }
.day-name { font-weight: 700; }
.day-date { color: var(--muted); font-weight: 500; }
.day-count { margin-left: auto; font-size: .8rem; color: var(--muted); font-weight: 500; }

.rows {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.row {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto auto; gap: 1.1rem; align-items: start;
  padding: 1.05rem 1.15rem; scroll-margin-top: 1.5rem;
}
.row + .row { border-top: 1px solid var(--line); }
.row:first-child { border-radius: var(--r-lg) var(--r-lg) 0 0; }
.row:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.row:only-child { border-radius: var(--r-lg); }
.row.is-next { background: var(--next-soft); box-shadow: inset 3px 0 0 var(--next); }
.row:target { box-shadow: inset 3px 0 0 var(--accent); background: var(--accent-soft); }

.row-time { display: grid; gap: .15rem; font-weight: 600; font-variant-numeric: tabular-nums; padding-top: .05rem; }
.row-date { font-size: .8rem; font-weight: 500; color: var(--muted); }
.next-tag { font-size: .72rem; font-weight: 700; color: var(--next); }

.row-main { display: grid; gap: .5rem; min-width: 0; }
.row-text { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; line-height: 1.55; }
.row-link { display: inline-flex; align-items: center; gap: .35rem; width: fit-content; max-width: 100%; font-size: .85rem; text-decoration: none; color: var(--accent); }
.row-link .i { width: 14px; height: 14px; }
.row-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-link:hover span { text-decoration: underline; }
.row-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--line); }
.row-actions { display: flex; gap: .15rem; align-items: center; }
.row-actions form { margin: 0; }
.row-error { font-size: .84rem; color: var(--bad); background: var(--bad-soft); padding: .45rem .65rem; border-radius: var(--r-sm); overflow-wrap: anywhere; }

.statuses { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.status {
  display: inline-flex; align-items: center; gap: .4rem; height: 28px; padding: 0 .55rem 0 .3rem;
  border: 1px solid var(--line); border-radius: 999px; font-size: .8rem; font-weight: 500; background: var(--surface);
}
.status .pb { width: 18px; height: 18px; border-radius: 50%; font-size: .56rem; }
.status-text { color: var(--muted); }
.status-text::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin: 0 .35rem .1rem .1rem; }
.status.is-done .status-text { color: var(--good); }
.status.is-failed { border-color: transparent; background: var(--bad-soft); }
.status.is-failed .status-text { color: var(--bad); }
.status.is-publishing .status-text { color: var(--warn); }

/* Empty states ---------------------------------------------------------- */
.empty {
  display: grid; justify-items: center; text-align: center; gap: .6rem;
  padding: 3.5rem 1.5rem; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
}
.empty h2 { font-size: 1.1rem; }
.empty p { color: var(--muted); max-width: 44ch; margin-bottom: .5rem; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.empty-icon.is-good { background: var(--good-soft); color: var(--good); }
.empty-icon .i { width: 22px; height: 22px; }

/* Calendar -------------------------------------------------------------- */
.cal {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden;
}
.cal-day { min-height: 420px; display: flex; flex-direction: column; min-width: 0; }
.cal-day + .cal-day { border-left: 1px solid var(--line); }
.cal-day.is-past { background: var(--surface-2); }
.cal-head { display: flex; align-items: center; gap: .4rem; padding: .7rem .7rem .6rem; border-bottom: 1px solid var(--line); }
.cal-dow { font-size: .8rem; color: var(--muted); font-weight: 500; }
.cal-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-day.is-today .cal-num { background: var(--accent); color: var(--accent-ink); border-radius: 999px; min-width: 26px; height: 26px; display: inline-grid; place-items: center; padding: 0 .35rem; }
.cal-head .icon-btn { margin-left: auto; width: 28px; height: 28px; }
.cal-head .icon-btn .i { width: 16px; height: 16px; }
.cal-list { list-style: none; margin: 0; padding: .5rem; display: grid; gap: .4rem; align-content: start; }

.chip {
  display: grid; gap: .3rem; width: 100%; text-align: left; font: inherit; color: var(--ink); text-decoration: none; cursor: pointer;
  padding: .5rem .55rem; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); border-left: 3px solid var(--accent);
}
.chip:hover { border-color: var(--line-strong); border-left-color: var(--accent); box-shadow: var(--shadow); }
.chip.is-published { border-left-color: var(--good); opacity: .85; }
.chip.is-failed { border-left-color: var(--bad); background: var(--bad-soft); }
.chip-top { display: flex; align-items: center; justify-content: space-between; gap: .3rem; font-size: .76rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip-badges { display: inline-flex; gap: 2px; }
.chip-badges .pb { width: 15px; height: 15px; border-radius: 4px; font-size: .48rem; }
.chip-text { font-size: .8rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

.cal-legend { display: flex; align-items: center; gap: .45rem; margin-top: .9rem; font-size: .8rem; color: var(--muted); }
.lg { width: 10px; height: 10px; border-radius: 3px; margin-left: .6rem; }
.lg:first-child { margin-left: 0; }
.lg.is-queue { background: var(--accent); }
.lg.is-published { background: var(--good); }
.lg.is-failed { background: var(--bad); }

/* Composer dialog ------------------------------------------------------- */
.composer {
  width: min(980px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem);
  padding: 0; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
}
.composer::backdrop { background: rgba(8, 22, 25, .5); }
.composer[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.composer form { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }

.cmp-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.cmp-head h2 { font-size: 1.1rem; letter-spacing: -.01em; }
.cmp-errors { margin: 1rem 1.25rem 0; padding: .7rem .9rem; border-radius: var(--r-sm); background: var(--bad-soft); color: var(--bad); font-size: .88rem; display: grid; gap: .25rem; }

.cmp-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); min-height: 0; overflow-y: auto; }
.cmp-edit { display: grid; gap: 1.1rem; align-content: start; padding: 1.25rem; }
.cmp-preview { background: var(--surface-2); border-left: 1px solid var(--line); padding: 1.25rem; display: grid; gap: .8rem; align-content: start; }

.channels { border: 0; padding: 0; margin: 0; display: grid; gap: .45rem; }
.channel-list { display: flex; flex-wrap: wrap; gap: .45rem; }
.channel {
  position: relative; display: inline-flex; align-items: center; gap: .45rem; cursor: pointer;
  height: 36px; padding: 0 .75rem 0 .45rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); font-size: .88rem; font-weight: 500;
  user-select: none;
}
.channel input { position: absolute; opacity: 0; pointer-events: none; }
.channel .pb { border-radius: 50%; filter: grayscale(1); opacity: .55; }
.channel:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.channel:has(input:checked) .pb { filter: none; opacity: 1; }
.channel:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.channel.is-disabled { cursor: not-allowed; opacity: .45; border-style: dashed; }
.channel.is-over { border-color: var(--bad); background: var(--bad-soft); }
.channel.is-warn { border-color: var(--warn); background: var(--warn-soft); }

.counts { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-top: -.6rem; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.counts .is-over { color: var(--bad); font-weight: 600; }

.media-pick {
  position: relative; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: .55rem;
  padding: .8rem .9rem; border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  cursor: pointer; color: var(--ink-2); font-weight: 500; font-size: .9rem;
}
.media-pick .opt { font-size: .8rem; justify-self: end; }
.media-pick:hover { border-color: var(--accent); color: var(--ink); background: var(--surface-2); }
.media-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.media-preview { display: flex; gap: .9rem; align-items: center; }
.media-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--line); }
.media-actions { display: flex; gap: .4rem; }

.pv-tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.pv-tab {
  display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-size: .82rem; font-weight: 500; cursor: pointer;
  height: 30px; padding: 0 .6rem 0 .35rem; border-radius: var(--r-sm); border: 1px solid transparent; background: none; color: var(--muted);
}
.pv-tab .pb { width: 18px; height: 18px; border-radius: 50%; font-size: .55rem; }
.pv-tab[aria-selected="true"] { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: var(--shadow); }
.pv-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem; display: grid; gap: .75rem; box-shadow: var(--shadow); }
.pv-head { display: flex; gap: .6rem; align-items: center; font-size: .9rem; }
.pv-head > span:last-child { display: grid; line-height: 1.3; }
.pv-when { font-size: .78rem; color: var(--muted); }
.pv-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; line-height: 1.55; min-height: 1.5em; }
.pv-text .pv-url { color: var(--accent); }
.pv-text.is-empty { color: var(--muted); font-style: italic; }
.pv-image { border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.pv-image img { width: 100%; max-height: 300px; object-fit: cover; }
.pv-image.is-missing { display: grid; place-items: center; height: 160px; color: var(--muted); font-size: .85rem; border-style: dashed; }
.pv-head { order: -2; }
.pv-card.is-instagram .pv-image { order: -1; }
.pv-linkcard { display: flex; align-items: center; gap: .5rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); font-size: .84rem; color: var(--ink-2); }
.pv-linkcard span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-note { font-size: .8rem; color: var(--muted); }

.cmp-foot {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .9rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface);
  border-radius: 0 0 16px 16px;
}
.when { position: relative; display: block; }
.when .i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.when .input { padding-left: 2.2rem; height: 38px; width: auto; }
.tz { font-size: .8rem; color: var(--muted); }
.spacer { flex: 1; }

/* Toasts ---------------------------------------------------------------- */
.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 50; display: grid; gap: .5rem; width: min(380px, calc(100vw - 2.5rem)); }
.toast {
  display: flex; align-items: flex-start; gap: .6rem; padding: .75rem .6rem .75rem .9rem;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); font-size: .9rem; animation: pop .18s ease-out;
}
.toast p { flex: 1; padding-top: .05rem; }
.toast > .i { margin-top: .1rem; }
.toast-ok > .i { color: var(--good); }
.toast-error { border-color: var(--bad); }
.toast-error > .i { color: var(--bad); }
.toast .icon-btn { width: 26px; height: 26px; margin-top: -.15rem; }
.toast .icon-btn .i { width: 15px; height: 15px; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }

.fab { display: none; }

/* Small shared bits ----------------------------------------------------- */
.link-btn { font: inherit; font-size: .82rem; font-weight: 600; color: var(--accent); background: none; border: 0; padding: .2rem 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.select {
  font: inherit; font-size: .82rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); height: 30px; padding: 0 .5rem; max-width: 12rem;
}
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.tpl-tools { display: inline-flex; align-items: center; gap: .75rem; }
.text-meta { display: grid; gap: .3rem; margin-top: -.6rem; }
.text-meta .counts { margin-top: 0; }
.blanks { font-size: .8rem; color: var(--warn); background: var(--warn-soft); padding: .35rem .6rem; border-radius: var(--r-sm); width: fit-content; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85rem; }
.help { font-size: .8rem; color: var(--muted); }
.tag { font-size: .7rem; font-weight: 600; color: var(--warn); background: var(--warn-soft); padding: .05rem .4rem; border-radius: 4px; margin-left: .35rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.actions-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.form-stack { display: grid; gap: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 1.25rem; }
.panel-title { display: flex; align-items: center; gap: .4rem; font-size: 1rem; }
.panel-title .opt { font-size: .85rem; font-weight: 400; }

.banner {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem;
  padding: .8rem 1rem; border-radius: var(--r-md); background: var(--warn-soft); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.banner > .i { color: var(--warn); }
.banner p { flex: 1; font-size: .9rem; }

/* Settings -------------------------------------------------------------- */
.settings-section { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 2rem; padding: 1.75rem 0; border-top: 1px solid var(--line); scroll-margin-top: 1rem; }
.settings-section:first-of-type { border-top: 0; padding-top: 0; }
.section-head h2 { font-size: 1.05rem; margin-bottom: .35rem; }
.section-head p { font-size: .88rem; color: var(--muted); }

.acct-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.acct-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 1.1rem; display: grid; gap: .8rem; align-content: start; scroll-margin-top: 1rem; }
.acct-card:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.acct-head { display: flex; align-items: center; gap: .7rem; }
.acct-head .pb { width: 36px; height: 36px; border-radius: 10px; font-size: .85rem; }
.acct-title h3 { font-size: 1rem; }
.acct-status { font-size: .84rem; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.acct-card.is-on .acct-status { color: var(--good); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.dot.on { background: var(--good); }
.acct-desc { font-size: .86rem; color: var(--ink-2); }
.acct-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.acct-actions form { margin: 0; }
.manual { border-top: 1px solid var(--line); padding-top: .7rem; }
.manual summary { font-size: .84rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.manual summary:hover { color: var(--ink); }
.manual[open] summary { margin-bottom: .9rem; }

.app-blocks { display: grid; gap: 1rem; }
.steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .35rem; font-size: .86rem; color: var(--ink-2); max-width: 70ch; }
.steps em { font-style: normal; font-weight: 600; color: var(--ink); }
.copy-row { display: flex; gap: .5rem; }
.copy-row .input { background: var(--surface-2); }

/* Account lists --------------------------------------------------------- */
.acct-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-md); }
.acct-list li { display: flex; align-items: center; gap: .4rem; padding: .5rem .5rem .5rem .75rem; }
.acct-list li + li { border-top: 1px solid var(--line); }
.acct-list form { margin: 0; }
.acct-li-name { flex: 1; min-width: 0; display: grid; font-weight: 500; font-size: .9rem; overflow-wrap: anywhere; }
.acct-li-name .help { font-weight: 400; font-size: .76rem; }
.add-acct .i { width: 16px; height: 16px; }
.acct-more { padding-left: .2rem; font-size: .82rem; }
.dup-warning { font-size: .8rem; color: var(--warn); background: var(--warn-soft); padding: .45rem .65rem; border-radius: var(--r-sm); margin-top: .2rem; }
.dup-warning.is-error { color: var(--bad); background: var(--bad-soft); }

/* Choose a Page --------------------------------------------------------- */
.page-group { display: grid; gap: .35rem; }
.page-option.is-child { margin-left: 1.75rem; }
.page-option .pb { width: 24px; height: 24px; border-radius: 7px; font-size: .62rem; }
.choose { max-width: 640px; }
.page-list { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; }
.page-option { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); cursor: pointer; }
.page-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.page-option input { accent-color: var(--accent); width: 18px; height: 18px; }
.page-info { display: grid; gap: .15rem; }
.page-info span { display: inline-flex; align-items: center; gap: .35rem; font-size: .84rem; color: var(--muted); }
.page-info .pb { width: 16px; height: 16px; font-size: .5rem; border-radius: 4px; }

/* Templates ------------------------------------------------------------- */
.tpl-new { margin-bottom: 1.5rem; max-width: 720px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.tpl-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 1.1rem; scroll-margin-top: 1rem; }
.tpl-card:target { border-color: var(--accent); }
.tpl-view { display: grid; gap: .8rem; height: 100%; grid-template-rows: auto 1fr auto; }
.tpl-view .btn { justify-self: start; }
.tpl-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tpl-head h2 { font-size: 1rem; }
.tpl-actions { display: flex; gap: .1rem; }
.tpl-actions form { margin: 0; }
.tpl-body {
  margin: 0; font: inherit; font-size: .88rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-sm); padding: .75rem .85rem;
}
.tpl-body mark { background: var(--warn-soft); color: var(--warn); border-radius: 4px; padding: 0 .15rem; font-weight: 500; }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .cal { grid-template-columns: repeat(7, minmax(120px, 1fr)); overflow-x: auto; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: .5rem; padding: .6rem .9rem;
  }
  .sidebar .brand { margin-right: auto; }
  .new-btn, .accounts, .side-foot .who, .side-foot .avatar { display: none; }
  .side-foot { margin: 0; border: 0; padding: 0; order: 2; }
  .nav { order: 3; width: 100%; display: flex; overflow-x: auto; gap: .25rem; }
  .nav a { height: 34px; flex: none; }
  .nav a .i { display: none; }
  .nav-count { margin-left: .3rem; }
  .main { padding-top: 1.25rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .cmp-body { grid-template-columns: 1fr; }
  .settings-section { grid-template-columns: 1fr; gap: 1rem; }
  .acct-grid { grid-template-columns: 1fr; }
  .cmp-preview { border-left: 0; border-top: 1px solid var(--line); }
  .fab {
    display: grid; place-items: center; position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 20;
    width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-pop);
  }
  .fab .i { width: 24px; height: 24px; }
  .toasts { bottom: 5.5rem; }
}
@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: flex-start; }
  .row { grid-template-columns: minmax(0, 1fr) auto; gap: .6rem .9rem; }
  .row-time { grid-column: 1; grid-row: 1; display: flex; gap: .5rem; align-items: baseline; }
  .row-main { grid-column: 1; grid-row: 2; }
  .row:not(:has(.row-thumb)) .row-main { grid-column: 1 / -1; }
  .row-thumb { grid-column: 2; grid-row: 1 / span 2; width: 56px; height: 56px; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: .5rem; }
  .cal { display: grid; grid-template-columns: 1fr; overflow: visible; }
  .cal-day { min-height: 0; }
  .cal-day + .cal-day { border-left: 0; border-top: 1px solid var(--line); }
  .composer { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .composer form { max-height: 100dvh; height: 100%; }
  .cmp-body { flex: 1; }
  .cmp-foot { border-radius: 0; }
  .when .input { width: 100%; }
  .when { flex: 1 1 100%; }
  .tz { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
