/* ============================================================
   APEX DESIGN SYSTEM — refined dark theme (Linear/Vercel style)
   Layered near-black surfaces, subtle borders, Inter type.
   Appended last so these rules win the cascade.
   ============================================================ */
:root {
  /* Pure black ground. Every surface and border below sits one step darker than it
     did on the old #000 ground, so each keeps the same lift above the page. */
  --bg: #000000;
  --surface-1: #151518;
  --surface-card: #060608;
  --surface-row: #161619;
  --surface-pop: #1c1c20;
  --surface-2: #1a1a1d;
  --surface-3: #212125;
  --border: #26262b;
  --border-panel: #1f1f23;
  --border-strong: #313138;
  --text-1: #ededf0;
  --text-2: #a1a1aa;
  --text-3: #7e7e8a;
  --accent: #22c55e;
  --accent-bright: #4ade80;
  --accent-soft: rgba(34, 197, 94, 0.14);
  --field-required-border: rgba(34, 197, 94, 0.6);
  --field-required-ring: 0 0 0 2px rgba(34, 197, 94, 0.13);
  --field-required-hover: rgba(34, 197, 94, 0.45);
  --field-optional-border: #1da1f2;
  --field-optional-ring: 0 0 0 2px rgba(29, 161, 242, 0.15);
  --field-optional-hover: rgba(29, 161, 242, 0.45);
  --recess: rgba(0, 0, 0, 0.2);
  --blue: #4d9fff;
  --danger: #ef4444;
  /* Gold is for what's special: priority, favourite, pinned, premium, badges. Anything
     middling or needing a look (a fair rate, a partly kept rule, a checkup coming up) is
     orange, so a gold mark never reads as a warning. */
  --gold: #eab308;
  --gold-bright: #fbbf24;
  --warn: #f97316;
  --warn-bright: #fb923c;
  --tray-edge: color-mix(in srgb, #6b7280 22%, transparent);
  --danger-bright: #f87171;
  --milestone: #f472b6;
  --cat-hairline: 10%;
  --cat-toplight: 0.025;
  --sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.030), rgba(255, 255, 255, 0.008));
  --hairline: rgba(255, 255, 255, 0.035);
  --hairline-strong: rgba(255, 255, 255, 0.05);
  --inset-light: rgba(255, 255, 255, 0.045);
  --danger-soft: rgba(239, 68, 68, 0.1);
  --danger-line: rgba(239, 68, 68, 0.4);
  --fs-9: 9px;
  --fs-10: 10px;
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-16: 16px;
  --fs-18: 18px;
  --fs-20: 20px;
  --fs-22: 22px;
  --fs-24: 24px;
  --dur-fast: 0.12s;
  --dur-base: 0.2s;
  --dur-slow: 0.32s;
  --rate-bad: #dc3545;
  --rate-mid: var(--warn);
  --rate-good: #22c55e;
  --rate-none: #6b7280;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.5), 0 10px 28px rgba(0, 0, 0, 0.45);
  --proc-line: var(--border-panel);
  --proc-surface: var(--surface-card);
  --proc-well: var(--bg);
  --proc-field: var(--surface-2);
  --proc-field-line: var(--border-strong);
  --proc-accent: #22c55e;
  --proc-accent-well: #0a2010;
  --proc-ink: var(--text-1);
  --proc-ink-dim: var(--text-3);
  --proc-ink-faint: #63636d;
  --proc-measure: 500px;
  --proc-step-gap: 2.5rem;
  --sections-chrome: calc(var(--sections-rail-w) + 1.25rem + 1px);
  --sections-panel-w: min(calc(var(--sections-chrome) + var(--proc-measure)), 92vw);
  --sections-rail-w: 52px;
  --row-near: rgba(34, 197, 94, 0.45);
  --row-done: #22c55e;
  --row-published: rgba(34, 197, 94, 0.22);
  --row-favorite: var(--gold-bright);
  --row-overdue: var(--danger-bright);
  --dash-chip-row: 19px;
  --sidebar-nav-w: 230px;
  --sidebar-col: clamp(275px, 25vw, 480px);
  /* The nav runs right up to the column's edge, beside the page. */
  --sidebar-pad-right: 0px;
  --sidebar-pad-left: max(12px, calc(var(--sidebar-col) - var(--sidebar-nav-w) - var(--sidebar-pad-right)));
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background-color: #000;
}

/* Thin, quiet scrollbars.

   These were briefly set to fade in on container hover, which does not work in
   WebKit: scrollbar pseudo-elements are not restyled when an ANCESTOR's :hover
   changes, so `:hover::-webkit-scrollbar-thumb` never fires and the thumb stayed
   invisible. `::-webkit-scrollbar-thumb:hover` - pointing at the thumb itself -
   does work, but it is unreachable if the thumb is transparent to begin with.
   So the thumb is always present, just quieter than it was, and brightens when
   pointed at directly. */
* { scrollbar-width: thin; scrollbar-color: var(--surface-row) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-row); border-radius: var(--radius-xs); }
::-webkit-scrollbar-thumb:hover { background: #3a3a42; }

::selection { background: rgba(34, 197, 94, 0.3); }

/* ---------- Sidebar shell ---------- */

#app-sidebar {
  /* height:100dvh is a content-box height without this, so the 1rem padding pushed the
     border box to 100dvh+32px. Harmless while the sidebar was position:fixed; once it
     moved into flow it made the whole page scroll 32px. */
  box-sizing: border-box;
  background-color: #000 !important;
  /* Sidebar and main share one black; the hairline is what separates them. */
  border-right: 1px solid #2f3336;
  --x-hover: rgba(231, 233, 234, 0.1);
}

/* ---- Full-width sidebar, after X's ----
   Big icon-and-label rows in one near-white, the page you're on in bold, each lit as a
   pill hugging its content on hover. One rule per row: the word goes to the page, the +
   on the right makes one. The + stays hidden until the row is hovered or focused, and is
   always shown on the row you're on and on touch screens, which have no hover. */
/* The column is a quarter of the window, within 275–480px; the nav inside stays 230px
   wide against its right edge, so the extra width is empty space on the far left. */
/* The phone drawer is the nav alone, filling it: none of the wide-screen column's
   empty space. */
@media (max-width: 819px) {
  :root { --sidebar-col: 275px; --sidebar-nav-w: 251px; --sidebar-pad-right: 12px; }
}
.sidebar-header { display: flex; align-items: center; padding: 6px 0 10px; }
.sidebar-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 0;
}
.sidebar-row-links {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
#app-sidebar .sidebar-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px 10px 12px;
  border-radius: 9999px;
  color: #e7e9ea;
  font-size: 16px;
  font-weight: 400;
  line-height: 20px;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color var(--dur-fast);
}
#app-sidebar .sidebar-nav-link:hover { background-color: var(--x-hover); text-decoration: none; }
/* The page you're on keeps its pill lit, so it reads at a glance and not just by weight. */
#app-sidebar .sidebar-nav-link.is-current { font-weight: 700; color: #fff; background-color: rgba(231, 233, 234, 0.08); }
#app-sidebar .sidebar-nav-link.is-current:hover { background-color: rgba(231, 233, 234, 0.13); }
/* Fixed-width icon slot so every label starts on the same line. */
.sidebar-row-icon {
  width: 24px;
  margin-right: 16px;
  font-size: 18px;
  text-align: center;
}

/* A hairline between nav groups, inset to the pills' edge. */
.nav-divider {
  height: 1px;
  margin: 8px 16px 8px 12px;
  background-color: #2f3336;
}

/* Something waiting in More (a request, an unread notification): a dot on More, so it's
   seen without opening it. Duels waiting only dot it in rail mode, where the avatar that
   carries them folds into More. */
#sidebar-more-toggle { position: relative; }
.more-dot {
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-radius: 50%;
  background-color: var(--danger);
}
.more-dot.is-rail-only { display: none; }

.sidebar-row-create {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  color: #71767b;
  font-size: var(--fs-13);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--dur-fast), color var(--dur-fast), background-color var(--dur-fast);
}
.nav-row:hover .sidebar-row-create,
.nav-row:focus-within .sidebar-row-create,
.nav-row.is-active .sidebar-row-create { opacity: 1; }
.sidebar-row-create:hover { color: #fff; text-decoration: none; background-color: rgba(231, 233, 234, 0.14); }
/* 1px off the pill's right end, at every width (the phone drawer included). The layout
   gap reads 3px all round, but the rounded end makes 3px at the side look wider than
   above and below, so 1px is what reads as even. */
.sidebar-row-create { margin-right: 1px; }
@media (hover: none) {
  .sidebar-row-create { opacity: 1; }
}
.nav-more { padding: 7px 0; }

/* The pill is the whole row, + included: lit on hover and on the page you're on, so a
   row's + sits inside its pill rather than floating apart from the label. The rows keep
   their spacing as margin, outside the pill, and end where the New button does. */
#app-sidebar .sidebar-row { padding: 0; margin: 7px 0; border-radius: 9999px; transition: background-color var(--dur-fast); }
/* Each row contains its margin, so it doesn't merge with a divider's and the groups keep
   the spacing they had when it was padding. (The icon rail lays its rows out itself.) */
@media (max-width: 819px), (min-width: 1181px) {
  #app-sidebar .nav-row { display: flow-root; }
}
@media (min-width: 820px) {
  #app-sidebar .sidebar-row { margin-right: 16px; }
}
#app-sidebar .sidebar-row:hover { background-color: var(--x-hover); }
#app-sidebar .nav-row.is-active > .sidebar-row { background-color: rgba(231, 233, 234, 0.08); }
#app-sidebar .nav-row.is-active > .sidebar-row:hover { background-color: rgba(231, 233, 234, 0.13); }
#app-sidebar .sidebar-row .sidebar-nav-link { flex: 1; min-width: 0; }
#app-sidebar .sidebar-row .sidebar-nav-link:hover,
#app-sidebar .sidebar-row .sidebar-nav-link.is-current { background-color: transparent; }
/* More, which isn't a .sidebar-row, gets the same full-width pill on its own link. */
#app-sidebar #sidebar-more-toggle { display: flex; }
@media (min-width: 820px) {
  #app-sidebar #sidebar-more-toggle { margin-right: 16px; }
}
/* The page you're on: its icon in the accent, so it reads at a glance, not just by weight. */
#app-sidebar .nav-row.is-active .sidebar-row-icon { color: var(--accent-bright); }

/* More's menu, in the rows' terms: an icon in a fixed slot, and a pill on hover. */
#sidebar-more-dropdown .more-link { display: flex; align-items: center; gap: 12px; margin: 0 6px; padding: 8px 12px; border-radius: 8px; transition: background-color var(--dur-fast); }
#sidebar-more-dropdown .more-link:hover { background-color: var(--x-hover); }
#sidebar-more-dropdown .more-link > i { width: 16px; text-align: center; color: var(--text-3); }
#sidebar-more-dropdown .more-link.is-active > i { color: var(--accent-bright); }
@media (min-width: 820px) and (max-width: 1180px) {
  #sidebar-more-dropdown a.rail-only { display: flex !important; }
}

/* The account, pushed to the foot of the sidebar: a quiet card the width of the New
   button above it, the avatar ringed with badge progress. It opens your profile. */
.sidebar-account {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: auto 16px 14px 0;
  padding: 9px 14px 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  background-color: rgba(255, 255, 255, 0.025);
  color: #e7e9ea;
  text-decoration: none;
  transition: background-color var(--dur-fast), border-color var(--dur-fast);
}
.sidebar-account:hover { background-color: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.1); text-decoration: none; }
.sidebar-account.is-active { border-color: rgba(255, 255, 255, 0.14); }
/* Badge progress: an arc in the avatar's own hue over a faint full track, cut to a ring
   by a mask so the gap shows whatever the card behind it is painting. */
.sidebar-account-ring { position: relative; display: inline-flex; flex-shrink: 0; padding: 4px; border-radius: 50%; }
.sidebar-account-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(hsl(var(--soc-hue) 65% 62%) var(--ring), rgba(255, 255, 255, 0.1) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
}
.sidebar-account-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; line-height: 20px; letter-spacing: -0.01em; }
.sidebar-account-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sidebar-account-sub { font-size: var(--fs-11); font-weight: 400; line-height: 14px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Tighter rows at every height on desktop. These used to apply only to windows 820px
   tall or less, so a taller window got 54px rows to a short one's 40px: the same
   sidebar looked loosely spaced on a big screen. The phone's drawer keeps its own. */
@media (min-width: 820px) {
  #app-sidebar .sidebar-row { margin-top: 2px; margin-bottom: 2px; }
  .nav-more { padding: 2px 0; }
  #app-sidebar .sidebar-nav-link { padding-top: 8px; padding-bottom: 8px; }
  .nav-divider { margin-top: 5px; margin-bottom: 5px; }
  .sidebar-account { padding-top: 7px; padding-bottom: 7px; }
}

/* Rows a short window can't fit, moved up into More (fitSidebar): the same icon and
   name, above More's own links and set off from them. */
#app-sidebar .nav-row.is-overflowed, #app-sidebar .nav-divider.is-overflowed { display: none !important; }
.sidebar-more-overflow { padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.sidebar-more-overflow[hidden] { display: none; }
.sidebar-more-overflow .more-link { display: flex; align-items: center; gap: 10px; }
.sidebar-more-overflow .more-link i { width: 16px; color: var(--text-3); text-align: center; }

/* The New button's form switcher (openComposeSwitcher): across the top of the screen,
   over whichever form is open, one tab per kind. */
/* The create popup's switcher: small tabs just under its header, inside the card — every
   kind in view, five to a row and centred (a ninth or tenth starts a second row, also
   centred), rather than one row scrolled so Task fell off its left edge. The one open is
   a quiet green. */
.compose-switcher {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 8px 12px;
  border-bottom: 1px solid var(--border-panel); background: var(--recess);
}
.compose-switcher button {
  display: inline-flex; flex: 0 0 calc((100% - 16px) / 5); justify-content: center; align-items: center; gap: 6px; padding: 5px 6px; box-sizing: border-box;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--text-3);
  font: inherit; font-size: var(--fs-12); white-space: nowrap; cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.compose-switcher button i { font-size: var(--fs-11); }
.compose-switcher button:hover { background: var(--surface-2); color: var(--text-1); }
.compose-switcher button.is-active { border-color: rgba(34, 197, 94, 0.35); background: var(--accent-soft); color: var(--accent-bright); }
/* Every sidebar form opens the same way: at the top, 520px wide (a note's writing space
   wider), so switching between them doesn't make the card jump about. */
[id^="sidebar-new-"][id$="-modal"] { align-items: flex-start !important; overflow-y: auto; }
[id^="sidebar-new-"][id$="-modal"]:not(#sidebar-new-note-modal) > * { max-width: 520px !important; }

#sidebar-more-dropdown {
  background-color: var(--surface-pop) !important;
  background-image: var(--sheen);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-card) !important;
}

/* ---------- Home layout ---------- */
/* transparent, not --bg: the body/canvas paints the same colour plus the wash */
#home-container { background: transparent; }
/* Home is exactly one screen tall and only its columns scroll, so the page itself never
   should. Anything that briefly hangs past the bottom (a dropdown or tooltip parented to
   <body>) would otherwise give the window a scrollbar of its own. On html, not body:
   body carries an inline `overflow: auto`, and html's value is the one the viewport takes. */
html:has(#home-container) { overflow: hidden; }

/* Date separators in the daily column — quieter, more editorial */
.date-separator {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  margin: 0 0 14px;
  padding: 0.5rem 0.5rem 0;
  border-radius: 0.25rem;
  height: auto;
  text-align: center;
  font-weight: bold;
  color: var(--text-1);
  font-size: var(--fs-14);
  letter-spacing: 0.02em;
}
.date-title-line { display: flex; align-items: center; justify-content: center; }

/* Task rows light up a little under the pointer, in both columns, as the landing page's
   picture of Home does. On the cells, not the row: the row's tint is inline
   (TasksHelper#task_row_background), which a row rule can't outrank, so lifting the row
   itself never showed. A block's own header and footer rows stay as they are. */
.daily-column tbody tr.task-row:not(.place-task):not(.block-task):not(.block-cancel-row) > td,
.categories-column tbody tr.task-row > td {
  transition: background-color var(--dur-fast, 0.15s) ease;
}
@media (hover: hover) { .daily-column tbody tr.task-row:not(.place-task):not(.block-task):not(.block-cancel-row):hover > td,
.categories-column tbody tr.task-row:hover > td {
  background-color: rgba(255, 255, 255, 0.06);
} }

/* Category / inbox card polish (colors stay dynamic via inline styles) */
.categories-column .category-header {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Empty-state links */
.categories-column a[data-turbo-frame="modal"],
.daily-column a[href*="adding_at_end"] { transition: color var(--dur-fast); }

/* ---------- Buttons & inputs ---------- */

.btn-primary:active { transform: scale(0.98); }

/* ---------- Toasts ---------- */
#toast-container > * {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

/* ---- Sidebar polish ---- */
/* One count pill in the More menu: red for something waiting on you (a request, a duel). */
.more-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; margin-left: auto; padding: 0 5px; box-sizing: border-box; border-radius: 999px; background: var(--surface-3); color: var(--text-1); font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.more-pill.is-action { background: var(--danger); color: #fff; }

/* Rows that spill into More on a short window look like the rows under them, a hairline
   apart. */
#sidebar-more-overflow:not([hidden]) { padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--border-panel); }
#sidebar-more-overflow .sidebar-row, #sidebar-more-overflow .nav-row { margin: 0; padding: 0; list-style: none; }
#sidebar-more-overflow a { display: flex !important; align-items: center; gap: 10px; min-height: 0 !important; padding: 7px 16px !important; color: var(--text-1); font-size: var(--fs-13) !important; font-weight: 400 !important; text-decoration: none; }
#sidebar-more-overflow a i, #sidebar-more-overflow a .sidebar-row-icon { width: 16px; margin: 0 !important; color: var(--text-3); font-size: var(--fs-13) !important; text-align: center; }
#sidebar-more-overflow a:hover { background: rgba(255, 255, 255, 0.05); }
#sidebar-more-overflow .sidebar-row-add, #sidebar-more-overflow [class*="add"] { display: none !important; }
/* A phone's popup is narrower: still five to a row, each tab its icon over a small label,
   so all ten stay in two even rows. */
@media (max-width: 600px) {
  .compose-switcher { gap: 2px; padding: 6px 6px; }
  .compose-switcher button { flex: 0 0 calc((100% - 8px) / 5) !important; flex-direction: column; gap: 3px; padding: 5px 2px; font-size: 10px; }
  .compose-switcher button i { font-size: var(--fs-12); }
}
