/* Project VS styles.
   Design: NotebookLM's layout with an Apple-like finish: one consistent set of colors, type sizes,
   corner radii, shadows and motion (the tokens on :root). Use the tokens instead of new values,
   so every screen keeps feeling like the same product.

   Two layouts, switched at 860px:
     Computer (861px and up): expansive. Grids, side-by-side panels, search/sort, full toolbar.
     Phone (860px and below): practical. Grouped lists, one thing at a time, bottom tabs, big "+".
   Helpers: .wide-only shows only on computers, .phone-only only on phones. */

:root {
  /* Colors (Apple's system neutrals) */
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f3;                 /* fills: search boxes, segmented controls */
  --surface-raised: #ffffff;            /* dialogs */
  --glass: rgb(245 245 247 / 0.72);     /* translucent bars and menus (with backdrop blur) */
  --glass-menu: rgb(255 255 255 / 0.82);
  --hover: rgb(0 0 0 / 0.045);
  --press: rgb(0 0 0 / 0.08);
  --text: #1d1d1f;
  --text-2: #424245;
  --muted: #86868b;
  --separator: rgb(0 0 0 / 0.09);
  --border-strong: rgb(0 0 0 / 0.16);
  --accent: #0071e3;
  --accent-text: #0066cc;
  --on-accent: #ffffff;
  --accent-soft: rgb(0 113 227 / 0.10);
  --success: #1f8a3b;
  --success-soft: rgb(52 199 89 / 0.15);
  --warning: #b25000;
  --danger: #d70015;
  --danger-soft: rgb(255 59 48 / 0.12);
  --on-danger: #ffffff;
  --purple: #8944ab;                    /* file-type colors */
  --pink: #d30f45;
  --line-icon: #1d1d1f;                 /* project icons: black lines */

  /* Shadows (soft, layered) */
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 6px rgb(0 0 0 / 0.04);
  --shadow-2: 0 2px 6px rgb(0 0 0 / 0.05), 0 12px 32px rgb(0 0 0 / 0.09);
  --shadow-3: 0 4px 12px rgb(0 0 0 / 0.08), 0 24px 64px rgb(0 0 0 / 0.18);

  /* Shape */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 26px;
  --r-pill: 999px;

  /* Motion: one easing curve everywhere (fast start, soft landing) */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 0.16s;
  --t-med: 0.3s;

  /* Type */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --topbar-h: 60px;
  color-scheme: light;
}

/* Project colors. Each class sets --tint. */
.tint-blue   { --tint: #e6eefb; }
.tint-green  { --tint: #e2f3e7; }
.tint-yellow { --tint: #faf2db; }
.tint-orange { --tint: #fbeadb; }
.tint-pink   { --tint: #fae6ed; }
.tint-purple { --tint: #eee8fa; }
.tint-teal   { --tint: #dff2f1; }
.tint-gray   { --tint: #ececef; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-raised: #2c2c2e;
    --glass: rgb(22 22 23 / 0.72);
    --glass-menu: rgb(44 44 46 / 0.82);
    --hover: rgb(255 255 255 / 0.06);
    --press: rgb(255 255 255 / 0.1);
    --text: #f5f5f7;
    --text-2: #d1d1d6;
    --muted: #98989d;
    --separator: rgb(255 255 255 / 0.1);
    --border-strong: rgb(255 255 255 / 0.2);
    --accent: #0a84ff;
    --accent-text: #409cff;
    --accent-soft: rgb(10 132 255 / 0.2);
    --success: #30d158;
    --success-soft: rgb(48 209 88 / 0.18);
    --warning: #ff9f0a;
    --danger: #ff453a;
    --danger-soft: rgb(255 69 58 / 0.18);
    --purple: #bf5af2;
    --pink: #ff375f;
    --line-icon: #f5f5f7;      /* black lines would vanish on dark tiles */
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.5);
    --shadow-2: 0 2px 8px rgb(0 0 0 / 0.5), 0 12px 32px rgb(0 0 0 / 0.45);
    --shadow-3: 0 24px 64px rgb(0 0 0 / 0.7);
    color-scheme: dark;
  }
  .tint-blue   { --tint: #17243a; }
  .tint-green  { --tint: #15281c; }
  .tint-yellow { --tint: #2c2816; }
  .tint-orange { --tint: #312418; }
  .tint-pink   { --tint: #311f28; }
  .tint-purple { --tint: #241f36; }
  .tint-teal   { --tint: #132a29; }
  .tint-gray   { --tint: #262628; }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-optical-sizing: auto;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; letter-spacing: inherit; }
input, textarea { font: inherit; letter-spacing: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
a { color: var(--accent-text); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* Material Symbols icon: <span class="ms">name</span> */
.ms {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: 'liga';
  font-variation-settings: 'wght' 350;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  flex-shrink: 0;
}
/* Project icons: thin, monochrome line drawings. */
.ms-line { font-variation-settings: 'wght' 250; color: var(--line-icon); }

.spacer { flex: 1; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.warn { color: var(--danger); }
.count { margin-left: 6px; font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.list-empty { margin: 20px 8px; color: var(--muted); text-align: center; grid-column: 1 / -1; }

@media (max-width: 860px) { .wide-only { display: none !important; } }
@media (min-width: 861px) { .phone-only { display: none !important; } }

/* A thin progress bar. Set the inner span's width. */
.meter {
  display: block;
  height: 4px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--text) 9%, transparent);
}
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width var(--t-med) var(--ease); }
.meter-lg { height: 6px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: var(--r-pill);
  background: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn .ms { font-size: 18px; margin-left: -4px; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-sm .ms { font-size: 16px; }
.btn-filled { background: var(--accent); color: var(--on-accent); }
.btn-filled:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-inverse { background: var(--text); color: var(--bg); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-tonal { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--separator); }
.btn-tonal:hover { background: var(--hover); }
.btn-text { color: var(--accent-text); padding: 0 12px; }
.btn-text:hover { background: var(--accent-soft); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-2);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--hover); }
.icon-btn:active { background: var(--press); transform: scale(0.94); }

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--muted);
  transition: box-shadow var(--t-fast) var(--ease);
}
.search-box .ms { font-size: 18px; }
.search-box:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.search-box input { flex: 1; min-width: 0; border: none; outline: none; background: none; color: var(--text); }
.search-box input::placeholder { color: var(--muted); }

/* Floating "+" button (phone): big and thumb-friendly. */
.fab {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 56px;
  height: 56px;
  padding: 0 16px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
.fab:active { transform: scale(0.94); }
.fab .ms { font-size: 26px; }
.fab-extended { padding: 0 22px 0 16px; }
.fab-page { position: fixed; right: 20px; bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--topbar-h);
  padding: 0 16px;
  flex-shrink: 0;
}
/* Home: stays at the top while scrolling, frosted like macOS / iOS bars. */
.topbar-glass {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 var(--separator);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  border-radius: var(--r-sm);
}
.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #4285f4, #9b72cb 55%, #d96570);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.03em;
  box-shadow: inset 0 0 0 0.5px rgb(255 255 255 / 0.3);
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: none;
  border-radius: var(--r-pill);
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  cursor: default;
}
.save-status .ms { font-size: 17px; }
.save-status[data-spin="true"] .ms { animation: spin 1.2s linear infinite; }
.save-status[data-attention="true"] { color: var(--danger); }
.save-status[data-cloud="signin"] { cursor: pointer; background: var(--danger-soft); }
@keyframes spin { to { transform: rotate(-360deg); } }

.finished-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.finished-pill[hidden] { display: none; }
.finished-pill .ms { font-size: 16px; }

.account-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #9b72cb);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Splash (cinematic loading screen) ---------- */

.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 115%, #1b1238 0%, #050608 62%);
  color: #fff;
}
.splash::after { /* vignette */
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgb(0 0 0 / 0.55) 100%);
  pointer-events: none;
}

/* Slow-drifting colored light behind everything. */
.splash-orb {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  mix-blend-mode: screen;
  animation: drift 14s ease-in-out infinite alternate, orb-in 1.6s ease both;
}
.orb-1 { top: -28vmax; left: -18vmax; background: #4285f4; }
.orb-2 { bottom: -32vmax; right: -22vmax; background: #9b72cb; animation-delay: -5s, 0s; }
.orb-3 { top: 35%; left: 58%; width: 34vmax; height: 34vmax; background: #d96570; opacity: 0.3; animation-delay: -9s, 0s; }
@keyframes drift { to { transform: translate(7vmax, 5vmax) scale(1.15); } }
@keyframes orb-in { from { opacity: 0; } }

.splash-center {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  text-align: center;
}

.splash-logo {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  overflow: hidden;
  border-radius: 26px;
  background: linear-gradient(135deg, #4285f4, #9b72cb 55%, #d96570);
  font: 700 34px var(--font);
  letter-spacing: -0.04em;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.18), 0 24px 70px rgb(155 114 203 / 0.5);
  animation: logo-in 1.1s var(--ease) both;
}
.splash-logo::after { /* a sweep of light across the logo */
  content: '';
  position: absolute;
  inset: -50%;
  background: linear-gradient(115deg, transparent 40%, rgb(255 255 255 / 0.55) 50%, transparent 60%);
  transform: translateX(-100%);
  animation: shine 1.4s 0.7s ease-in-out both;
}
@keyframes logo-in { from { opacity: 0; transform: scale(0.6) translateY(14px); filter: blur(14px); } }
@keyframes shine { to { transform: translateX(100%); } }

.splash-title {
  margin: 28px 0 6px;
  font: 600 40px var(--font);
  letter-spacing: -0.035em;
  background: linear-gradient(90deg, #ffffff, #c9d6ff 50%, #ffffff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-in 1.3s 0.35s var(--ease) both;
}
@keyframes title-in { from { opacity: 0; letter-spacing: 0.4em; filter: blur(8px); } }

.splash-tagline {
  margin: 0;
  color: rgb(255 255 255 / 0.6);
  font-size: 15px;
  letter-spacing: 0.01em;
  animation: fade-up 0.9s 0.95s ease both;
}
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } }

/* Loading line, then (same spot) the Enter button. */
.splash-progress {
  width: 140px;
  height: 2px;
  margin-top: 44px;
  overflow: hidden;
  border-radius: 2px;
  background: rgb(255 255 255 / 0.12);
  animation: fade-up 0.6s 1.1s ease both;
  transition: opacity 0.3s ease;
}
.splash-progress span {
  display: block;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  animation: sweep 1.2s 1.1s ease-in-out infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.splash.is-ready .splash-progress,
.splash.show-auth .splash-progress { display: none; }

.splash-enter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  margin-top: 30px;
  padding: 0 30px 0 34px;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: var(--r-pill);
  background: rgb(255 255 255 / 0.1);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: #fff;
  font: 500 16px var(--font);
  letter-spacing: 0.01em;
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.35), inset 0 1px 0 rgb(255 255 255 / 0.15);
  cursor: pointer;
  animation: enter-in 0.7s var(--ease) both;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), border-color var(--t-fast);
}
.splash-enter[hidden] { display: none; }
.splash-enter:hover { background: rgb(255 255 255 / 0.18); border-color: rgb(255 255 255 / 0.35); }
.splash-enter:hover svg { transform: translateX(3px); }
.splash-enter:active { transform: scale(0.96); }
.splash-enter svg { transition: transform var(--t-fast) var(--ease); }
.splash-enter:focus-visible { outline: 2px solid rgb(255 255 255 / 0.7); outline-offset: 4px; }
@keyframes enter-in { from { opacity: 0; transform: translateY(10px) scale(0.96); filter: blur(6px); } }

.splash-auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 36px;
  animation: fade-up 0.6s ease both;
}
.splash-auth[hidden] { display: none; }
.signin-btn { /* "Sign in with Google" on the loading screen */
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: var(--r-pill);
  background: #ffffff;
  color: #1d1d1f;
  font: 500 15px var(--font);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.35);
  cursor: pointer;
}
.signin-btn:disabled { opacity: 0.7; cursor: progress; }
.splash-link {
  padding: 6px 10px;
  border: none;
  background: none;
  color: rgb(255 255 255 / 0.75);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.splash-note { max-width: 300px; margin: 4px 0 0; color: rgb(255 255 255 / 0.5); font-size: 12px; }

/* Exit: the title lifts and blurs away, the light blooms, the screen dissolves, the app rises in. */
.splash.is-leaving { pointer-events: none; animation: splash-out 0.75s 0.35s var(--ease) forwards; }
.splash.is-leaving .splash-center { animation: center-out 0.6s var(--ease) forwards; }
.splash.is-leaving .splash-orb { animation: orb-bloom 1.1s var(--ease) forwards; }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }
@keyframes center-out { to { opacity: 0; transform: translateY(-18px) scale(1.06); filter: blur(10px); } }
@keyframes orb-bloom { to { transform: scale(1.7); opacity: 0.85; } }

#app.app-entering { animation: app-in 0.9s 0.4s var(--ease) both; }
@keyframes app-in { from { opacity: 0; transform: scale(0.97); filter: blur(8px); } }

@media (prefers-reduced-motion: reduce) {
  .splash, .splash *, #app.app-entering { animation: none !important; }
  .splash.is-leaving { opacity: 0; transition: opacity 0.3s; }
  .save-status .ms { animation: none !important; }
}

/* Smooth cross-fade between screens (View Transitions, see route() in app.js). */
::view-transition-old(root) { animation: vt-out 0.22s var(--ease) both; }
::view-transition-new(root) { animation: vt-in 0.38s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: scale(0.99); } }
@keyframes vt-in { from { opacity: 0; transform: scale(1.01); } }

/* ---------- Home ---------- */

.home { max-width: 1240px; margin: 0 auto; padding: 0 32px 64px; }

.home-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin: 32px 0 22px;
}
.large-title { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.home-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.home-search { width: 220px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--separator); }

.home-section + .home-section { margin-top: 36px; }
.section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0 0 14px -6px;
  padding: 4px 6px;
  border: none;
  border-radius: var(--r-sm);
  background: none;
  cursor: pointer;
}
.section-toggle:hover { background: var(--hover); }
.section-title { margin: 0; font-size: 20px; font-weight: 600; }
.section-chevron { color: var(--muted); transition: transform var(--t-med) var(--ease); }
.finished-section.is-collapsed .section-chevron { transform: rotate(-90deg); }
.finished-section.is-collapsed .tile-grid { display: none; }

/* Computer tiles: compact, fixed size, same proportions as before (230 × 210). */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 176px);
  gap: 14px;
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 230 / 210;
  padding: 15px 14px 14px;
  border: none;
  border-radius: var(--r-xl);
  background: var(--tint, var(--surface));
  text-align: left;
  cursor: pointer;
  transition: transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease);
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.tile:active { transform: scale(0.98); }
.tile-icon .ms { font-size: 30px; font-variation-settings: 'wght' 200; }
.tile-text { display: flex; flex-direction: column; flex: 1; min-width: 0; margin-top: 10px; }
.tile-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
  display: -webkit-box;   /* at most 2 lines, then "…" */
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-meta { margin: auto 0 0; font-size: 11.5px; color: var(--text-2); opacity: 0.85; }
.tile .meter { margin-top: 7px; }
.tile-menu {
  position: absolute;
  top: 8px;
  right: 6px;
  width: 30px;
  height: 30px;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease), background var(--t-fast);
}
.tile:hover .tile-menu, .tile:focus-within .tile-menu { opacity: 1; }
@media (hover: none) { .tile-menu { opacity: 1; } }
.tile.is-finished { filter: saturate(0.35); }
.tile.is-finished:hover { filter: none; }

.tile-new {
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--separator);
}
.tile-new:hover { background: var(--surface); box-shadow: var(--shadow-2); }
.tile-new-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.tile-new-icon .ms { font-size: 26px; }
.tile-new-label { font-size: 13px; font-weight: 600; color: var(--text-2); }

/* Phone: the same tiles become an iPhone-style grouped list. */
@media (max-width: 860px) {
  .topbar { height: 54px; padding: 0 8px 0 12px; gap: 2px; }
  .brand-name { font-size: 16px; }
  .home { padding: 0 16px 112px; }
  .home-head { margin: 14px 4px 16px; }
  .large-title { font-size: 32px; }
  .home-section + .home-section { margin-top: 28px; }
  .section-toggle { margin-left: 8px; }
  .section-title { font-size: 19px; }
  .tile-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    border-radius: var(--r-lg);
    background: var(--surface);
  }
  .tile {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    aspect-ratio: auto;
    min-height: 68px;
    padding: 10px 6px 10px 14px;
    border-radius: 0;
    background: transparent;
  }
  .tile:hover { transform: none; box-shadow: none; }
  .tile:active { transform: none; background: var(--press); }
  .tile:not(.tile-new) ~ .tile::before { /* inset hairline separator between rows, like iOS lists */
    content: '';
    position: absolute;
    top: 0;
    left: 68px;
    right: 0;
    height: 0.5px;
    background: var(--separator);
  }
  .tile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 11px;
    background: var(--tint);
  }
  .tile-icon .ms { font-size: 24px; font-variation-settings: 'wght' 250; }
  .tile-text { margin: 0; }
  .tile-title { margin: 0 0 1px; font-size: 16px; font-weight: 500; -webkit-line-clamp: 1; }
  .tile-meta { margin: 0; font-size: 13px; color: var(--muted); opacity: 1; }
  .tile .meter { width: 60%; margin-top: 6px; }
  .tile-menu { position: static; width: 36px; height: 36px; }
}

/* ---------- Project workspace ---------- */

.workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* "dynamic" height: excludes the phone browser's address bar */
}
body:has(.workspace) { overflow: hidden; }

.ws-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  background: var(--tint, transparent);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
.ws-icon:active { transform: scale(0.94); }
.ws-icon .ms { font-size: 21px; }

.title-input {
  flex: 0 1 520px;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.title-input:hover { background: var(--hover); }
.title-input:focus { outline: none; background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }

.panels {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 12px;
  padding: 0 12px 12px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.side-panel { flex: 0 0 290px; }
.side-panel.is-wide { flex-basis: 400px; }
.main-panel { flex: 1 1 auto; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 52px;
  padding: 0 8px 0 18px;
  border-bottom: 0.5px solid var(--separator);
  flex-shrink: 0;
}
.panel-title { flex: 1; margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; }
.panel-head-actions { display: flex; align-items: center; }
.panel-body { flex: 1; min-height: 0; overflow: auto; padding: 14px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 44px 16px;
  text-align: center;
  color: var(--muted);
}
.empty-state > .ms { font-size: 44px; color: var(--muted); font-variation-settings: 'wght' 200; }
.empty-state p { margin: 0; max-width: 260px; }
.empty-state .empty-title { color: var(--text); font-size: 16px; font-weight: 600; }
.empty-state .btn { margin-top: 8px; }

/* Collapsing side panels into a thin rail (computer only). */
@media (min-width: 861px) {
  .side-panel { transition: flex-basis var(--t-med) var(--ease); }
  .side-panel.collapsed { flex-basis: 52px; }
  .side-panel.collapsed .panel-title,
  .side-panel.collapsed .panel-head-actions,
  .side-panel.collapsed .panel-body { display: none; }
  .side-panel.collapsed .panel-head { justify-content: center; padding: 0; border-bottom: none; }
}
@media (min-width: 861px) and (max-width: 1200px) {
  .side-panel:not(.collapsed):not(.is-wide) { flex-basis: 260px; }
  .side-panel.is-wide:not(.collapsed) { flex-basis: 340px; }
}

/* Bottom tabs: hidden on computers, shown on phones. */
.tabbar { display: none; }

@media (max-width: 860px) {
  .title-input { font-size: 16px; padding: 0 6px; }
  .workspace .save-status[data-attention="false"] .save-status-text { display: none; } /* icon only unless it matters */
  .panels { padding: 0 8px 6px; gap: 0; }
  .side-panel, .main-panel, .side-panel.is-wide { flex: 1 1 auto; }
  .side-panel.is-wide .panel-head { display: none; } /* a phase is open: its "‹ Phases" bar is the header */
  .panel { display: none; border-radius: var(--r-lg); }
  .workspace[data-tab="phases"] [data-panel="phases"],
  .workspace[data-tab="notes"] [data-panel="notes"],
  .workspace[data-tab="tools"] [data-panel="tools"] { display: flex; }
  .collapse-btn { display: none; }

  .tabbar {
    display: flex;
    flex-shrink: 0;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    background: var(--glass);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 -0.5px 0 var(--separator);
  }
  .tabbar button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0;
    cursor: pointer;
  }
  .tabbar .ms { font-size: 25px; transition: font-variation-settings var(--t-fast); }
  .tabbar [aria-pressed="true"] { color: var(--accent); }
  .tabbar [aria-pressed="true"] .ms { font-variation-settings: 'wght' 500; }

  /* While typing, hide the tabs so the keyboard leaves more room for text. */
  .workspace:has(.editor-page:focus, .note-title:focus, .phase-detail input:focus, .phase-detail textarea:focus) .tabbar { display: none; }
}

/* ---------- Shared bits: section labels, status pills, date chips, check items ---------- */

.section-label {
  display: flex;
  align-items: center;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.section-label .count { margin-left: 6px; font-size: 12px; }

.status-pill {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.status-pill.status-not-started { background: var(--surface-2); color: var(--text-2); }
.status-pill.status-in-progress { background: var(--accent-soft); color: var(--accent-text); }
.status-pill.status-done { background: var(--success-soft); color: var(--success); }

/* Calendar-style date block: "OCT / 15" */
.date-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 42px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: inset 0 0 0 0.5px var(--separator), var(--shadow-1);
  line-height: 1;
}
.date-chip-month { padding-top: 5px; color: var(--danger); font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.date-chip-day { padding-top: 3px; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.date-chip.is-past { opacity: 0.5; }
.date-chip.is-overdue { background: var(--danger-soft); }

.item-list { margin: 0; padding: 0; list-style: none; }
.item, .event, .linked-note {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 2px 0;
}
.item + .item, .event + .event, .linked-note + .linked-note { box-shadow: 0 -0.5px 0 var(--separator); }

/* Round check circle, like Apple Reminders. */
.check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: none;
  color: transparent;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast), transform var(--t-fast) var(--ease);
}
.check .ms { font-size: 14px; font-variation-settings: 'wght' 600; }
.check:active { transform: scale(0.88); }
.item.is-done .check { border-color: var(--accent); background: var(--accent); color: #fff; }
.item.is-done .item-text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }

.item-text {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font-size: 14px;
}
.item-remove { width: 28px; height: 28px; opacity: 0; color: var(--muted); }
.item-remove .ms { font-size: 17px; }
.item:hover .item-remove, .event:hover .item-remove, .linked-note:hover .item-remove,
.item:focus-within .item-remove, .event:focus-within .item-remove { opacity: 1; }
@media (hover: none) { .item-remove { opacity: 0.6; } }

.add-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--accent-text);
  cursor: text;
}
.add-item .ms { width: 20px; font-size: 20px; }
.add-item input { flex: 1; min-width: 0; padding: 6px 0; border: none; outline: none; background: none; color: var(--text); }
.add-item input::placeholder { color: var(--accent-text); opacity: 0.85; }

/* ---------- Phases panel ---------- */

.phase-overview { display: flex; flex-direction: column; gap: 8px; margin: 2px 4px 14px; }
.phase-overview-text { color: var(--text-2); font-size: 13px; }
.phase-overview-text strong { color: var(--text); font-weight: 600; }

.phase-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.phase-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.phase-row:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--hover)); }
.phase-row:active { transform: scale(0.985); }
.phase-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--separator);
}
.phase-num.status-in-progress { background: var(--accent); color: #fff; box-shadow: none; }
.phase-num.status-done { background: var(--success); color: #fff; box-shadow: none; }
.phase-num .ms { font-size: 15px; font-variation-settings: 'wght' 600; }
.phase-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.phase-row .status-pill { min-width: 84px; text-align: center; } /* same width, so the progress bars line up */
.phase-name { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.phase-meta { color: var(--muted); font-size: 12px; }
.phase-main .meter { margin-top: 6px; }

.add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 11px 12px;
  border: none;
  border-radius: var(--r-lg);
  background: none;
  box-shadow: inset 0 0 0 1.5px var(--separator);
  color: var(--accent-text);
  font-weight: 500;
  cursor: pointer;
}
.add-row:hover { background: var(--accent-soft); box-shadow: none; }
/* Attached files (phase detail, Tools, compare picker) */
.file-row { display: flex; align-items: center; gap: 4px; }
.file-row + .file-row { box-shadow: 0 -0.5px 0 var(--separator); }
.file-open {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 7px 4px;
  border: none;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  cursor: pointer;
}
.file-open:hover { background: var(--hover); }
.file-row:hover .item-remove, .file-row:focus-within .item-remove { opacity: 1; }
.file-thumb {
  --kind: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 10px;
  background: color-mix(in srgb, var(--kind) 14%, transparent);
  color: var(--kind);
}
.file-thumb .ms { font-size: 20px; font-variation-settings: 'wght' 300; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb.kind-pdf { --kind: var(--danger); }
.file-thumb.kind-image { --kind: var(--purple); }
.file-thumb.kind-office { --kind: var(--accent); }
.file-thumb.kind-video { --kind: var(--warning); }
.file-thumb.kind-audio { --kind: var(--pink); }
.file-text { display: flex; flex-direction: column; min-width: 0; }
.file-name { overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.drop-hint { margin-top: 8px; }
.panel-body.is-dragover {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: var(--r-xl);
}

/* Phase detail */
.phase-detail { display: flex; flex-direction: column; gap: 14px; }
.detail-bar {
  position: sticky;
  top: -14px;
  z-index: 2;
  display: flex;
  align-items: center;
  margin: -14px -14px 0;
  padding: 6px 6px 6px 4px;
  background: var(--glass-menu);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.back-link {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 10px 0 2px;
  border: none;
  border-radius: var(--r-pill);
  background: none;
  color: var(--accent-text);
  font-size: 15px;
  cursor: pointer;
}
.back-link .ms { font-size: 26px; }
.back-link:hover { background: var(--accent-soft); }

.phase-name-input {
  width: 100%;
  padding: 0;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

/* iOS-style segmented control */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--surface-2);
}
.segmented button {
  height: 30px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 0.5px var(--separator); }
@media (prefers-color-scheme: dark) { .segmented button[aria-checked="true"] { background: #636366; } }

.date-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 12px 8px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.mini-field span { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.mini-field input { width: 100%; min-width: 0; padding: 0; border: none; outline: none; background: none; color: var(--text); font-size: 14px; }
.date-hint { min-height: 18px; margin: -8px 2px 0; color: var(--muted); font-size: 12px; }

.phase-summary {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: none;
  border-radius: var(--r-md);
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  overflow: hidden;
}
.phase-summary:focus, .mini-field:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

.detail-section { padding-top: 4px; }

/* Event rows: date block + title + when; the row opens the event, ⋯ has calendar actions. */
.event-open {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 6px 4px;
  border: none;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  cursor: pointer;
}
.event-open:hover { background: var(--hover); }
.event-text { display: flex; flex-direction: column; min-width: 0; }
.event-title { overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.event-when { color: var(--muted); font-size: 12px; }
/* "+ Add …" as a button (same look as the "+ Add a task" boxes). */
.add-item-btn { width: 100%; padding: 0; border: none; background: none; font-size: 14px; text-align: left; cursor: pointer; }
.add-item-btn:hover span { text-decoration: underline; text-underline-offset: 3px; }
.linked-note-open {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border: none;
  border-radius: var(--r-sm);
  background: none;
  text-align: left;
  cursor: pointer;
}
.linked-note-open span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linked-note-open .ms { color: var(--accent-text); font-size: 19px; }
.linked-note-open:hover { background: var(--hover); }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Tools panel ---------- */

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
  padding: 14px;
  border: none;
  border-radius: var(--r-lg);
  background: var(--tint);
  text-align: left;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease);
}
button.tool-tile:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
button.tool-tile:active { transform: scale(0.97); }
.tool-tile .ms { font-size: 24px; font-variation-settings: 'wght' 300; }
.tool-text { display: flex; flex-direction: column; min-width: 0; width: 100%; }
.tool-name { font-size: 13px; font-weight: 600; }
.tool-summary { overflow: hidden; color: var(--text-2); font-size: 11.5px; opacity: 0.85; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 600;
}
.tools-section { margin: 22px 4px 8px; }
.upnext { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.upnext-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 6px;
  border: none;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  cursor: pointer;
}
.upnext-item:hover { background: var(--hover); }
.upnext-item .file-thumb { width: 40px; height: 40px; } /* same size as the date blocks */
.upnext-text { display: flex; flex-direction: column; min-width: 0; }
.upnext-title { overflow: hidden; font-size: 13.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.upnext-sub { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Notes panel ---------- */
/* Computer: list column on the left + open note (or overview) on the right.
   Phone: data-open="false" shows the list, data-open="true" shows the note full-screen. */

.notes-panel { flex-direction: row; }

.notes-list-col {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 0 260px;
  min-height: 0;
  border-right: 0.5px solid var(--separator);
}
.notes-search { flex-shrink: 0; margin: 10px 10px 6px; }
.notes-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px 16px;
}

.note-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "title date" "snippet snippet";
  gap: 1px 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.note-item:hover { background: var(--hover); }
.note-item.is-active { background: var(--accent); color: #fff; }
.note-item-title { grid-area: title; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.note-item-date { grid-area: date; color: var(--muted); font-size: 12px; }
.note-item-snippet { grid-area: snippet; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.note-item.is-active .note-item-date, .note-item.is-active .note-item-snippet { color: rgb(255 255 255 / 0.8); }

.notes-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.notes-overview { flex: 1; overflow-y: auto; padding: 28px 32px 40px; }
.overview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.overview-title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.025em; }
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.note-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 150px;
  padding: 16px;
  border: none;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
  transition: transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), background var(--t-fast);
}
.note-card:hover { background: var(--surface); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.note-card:active { transform: scale(0.98); }
.note-card-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.note-card-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-2);
  font-size: 13px;
}
.note-card-date { margin-top: auto; color: var(--muted); font-size: 12px; }
.notes-empty { flex: 1; justify-content: center; }

/* container-type lets the toolbar below adapt to the note's own width (side panels open or not). */
.note-view { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; container-type: inline-size; }
.note-item-clip { font-size: 15px; vertical-align: -3px; color: var(--muted); }
.note-item.is-active .note-item-clip { color: inherit; }

/* A note and the file it's about, side by side (computers). */
.note-layout { flex: 1; min-height: 0; display: flex; }
.note-file-pane {
  display: flex;
  flex-direction: column;
  flex: 0 0 46%;
  min-width: 0;
  border-left: 0.5px solid var(--separator);
  background: var(--surface-2);
}
.note-file-pane[hidden] { display: none; }
.pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 6px 0 12px;
  border-bottom: 0.5px solid var(--separator);
  background: var(--surface);
  flex-shrink: 0;
}
.pane-head .file-thumb { width: 30px; height: 30px; border-radius: 8px; }
.pane-title { flex: 1; min-width: 0; overflow: hidden; font-size: 13.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.pane-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
@media (max-width: 860px) { .note-file-pane { display: none !important; } }
/* Not enough room for note + file (e.g. both side panels open)? Hide the file; its chip still opens it. */
.notes-main { container: notes-main / inline-size; }
@container notes-main (max-width: 720px) { .note-file-pane { display: none; } }

/* "About: Floor plan.pdf" under a note's title */
.related-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  margin: -8px 0 20px;
  padding: 4px 2px 4px 4px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  align-self: flex-start;
}
.related-open {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 2px 6px 2px 2px;
  border: none;
  border-radius: var(--r-sm);
  background: none;
  text-align: left;
  cursor: pointer;
}
.related-open:hover { background: var(--hover); }
.related-chip .file-thumb { width: 32px; height: 32px; border-radius: 8px; }
.related-text { display: flex; flex-direction: column; min-width: 0; }
.related-label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.related-name { overflow: hidden; font-size: 13.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.related-chip .icon-btn { width: 30px; height: 30px; }

@media (min-width: 861px) and (max-width: 1200px) {
  .notes-list-col { flex-basis: 230px; }
}

@media (max-width: 860px) {
  .notes-list-col { flex: 1 1 auto; border-right: none; }
  .notes-panel[data-open="true"] .notes-list-col { display: none; }
  .notes-panel[data-open="false"] .notes-main { display: none; }
  .notes-list { padding-bottom: 92px; } /* room for the floating button */
  .note-item { padding: 13px 12px; }   /* bigger tap targets */
  .notes-search { margin: 10px 8px 4px; }
}

/* ---------- Notes editor ---------- */

.editor { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* The toolbar doubles as the note's header, so it lines up with the other panel headers. */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 52px;
  padding: 0 8px;
  border-bottom: 0.5px solid var(--separator);
  flex-shrink: 0;
}
.tb-start, .tb-end { display: flex; align-items: center; flex-shrink: 0; }
.tb-tools {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tb-tools::-webkit-scrollbar { display: none; }

.tb-btn, .tb-block {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.tb-btn { width: 32px; }
.tb-block { gap: 2px; min-width: 124px; padding: 0 2px 0 10px; justify-content: space-between; font-size: 13.5px; }
.tb-block-icon { display: none; }
.tb-btn:hover, .tb-block:hover { background: var(--hover); }
.tb-btn.is-active { background: var(--accent-soft); color: var(--accent-text); }
.tb-sep { width: 0.5px; height: 18px; margin: 0 6px; background: var(--border-strong); flex-shrink: 0; }

.editor-scroll { flex: 1; min-height: 0; overflow-y: auto; cursor: text; }
.editor-doc {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  min-height: 100%;
  margin: 0 auto;
  padding: 36px 48px 0;
}

.note-title {
  width: 100%;
  padding: 0;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
}
.note-title::placeholder { color: var(--muted); opacity: 0.6; }
.note-meta { margin: 8px 0 22px; color: var(--muted); font-size: 12px; }

.editor-page {
  position: relative;
  flex: 1;
  padding-bottom: 160px;
  outline: none;
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}
.editor-page.is-empty::before {
  content: attr(data-placeholder);
  position: absolute;
  color: var(--muted);
  pointer-events: none;
}
.editor-page > :first-child { margin-top: 0; }
.editor-page p { margin: 0 0 0.6em; }
.editor-page h1 { margin: 1.1em 0 0.4em; font-size: 24px; font-weight: 700; line-height: 1.25; letter-spacing: -0.025em; }
.editor-page h2 { margin: 1.1em 0 0.4em; font-size: 19px; font-weight: 650; line-height: 1.3; }
.editor-page h3 { margin: 1em 0 0.3em; font-size: 16px; font-weight: 650; }
.editor-page ul, .editor-page ol { margin: 0 0 0.6em; padding-left: 1.5em; }
.editor-page li { margin: 0.15em 0; }
.editor-page blockquote {
  margin: 0 0 0.6em;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--accent);
  color: var(--text-2);
}
.editor-page pre, .editor-page code { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: 0.9em; }
.editor-page pre { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); overflow-x: auto; }
.editor-page hr { border: none; border-top: 0.5px solid var(--separator); margin: 1.4em 0; }

/* Narrow note (phone, or computer with both side panels open): compact toolbar. */
@container (max-width: 640px) {
  .tb-block { min-width: 0; padding: 0 0 0 6px; }
  .tb-block-icon { display: inline-block; }
  .tb-block-label { display: none; }
  .tb-sep { margin: 0 3px; }
  .editor-doc { padding: 26px 24px 0; }
}
@container (max-width: 500px) {
  .editor-toolbar { gap: 0; padding: 0 2px; }
  .tb-btn[data-wide], .tb-block-caret { display: none; }
  .tb-block { width: 32px; padding: 0; justify-content: center; }
}

/* Phone: essentials only, bigger text. Buttons sized so the toolbar fits a 360px-wide phone. */
@media (max-width: 860px) {
  .tb-btn[data-wide] { display: none; }
  .editor-toolbar .icon-btn { width: 34px; height: 34px; }
  .tb-tools { gap: 0; }
  .tb-btn { width: 32px; }
  .tb-sep { margin: 0 2px; }
  .editor-doc { padding: 20px 18px 0; }
  .note-title { font-size: 26px; }
  .editor-page { padding-bottom: 96px; font-size: 16px; }
}

/* ---------- Timeline sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(0 0 0 / 0.3);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in var(--t-med) var(--ease) both;
}
.sheet {
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  height: min(760px, 100%);
  overflow: hidden;
  border-radius: var(--r-2xl);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: sheet-in 0.45s var(--ease) both;
}
.sheet-backdrop.is-closing { animation: fade-out 0.28s var(--ease) forwards; }
.sheet-backdrop.is-closing .sheet { animation: sheet-out 0.28s var(--ease) forwards; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(16px) scale(0.98); } }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 16px 14px 24px;
  border-bottom: 0.5px solid var(--separator);
}
.sheet-heading { flex: 1; min-width: 0; }
.sheet-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.025em; }
.sheet-sub { margin: 0; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

.legend { display: flex; align-items: center; gap: 14px; color: var(--text-2); font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; flex-shrink: 0; border-radius: 50%; }
.legend-dot.status-not-started { background: var(--muted); }
.legend-dot.status-in-progress { background: var(--accent); }
.legend-dot.status-done { background: var(--success); }
.legend-diamond { display: inline-block; width: 9px; height: 9px; background: var(--warning); transform: rotate(45deg); border-radius: 2px; }

/* Gantt chart: fixed names column on the left, scrollable calendar on the right. */
.gantt { --row-h: 54px; --head-h: 38px; flex: 1; min-height: 0; display: flex; overflow-y: auto; }
.gantt-names {
  position: sticky;
  left: 0;
  z-index: 2;
  flex: 0 0 var(--name-w);
  background: var(--surface);
  box-shadow: 0.5px 0 0 var(--separator);
}
.gantt-corner {
  display: flex;
  align-items: center;
  height: var(--head-h);
  padding: 0 16px;
  border-bottom: 0.5px solid var(--separator);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.gantt-name {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: var(--row-h);
  padding: 0 12px 0 16px;
  border: none;
  border-bottom: 0.5px solid var(--separator);
  background: none;
  text-align: left;
  cursor: pointer;
}
.gantt-name:hover { background: var(--hover); }
.gantt-name-text { display: flex; flex-direction: column; min-width: 0; }
.gantt-name-title { overflow: hidden; font-size: 13.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.gantt-name-dates { overflow: hidden; color: var(--muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }

.gantt-scroll { flex: 1; min-width: 0; overflow-x: auto; }
.gantt-canvas { position: relative; min-height: 100%; }
.gantt-months { position: relative; height: var(--head-h); border-bottom: 0.5px solid var(--separator); }
.gantt-month {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding-left: 10px;
  overflow: hidden;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.gantt-rows { position: relative; }
.gantt-gridline { position: absolute; top: 0; bottom: 0; width: 0.5px; background: var(--separator); }
.gantt-today { position: absolute; top: 0; bottom: 0; z-index: 1; width: 1.5px; background: var(--danger); }
.gantt-today span {
  position: absolute;
  top: 4px;
  left: 50%;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  transform: translateX(-50%);
}
.gantt-row { position: relative; height: var(--row-h); border-bottom: 0.5px solid var(--separator); }
.gantt-bar {
  position: absolute;
  top: 13px;
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  overflow: hidden;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: filter var(--t-fast), transform var(--t-fast) var(--ease);
}
.gantt-bar span { overflow: hidden; text-overflow: ellipsis; }
.gantt-bar:hover { filter: brightness(1.08); transform: translateY(-1px); }
.gantt-bar.status-not-started { background: color-mix(in srgb, var(--muted) 75%, var(--surface)); }
.gantt-bar.status-in-progress { background: var(--accent); }
.gantt-bar.status-done { background: var(--success); }
.gantt-milestone {
  position: absolute;
  top: 20px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--shadow-1);
  cursor: pointer;
}
.gantt-milestone.status-done { background: var(--success); }
.gantt-milestone.status-not-started { background: var(--muted); }
.gantt-nodates { position: absolute; top: 18px; left: 12px; color: var(--muted); font-size: 12px; }
.gantt-event {
  position: absolute;
  top: 44px;
  z-index: 1;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 2px;
  background: var(--warning);
  transform: rotate(45deg);
}

@media (max-width: 860px) {
  .sheet-backdrop { padding: 0; place-items: end stretch; }
  .sheet { width: 100%; height: calc(100% - 12px); border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .sheet-head { padding: 12px 10px 10px 18px; }
  .gantt { --row-h: 56px; }
}

/* ---------- Calendar tool (Google Calendar–style) ---------- */

.sheet.calendar, .sheet.links { width: min(1320px, 100%); height: 100%; }
.cal-head { flex-wrap: wrap; row-gap: 10px; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav [hidden] { display: none; }
.cal-period { margin-left: 8px; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.cal-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 10px 16px;
  border-bottom: 0.5px solid var(--separator);
}
.cal-views { grid-template-columns: repeat(4, auto); min-width: 340px; }
.cal-views button { padding: 0 14px; }
.cal-body { position: relative; overflow: auto; }
.legend-dot.is-event { background: var(--accent); }
.legend-dot.is-deadline { background: var(--warning); }

/* Month */
.cal-month { display: flex; flex-direction: column; min-height: 100%; }
.cal-dow {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 0.5px solid var(--separator);
  background: var(--surface);
}
.cal-dow span { padding: 8px 0 6px; color: var(--muted); font-size: 11px; font-weight: 600; text-align: center; text-transform: uppercase; letter-spacing: 0.04em; }
.cal-week {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-height: 112px;
  border-bottom: 0.5px solid var(--separator);
}
/* The day cells sit behind everything; clicking an empty one adds an event that day. */
.cal-cell { grid-row: 1 / -1; border-right: 0.5px solid var(--separator); cursor: pointer; transition: background var(--t-fast); }
.cal-cell:hover { background: var(--hover); }
.cal-cell.is-outside { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.cal-daynum {
  z-index: 1;
  grid-row: 1;
  justify-self: center;
  align-self: start;
  margin-top: 4px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  line-height: 24px;
  text-align: center;
  pointer-events: none;
}
.cal-daynum.is-outside { color: var(--muted); }
.cal-daynum.is-today { background: var(--accent); color: var(--on-accent); font-weight: 700; }

.cal-bar {
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 20px;
  margin: 1px 3px;
  padding: 0 8px;
  overflow: hidden;
  border: none;
  border-radius: 6px;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: filter var(--t-fast);
}
.cal-bar span { overflow: hidden; text-overflow: ellipsis; }
.cal-bar .ms { font-size: 14px; }
.cal-bar:hover { filter: brightness(1.08); }
.cal-bar.cont-left { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-bar.cont-right { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-bar.status-not-started { background: color-mix(in srgb, var(--muted) 80%, var(--surface)); }
.cal-bar.status-in-progress { background: var(--accent); }
.cal-bar.status-done { background: var(--success); }
.cal-bar.is-event { background: var(--accent-soft); color: var(--accent-text); }
.cal-bar.is-deadline { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }

.cal-day-items { z-index: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 2px 3px 4px; pointer-events: none; }
.cal-chip, .cal-more { pointer-events: auto; }
.cal-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 20px;
  padding: 0 6px;
  border: none;
  border-radius: 6px;
  background: none;
  font-size: 11.5px;
  white-space: nowrap;
  text-align: left;
  cursor: pointer;
}
.cal-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.cal-chip:hover { background: var(--hover); }
.cal-chip.is-allday { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.cal-chip.is-allday:hover { filter: brightness(1.08); }
.cal-chip.is-deadline { color: var(--warning); font-weight: 600; }
.cal-chip.is-deadline .ms { font-size: 14px; }
.cal-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--accent); }
.cal-time { color: var(--muted); }
.cal-more {
  align-self: flex-start;
  padding: 0 6px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.cal-more:hover { background: var(--hover); }

/* Week */
.cal-body[data-cal-view="week"] { overflow: hidden; display: flex; flex-direction: column; }
.wk { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wk-head, .wk-allday { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); flex-shrink: 0; }
.wk-head { border-bottom: 0.5px solid var(--separator); }
.wk-day-head { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; }
.wk-dow { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.wk-num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 20px; font-weight: 500; }
.wk-day-head.is-today .wk-dow { color: var(--accent-text); }
.wk-day-head.is-today .wk-num { background: var(--accent); color: var(--on-accent); }
.wk-allday { padding: 4px 0; border-bottom: 0.5px solid var(--separator); }
.wk-allday .cal-bar { height: 22px; }
.wk-allday-label { grid-row: 1 / -1; align-self: center; color: var(--muted); font-size: 10.5px; text-align: center; }
.wk-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.wk-grid { position: relative; display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); }
.wk-hours { position: relative; }
.wk-hours span { position: absolute; right: 8px; color: var(--muted); font-size: 10.5px; transform: translateY(-50%); }
.wk-col {
  position: relative;
  border-left: 0.5px solid var(--separator);
  background-image: linear-gradient(var(--separator) 0.5px, transparent 0.5px); /* hour lines */
  background-size: 100% 48px;
  cursor: pointer;
}
.wk-col.is-today { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.wk-block {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 7px;
  overflow: hidden;
  border: none;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--text);
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
}
.wk-block:hover { background: color-mix(in srgb, var(--accent) 24%, var(--surface)); }
.wk-block-title { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.wk-block-time { color: var(--text-2); font-size: 10.5px; white-space: nowrap; }
.wk-now { position: absolute; left: -4px; right: 0; z-index: 2; height: 2px; background: var(--danger); pointer-events: none; }
.wk-now::before { content: ''; position: absolute; left: 0; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* Schedule */
.sched { width: 100%; max-width: 860px; margin: 0 auto; padding: 8px 20px 40px; }
.sched-month { margin: 20px 0 8px 76px; font-size: 15px; font-weight: 600; }
.sched-day { display: flex; gap: 16px; padding: 8px 0; border-top: 0.5px solid var(--separator); }
.sched-date { display: flex; flex-direction: column; align-items: center; width: 60px; flex-shrink: 0; padding-top: 4px; }
.sched-dow { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.sched-num { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-size: 20px; font-weight: 500; }
.sched-day.is-today .sched-dow { color: var(--accent-text); }
.sched-day.is-today .sched-num { background: var(--accent); color: var(--on-accent); }
.sched-items { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sched-item {
  display: grid;
  grid-template-columns: 170px 10px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  cursor: pointer;
}
.sched-item:hover { background: var(--hover); }
.sched-time { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.sched-dot { width: 10px; height: 10px; border-radius: 50%; }
.sched-dot.is-event { background: var(--accent); }
.sched-dot.is-deadline { background: var(--warning); }
.sched-dot.status-not-started { background: var(--muted); }
.sched-dot.status-in-progress { background: var(--accent); }
.sched-dot.status-done { background: var(--success); }
.sched-text { display: flex; flex-direction: column; min-width: 0; }
.sched-title { overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.sched-sub { color: var(--muted); font-size: 12px; }
.sched-empty { margin: 0; padding: 12px 10px; color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
  .cal-head { padding-bottom: 8px; }
  .cal-nav { order: 5; width: 100%; }
  .cal-period { font-size: 16px; }
  .cal-views { width: 100%; min-width: 0; grid-template-columns: repeat(4, 1fr); }
  .cal-views button { padding: 0 4px; }
  .cal-week { min-height: 84px; }
  .cal-bar, .cal-chip { height: 16px; padding: 0 4px; font-size: 9.5px; }
  .cal-time, .cal-dot, .cal-chip .ms { display: none; }
  .wk-head, .wk-allday, .wk-grid { grid-template-columns: 40px repeat(7, minmax(0, 1fr)); }
  .wk-num { width: 28px; height: 28px; font-size: 15px; }
  .wk-block-time { display: none; }
  .sched { padding: 4px 12px 32px; }
  .sched-month { margin-left: 8px; }
  .sched-day { gap: 8px; }
  .sched-date { width: 44px; }
  .sched-item { grid-template-columns: 10px 1fr; padding: 8px 6px; }
  .sched-time { grid-column: 2; grid-row: 2; font-size: 12px; }
  .sched-dot { grid-row: 1; }
}

/* ---------- Links tool ---------- */

.links-body { overflow-y: auto; padding: 20px; }
.link-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.link-group { padding: 12px 12px 8px; border-radius: var(--r-xl); background: var(--surface-2); }
.link-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding-left: 4px; }
.link-group-icon { display: inline-flex; color: var(--muted); }
.link-group-icon .ms { font-size: 20px; font-variation-settings: 'wght' 300; }
.link-group-name { min-width: 0; margin: 0; overflow: hidden; font-size: 15px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.link-group-head .count { margin-left: 0; }
.link-group-head .btn:disabled { opacity: 0.4; cursor: default; }
.link-list { display: flex; flex-direction: column; margin: 0 0 4px; padding: 4px; border-radius: var(--r-lg); background: var(--surface); list-style: none; }
.link-row { display: flex; align-items: center; gap: 4px; }
.link-row + .link-row { box-shadow: 0 -0.5px 0 var(--separator); }
.link-open {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 7px 6px;
  border-radius: var(--r-md);
  color: inherit;
  text-decoration: none;
}
.link-open:hover { background: var(--hover); }
/* A letter tile; the site's own icon (favicon) covers it when there is one. */
.link-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 9px;
  background: var(--tint);
  color: var(--text-2);
  font-size: 15px;
  font-weight: 700;
}
.link-icon img { position: absolute; inset: 6px; width: 22px; height: 22px; border-radius: 4px; opacity: 0; transition: opacity var(--t-med) var(--ease); }
.link-icon:has(img.is-loaded) { background: var(--surface); box-shadow: inset 0 0 0 0.5px var(--separator); }
.link-icon:has(img.is-loaded) > span { visibility: hidden; }
.link-icon img.is-loaded { opacity: 1; }
.link-text { display: flex; flex-direction: column; min-width: 0; }
.link-title { overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.link-host { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.link-empty { margin: 4px 6px 8px; }
.link-group .add-item-btn { padding: 4px 6px; }
.links-hint { margin: 18px 4px 0; }

@media (max-width: 860px) {
  .links-body { padding: 12px; }
  .link-groups { grid-template-columns: 1fr; }
}

/* ---------- File viewer & compare ---------- */

.sheet.viewer, .sheet.compare { width: min(1320px, 100%); height: 100%; }
.viewer .sheet-head { gap: 12px; padding: 12px 12px 12px 16px; }
.viewer-title { overflow: hidden; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.viewer-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.viewer-body, .compare-body { background: var(--surface-2); }

.zoom-controls {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
}
.zoom-controls .icon-btn { width: 30px; height: 30px; }
.zoom-label {
  min-width: 52px;
  height: 30px;
  border: none;
  border-radius: var(--r-pill);
  background: none;
  color: var(--text-2);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.zoom-label:hover { background: var(--hover); }

.loading-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--separator);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin-cw 0.8s linear infinite;
}
@keyframes spin-cw { to { transform: rotate(360deg); } }

/* A scrolling column of pages, like a PDF reader. */
/* scrollbar-gutter keeps room for the scrollbar, so pages don't resize (and redraw) when it appears. */
.doc-scroller { flex: 1; min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.page-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: max-content;
  min-width: 100%;
  padding: 16px;
}
.page {
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 4px;
  background: #ffffff; /* paper stays white in dark mode, like Preview */
  box-shadow: var(--shadow-2);
}
.page canvas { display: block; }

.media-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px; min-height: 0; }
.media-wrap video { max-width: 100%; max-height: 100%; border-radius: var(--r-md); background: #000; }
.media-wrap audio { width: min(480px, 100%); }
.media-icon { font-size: 72px; color: var(--muted); font-variation-settings: 'wght' 200; }
.text-preview {
  flex: 1;
  margin: 0;
  padding: 20px 24px;
  overflow: auto;
  background: var(--surface);
  color: var(--text);
  font: 13px/1.6 ui-monospace, 'SF Mono', Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Compare: picker */
.picker-body { overflow-y: auto; padding: 8px 20px 20px; }
.picker-group { margin: 18px 4px 6px; }
.picker-list { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px 8px 8px;
  border: none;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.picker-item:hover { background: var(--hover); }
.picker-item[aria-pressed="true"] { background: var(--accent-soft); }
.picker-item .file-text { flex: 1; }
.pick-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.picker-item[aria-pressed="true"] .pick-tag { border-color: var(--accent); background: var(--accent); }
.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 12px 16px;
  border-top: 0.5px solid var(--separator);
}

/* Compare: header, toolbar */
.compare-head { padding: 12px 12px 12px 16px; }
.compare-files { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.cmp-name { min-width: 0; overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ab-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.tag-a { background: var(--accent); }
.tag-b { background: var(--warning); }
.compare-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 16px;
  border-bottom: 0.5px solid var(--separator);
}
.compare-modes { grid-template-columns: repeat(4, auto); min-width: 380px; }
.compare-modes button { padding: 0 12px; }
.compare-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-left: auto; }
.page-stepper { display: inline-flex; align-items: center; gap: 2px; color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.page-stepper .icon-btn:disabled { opacity: 0.35; cursor: default; }
.reveal-slider { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.reveal-slider input { width: 150px; accent-color: var(--accent); }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Compare: side by side */
.split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5px;
  background: var(--separator);
}
.pane { position: relative; display: flex; min-width: 0; min-height: 0; background: var(--surface-2); }
.pane-tag { position: absolute; top: 10px; left: 10px; z-index: 2; box-shadow: var(--shadow-1); }

/* Compare: overlay / swipe / difference stage */
.stage { position: relative; margin: 16px auto; overflow: hidden; border-radius: 4px; background: #ffffff; box-shadow: var(--shadow-2); }
.stage .layer { position: absolute; top: 0; left: 0; display: block; }
.stage.mode-difference .layer-b { mix-blend-mode: difference; }
.stage.mode-swipe { cursor: ew-resize; touch-action: pan-y; user-select: none; }
.swipe-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 2px;
  background: #ffffff;
  box-shadow: 0 0 0 0.5px rgb(0 0 0 / 0.3), 0 0 12px rgb(0 0 0 / 0.25);
  transform: translateX(-50%);
  pointer-events: none;
}
.swipe-handle span {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  color: #1d1d1f;
  box-shadow: var(--shadow-2);
  transform: translate(-50%, -50%);
}

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .compare-toolbar { padding: 8px 12px; }
  .compare-modes { width: 100%; min-width: 0; grid-template-columns: repeat(4, 1fr); }
  .compare-modes button { padding: 0 4px; }
  .compare-controls { width: 100%; justify-content: space-between; margin-left: 0; }
  .reveal-slider input { width: 120px; }
  .viewer-title { font-size: 15px; }
  .picker-body { padding: 4px 12px 16px; }
}

/* ---------- Dialogs ---------- */

dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: none;
  border-radius: var(--r-2xl);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-3);
}
dialog[open] { animation: dialog-in 0.32s var(--ease) both; }
dialog::backdrop {
  background: rgb(0 0 0 / 0.28);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in 0.25s ease both;
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }

.dialog-form { display: flex; flex-direction: column; gap: 18px; padding: 26px 24px 20px; }
.dialog-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.dialog-text { margin: -8px 0 0; color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { padding: 0; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select, .field textarea {
  height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: var(--r-md);
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px; /* 16px stops iPhones zooming in on focus */
  transition: box-shadow var(--t-fast) var(--ease);
}
.field textarea { height: auto; min-height: 76px; padding: 10px 14px; line-height: 1.45; resize: vertical; }
.field select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.field input:focus, .field select:focus, .field textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.field[hidden], .field-pair[hidden] { display: none; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* iOS-style on/off switch: <label class="switch"><input type="checkbox"><span class="switch-track"></span>Label</label> */
.switch { position: relative; display: flex; align-items: center; gap: 12px; font-size: 15px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  transition: background var(--t-fast) var(--ease);
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.2);
  transition: transform var(--t-med) var(--ease);
}
.switch input:checked + .switch-track { background: var(--success); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

.picker { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: none; min-width: 0; }
.picker legend { margin-bottom: 8px; }

/* Radio inputs are hidden visually but stay focusable for the keyboard. */
.icon-opt, .tint-opt { position: relative; }
.icon-opt input, .tint-opt input { position: absolute; opacity: 0; pointer-events: none; }

.icon-scroller {
  max-height: 232px;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px 4px;
  border-radius: var(--r-md);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 18px), transparent); /* soft fade at the bottom edge */
}
.icon-group-label {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 6px 2px 6px;
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 8px; }
.icon-opt span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.icon-opt .ms { font-size: 25px; }
.icon-opt span:hover { background: var(--hover); }
.icon-opt input:checked + span { background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line-icon); }
.icon-opt input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }

.tint-row { display: flex; flex-wrap: wrap; gap: 12px; }
.tint-opt span {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--tint);
  box-shadow: inset 0 0 0 0.5px var(--border-strong);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
.tint-opt span:hover { transform: scale(1.08); }
.tint-opt input:checked + span { box-shadow: inset 0 0 0 0.5px var(--border-strong), 0 0 0 2px var(--surface-raised), 0 0 0 4px var(--accent); }
.tint-opt input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 4px; }

/* ---------- Dropdown menu (frosted, like macOS) ---------- */

.menu {
  position: fixed;
  z-index: 300;
  min-width: 200px;
  max-width: calc(100vw - 16px);
  max-height: min(420px, calc(100vh - 16px));
  overflow-y: auto;
  padding: 5px;
  border-radius: var(--r-md);
  background: var(--glass-menu);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-3), inset 0 0 0 0.5px var(--separator);
  animation: menu-in 0.18s var(--ease) both;
}
@keyframes menu-in { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }
.menu-header {
  margin: 0 0 4px;
  padding: 6px 10px 8px;
  border-bottom: 0.5px solid var(--separator);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: none;
  border-radius: 7px;
  background: none;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.menu-item .ms { width: 20px; font-size: 18px; color: var(--text-2); }
.menu-item:hover, .menu-item:focus-visible { background: var(--accent); color: #fff; outline: none; }
.menu-item:hover .ms, .menu-item:focus-visible .ms { color: #fff; }
.menu-item.danger, .menu-item.danger .ms { color: var(--danger); }
.menu-item.danger:hover, .menu-item.danger:focus-visible { background: var(--danger); color: #fff; }
.menu-item.danger:hover .ms, .menu-item.danger:focus-visible .ms { color: #fff; }
@media (max-width: 860px) { .menu-item { height: 44px; font-size: 15px; } }

/* ---------- Toasts ---------- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 11px 18px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--text) 88%, transparent);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: var(--bg);
  box-shadow: var(--shadow-3);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  animation: toast-in 0.4s var(--ease) both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@media (max-width: 860px) {
  .toast-host { bottom: calc(92px + env(safe-area-inset-bottom)); }
  .toast { border-radius: var(--r-lg); }
}

/* ---------- Error screen ---------- */

.fatal { max-width: 560px; margin: 80px auto; padding: 0 16px; }
