/* ═══════════════════════════════════════════════════════════
   songyang-docs — Redesign
   Premium SaaS · Wine + Cream · Light/Dark
   ═══════════════════════════════════════════════════════════ */

:root[data-theme="light"] {
  /* surface — cool slate neutrals */
  --bg:           #f1f5f9;
  --bg-2:         #e2e8f0;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --surface-solid:#ffffff;
  --paper:        #ffffff;

  --line:         #e2e8f0;
  --line-2:       #f1f5f9;
  --line-3:       #cbd5e1;

  /* ink — slate */
  --ink:          #0f172a;
  --ink-2:        #334155;
  --ink-3:        #64748b;
  --ink-4:        #94a3b8;

  /* brand — soft indigo */
  --wine:         #5b5bd6;
  --wine-deep:    #4f46e5;
  --wine-ink:     #4338ca;
  --wine-tint:    #eef2ff;
  --wine-tint-2:  #e0e7ff;
  --amber:        #f43f5e;
  --amber-2:      #e11d48;
  --amber-soft:   #fff1f2;
  --cream:        #f8fafc;
  --cream-2:      #f1f5f9;

  --ok:           #22c55e;
  --ok-soft:      #f0fdf4;
  --warn:         #f59e0b;
  --warn-soft:    #fffbeb;
  --err:          #ef4444;
  --err-soft:     #fef2f2;
  --info:         #5b5bd6;
  --info-soft:    #eef2ff;

  /* flat material */
  --glass-bg:     #ffffff;
  --glass-bd:     #e2e8f0;
  --glass-blur:   none;

  --sh-card:      0 1px 2px rgba(15,23,42,0.04), 0 1px 1px rgba(15,23,42,0.02);
  --sh-card-hi:   0 4px 12px rgba(15,23,42,0.06), 0 2px 4px rgba(15,23,42,0.03);
  --sh-cta:       0 1px 2px rgba(91,91,214,0.18), 0 4px 12px -4px rgba(91,91,214,0.25);
  --sh-pill:      0 1px 2px rgba(15,23,42,0.04);

  --bg-radial-1:  none;
  --bg-radial-2:  none;
  --bg-radial-3:  none;
}

:root[data-theme="dark"] {
  /* surface — deep navy-slate */
  --bg:           #0b1020;
  --bg-2:         #0f1629;
  --surface:      #151c33;
  --surface-2:    #1b243d;
  --surface-solid:#151c33;
  --paper:        #fafafa;

  --line:         #243049;
  --line-2:       #1a2238;
  --line-3:       #324063;

  --ink:          #f1f5f9;
  --ink-2:        #cbd5e1;
  --ink-3:        #94a3b8;
  --ink-4:        #64748b;

  /* lighter indigo on dark */
  --wine:         #818cf8;
  --wine-deep:    #6366f1;
  --wine-ink:     #a5b4fc;
  --wine-tint:    rgba(129, 140, 248, 0.12);
  --wine-tint-2:  rgba(129, 140, 248, 0.20);
  --amber:        #fb7185;
  --amber-2:      #f43f5e;
  --amber-soft:   rgba(251, 113, 133, 0.12);
  --cream:        #1b243d;
  --cream-2:      #243049;

  --ok:           #4ade80;
  --ok-soft:      rgba(74, 222, 128, 0.12);
  --warn:         #fbbf24;
  --warn-soft:    rgba(251, 191, 36, 0.12);
  --err:          #f87171;
  --err-soft:     rgba(248, 113, 113, 0.12);
  --info:         #818cf8;
  --info-soft:    rgba(129, 140, 248, 0.12);

  --glass-bg:     #151c33;
  --glass-bd:     #243049;
  --glass-blur:   none;

  --sh-card:      0 1px 2px rgba(0,0,0,0.4), 0 1px 1px rgba(0,0,0,0.3);
  --sh-card-hi:   0 4px 12px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.4);
  --sh-cta:       0 1px 2px rgba(99,102,241,0.3), 0 4px 12px -4px rgba(99,102,241,0.4);
  --sh-pill:      0 1px 2px rgba(0,0,0,0.4);

  --bg-radial-1:  none;
  --bg-radial-2:  none;
  --bg-radial-3:  none;
}

:root {
  /* type scale */
  --fs-display: 38px;
  --fs-h1: 28px;
  --fs-h2: 20px;
  --fs-h3: 16px;
  --fs-body: 14px;
  --fs-meta: 12px;
  --fs-micro: 11px;

  --fw-reg: 400;
  --fw-med: 500;
  --fw-semi: 600;
  --fw-bold: 700;
  --fw-heavy: 800;

  /* spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 28px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;

  /* radius */
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;
  --r-2xl: 28px;
  --r-pill: 999px;

  /* fonts */
  --font-sans: 'IBM Plex Sans Thai', 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-display: 'IBM Plex Sans Thai', 'IBM Plex Sans', system-ui, sans-serif;
}

/* reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-med);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-3); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: padding-box; border: 2px solid transparent; }

/* ═══ Surface utilities (flat material) ═══ */
.glass, .card, .card-solid {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card);
}

/* ═══ App shell ═══ */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: var(--s-5) var(--s-4) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3) var(--s-5);
  margin-bottom: var(--s-2);
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  background: var(--wine);
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.brand-name {
  font-weight: var(--fw-heavy);
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--ink);
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-3);
  font-weight: var(--fw-med);
  margin-top: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: var(--fw-heavy);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  padding: var(--s-4) var(--s-3) var(--s-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 9px var(--s-3);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: var(--fw-semi);
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  position: relative;
  background: transparent;
  text-align: left;
  width: 100%;
}
.nav-item:hover {
  background: var(--wine-tint);
  color: var(--ink);
}
.nav-item.active {
  background: var(--wine-tint);
  color: var(--wine);
  border-color: transparent;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -1px; top: 22%; bottom: 22%;
  width: 3px;
  background: var(--wine);
  border-radius: 0 3px 3px 0;
}
.nav-item .icn {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: currentColor;
}
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  font-weight: var(--fw-bold);
  color: var(--ink-4);
  background: var(--line-2);
  padding: 1px 7px;
  border-radius: var(--r-pill);
}
.nav-item.active .count { color: var(--wine); background: var(--wine-tint); }

/* Stub indicator dot — shown next to nav items whose feature isn't wired yet */
.nav-item .nav-stub-dot {
  margin-left: auto;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--warn, var(--amber, #f59e0b));
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--warn, #f59e0b) 18%, transparent);
  flex-shrink: 0;
}

.sidebar-foot {
  margin-top: auto;
  padding: var(--s-3);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-pill);
  background: var(--wine);
  display: grid; place-items: center;
  color: #fff;
  font-weight: var(--fw-heavy);
  font-size: 13px;
}
.user-name { font-size: 13px; font-weight: var(--fw-bold); color: var(--ink); line-height: 1.2; }
.user-role { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-7) var(--s-2);
}
.crumb {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 12px;
  color: var(--ink-3);
  font-weight: var(--fw-semi);
}
.crumb-current { color: var(--ink); }
.crumb-sep { color: var(--ink-4); }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--ink-2);
  transition: all 0.15s;
}
.icon-btn:hover { color: var(--wine); border-color: var(--line-3); }
.icon-btn .dot {
  position: absolute; top: 9px; right: 9px;
  width: 7px; height: 7px;
  background: var(--wine);
  border-radius: 50%;
  border: 2px solid var(--bg);
}
.icon-btn { position: relative; }

/* Main content */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 var(--s-7) var(--s-12);
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-6);
  padding: var(--s-4) 0 var(--s-7);
}
.page-title {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: var(--fw-heavy);
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ink);
}
.page-title em {
  font-style: normal;
  color: var(--wine);
}
.page-sub {
  font-size: 15px;
  color: var(--ink-3);
  margin-top: var(--s-2);
  max-width: 56ch;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-weight: var(--fw-bold);
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--wine);
  color: #fff;
  box-shadow: var(--sh-cta);
}
.btn-primary:hover:not(:disabled) {
  background: var(--wine-deep);
}
.btn-primary:active:not(:disabled) { background: var(--wine-ink); }

.btn-ghost {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line);
}
.btn-ghost:hover { color: var(--wine); border-color: var(--line-3); background: var(--surface-2); }

.btn-amber {
  background: var(--ink);
  color: var(--bg);
}
.btn-amber:hover { filter: brightness(1.08); }

.btn-sm { padding: 7px 13px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-lg { padding: 14px 22px; font-size: 14px; border-radius: var(--r-md); }
.btn-block { width: 100%; justify-content: center; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  font-weight: var(--fw-bold);
  color: var(--ink-2);
  letter-spacing: 0.005em;
}
.field-label .req { color: var(--wine); margin-left: 3px; }
.input, .textarea, .select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 14px;
  font-weight: var(--fw-semi);
  color: var(--ink);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); font-weight: var(--fw-med); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--wine);
  background: var(--surface-solid);
  box-shadow: 0 0 0 4px var(--wine-tint);
}
.textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a6557' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }

/* Pills / chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: var(--fw-bold);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--line-2);
  color: var(--ink-2);
  letter-spacing: 0.005em;
}
.chip-wine { background: var(--wine-tint); color: var(--wine); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-err { background: var(--err-soft); color: var(--err); }
.chip-info { background: var(--info-soft); color: var(--info); }

.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--fw-heavy);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Section divider */
.section-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.section-head h2 {
  font-size: 17px;
  font-weight: var(--fw-heavy);
  color: var(--ink);
  letter-spacing: -0.005em;
}

/* ═══ Doc type grid (View 1) ═══ */
.types-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-4);
}
.type-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
  overflow: hidden;
}
.type-card:hover { border-color: var(--line-3); }
.type-card.active {
  border-color: var(--wine);
  background: var(--wine-tint);
}

.type-icon-wrap {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--wine-tint);
  color: var(--wine);
}
.type-card.active .type-icon-wrap {
  background: var(--wine);
  color: #fff;
}

/* In-card "ถัดไป" CTA — appears on selected card */
.type-card-cta {
  margin-top: var(--s-3);
  padding: 9px 14px;
  background: var(--wine);
  color: #fff;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-shadow: var(--sh-cta);
  animation: cta-pop 0.25s cubic-bezier(.2,.7,.2,1.2) both;
  cursor: pointer;
}
.type-card-cta:hover { background: var(--wine-deep); }
@keyframes cta-pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.type-name {
  font-size: 15.5px;
  font-weight: var(--fw-heavy);
  color: var(--ink);
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.type-meta {
  display: flex;
  gap: var(--s-2);
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: var(--fw-semi);
  margin-top: 2px;
}
.type-meta .dot-sep { color: var(--ink-4); }
.type-tag {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--fw-heavy);
  letter-spacing: 0.1em;
  color: var(--ink-4);
  text-transform: uppercase;
}

/* Recent docs row */
.recent-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--s-3);
}
.recent-card {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-pill);
  transition: all 0.15s;
}
.recent-card:hover { border-color: var(--line-3); transform: translateY(-1px); box-shadow: var(--sh-card); }
.recent-thumb {
  width: 44px;
  height: 56px;
  border-radius: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
.recent-thumb::before, .recent-thumb::after {
  content: '';
  position: absolute;
  left: 6px; right: 6px;
  height: 1px;
  background: var(--line-3);
}
.recent-thumb::before { top: 10px; }
.recent-thumb::after { top: 16px; right: 18px; }
.recent-title { font-size: 13px; font-weight: var(--fw-bold); color: var(--ink); line-height: 1.3; }
.recent-meta { font-size: 11px; color: var(--ink-3); margin-top: 4px; font-weight: var(--fw-semi); display: flex; gap: 6px; align-items: center; }

/* ═══ Smart fill panel (View 2) ═══ */
.smart-fill {
  background: var(--wine-tint);
  border: 1px solid var(--wine-tint-2);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.smart-head {
  display: flex; align-items: center; gap: var(--s-3);
  margin-bottom: var(--s-4);
  position: relative;
}
.smart-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--wine);
  color: #fff;
}
.smart-title { font-size: 15px; font-weight: var(--fw-heavy); color: var(--ink); }
.smart-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; font-weight: var(--fw-semi); }

.smart-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: var(--s-3);
  position: relative;
}
.smart-tab {
  flex: 1;
  padding: 8px var(--s-3);
  border-radius: var(--r-sm);
  background: transparent;
  border: 0;
  color: var(--ink-3);
  font-weight: var(--fw-bold);
  font-size: 12.5px;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.smart-tab:hover { color: var(--ink); }
.smart-tab.active {
  background: var(--wine);
  color: #fff;
}

.drop-zone {
  border: 2px dashed var(--line-3);
  border-radius: var(--r-md);
  padding: var(--s-7) var(--s-4);
  text-align: center;
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.15s;
}
.drop-zone:hover { border-color: var(--wine); background: var(--surface-solid); }

/* ═══ Form layout (View 2) ═══ */
.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: var(--s-6);
  align-items: flex-start;
}
.form-stack { display: flex; flex-direction: column; gap: var(--s-5); }
.live-pane {
  position: sticky;
  top: var(--s-5);
  display: flex;
  flex-direction: column;
}
.live-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
}
.live-canvas {
  background: var(--bg-2);
  padding: var(--s-5);
  height: 580px;
  overflow: hidden;
  display: flex; justify-content: center;
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
}
.live-page {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px -12px rgba(0,0,0,0.25), 0 2px 6px rgba(0,0,0,0.08);
  width: 595px;        /* A4 width */
  min-height: 842px;
  padding: 48px 60px;
  transform: scale(0.52);
  transform-origin: top center;
  color: #111;
  font-family: 'Sarabun', var(--font-sans);
}

/* ═══ View 3 preview ═══ */
.preview-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.zoom-group {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 2px;
  gap: 2px;
}
.zoom-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: transparent;
  border: 0;
  color: var(--ink-2);
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: var(--fw-bold);
}
.zoom-btn:hover { background: var(--surface-solid); color: var(--ink); }
.zoom-val {
  min-width: 56px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: var(--fw-bold);
  color: var(--ink);
}
.preview-stage {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-7) var(--s-5);
  display: flex; justify-content: center;
  min-height: 70vh;
  overflow: auto;
}
.a4-paper {
  background: var(--paper);
  width: 794px;
  min-height: 1123px;
  padding: 60px 70px;
  box-shadow: 0 24px 56px -16px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.08);
  color: #111;
  font-family: 'Sarabun', var(--font-sans);
}

/* ═══ Weekly dashboard (View 4) ═══ */
.weekly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: var(--s-4);
}
.week-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: border-color 0.15s, background 0.15s;
}
.week-card:hover { border-color: var(--line-3); background: var(--surface-2); }
.week-card.done { border-color: var(--ok); }
.week-card.skip { opacity: 0.7; }

.week-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
}
.week-num {
  display: flex; align-items: center; gap: var(--s-2);
}
.week-num-badge {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--wine-tint);
  color: var(--wine);
  font-family: var(--font-mono);
  font-weight: var(--fw-heavy);
  font-size: 13px;
}
.week-card.done .week-num-badge { background: var(--ok-soft); color: var(--ok); }

.week-dates { font-size: 12px; color: var(--ink-3); font-weight: var(--fw-semi); line-height: 1.3; }
.week-dates strong { color: var(--ink); display: block; font-weight: var(--fw-heavy); }

.week-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px;
  font-weight: var(--fw-heavy);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.week-status.s-done { background: var(--ok-soft); color: var(--ok); }
.week-status.s-pending { background: var(--warn-soft); color: var(--warn); }
.week-status.s-draft { background: var(--line-2); color: var(--ink-3); }

.week-progress {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.week-progress-bar {
  height: 5px;
  background: var(--line-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.week-progress-bar > span {
  display: block;
  height: 100%;
  background: var(--wine);
  border-radius: inherit;
}
.week-card.done .week-progress-bar > span { background: var(--ok); }

.week-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  padding-top: var(--s-3);
  border-top: 1px dashed var(--line);
  margin-top: 2px;
}
.week-stat {
  display: flex; flex-direction: column; gap: 2px;
}
.week-stat-val { font-size: 16px; font-weight: var(--fw-heavy); color: var(--ink); font-family: var(--font-mono); line-height: 1; }
.week-stat-lab { font-size: 10.5px; color: var(--ink-3); font-weight: var(--fw-semi); letter-spacing: 0.03em; }

.week-actions {
  display: flex; gap: 6px;
  padding-top: var(--s-2);
  border-top: 1px solid var(--line);
}
.week-actions .btn { flex: 1; justify-content: center; padding: 7px 10px; font-size: 12px; }

/* KPI strip */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}
.kpi {
  position: relative;
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.kpi-label {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: 12px;
  font-weight: var(--fw-bold);
  color: var(--ink-3);
}
.kpi-label .icn { color: var(--wine); }
.kpi-val {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: var(--fw-heavy);
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-top: var(--s-2);
  line-height: 1.1;
}
.kpi-delta {
  font-size: 11.5px;
  font-weight: var(--fw-bold);
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--err); }

/* Project banner (View 4 head) */
.project-banner {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-6);
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-xl);
  position: relative;
  overflow: hidden;
  margin-bottom: var(--s-5);
}
.project-banner::after {
  content: '';
  position: absolute;
  right: -80px; top: -80px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: var(--wine);
  opacity: 0.5;
  pointer-events: none;
}
.project-banner-inner { position: relative; z-index: 1; flex: 1; min-width: 0; }
.project-banner-kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: var(--fw-heavy);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.78;
}
.project-banner-title {
  font-size: 22px;
  font-weight: var(--fw-heavy);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-top: 4px;
}
.project-banner-meta {
  display: flex; gap: var(--s-5); flex-wrap: wrap;
  font-size: 12.5px;
  font-weight: var(--fw-semi);
  opacity: 0.88;
  margin-top: var(--s-3);
}
.project-banner-meta span { display: inline-flex; align-items: center; gap: 5px; }
.project-banner-actions {
  display: flex;
  gap: var(--s-2);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.project-banner-actions .btn-ghost {
  background: rgba(255,255,255,0.1);
  color: var(--bg);
  border-color: rgba(255,255,255,0.2);
}
.project-banner-actions .btn-ghost:hover { background: rgba(255,255,255,0.18); color: var(--bg); border-color: rgba(255,255,255,0.3); }

/* Settings strip (View 4 quick form) */
.settings-strip {
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: var(--s-5);
}

/* Stepper (View 2/3) */
.stepper {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-5);
  font-size: 12.5px;
  font-weight: var(--fw-bold);
  color: var(--ink-3);
}
.step {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--line-2);
}
.step.active { background: var(--wine-tint); color: var(--wine); }
.step.done { background: var(--ok-soft); color: var(--ok); }
.step-num {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: rgba(0,0,0,0.08);
  border-radius: 50%;
}
[data-theme="dark"] .step-num { background: rgba(255,255,255,0.1); }
.step-arrow { color: var(--ink-4); font-size: 11px; }

/* Responsive */
/* ═══ Forced mobile preview mode ═══ */
body.device-mobile {
  background: var(--bg-2);
  padding: 32px 0;
}
body.device-mobile .app {
  max-width: 430px;
  margin: 0 auto;
  min-height: calc(100vh - 64px);
  border: 1px solid var(--line);
  border-radius: 32px;
  overflow: hidden;
  box-shadow: 0 32px 80px -20px rgba(15,23,42,0.25), 0 12px 24px rgba(15,23,42,0.08);
  background: var(--bg);
  grid-template-columns: 1fr;
  position: relative;
}
body.device-mobile .sidebar {
  position: absolute; bottom: 0; left: 0; right: 0; top: auto;
  height: 64px;
  flex-direction: row;
  padding: 8px;
  gap: 4px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-right: 0;
  z-index: 50;
  overflow-x: auto;
}
body.device-mobile .brand,
body.device-mobile .nav-section-label,
body.device-mobile .sidebar-foot { display: none; }
body.device-mobile .nav-item {
  flex-direction: column; gap: 2px; padding: 6px 10px;
  font-size: 10.5px;
  flex-shrink: 0;
}
body.device-mobile .nav-item.active::before { display: none; }
body.device-mobile .nav-item .count { display: none; }
body.device-mobile .nav-item .nav-stub-dot { display: none; }
body.device-mobile .main { padding: 0 var(--s-4) 88px; }
body.device-mobile .topbar { padding: var(--s-4) var(--s-4) 0; flex-wrap: wrap; gap: 8px; }
body.device-mobile .topbar-actions { margin-left: auto; }
body.device-mobile .page-head { flex-direction: column; align-items: flex-start; gap: var(--s-3); }
body.device-mobile .page-title { font-size: 24px; }
body.device-mobile .page-sub { font-size: 13px; }
body.device-mobile .types-grid { grid-template-columns: 1fr 1fr; }
body.device-mobile .field-row,
body.device-mobile .field-row.three { grid-template-columns: 1fr; }
body.device-mobile .form-grid { grid-template-columns: 1fr; }
body.device-mobile .live-pane { position: static; }
body.device-mobile .weekly-grid { grid-template-columns: 1fr; }
body.device-mobile .kpi-row { grid-template-columns: 1fr 1fr; }
body.device-mobile .project-banner { flex-direction: column; align-items: flex-start; gap: var(--s-3); padding: var(--s-4) var(--s-5); }
body.device-mobile .project-banner-title { font-size: 18px; }
body.device-mobile .project-banner-actions { width: 100%; }
body.device-mobile .project-banner-actions .btn { flex: 1; justify-content: center; }
body.device-mobile .a4-paper { width: 100%; padding: 24px 20px; min-height: auto; }
body.device-mobile .preview-stage { padding: var(--s-4); }
body.device-mobile .preview-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
body.device-mobile .stepper { font-size: 11px; flex-wrap: wrap; }

@media (max-width: 1100px) {
  .form-grid { grid-template-columns: 1fr; }
  .live-pane { position: static; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    height: 64px;
    flex-direction: row;
    padding: 8px;
    gap: 4px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    border-right: 0;
    z-index: 50;
    overflow-x: auto;
  }
  .brand, .nav-section-label, .sidebar-foot { display: none; }
  .nav-item {
    flex-direction: column; gap: 2px; padding: 6px 10px;
    font-size: 10.5px;
    flex-shrink: 0;
  }
  .nav-item.active::before { display: none; }
  .nav-item .count { display: none; }
  .nav-item .nav-stub-dot { display: none; }
  .main { padding: 0 var(--s-4) 88px; }
  .topbar { padding: var(--s-4) var(--s-4) 0; }
  .page-head { flex-direction: column; align-items: flex-start; gap: var(--s-3); }
  .page-title { font-size: 26px; }
  .types-grid { grid-template-columns: 1fr 1fr; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .types-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   MOTION SYSTEM — desktop full, mobile moderate
   ═══════════════════════════════════════════════════════════ */
:root {
  --motion-fast: 180ms;
  --motion-base: 260ms;
  --motion-slow: 460ms;
  --ease-out: cubic-bezier(.2,.7,.2,1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
}

/* Page-level fade-up entrance */
@keyframes fade-up   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in   { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-rt  { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pop-in    { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes shimmer   { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 var(--wine-tint-2); } 70% { box-shadow: 0 0 0 14px rgba(0,0,0,0); } 100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } }
@keyframes pulse-glow { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; transform: scale(0.96); } }
@keyframes brand-float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-2px) rotate(-2deg); } }
@keyframes icon-pop  { 0% { transform: scale(0.6) rotate(-8deg); opacity: 0; } 60% { transform: scale(1.18) rotate(2deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes gradient-sweep { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes ripple    { 0% { opacity: 0.55; transform: scale(0.85); } 100% { opacity: 0; transform: scale(1.6); } }

/* Default transitions on interactive surfaces */
.type-card, .week-card, .recent-card, .kpi {
  transition:
    transform var(--motion-fast) var(--ease-spring),
    box-shadow var(--motion-base) var(--ease-out),
    border-color var(--motion-fast) var(--ease-out),
    background var(--motion-fast) var(--ease-out);
}
.type-card:hover { transform: translateY(-3px); box-shadow: var(--sh-card-hi); }
.week-card:hover { transform: translateY(-3px) scale(1.005); box-shadow: var(--sh-card-hi); }
.kpi:hover       { transform: translateY(-2px); box-shadow: var(--sh-card-hi); }
.recent-card:hover { transform: translateY(-2px); box-shadow: var(--sh-card-hi); }

.btn { transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast), transform 160ms var(--ease-spring), box-shadow var(--motion-fast); }
.btn:hover:not(:disabled) { transform: translateY(-1.5px); }
.btn:active:not(:disabled) { transform: translateY(0); }

.icon-btn { transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast), transform 160ms var(--ease-spring); }
.icon-btn:hover { transform: scale(1.06); }
.icon-btn:active { transform: scale(0.96); }

.nav-item { transition: background var(--motion-fast), color var(--motion-fast), padding-left var(--motion-fast) var(--ease-out); }
.nav-item:hover { padding-left: calc(var(--s-3) + 4px); }

.step { transition: background var(--motion-fast), color var(--motion-fast), transform var(--motion-fast) var(--ease-spring); }
.step.active, .step.done { transform: scale(1.04); }

.input, .textarea, .select { transition: border-color var(--motion-fast), box-shadow var(--motion-base) var(--ease-out), background var(--motion-fast); }

.smart-tab { transition: background var(--motion-fast), color var(--motion-fast), transform 160ms var(--ease-spring); }
.smart-tab:active { transform: scale(0.97); }

.chip { transition: background var(--motion-fast), color var(--motion-fast), transform 160ms var(--ease-spring); }

.zoom-btn { transition: background var(--motion-fast), color var(--motion-fast), transform 140ms var(--ease-spring); }
.zoom-btn:hover { transform: scale(1.1); }

/* Brand mark — gentle float + hover spring */
.brand-mark { animation: brand-float 5s ease-in-out infinite; transition: transform 240ms var(--ease-spring); }
.brand-mark:hover { animation-play-state: paused; transform: rotate(-10deg) scale(1.08); }

/* Active type-card icon — pop in on select */
.type-card.active .type-icon-wrap { animation: icon-pop 360ms var(--ease-spring) both; }

/* Smart Fill icon — pulsing ripple */
.smart-icon { position: relative; }
.smart-icon::before {
  content: '';
  position: absolute; inset: -2px;
  border-radius: inherit;
  border: 2px solid var(--wine);
  opacity: 0;
  animation: ripple 2.4s ease-out infinite;
  pointer-events: none;
}

/* Live preview dot — pulse ring */
.live-head span[style*="background: var(--ok)"] { animation: pulse-ring 2s ease-out infinite; }

/* Page-level: every view fades up */
.in { animation: fade-up 380ms var(--ease-out) both; }

/* ═══ Staggered children ═══ */
.types-grid > * { animation: fade-up 420ms var(--ease-out) both; }
.types-grid > *:nth-child(1)  { animation-delay: 40ms; }
.types-grid > *:nth-child(2)  { animation-delay: 80ms; }
.types-grid > *:nth-child(3)  { animation-delay: 120ms; }
.types-grid > *:nth-child(4)  { animation-delay: 160ms; }
.types-grid > *:nth-child(5)  { animation-delay: 200ms; }
.types-grid > *:nth-child(6)  { animation-delay: 240ms; }
.types-grid > *:nth-child(7)  { animation-delay: 280ms; }
.types-grid > *:nth-child(8)  { animation-delay: 320ms; }
.types-grid > *:nth-child(9)  { animation-delay: 360ms; }
.types-grid > *:nth-child(10) { animation-delay: 400ms; }

.recent-strip > * { animation: fade-up 380ms var(--ease-out) both; }
.recent-strip > *:nth-child(1) { animation-delay: 80ms; }
.recent-strip > *:nth-child(2) { animation-delay: 120ms; }
.recent-strip > *:nth-child(3) { animation-delay: 160ms; }
.recent-strip > *:nth-child(4) { animation-delay: 200ms; }

.kpi-row > * { animation: fade-up 420ms var(--ease-out) both; }
.kpi-row > *:nth-child(1) { animation-delay: 60ms; }
.kpi-row > *:nth-child(2) { animation-delay: 120ms; }
.kpi-row > *:nth-child(3) { animation-delay: 180ms; }
.kpi-row > *:nth-child(4) { animation-delay: 240ms; }

.weekly-grid > * { animation: fade-up 380ms var(--ease-out) both; }
.weekly-grid > *:nth-child(1)  { animation-delay: 60ms; }
.weekly-grid > *:nth-child(2)  { animation-delay: 90ms; }
.weekly-grid > *:nth-child(3)  { animation-delay: 120ms; }
.weekly-grid > *:nth-child(4)  { animation-delay: 150ms; }
.weekly-grid > *:nth-child(5)  { animation-delay: 180ms; }
.weekly-grid > *:nth-child(6)  { animation-delay: 210ms; }
.weekly-grid > *:nth-child(7)  { animation-delay: 240ms; }
.weekly-grid > *:nth-child(8)  { animation-delay: 270ms; }
.weekly-grid > *:nth-child(9)  { animation-delay: 300ms; }
.weekly-grid > *:nth-child(10) { animation-delay: 330ms; }
.weekly-grid > *:nth-child(11) { animation-delay: 360ms; }
.weekly-grid > *:nth-child(12) { animation-delay: 390ms; }

.sidebar .nav-item { animation: slide-rt 320ms var(--ease-out) both; }
.sidebar .nav-item:nth-child(1) { animation-delay: 40ms; }
.sidebar .nav-item:nth-child(2) { animation-delay: 70ms; }
.sidebar .nav-item:nth-child(3) { animation-delay: 100ms; }
.sidebar .nav-item:nth-child(4) { animation-delay: 130ms; }
.sidebar .nav-item:nth-child(5) { animation-delay: 160ms; }
.sidebar .nav-item:nth-child(6) { animation-delay: 190ms; }
.sidebar .nav-item:nth-child(7) { animation-delay: 220ms; }

.form-stack > * { animation: fade-up 380ms var(--ease-out) both; }
.form-stack > *:nth-child(1) { animation-delay: 40ms; }
.form-stack > *:nth-child(2) { animation-delay: 100ms; }
.form-stack > *:nth-child(3) { animation-delay: 160ms; }
.form-stack > *:nth-child(4) { animation-delay: 220ms; }
.form-stack > *:nth-child(5) { animation-delay: 280ms; }

.live-pane { animation: fade-up 480ms var(--ease-out) 160ms both; }

/* Progress bar fill animation */
.week-progress-bar > span {
  transition: width 600ms var(--ease-out);
  background-size: 200% 100%;
  background-image: linear-gradient(90deg, var(--wine), var(--wine-deep), var(--wine));
  animation: gradient-sweep 4s ease-in-out infinite;
}

/* Project banner — soft glow drift */
.project-banner::after {
  animation: pulse-glow 5s ease-in-out infinite;
}

/* Type tag PRIORITY — subtle blink */
.type-tag { transition: color var(--motion-fast); }
.type-card.active .type-tag { color: var(--wine); }

/* ═══ Mobile dampening — moderate motion only ═══ */
body.device-mobile {
  --motion-fast: 140ms;
  --motion-base: 200ms;
  --motion-slow: 320ms;
}
body.device-mobile .type-card:hover,
body.device-mobile .week-card:hover,
body.device-mobile .kpi:hover,
body.device-mobile .recent-card:hover { transform: none; }
body.device-mobile .btn:hover:not(:disabled),
body.device-mobile .icon-btn:hover,
body.device-mobile .zoom-btn:hover { transform: none; }
body.device-mobile .brand-mark { animation: none; }
body.device-mobile .smart-icon::before { animation: none; opacity: 0; }
body.device-mobile .week-progress-bar > span { animation: none; background-image: linear-gradient(90deg, var(--wine), var(--wine-deep)); }
body.device-mobile .project-banner::after { animation: none; }
body.device-mobile .types-grid > *,
body.device-mobile .weekly-grid > *,
body.device-mobile .recent-strip > *,
body.device-mobile .kpi-row > *,
body.device-mobile .form-stack > * { animation-duration: 280ms; }
body.device-mobile .types-grid > *:nth-child(n+5) { animation-delay: 200ms; }
body.device-mobile .weekly-grid > *:nth-child(n+5) { animation-delay: 200ms; }

/* ═══ Animated palette-aware background ═══ */
body::before {
  content: '';
  position: fixed;
  inset: -15%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(closest-side at 18% 22%, var(--wine-tint-2), transparent 70%),
    radial-gradient(closest-side at 82% 70%, var(--wine-tint), transparent 70%),
    radial-gradient(closest-side at 50% 100%, var(--wine-tint-2), transparent 70%);
  filter: blur(40px);
  opacity: 0.85;
  animation: bg-drift 28s ease-in-out infinite alternate;
}
[data-theme="dark"] body::before { opacity: 0.6; filter: blur(60px); }

@keyframes bg-drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  33%  { transform: translate3d(2%, -1.5%, 0) rotate(8deg) scale(1.05); }
  66%  { transform: translate3d(-1.5%, 2%, 0) rotate(-6deg) scale(0.98); }
  100% { transform: translate3d(1%, 1%, 0) rotate(4deg) scale(1.04); }
}

/* second layer — orbiting blob */
body::after {
  content: '';
  position: fixed;
  width: 60vw; height: 60vw;
  max-width: 800px; max-height: 800px;
  top: -15%;
  right: -10%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(circle, var(--wine-tint-2), transparent 65%);
  filter: blur(50px);
  opacity: 0.6;
  animation: bg-orbit 36s linear infinite;
}
[data-theme="dark"] body::after { opacity: 0.4; }

@keyframes bg-orbit {
  0%   { transform: translate(0, 0) rotate(0); }
  25%  { transform: translate(-30%, 20%) rotate(90deg); }
  50%  { transform: translate(-50%, 50%) rotate(180deg); }
  75%  { transform: translate(-20%, 70%) rotate(270deg); }
  100% { transform: translate(0, 0) rotate(360deg); }
}

/* ═══ Scroll-spy section pins ═══ */
.section-pins {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 6px;
  padding: 12px 0;
  margin: -12px 0 var(--s-5);
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.pin {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--ink-3);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: all var(--motion-fast) var(--ease-out);
  position: relative;
}
.pin:hover { color: var(--ink); border-color: var(--line-3); }
.pin-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--line-3);
  transition: all var(--motion-fast) var(--ease-spring);
}
.pin.active {
  background: var(--wine-tint);
  border-color: var(--wine-tint-2);
  color: var(--wine);
  padding-right: 18px;
}
.pin.active .pin-dot {
  background: var(--wine);
  box-shadow: 0 0 0 4px var(--wine-tint-2);
  transform: scale(1.1);
}
.pin .pin-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-left: 4px;
}
.pin.active .pin-count { color: var(--wine); }

/* ═══ Drag-to-reorder visuals ═══ */
.type-card.dragging {
  opacity: 0.4;
  transform: scale(0.96);
  cursor: grabbing;
}
.type-card.drop-target {
  border-color: var(--wine) !important;
  box-shadow: var(--sh-card-hi), 0 0 0 4px var(--wine-tint) !important;
  transform: translateY(-3px);
}
.type-card.drop-target::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px dashed var(--wine);
  border-radius: inherit;
  pointer-events: none;
  animation: pulse-glow 1s ease-in-out infinite;
}
.drag-handle {
  position: absolute;
  top: 12px; left: 12px;
  width: 22px; height: 22px;
  display: none;
  align-items: center; justify-content: center;
  color: var(--ink-4);
  cursor: grab;
  border-radius: 4px;
  transition: all var(--motion-fast);
}
.drag-handle:hover { color: var(--wine); background: var(--wine-tint); }
.drag-handle:active { cursor: grabbing; }
.type-card:hover .drag-handle { display: flex; }
body.device-mobile .drag-handle { display: none !important; }
body.device-mobile .type-card[draggable="true"] { -webkit-user-drag: none; }

@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print — keep functional */
@media print {
  .sidebar, .topbar, .page-head, .preview-toolbar, .stepper { display: none !important; }
  body { background: #fff; }
  .preview-stage { background: #fff; border: 0; padding: 0; }
  .a4-paper { box-shadow: none; padding: 60px 70px; }
}

/* ═══════════════════════════════════════════
   New views — Recent / Projects / Archive / Settings
   ═══════════════════════════════════════════ */

/* ── List toolbar (search + filter pills) ── */
.list-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}
.search-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0 var(--s-3);
  height: 40px;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.search-field:focus-within {
  border-color: var(--wine);
  box-shadow: 0 0 0 3px var(--wine-tint);
}
.search-field .icn { color: var(--ink-3); flex-shrink: 0; }
.search-field input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  padding: 0 var(--s-2);
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
}
.search-field input::placeholder { color: var(--ink-3); }
.search-clear {
  display: grid; place-items: center;
  width: 22px; height: 22px; border: 0;
  background: var(--bg-2); color: var(--ink-3);
  border-radius: 999px; cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.search-clear:hover { background: var(--line-2); color: var(--ink); }

.filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: var(--fw-bold);
  cursor: pointer;
  transition: all var(--motion-fast);
  white-space: nowrap;
}
.filter-pill:hover { border-color: var(--line-3); color: var(--ink); }
.filter-pill.active {
  background: var(--wine-tint);
  border-color: var(--wine-tint-2);
  color: var(--wine);
}
.filter-pill-count {
  font-size: 11px;
  font-weight: var(--fw-heavy);
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink-3);
}
.filter-pill.active .filter-pill-count {
  background: var(--wine);
  color: #fff;
}

/* ── Document list ── */
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: all var(--motion-fast);
}
.doc-row:hover {
  border-color: var(--line-3);
  transform: translateY(-1px);
  box-shadow: var(--sh-card);
}
.doc-row-body {
  flex: 1;
  min-width: 0;
}
.doc-row-title {
  font-size: 13.5px;
  font-weight: var(--fw-bold);
  color: var(--ink);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-row-meta {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 4px;
  font-weight: var(--fw-semi);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.doc-row-meta .icn { vertical-align: -1px; margin-right: 2px; }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--s-9) var(--s-4);
  background: var(--surface);
  border: 1px dashed var(--line-3);
  border-radius: var(--r-lg);
  gap: 10px;
}
.empty-state-icon {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--bg-2);
  color: var(--ink-3);
  margin-bottom: 4px;
}
.empty-state-title {
  font-size: 16px;
  font-weight: var(--fw-heavy);
  color: var(--ink);
}
.empty-state-sub {
  font-size: 13px;
  color: var(--ink-3);
}

/* ── Project list cards ── */
.project-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition: all var(--motion-fast) var(--ease-spring);
}
.project-card:hover {
  border-color: var(--line-3);
  transform: translateY(-2px);
  box-shadow: var(--sh-card-hi);
}
.project-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: var(--s-3);
}
.project-card-no {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--fw-heavy);
  letter-spacing: 0.04em;
  color: var(--wine);
  text-transform: uppercase;
}
.project-card-title {
  font-size: 17px;
  font-weight: var(--fw-heavy);
  color: var(--ink);
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.project-card-meta {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: var(--fw-semi);
  margin-bottom: 14px;
}
.project-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.project-card-meta .icn { color: var(--wine); }

.project-card-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.project-card-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
}
.project-card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--wine), var(--wine-deep));
  border-radius: 999px;
  transition: width 400ms var(--ease-out);
}
.project-card-progress-label {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: var(--fw-heavy);
  color: var(--ink);
  min-width: 42px;
  text-align: right;
}
.project-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  padding-top: 12px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.project-card-stats {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: var(--fw-semi);
  display: flex;
  gap: 6px;
  align-items: center;
}
.project-card-stats strong {
  color: var(--ink);
  font-weight: var(--fw-heavy);
}

/* ── Stub badge ── */
.stub-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--amber-soft, var(--warn-soft));
  color: var(--amber, var(--warn));
  font-size: 10px;
  font-weight: var(--fw-heavy);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 6px;
}
.stub-badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: stub-pulse 1.8s ease-in-out infinite;
}
@keyframes stub-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ── Stub banner ── */
.stub-banner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--warn-soft, rgba(245, 158, 11, 0.08));
  border: 1px solid var(--warn-bd, rgba(245, 158, 11, 0.25));
  border-radius: var(--r-md);
  margin-bottom: var(--s-5);
}
.stub-banner-icon {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--warn);
  flex-shrink: 0;
}
[data-theme="dark"] .stub-banner-icon { background: rgba(0, 0, 0, 0.25); }
.stub-banner-title {
  font-size: 14.5px;
  font-weight: var(--fw-heavy);
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 3px;
}
.stub-banner-sub {
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: var(--fw-medium);
  line-height: 1.5;
}

/* ── Archive table ── */
.archive-table {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.archive-table-head,
.archive-table-row {
  display: grid;
  grid-template-columns: 130px 110px 150px 1fr 120px;
  gap: var(--s-3);
  padding: 12px var(--s-4);
  align-items: center;
}
.archive-table-head {
  background: var(--bg-2);
  font-size: 11px;
  font-weight: var(--fw-heavy);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
.archive-table-row {
  font-size: 13px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  font-weight: var(--fw-semi);
}
.archive-table-row:last-of-type { border-bottom: 0; }
.archive-table .mono {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: var(--fw-bold);
  color: var(--wine);
}
.archive-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archive-table.is-stub { user-select: none; }
.archive-table.is-stub .archive-table-row { opacity: 0.55; filter: saturate(0.7); }

.stub-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.85) 50%);
  display: grid;
  place-items: center;
  padding: var(--s-5);
  pointer-events: none;
}
[data-theme="dark"] .stub-overlay {
  background: linear-gradient(180deg, rgba(15,15,18,0.2) 0%, rgba(15,15,18,0.88) 50%);
}
.stub-overlay-card {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  box-shadow: var(--sh-card-hi);
  text-align: center;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.stub-overlay-icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--wine-tint);
  color: var(--wine);
  margin-bottom: 4px;
}
.stub-overlay-title {
  font-size: 16px;
  font-weight: var(--fw-heavy);
  color: var(--ink);
  letter-spacing: -0.01em;
}
.stub-overlay-sub {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
  margin-bottom: 8px;
}

/* ── Settings ── */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--s-4);
}
.settings-section-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 14px var(--s-5);
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.settings-section-icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--wine-tint);
  color: var(--wine);
}
.settings-section-head h3 {
  font-size: 14px;
  font-weight: var(--fw-heavy);
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0;
}
.settings-rows {
  display: flex;
  flex-direction: column;
}
.settings-row {
  display: grid;
  grid-template-columns: 220px 1fr 40px;
  gap: var(--s-4);
  align-items: center;
  padding: 14px var(--s-5);
  border-bottom: 1px solid var(--line);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row-label {
  font-size: 13px;
  font-weight: var(--fw-bold);
  color: var(--ink);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.settings-row-value {
  font-size: 13px;
  color: var(--ink-2);
  font-weight: var(--fw-medium);
}
.settings-row.is-stub .settings-row-value { color: var(--ink-3); font-style: italic; }
.settings-row-action {
  width: 32px !important;
  height: 32px !important;
}
.settings-row-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.settings-foot {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-top: var(--s-4);
}

/* Stagger animations for new views */
.doc-list > * { animation: fade-up 380ms var(--ease-out) both; }
.doc-list > *:nth-child(1) { animation-delay: 40ms; }
.doc-list > *:nth-child(2) { animation-delay: 80ms; }
.doc-list > *:nth-child(3) { animation-delay: 120ms; }
.doc-list > *:nth-child(4) { animation-delay: 160ms; }
.doc-list > *:nth-child(5) { animation-delay: 200ms; }
.doc-list > *:nth-child(n+6) { animation-delay: 240ms; }

.project-list > * { animation: fade-up 420ms var(--ease-out) both; }
.project-list > *:nth-child(1) { animation-delay: 60ms; }
.project-list > *:nth-child(2) { animation-delay: 120ms; }
.project-list > *:nth-child(3) { animation-delay: 180ms; }
.project-list > *:nth-child(4) { animation-delay: 240ms; }
.project-list > *:nth-child(n+5) { animation-delay: 300ms; }

.settings-section { animation: fade-up 400ms var(--ease-out) both; }
.settings-section:nth-child(2) { animation-delay: 60ms; }
.settings-section:nth-child(3) { animation-delay: 120ms; }
.settings-section:nth-child(4) { animation-delay: 180ms; }
.settings-section:nth-child(5) { animation-delay: 240ms; }

/* Mobile adjustments */
body.device-mobile .archive-table-head,
body.device-mobile .archive-table-row {
  grid-template-columns: 1fr 100px;
  font-size: 12px;
}
body.device-mobile .archive-table-head > :nth-child(3),
body.device-mobile .archive-table-head > :nth-child(4),
body.device-mobile .archive-table-head > :nth-child(5),
body.device-mobile .archive-table-row > :nth-child(3),
body.device-mobile .archive-table-row > :nth-child(4),
body.device-mobile .archive-table-row > :nth-child(5) { display: none; }
body.device-mobile .settings-row {
  grid-template-columns: 1fr 40px;
}
body.device-mobile .settings-row-value {
  grid-column: 1 / -1;
  font-size: 12.5px;
  padding-top: 4px;
}
body.device-mobile .project-card-meta { gap: 10px; }
body.device-mobile .project-card-title { font-size: 15px; }

@media (max-width: 720px) {
  .archive-table-head,
  .archive-table-row {
    grid-template-columns: 1fr 100px;
  }
  .archive-table-head > :nth-child(3),
  .archive-table-head > :nth-child(4),
  .archive-table-head > :nth-child(5),
  .archive-table-row > :nth-child(3),
  .archive-table-row > :nth-child(4),
  .archive-table-row > :nth-child(5) { display: none; }
  .settings-row {
    grid-template-columns: 1fr 40px;
  }
  .settings-row-value {
    grid-column: 1 / -1;
  }
}
