/**
 * The Work v5.0 — Kintsugi UI
 * Source: design_handoff_kintsugi_redesign/styles.css + design-tokens.css
 */

/* ============================================
   RESET
   ============================================ */

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

/* ============================================
   iOS PWA BASE
   ============================================ */

html {
  height: -webkit-fill-available;
}

* {
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  line-height: 1.55;
}

/* ============================================
   DESIGN TOKENS — shared across all themes
   ============================================ */

:root {
  /* Gold — the seam */
  --gold: #a07e2c;
  --gold-bright: #c89b35;
  --gold-glow: rgba(200, 155, 53, 0.35);
  --gold-wash: rgba(200, 155, 53, 0.08);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-pill: 20px;

  /* Elevation */
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.04);
  --elev-2: 0 1px 2px rgba(0, 0, 0, 0.15), 0 8px 20px -8px rgba(0, 0, 0, 0.2);
  --seam-glow: 0 0 6px var(--gold-glow);

  /* Typography */
  --font-serif: "Newsreader", "Cormorant Garamond", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;

  /* Legacy aliases — referenced by existing JS */
  --font-primary: var(--font-sans);
  --font-family: var(--font-sans);
  --shadow-sm: var(--elev-1);
  --shadow-md: var(--elev-2);
  --overlay-dark: rgba(0, 0, 0, 0.8);
  --touch-target: 44px;
}

/* ============================================
   THEME: Porcelain — default light
   ============================================ */

:root:not([data-theme]),
[data-theme="light"] {
  --bg: #f6f2ec;
  --bg-raised: #ede7dd;
  --bg-sunk: #e3dccf;
  --ink: #1d1a17;
  --ink-2: #4a443c;
  --ink-3: #8a8278;
  --ink-4: #b5ad9f;
  --rule: #d9d0bf;
  --rule-soft: #e4dccb;
  --good: #4c6b38;
  --danger: #a8432f;
  color-scheme: light;
}

/* ============================================
   THEME: Sumi — dark
   ============================================ */

[data-theme="dark"] {
  --bg: #141316;
  --bg-raised: #1d1c1f;
  --bg-sunk: #0d0c0e;
  --ink: oklch(94% 0.012 38);
  --ink-2: oklch(76% 0.013 38);
  --ink-3: oklch(73% 0.014 35);
  --ink-4: oklch(53% 0.01 35);
  --rule: #2a2926;
  --rule-soft: #23221f;
  --good: #7a9b65;
  --danger: #b86655;
  color-scheme: dark;
}

/* ============================================
   THEME: Sumi Light — alt light
   ============================================ */

[data-theme="sumi-light"] {
  --bg: #f6f2ec;
  --bg-raised: #ede7dd;
  --bg-sunk: #e3dccf;
  --ink: oklch(17% 0.012 40);
  --ink-2: oklch(39% 0.014 40);
  --ink-3: oklch(56% 0.016 42);
  --ink-4: oklch(74% 0.012 42);
  --rule: #d9d0bf;
  --rule-soft: #e4dccb;
  --good: #4c6b38;
  --danger: #a8432f;
  color-scheme: light;
}

/* System preference fallback when no data-theme set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #141316;
    --bg-raised: #1d1c1f;
    --bg-sunk: #0d0c0e;
    --ink: oklch(94% 0.012 38);
    --ink-2: oklch(76% 0.013 38);
    --ink-3: oklch(73% 0.014 35);
    --ink-4: oklch(53% 0.01 35);
    --rule: #2a2926;
    --rule-soft: #23221f;
    --good: #7a9b65;
    --danger: #b86655;
    color-scheme: dark;
  }
}

/* ============================================
   TYPE UTILITIES
   ============================================ */

.serif {
  font-family: var(--font-serif);
  font-feature-settings: "ss01";
}
.mono {
  font-family: var(--font-mono);
  font-feature-settings: "zero", "ss01";
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}

.t-display-xl {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.t-display {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.t-body-lg {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: -0.005em;
}
.t-body {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.005em;
}
.t-body-sm {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 13px;
  line-height: 1.5;
}
.t-label {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 12px;
  line-height: 1.4;
}
.t-eyebrow {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.t-meta {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

/* ============================================
   THE SEAM — one per screen
   ============================================ */

.seam {
  position: relative;
  height: 1px;
  width: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--gold) 18%,
    var(--gold-bright) 50%,
    var(--gold) 82%,
    transparent 100%
  );
  overflow: visible;
  flex-shrink: 0;
}
.seam::before {
  content: "";
  position: absolute;
  inset: -0.5px 0;
  background: inherit;
  filter: blur(1.5px);
  opacity: 0.5;
}
.seam-irregular {
  position: relative;
  height: 8px;
  width: 100%;
  pointer-events: none;
}
.seam-irregular svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.seam-irregular path {
  stroke: var(--gold);
  stroke-width: 1.2;
  fill: none;
  filter: drop-shadow(0 0 2px var(--gold-glow));
}

/* ============================================
   APP SHELL / LAYOUT
   ============================================ */

.app-shell {
  height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.app-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}
.app-body::-webkit-scrollbar {
  display: none;
}

/* ============================================
   APPBAR
   ============================================ */

.appbar {
  padding: 8px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.appbar-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
}
.appbar-title.serif {
  font-weight: 300;
  font-size: 26px;
  letter-spacing: -0.03em;
}
.appbar-title em {
  font-style: italic;
  color: var(--gold);
}
.appbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover {
  border-color: var(--gold);
  color: var(--ink);
}
.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   TAB BAR
   ============================================ */

.tabbar {
  display: flex;
  justify-content: space-around;
  padding: 0 16px 0;
  border-top: 1px solid var(--rule);
  background: var(--bg);
  flex-shrink: 0;
  position: relative;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  padding: 8px 4px 0;
  background: transparent;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
  position: relative;
}
.tab svg {
  width: 22px;
  height: 22px;
}
.tab-label {
  font-size: 10px;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.tab.active {
  color: var(--ink);
}
.tab-indicator {
  display: none;
}
.tab.active .tab-indicator {
  display: block;
  position: absolute;
  top: 0;
  height: 2px;
  width: 24px;
  background: var(--gold);
  border-radius: 0 0 2px 2px;
  box-shadow: 0 0 8px var(--gold-glow);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn-primary {
  background: var(--ink);
  color: var(--bg);
}
.btn-primary:hover {
  opacity: 0.88;
}
.btn-gold {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--gold);
  position: relative;
}
.btn-gold::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--gold-wash), transparent);
  opacity: 0.4;
  pointer-events: none;
}
.btn-gold span {
  position: relative;
}
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--rule);
}
.btn-ghost:hover {
  color: var(--ink);
  border-color: var(--ink-3);
}

/* ============================================
   CATEGORY CHIPS
   ============================================ */

.chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 20px 2px;
  margin-bottom: 14px;
  scrollbar-width: none;
  flex-shrink: 0;
}
.chip-row::-webkit-scrollbar {
  display: none;
}
.chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.chip:hover {
  color: var(--ink);
}
.chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.chip-count {
  margin-left: 6px;
  font-size: 10px;
  opacity: 0.55;
  font-family: var(--font-mono);
}

/* ============================================
   CONVERSATIONS LIST
   ============================================ */

.conv-list {
  padding: 6px 20px 20px;
}
.conv {
  padding: 16px 0;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}
.conv:last-child {
  border-bottom: none;
}
.conv-title {
  font-size: 15.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--ink);
  margin-bottom: 6px;
}
.conv-preview {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.conv-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}
.conv-cat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}
.conv-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding-top: 2px;
}
.conv-time {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.conv-tag {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.conv-seam {
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 18px;
  background: var(--gold);
  transform: translate(-22px, -50%);
  border-radius: 2px;
  box-shadow: 0 0 4px var(--gold-glow);
  opacity: 0;
}
.conv.unread .conv-seam {
  opacity: 1;
}
.conv.unread .conv-title {
  color: var(--ink);
}

/* Category dot colors */
.conv-cat-dot.cat-relationship {
  background: #9b5555;
}
.conv-cat-dot.cat-work {
  background: #5a7b8c;
}
.conv-cat-dot.cat-family {
  background: #8a6ba0;
}
.conv-cat-dot.cat-personal {
  background: #6f8a5f;
}
.conv-cat-dot.cat-trauma {
  background: #b87d2a;
}
.conv-cat-dot.cat-health {
  background: #6f9a6f;
}

/* Section date headers */
.conv-section-header {
  padding: 16px 0 8px;
}
.conv-section-header .eyebrow {
  color: var(--ink-3);
}

/* ============================================
   CHAT MESSAGES
   ============================================ */

.chat-scroll {
  padding: 16px 16px 120px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.msg-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 88%;
}
.msg-group-user {
  align-self: flex-end;
  align-items: flex-end;
}
.msg-group-claude {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-role {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
  margin-bottom: 6px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.msg-role::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
}
.msg-role-claude {
  color: var(--gold-bright);
}
.msg-role-claude::before {
  background: var(--gold-bright);
  box-shadow: 0 0 6px var(--gold-glow);
}

.msg {
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  color: var(--ink);
}

/* User bubble — solid ink, inverted */
.msg-user {
  background: var(--ink);
  color: var(--bg);
  padding: 13px 16px;
  border-radius: 18px 18px 4px 18px;
  border: none;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.15),
    0 8px 20px -8px rgba(0, 0, 0, 0.2);
}

/* Claude bubble — raised surface + gold left seam */
.msg-claude {
  padding: 14px 16px 14px 18px;
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--rule-soft);
  border-radius: 4px 18px 18px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
/* THE SIGNATURE — vertical gold seam on every Claude bubble */
.msg-claude::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10%;
  bottom: 10%;
  width: 2px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--gold) 20%,
    var(--gold-bright) 50%,
    var(--gold) 80%,
    transparent 100%
  );
  box-shadow: 0 0 6px var(--gold-glow);
}
.msg-claude strong {
  color: var(--ink);
  font-weight: 600;
}
.msg-claude em {
  color: var(--gold);
  font-style: italic;
}

.msg-meta {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  margin-top: 6px;
  letter-spacing: 0.02em;
  padding: 0 4px;
}

/* ============================================
   DRAFT CARD (RAW / A / B)
   ============================================ */

.draft-card {
  margin-top: 10px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-raised);
}
.draft-header {
  display: flex;
  padding: 0;
  border-bottom: 1px solid var(--rule);
}
.draft-tab {
  flex: 1;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.draft-tab.active {
  color: var(--ink);
  border-bottom-color: var(--gold);
  background: var(--bg-sunk);
}
.draft-body {
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  min-height: 80px;
}

/* ============================================
   COMPOSER
   ============================================ */

.composer {
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--rule);
  background: var(--bg);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.composer-input {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 20px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.4;
  letter-spacing: -0.005em;
  caret-color: var(--gold);
}
.composer-input:focus {
  outline: none;
  border-color: var(--gold);
}
.composer-input::placeholder {
  color: var(--ink-3);
}
.composer-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.composer-btn:hover {
  transform: scale(1.04);
}
.composer-btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   PIN SCREEN
   ============================================ */

.pin-screen {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 40px 28px;
}
.pin-logo {
  margin-top: 0;
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 34px;
  letter-spacing: -0.03em;
  line-height: 1;
  text-align: center;
}
.pin-logo em {
  font-style: italic;
  color: var(--gold);
  font-weight: 400;
}
.pin-sub {
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
  letter-spacing: 0.01em;
}
.pin-dots {
  display: flex;
  gap: 18px;
  margin-top: 0;
  margin-bottom: 0;
}
.pin-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-4);
  transition: all 0.2s;
}
.pin-dot.filled,
.pin-dot.success {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 10px var(--gold-glow);
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
}
.pin-key {
  aspect-ratio: 1;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 28px;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.pin-key:hover {
  border-color: var(--gold);
}
.pin-key:active {
  background: var(--gold);
  color: var(--bg);
  border-color: var(--gold);
  transform: scale(0.95);
}
.pin-key-empty {
  border: none;
  pointer-events: none;
}
.pin-footer {
  margin-top: 0;
  padding-top: 0;
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--ink-3);
}
.pin-footer button {
  background: none;
  border: none;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  font-size: inherit;
}
.pin-footer button:hover {
  color: var(--gold);
}
.pin-error {
  color: var(--danger);
  text-align: center;
  font-size: 13px;
  margin-top: 8px;
  padding: 8px 16px;
  background: color-mix(in oklab, var(--danger) 12%, transparent);
  border-radius: 8px;
}
.pin-hint {
  color: var(--ink-3);
  text-align: center;
  font-size: 13px;
  margin-top: 8px;
}

/* ============================================
   DASHBOARD
   ============================================ */

.dash-head {
  padding: 8px 20px 16px;
}
.dash-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.dash-title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 32px;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-top: 6px;
  color: var(--ink);
}
.dash-title em {
  font-style: italic;
  color: var(--gold);
}
.dash-title .delta-good-text {
  color: var(--good);
  font-style: normal;
}
.dash-title .delta-bad-text {
  color: var(--danger);
  font-style: normal;
}
.dash-title .delta-bad-text em {
  color: var(--danger);
  font-style: italic;
}
.dash-period {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.dash-segments {
  display: flex;
  padding: 0 20px;
  gap: 2px;
  margin-bottom: 20px;
  flex-shrink: 0;
}
.seg {
  flex: 1;
  padding: 9px 8px;
  background: transparent;
  border: 1px solid var(--rule);
  border-right: none;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.15s;
}
.seg:first-child {
  border-radius: 8px 0 0 8px;
}
.seg:last-child {
  border-radius: 0 8px 8px 0;
  border-right: 1px solid var(--rule);
}
.seg.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  z-index: 1;
}
.dash-body {
  padding: 0 20px 80px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}
.stat {
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg-raised);
}
.stat-eyebrow {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-value {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 28px;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}
.stat-delta {
  margin-top: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--ink-2);
  letter-spacing: 0.02em;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 6px;
  border-radius: 999px;
  background: var(--bg-sunk);
  border: 1px solid var(--rule-soft);
}
.stat-delta .arrow {
  font-size: 9px;
  line-height: 1;
}
.stat-delta.up,
.stat-delta.good {
  color: var(--good);
  background: color-mix(in oklab, var(--good) 14%, transparent);
  border-color: color-mix(in oklab, var(--good) 35%, transparent);
}
.stat-delta.down {
  color: var(--danger);
  background: color-mix(in oklab, var(--danger) 14%, transparent);
  border-color: color-mix(in oklab, var(--danger) 35%, transparent);
}
.stat-delta.neutral {
  color: var(--gold);
  background: var(--gold-wash);
  border-color: color-mix(in oklab, var(--gold) 30%, transparent);
}

.section-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 8px 0 10px;
  gap: 12px;
}
.section-h-title {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-3);
}
.section-h-action {
  font-size: 11px;
  color: var(--gold);
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  letter-spacing: 0.02em;
}

.theme-card {
  padding: 16px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.theme-card:last-child {
  border-bottom: none;
}
.theme-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}
.theme-name {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.theme-freq {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--gold-bright);
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--gold) 25%, transparent);
  background: var(--gold-wash);
}
.theme-freq.bad {
  color: var(--danger);
  background: color-mix(in oklab, var(--danger) 12%, transparent);
  border-color: color-mix(in oklab, var(--danger) 35%, transparent);
}
.theme-freq.neutral {
  color: var(--ink-2);
  background: var(--bg-sunk);
  border-color: var(--rule);
}
.theme-freq.new {
  color: var(--gold-bright);
  background: var(--gold-wash);
  border-color: color-mix(in oklab, var(--gold) 45%, transparent);
}
.theme-detail {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
}
.theme-bar {
  margin-top: 10px;
  display: flex;
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--bg-sunk);
  position: relative;
}
.theme-bar-fill {
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}
.theme-quote {
  margin-top: 10px;
  padding-left: 12px;
  border-left: 1px solid var(--gold);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
}

/* ============================================
   SETTINGS
   ============================================ */

.settings-body {
  padding: 0 20px 80px;
}
.setting-group {
  margin-bottom: 24px;
}
.setting-group-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 8px;
  padding-left: 2px;
}
.setting-list {
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-raised);
}
.setting-row {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
}
.setting-row:last-child {
  border-bottom: none;
}
.setting-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.setting-row-title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.setting-row-sub {
  font-size: 11.5px;
  color: var(--ink-3);
}
.setting-row-right {
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.setting-row-right svg {
  width: 12px;
  height: 12px;
}

.toggle {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--bg-sunk);
  border: 1px solid var(--rule);
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink-3);
  top: 3px;
  left: 3px;
  transition: all 0.2s;
}
.toggle.on {
  background: var(--gold);
  border-color: var(--gold);
}
.toggle.on::after {
  left: 21px;
  background: var(--bg);
}

.protocol-card {
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--bg-raised);
  position: relative;
  overflow: hidden;
}
.protocol-card-seam {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.protocol-v {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.protocol-v-num {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 28px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.protocol-v-num em {
  font-style: italic;
  color: var(--gold);
}
.protocol-v-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.protocol-v-source {
  display: inline-block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--gold);
  background: var(--gold-wash);
}
.protocol-v-note {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.55;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.privacy-badge .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 6px var(--good);
}

/* ============================================
   THEME SWITCHER (Settings > Appearance)
   ============================================ */

.theme-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 12px;
}
.theme-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 6px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink-2);
  transition: all 0.15s;
}
.theme-opt-preview {
  width: 56px;
  height: 40px;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.theme-opt-preview .tp-top {
  position: absolute;
  inset: 0;
}
.theme-opt-preview .tp-seam {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transform: translateY(-50%);
}
.theme-opt-preview.light .tp-top {
  background: #f2ede4;
}
.theme-opt-preview.dark .tp-top {
  background: #17161a;
}
.theme-opt-preview.system .tp-top {
  background: linear-gradient(90deg, #f2ede4 0%, #f2ede4 50%, #17161a 50%, #17161a 100%);
}
.theme-opt-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.theme-opt.active {
  border-color: var(--gold);
  color: var(--ink);
}
.theme-opt.active .theme-opt-preview {
  box-shadow: 0 0 0 2px var(--gold-wash);
}

/* ============================================
   SESSION PREP CARD
   ============================================ */

.prep-brief {
  padding: 20px;
  margin-bottom: 18px;
  border: 1px solid var(--gold);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--gold-wash) 0%, transparent 50%);
  position: relative;
}
.prep-brief-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 8px;
}
.prep-brief-body {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  font-weight: 400;
  letter-spacing: -0.005em;
}

/* ============================================
   PWA: SCREEN OVERLAY (PIN auth)
   ============================================ */

.screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: stretch;
}
.screen.active {
  display: flex;
}

/* ============================================
   PWA: MODAL
   ============================================ */

.modal {
  position: fixed;
  inset: 0;
  background: var(--overlay-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 32px;
}

.preview-modal {
  position: fixed;
  inset: 0;
  background: var(--overlay-dark);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 20000;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.preview-content {
  background: var(--bg-raised);
  border-radius: var(--radius-lg);
  border: 1px solid var(--rule);
  padding: 24px;
  width: 100%;
  max-width: 600px;
  margin: auto;
}
.preview-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}
.preview-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--ink-2);
}
.preview-content pre {
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink-2);
  margin-bottom: 20px;
  max-height: 60vh;
  overflow-y: auto;
}
.modal-content {
  background: var(--bg-raised);
  border-radius: var(--radius-lg);
  max-width: 400px;
  width: 100%;
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  overflow: hidden;
}
.modal-large {
  max-width: 560px;
}
.modal-fullscreen {
  max-width: 100%;
  width: 100%;
  height: 100%;
  border-radius: 0;
  margin: 0;
}
.modal-session-prep {
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

/* Session Prep — controls (timeframe selector + focus input) */
.session-prep-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
}
.session-prep-timeframe-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.timeframe-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 500;
}
.timeframe-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.timeframe-btn {
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
  min-height: 44px;
}
.timeframe-btn:hover {
  color: var(--ink);
  border-color: var(--ink-3);
}
.timeframe-btn.timeframe-active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.session-prep-focus-row {
  width: 100%;
}
.session-prep-focus-input {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}
.session-prep-focus-input:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 0 1px var(--gold-glow);
}
.session-prep-focus-input::placeholder {
  color: var(--ink-3);
}

/* Session Prep — content body (briefing output / picker / empty states) */
.session-prep-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}

/* Session Prep — actions row */
.session-prep-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--rule);
}
.session-prep-action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.session-prep-action-row .btn {
  flex: 1;
  min-width: 140px;
}

/* Session Prep — Custom mode conversation picker */
.prep-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.prep-picker-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.prep-picker-links {
  display: flex;
  gap: 12px;
}
.prep-picker-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--gold);
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.prep-picker-link:hover {
  color: var(--gold-bright);
}
.prep-picker-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}
.prep-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  min-height: 44px;
}
.prep-picker-item:last-child {
  border-bottom: none;
}
.prep-picker-item:hover {
  background: var(--bg-raised);
}
.prep-picker-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--gold);
}
.prep-picker-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.prep-picker-item-title {
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prep-picker-item-meta {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono, inherit);
}

/* Audit modal body — scrollable inner region (header + actions stay pinned) */
.protocol-audit-content,
.audit-detail-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}

/* Reusable workflow progress bar (audit, state report, etc.) */
.workflow-progress {
  padding: 24px 4px;
}
.workflow-progress-bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: var(--bg-base, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--rule, rgba(255, 255, 255, 0.08));
  border-radius: 4px;
  overflow: hidden;
}
.workflow-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold, #c9a86a), var(--gold, #c9a86a));
  transition: width 0.25s linear;
  box-shadow: 0 0 8px rgba(201, 168, 106, 0.4);
}
.workflow-progress-fill.progress-pulse {
  animation: workflow-progress-pulse 0.4s ease-out;
}
@keyframes workflow-progress-pulse {
  0% {
    box-shadow: 0 0 8px rgba(201, 168, 106, 0.4);
  }
  50% {
    box-shadow: 0 0 18px rgba(201, 168, 106, 0.85);
  }
  100% {
    box-shadow: 0 0 8px rgba(201, 168, 106, 0.4);
  }
}
.workflow-progress-label {
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

/* Attachment image viewer modal */
.attachment-modal {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attachment-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
}
.attachment-modal-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border-radius: var(--radius-lg);
  border: 1px solid var(--rule);
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow: hidden;
}
.attachment-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.attachment-modal-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-modal-close {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
}
.attachment-modal-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.attachment-modal-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.attachment-modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}
/* Simple alert modals (no modal-header) keep inner padding */
.modal-content:not(:has(.modal-header)) {
  padding: 32px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.modal-header h2 {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
}
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  -webkit-overflow-scrolling: touch;
}
.btn-text {
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  line-height: 1;
}
.btn-text:hover {
  color: var(--ink);
}
.modal-content h2 {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 16px;
  text-align: center;
}
.modal-content p {
  font-size: 14px;
  color: var(--ink-2);
  margin-bottom: 32px;
  line-height: 1.6;
  text-align: center;
}
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 32px 32px;
}
.modal-actions button {
  width: 100%;
}

@media (max-width: 480px) {
  .modal {
    padding: 20px;
  }
  .modal-content {
    padding: 24px;
  }
}

/* ============================================
   PWA: LOADING
   ============================================ */

.loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  z-index: 1000;
  font-size: 14px;
}

/* ============================================
   TOASTS
   ============================================ */

.toast-container {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
  left: 0;
  right: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--elev-2);
  animation: slideUp 0.25s ease-out;
}

.toast.error {
  border-left: 3px solid #e55;
}
.toast.success {
  border-left: 3px solid #5a5;
}
.toast.warning {
  border-left: 3px solid #da5;
}
.toast.info {
  border-left: 3px solid var(--gold);
}

.toast-icon {
  flex-shrink: 0;
  font-size: 14px;
}
.toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes pin-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-6px);
  }
  80% {
    transform: translateX(6px);
  }
}
.pin-dots.shake {
  animation: pin-shake 0.36s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-10px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(10px);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
.spinning {
  animation: spin 0.5s linear;
}
.refresh-btn.spinning {
  animation: spin 0.5s linear;
}

/* ============================================
   LEGACY MIGRATION SCAFFOLDING
   Removed in Step 9 cleanup after HTML rebuild
   ============================================ */

/* .app — full-height PWA container, used until app-shell migration completes */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
}

/* .view — per-screen content area, used until each screen's HTML is rebuilt */
.view {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Views not yet rebuilt still use direct overflow-y scroll on .view */
#import-view {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Refresh button (in old navbar) */
.refresh-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.refresh-btn:hover {
  color: var(--ink);
  border-color: var(--gold);
}
.refresh-btn:active {
  transform: rotate(180deg);
}
