/* ==========================================================================
   KaizenReply — Japanese Precision & Washi Paper Aesthetic Design System
   v3.0 — Glassmorphism · Dark Mode Elegance · Kaizen Animations
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Work+Sans:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=IBM+Plex+Mono:wght@400;500;600&family=Noto+Serif+JP:wght@400;600;700&display=swap');

/* ── Design Tokens — Matte Washi Paper & Deep Moss Palette ───────────────── */
:root {
  --radius: 0.375rem;
  --background: oklch(0.975 0.008 106);
  --foreground: oklch(0.225 0.018 153);
  --card: oklch(1 0 0);
  --primary: oklch(0.30 0.055 151);
  --primary-foreground: oklch(0.98 0.006 105);
  --secondary: oklch(0.948 0.010 105);
  --muted: oklch(0.952 0.007 105);
  --muted-foreground: oklch(0.49 0.018 145);
  --accent: oklch(0.93 0.025 151);
  --accent-foreground: oklch(0.28 0.05 151);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.91 0.009 112);
  --input: oklch(0.88 0.010 112);
  --ring: oklch(0.48 0.08 151);
  --seal: oklch(0.56 0.16 34);
  --proof: oklch(0.992 0.004 105);
  --ink-soft: oklch(0.40 0.018 153);
  --hanko: var(--seal);
  --font-sans: 'Work Sans', system-ui, sans-serif;
  --font-display: 'Instrument Serif', 'Noto Serif JP', serif;
  --font-jp: 'Noto Serif JP', serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --glass-bg: var(--card);
}

[data-theme="dark"], .dark {
  --background: oklch(0.17 0.018 156);
  --foreground: oklch(0.94 0.012 105);
  --card: oklch(0.205 0.018 156);
  --primary: oklch(0.73 0.105 151);
  --primary-foreground: oklch(0.15 0.025 156);
  --secondary: oklch(0.245 0.018 156);
  --muted: oklch(0.245 0.018 156);
  --muted-foreground: oklch(0.72 0.018 115);
  --accent: oklch(0.28 0.035 151);
  --border: oklch(0.36 0.018 156);
  --input: oklch(0.40 0.018 156);
  --ring: oklch(0.67 0.10 151);
  --seal: oklch(0.64 0.17 34);
  --proof: oklch(0.19 0.014 156);
  --ink-soft: oklch(0.77 0.018 115);
  --glass-bg: var(--card);
}

/* ── Reset & Base ─────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; border-color: var(--border); }
html { scroll-behavior: smooth; max-width: 100%; overflow-x: hidden; }
section[id], [id] { scroll-margin-top: 80px; }
body {
  margin: 0;
  max-width: 100%;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.35s ease, color 0.35s ease;
  background-image: radial-gradient(circle at 20% 20%, color-mix(in oklab, var(--foreground) 4%, transparent) 0.6px, transparent 0.8px);
  background-size: 12px 12px;
}
img, svg, video, canvas { max-width: 100%; height: auto; }
::selection { background: color-mix(in oklab, var(--seal) 18%, transparent); }

/* Washi Paper Noise Grain Overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  z-index: 100;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.1'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
.dark body::before { opacity: 0.06; mix-blend-mode: screen; }

.page-shell { width: min(1240px, calc(100% - 40px)); margin-inline: auto; }

h1, h2, h3, blockquote { font-family: var(--font-display); font-weight: 400; letter-spacing: 0; }
button, input, select, textarea { font-family: var(--font-sans); }

.hidden { display: none !important; }

/* ── Glassmorphic Header ────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.nav-shell {
  height: 66px;
  width: min(1320px, calc(100% - 32px));
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--foreground);
  text-decoration: none;
  font-size: 16px;
  font-weight: 700;
  transition: opacity 0.2s;
  flex-shrink: 0;
  min-width: 0;
}
.brand-lockup:hover { opacity: 0.85; }

.brand-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand-text-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.2;
}

.brand-lockup b {
  font-size: 18px;
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.1;
  color: var(--foreground);
}

.brand-tagline {
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted-foreground);
  margin-top: 2px;
  white-space: nowrap;
}

.brand-mark {
  width: 30px; height: 32px; display: grid; place-items: center;
  background: var(--hanko); color: #ffffff;
  font-family: var(--font-jp); font-size: 16px; font-weight: 700;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
  border-radius: 2px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--secondary);
  padding: 3px 5px;
  border-radius: 30px;
  border: 1px solid var(--border);
}
.nav-links a {
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 20px;
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.nav-links a:hover {
  color: var(--foreground);
}
.nav-links a.active {
  color: var(--primary-emphasis);
  background: var(--card);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent);
}
.nav-links a.active::after {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}

/* Dark Mode Navigation Active Indicator */
.dark .nav-links {
  background: rgba(16, 22, 32, 0.75);
  border-color: rgba(255, 255, 255, 0.08);
}
.dark .nav-links a.active {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.16);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.2), 0 0 0 1px rgba(34, 197, 94, 0.35);
}
.dark .nav-links a.active::after {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.nav-actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--foreground);
  width: 40px; height: 40px; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
}
.btn-icon:hover { background: var(--secondary); border-color: var(--primary); }

.btn-hero {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 32%, transparent);
}
.btn-hero:hover { background: var(--primary-emphasis); transform: translateY(-2px); box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 40%, transparent); }
.btn-hero:active { transform: translateY(0); }

.btn-paper {
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-paper:hover { background: var(--secondary); border-color: var(--primary); }

/* ── Hero Section ─────────────────────────────────────────────────────── */
.hero { min-height: calc(100vh - 66px); position: relative; isolation: isolate; overflow: hidden; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.hero-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; object-position: 75% center; filter: contrast(1.05) saturate(1.02); }
.hero-wash { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; background: linear-gradient(90deg, color-mix(in srgb, var(--background) 96%, transparent) 0%, color-mix(in srgb, var(--background) 82%, transparent) 42%, color-mix(in srgb, var(--background) 20%, transparent) 78%, transparent 100%); pointer-events: none; }
.dark .hero-art, .dark .quote-art { filter: brightness(.28) saturate(.65); }

.hero-grid { position: relative; z-index: 2; min-height: calc(100vh - 66px); width: 100%; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr); align-items: center; gap: 60px; padding-block: 32px; }
.hero-copy { position: relative; padding-left: 72px; max-width: 760px; }
.vertical-kaizen { position: absolute; left: 0; top: 5px; display: flex; flex-direction: column; align-items: center; font-family: var(--font-jp); color: var(--primary-emphasis); font-size: 27px; line-height: 1.13; }
.vertical-kaizen i { margin-top: 10px; width: 22px; height: 22px; border: 1px solid var(--hanko); color: var(--hanko); font-size: 9px; font-style: normal; display: grid; place-items: center; }

.eyebrow { margin: 0 0 16px; color: var(--primary-emphasis); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.hero h1 { margin: 0; font-size: clamp(3rem, 5vw, 5rem); line-height: .96; }
.hero h1 em { color: var(--primary-emphasis); font-style: normal; font-family: var(--font-display); }
.hero-lede { max-width: 560px; color: var(--muted-foreground); font-size: 16px; line-height: 1.75; margin: 24px 0; }
.hero-actions { display: flex; gap: 12px; }

.trust-list { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-wrap: wrap; gap: 18px; color: var(--muted-foreground); font-size: 12px; font-weight: 600; }
.trust-list li { display: flex; gap: 6px; align-items: center; }
.trust-list li span { color: var(--primary-emphasis); font-weight: 800; }

/* Mini Preview Card & Typewriter Animation */
.mini-preview { position: relative; z-index: 2; background: var(--card); border: 1px solid var(--border); padding: 22px; border-radius: var(--radius); box-shadow: 0 16px 40px color-mix(in oklab, var(--foreground) 6%, transparent); }
.mini-tabs { height: 36px; display: grid; grid-template-columns: 1fr 1fr; background: var(--secondary); padding: 3px; border-radius: var(--radius); color: var(--muted-foreground); font-size: 11px; font-weight: 700; }
.mini-tabs span { display: flex; align-items: center; justify-content: center; gap: 4px; cursor: default; }
.mini-tabs span.active { background: var(--card); color: var(--primary-emphasis); border-radius: calc(var(--radius) - 2px); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.mini-preview label { display: block; margin: 16px 0 7px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.mini-preview > p, .mini-evolved { min-height: 56px; padding: 12px; margin: 0; border: 1px solid var(--border); background: var(--card); font-size: 12px; line-height: 1.5; border-radius: var(--radius); }
.mini-flow { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px; color: var(--primary-emphasis); font-size: 11px; text-transform: uppercase; font-weight: 800; transition: all 0.3s ease; }
.mini-flow--glowing { color: var(--primary); text-shadow: 0 0 8px rgba(34, 197, 94, 0.4); animation: flowGlowPulse 0.8s ease-in-out infinite alternate; }
@keyframes flowGlowPulse {
  from { transform: scale(0.98); opacity: 0.85; }
  to { transform: scale(1.02); opacity: 1; }
}

.mini-evolved { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); color: var(--primary-emphasis); font-weight: 500; transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
.mini-evolved--active { border-color: var(--primary) !important; background: color-mix(in srgb, var(--primary) 7%, var(--card)) !important; animation: evolvedPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both; }
@keyframes evolvedPopIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.typewriter-cursor { display: inline-block; color: var(--primary); font-weight: 700; margin-left: 2px; animation: typewriterBlink 0.7s infinite; }
@keyframes typewriterBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.mini-score { margin-top: 14px; display: flex; align-items: baseline; gap: 4px; }
.mini-score b { font-size: 26px; color: var(--primary-emphasis); font-variant-numeric: tabular-nums; }
.mini-score span { font-size: 11px; color: var(--muted-foreground); }
.mini-score small { margin-left: auto; color: var(--primary-emphasis); font-weight: 800; font-size: 13px; transition: all 0.3s ease; }

/* ── Workstation Desk Section ──────────────────────────────────────────── */
.desk-section { padding: 80px 0; background: var(--washi-deep); border-bottom: 1px solid var(--border); }
.section-heading { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .65fr); gap: 50px; align-items: end; margin-bottom: 36px; }
.section-heading h2 { font-size: clamp(2.4rem, 4vw, 4.2rem); line-height: .98; margin: 0; }
.section-heading > p { color: var(--muted-foreground); line-height: 1.7; font-size: 15px; max-width: 540px; }

.desk-frame {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 2);
  box-shadow: 0 20px 70px color-mix(in oklab, var(--foreground) 8%, transparent);
}
.desk-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.035; pointer-events: none; }

.desk-column { display: flex; flex-direction: column; gap: 16px; }
.mode-tabs { display: flex; gap: 4px; background: var(--secondary); padding: 4px; border-radius: var(--radius); }
.mode-tabs button {
  flex: 1; padding: 10px 14px; border: none; background: transparent; color: var(--muted-foreground);
  font-size: 13px; font-weight: 700; cursor: pointer; border-radius: calc(var(--radius) - 2px); transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.mode-tabs button.active { background: var(--card); color: var(--foreground); box-shadow: 0 2px 6px rgba(0,0,0,0.05); }

.desk-title { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.desk-title > div { display: flex; align-items: center; gap: 10px; }
.desk-title span { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-foreground); font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.desk-title h3 { font-size: 16px; font-weight: 700; font-family: var(--font-sans); margin: 0; }
.desk-title small { font-size: 12px; color: var(--muted-foreground); }

textarea.desk-textarea {
  width: 100%; min-height: 150px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--background); color: var(--foreground); font-size: 14px; line-height: 1.6; resize: vertical;
  outline: none; transition: border-color 0.2s;
}
textarea.desk-textarea:focus { border-color: var(--primary); }

.demo-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; scrollbar-width: none; -ms-overflow-style: none; }
.demo-row::-webkit-scrollbar { display: none; }
.demo-row span { color: var(--muted-foreground); font-weight: 700; margin-right: 4px; }
.demo-row button {
  background: var(--secondary); border: 1px solid var(--border); color: var(--foreground);
  padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.demo-row button:hover { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }

/* Tone Chips Selector & Category Filters */
.chips-wrap { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--secondary); border: 1px solid var(--border); color: var(--foreground);
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.chip:hover { border-color: var(--primary); }
.chip.active { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }

.tone-cat-filters button {
  background: transparent; border: 1px solid var(--border); color: var(--muted-foreground);
  padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.tone-cat-filters button.active { background: var(--accent); color: var(--accent-foreground); border-color: var(--primary); }


.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.control-field { display: flex; flex-direction: column; gap: 6px; }
.control-field span { font-size: 12px; font-weight: 700; color: var(--muted-foreground); }
.control-field select, .control-field input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--background); color: var(--foreground); font-size: 13px; outline: none; cursor: pointer;
}

.context-toggle {
  background: transparent; border: 1px dashed var(--border); padding: 8px 12px; border-radius: var(--radius);
  color: var(--muted-foreground); font-size: 12px; font-weight: 700; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.context-toggle:hover { border-color: var(--primary); color: var(--foreground); }

.context-drawer { display: flex; flex-direction: column; gap: 12px; background: var(--secondary); padding: 14px; border-radius: var(--radius); }
.context-drawer label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 700; color: var(--muted-foreground); }
.context-drawer input, .context-drawer textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--foreground); font-size: 13px; }

.draft-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: stretch;
}
.draft-actions button {
  flex: 1 1 0%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap !important;
  word-break: keep-all !important;
  padding: 10px 10px;
  font-size: 13px;
  font-weight: 600;
  min-height: 42px;
  line-height: 1;
}
.draft-actions button span,
#evolveBtnText {
  white-space: nowrap !important;
  word-break: keep-all !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.shortcut { font-size: 11px; color: var(--muted-foreground); text-align: center; margin: 0; }

/* ── Desk Columns ─────────────────────────────────────────────────────── */
.desk-frame-inner {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 280px;
}

.draft-column {
  padding: 24px;
  background: var(--card);
  min-width: 0;
  border-right: 1px solid var(--border);
  border-bottom: none;
}

.output-column {
  padding: 24px;
  background: var(--proof);
  min-width: 0;
  border-bottom: none;
}

.desk-marginalia-aside {
  padding: 0;
  background: var(--secondary);
  min-width: 0;
  border-left: 1px solid var(--border);
  border-top: none;
}
.result-state { min-height: 380px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; gap: 12px; }
.result-state h3 { font-size: 20px; margin: 0; font-family: var(--font-sans); font-weight: 700; }
.result-state p { color: var(--muted-foreground); font-size: 13px; max-width: 300px; margin: 0; }

/* ── Japanese / Kaizen Loading Animation ─────────────────────────────── */
@keyframes kaizen-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes kaizen-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.88); }
}

@keyframes kaizen-inkdrop {
  0% { transform: translateY(-12px) scale(0.7); opacity: 0; }
  60% { transform: translateY(2px) scale(1.05); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes kaizen-wave {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

@keyframes hanko-stamp {
  0% { opacity: 0; transform: scale(1.3) rotate(-3deg); }
  60% { opacity: 1; transform: scale(0.95) rotate(1deg); }
  80% { transform: scale(1.02) rotate(-0.5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

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

/* Kaizen Loader Spinner */
.kaizen-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  min-height: 280px;
}

.kaizen-loader__circle {
  position: relative;
  width: 56px;
  height: 56px;
}

.kaizen-loader__circle::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: kaizen-spin 1s linear infinite;
}

.kaizen-loader__kanji {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-jp);
  font-size: 22px;
  color: var(--primary-emphasis);
  animation: kaizen-pulse 1s ease-in-out infinite;
}

.kaizen-loader__dots {
  display: flex;
  gap: 6px;
}

.kaizen-loader__dot {
  width: 5px;
  height: 20px;
  background: var(--primary);
  border-radius: 3px;
  animation: kaizen-wave 1.2s ease-in-out infinite;
}
.kaizen-loader__dot:nth-child(1) { animation-delay: 0s; }
.kaizen-loader__dot:nth-child(2) { animation-delay: 0.15s; }
.kaizen-loader__dot:nth-child(3) { animation-delay: 0.3s; }
.kaizen-loader__dot:nth-child(4) { animation-delay: 0.45s; }
.kaizen-loader__dot:nth-child(5) { animation-delay: 0.6s; }

.kaizen-loader__text {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.kaizen-loader__sub {
  font-size: 11px;
  color: var(--muted-foreground);
  font-family: var(--font-jp);
  opacity: 0.7;
}

/* Animated result entry */
.evolved-result-animate { animation: fadeUp 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; }

/* Spin for legacy spinner usage */
.spin { animation: kaizen-spin 1s linear infinite; }

.evolved-result { display: flex; flex-direction: column; gap: 16px; width: 100%; }
.result-version { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--primary-emphasis); }
.result-version small { background: var(--accent); color: var(--accent-foreground); padding: 2px 8px; border-radius: 10px; }

.comparison { display: flex; flex-direction: column; gap: 10px; }
.comparison article { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--background); }
.comparison article.after { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, var(--card)); }
.comparison article span { font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--muted-foreground); display: block; margin-bottom: 4px; }
.comparison article.after span { color: var(--primary-emphasis); }
.comparison article p { font-size: 13px; margin: 0; line-height: 1.5; }

/* ── Editorial Proofing Desk & Redline Manuscript ───────────────────────── */
.manuscript-tabs {
  display: flex;
  gap: 4px;
  background: var(--secondary);
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.manuscript-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-foreground);
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}
.manuscript-tab.active {
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.manuscript-paper {
  background: var(--proof);
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.8;
  padding: 32px 36px;
  position: relative;
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  max-width: 100%;
}

.manuscript-paper p {
  margin: 0;
  white-space: pre-wrap;
  max-width: 68ch;
}

/* Redline Diff formatting */
.manuscript-del {
  text-decoration: line-through;
  color: var(--muted-foreground);
  opacity: 0.75;
  background: rgba(201, 74, 54, 0.08);
  padding: 1px 4px;
  border-radius: 2px;
  margin-right: 2px;
}
.dark .manuscript-del {
  background: rgba(229, 77, 56, 0.15);
  color: #a0a6b0;
}

.manuscript-add {
  background: var(--accent);
  border-bottom: 2px solid var(--primary);
  color: var(--foreground);
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 2px;
}

/* Marginalia Notes Side Panel */
.marginalia-panel {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--hanko);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.marginalia-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 6px;
}

.marginalia-item {
  font-size: 12px;
  color: var(--foreground);
  line-height: 1.4;
}
.marginalia-item span.glyph {
  color: var(--hanko);
  font-weight: 700;
}

/* 5S Product Mechanics Summary Bar */
.five-s-summary-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.five-s-badge {
  padding: 4px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 700;
  color: var(--foreground);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.five-s-badge span.kanji {
  font-family: var(--font-jp);
  color: var(--primary-emphasis);
  font-size: 12px;
}

.takeaway-box {
  background: var(--accent);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-emphasis);
  display: flex;
  align-items: center;
  gap: 8px;
}

.notes-panel { background: var(--secondary); padding: 14px; border-radius: var(--radius); }
.notes-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; margin-bottom: 10px; }
.note-row { display: flex; gap: 8px; margin-top: 8px; font-size: 12px; }
.note-row span { width: 18px; height: 18px; background: var(--hanko); color: #fff; font-size: 10px; display: grid; place-items: center; border-radius: 2px; flex-shrink: 0; }
.note-row b { display: block; color: var(--foreground); }
.note-row small { display: block; color: var(--muted-foreground); margin-top: 2px; }

.score-panel { background: var(--card); border: 1px solid var(--border); padding: 14px; border-radius: var(--radius); }
.score-total { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.score-total span { font-size: 12px; font-weight: 700; color: var(--muted-foreground); }
.score-total b { font-size: 24px; color: var(--primary-emphasis); }
.score-total em { font-style: normal; color: var(--primary-emphasis); font-size: 13px; font-weight: 800; margin-left: 6px; }

.score-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 11px; }
.score-bars > div { display: flex; flex-direction: column; gap: 2px; }
.score-bars div > div { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.score-bars i { display: block; height: 100%; background: var(--primary); transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94); }

.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result-actions button { flex: 1 1 auto; justify-content: center; min-width: 90px; }

/* ── Reply Mode Output Cards ─────────────────────────────────────────── */
.reply-results { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.reply-results article { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--background); display: flex; flex-direction: column; gap: 8px; }
.reply-results article span { font-size: 10px; font-weight: 800; color: var(--primary-emphasis); text-transform: uppercase; }
.reply-results article p { font-size: 13px; margin: 0; line-height: 1.5; }
.reply-results article div { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Recent History Items ────────────────────────────────────────────── */
.history-item {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--background); font-size: 12px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: all 0.2s;
}
.history-item:hover { border-color: var(--primary); }

/* ── Process & Philosophy Sections ───────────────────────────────────── */
.process-section, .philosophy-section, .features-section, .quote-section { padding: 80px 0; border-bottom: 1px solid var(--border); }

.process-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; margin-top: 40px; }
.process-grid > div { position: relative; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); transition: all 0.25s; }
.process-grid > div:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.process-grid span { font-size: 12px; font-weight: 800; color: var(--primary-emphasis); }
.process-grid h3 { font-size: 18px; margin: 8px 0 4px; font-family: var(--font-sans); font-weight: 700; }
.process-grid p { font-size: 12px; color: var(--muted-foreground); margin: 0; }

.philosophy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; }
.philosophy-copy blockquote { font-size: 36px; line-height: 1.1; color: var(--primary-emphasis); margin: 24px 0 0; }

.five-s { background: var(--card); border: 1px solid var(--border); padding: 30px; border-radius: calc(var(--radius) * 2); }
.five-s-title { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 16px; }
.five-s-title span { font-size: 32px; font-family: var(--font-jp); color: var(--hanko); }
.five-s-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; text-align: center; }
.five-s-grid article { padding: 12px 6px; background: var(--secondary); border-radius: var(--radius); transition: all 0.2s; }
.five-s-grid article:hover { background: var(--accent); }
.five-s-grid span { font-family: var(--font-jp); font-size: 18px; display: block; color: var(--primary-emphasis); }
.five-s-grid b { font-size: 12px; display: block; margin: 2px 0; }
.five-s-grid small { font-size: 10px; color: var(--muted-foreground); display: block; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 40px; }
.feature-grid article { padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
.feature-grid article:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,0.1); }
.feature-grid h3 { font-size: 18px; margin: 12px 0 6px; font-family: var(--font-sans); font-weight: 700; }
.feature-grid p { font-size: 13px; color: var(--muted-foreground); margin: 0; line-height: 1.6; }

/* ── Quotes Carousel Section (Kotowaza Theme) ─────────────────────────── */
.quote-section {
  position: relative;
  overflow: hidden;
  color: #ffffff;
  background: linear-gradient(160deg, #060a10 0%, #0b1220 40%, #0a1a14 100%);
  padding: 100px 0 80px;
}
.quote-art {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0.18; filter: saturate(0.4) blur(1px);
}
.quote-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(6,10,16,0.92) 0%, rgba(6,10,16,0.75) 50%, rgba(6,10,16,0.96) 100%);
}

.quote-layout { position: relative; z-index: 2; max-width: 800px; margin: auto; }

.quote-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 40px;
}

.quote-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* Enhanced Quote Card */
.quote-card {
  background: linear-gradient(135deg, rgba(16,22,32,0.9) 0%, rgba(10,18,28,0.95) 100%);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.07);
  border-top: 1px solid rgba(34,197,94,0.15);
  border-radius: 20px;
  padding: 48px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(34,197,94,0.05), 0 1px 0 rgba(255,255,255,0.05) inset;
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.6s cubic-bezier(0.25,0.46,0.45,0.94) both;
}

/* Decorative large kanji watermark */
.quote-card::before {
  content: attr(data-kanji);
  position: absolute;
  right: -20px;
  top: -20px;
  font-family: var(--font-jp);
  font-size: 200px;
  color: rgba(34,197,94,0.03);
  line-height: 1;
  pointer-events: none;
  user-select: none;
  text-shadow: 0 2px 16px rgba(0,0,0,0.6);
}
.quote-card blockquote p:not([lang]) { font-size: 17px; opacity: 0.95; color: #e6edf3; }

/* Quote index badge */
.quote-index {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.tag-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #c9d1d9;
  padding: 5px 14px;
  font-size: 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.22s ease;
  font-weight: 600;
}
.tag-btn:hover { background: rgba(22,166,106,0.2); border-color: rgba(34,197,94,0.5); color: #ffffff; }
.tag-btn.active { background: rgba(34,197,94,0.2); border-color: rgba(34,197,94,0.6); color: #4ade80; font-weight: 700; }

/* Quote card left accent */
.quote-card::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, rgba(34,197,94,0.8) 0%, rgba(22,166,106,0.3) 60%, transparent 100%);
  border-radius: 20px 0 0 20px;
}

.quote-card__meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.quote-card__tag { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; color: rgba(34,197,94,0.9); }
.quote-card__jlpt { font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: 20px; background: rgba(34,197,94,0.1); color: #4ade80; border: 1px solid rgba(34,197,94,0.2); letter-spacing: 0.05em; }

.quote-card__kanji {
  font-family: 'Noto Serif JP', serif;
  font-size: clamp(1.5rem, 4vw, 3.2rem);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 12px;
  color: #ffffff;
  text-shadow: 0 4px 24px rgba(0,0,0,0.5);
  letter-spacing: 0.04em;
  word-break: break-word;
  max-width: 100%;
}

.quote-card__reading {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  margin: 0 0 28px;
  letter-spacing: 0.04em;
}

.quote-card__meaning {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.5vw, 1.45rem);
  line-height: 1.55;
  color: rgba(255,255,255,0.9);
  margin: 0 0 24px;
  font-style: italic;
  padding-left: 20px;
  position: relative;
  border: none;
}
.quote-card__meaning::before {
  content: '"';
  position: absolute; left: 0; top: -6px;
  font-size: 2.2em; color: rgba(34,197,94,0.45);
  font-family: var(--font-display); line-height: 1;
}

.quote-card__details {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 20px; padding-bottom: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.quote-card__literal { font-size: 12px; color: rgba(255,255,255,0.35); font-style: italic; }
.quote-card__equiv { font-size: 12px; color: rgba(255,255,255,0.4); font-weight: 600; }

.quote-card__example {
  background: rgba(34,197,94,0.06);
  border-left: 2px solid rgba(34,197,94,0.35);
  padding: 12px 16px; border-radius: 0 8px 8px 0; margin-bottom: 28px;
}
.quote-card__example-ja { display: block; font-family: 'Noto Serif JP', serif; font-size: 14px; color: rgba(255,255,255,0.8); margin-bottom: 5px; line-height: 1.6; }
.quote-card__example-en { display: block; font-size: 12px; color: rgba(255,255,255,0.4); line-height: 1.5; }

.quote-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.quote-card__refresh-hint { display: flex; align-items: center; gap: 6px; font-size: 11px; color: rgba(255,255,255,0.28); font-weight: 500; letter-spacing: 0.05em; }


/* ── Social Share Card Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 2.5);
  max-width: 680px; width: 100%;
  padding: 28px;
  display: flex; flex-direction: column; gap: 20px;
  box-shadow: 0 40px 80px rgba(0,0,0,0.3);
  animation: modalSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.94) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 20px; margin: 0; font-family: var(--font-sans); font-weight: 700; }
.modal-body { width: 100%; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border); background: var(--background); position: relative; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* Canvas generating state */
.modal-body.generating {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
footer { padding: 40px 0; border-top: 1px solid var(--border); text-align: center; font-size: 13px; color: var(--muted-foreground); }
.footer-grid { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.footer-grid div { display: flex; gap: 20px; }
.footer-grid a { color: var(--foreground); text-decoration: none; font-weight: 600; }

/* ── Interactive Kaizen Word Diff Marks ────────────────────────────────── */
.kaizen-diff-mark {
  background: rgba(22, 166, 106, 0.14);
  color: var(--primary-emphasis);
  border-bottom: 2px dashed var(--primary);
  border-radius: 3px;
  padding: 1px 4px;
  cursor: pointer;
  position: relative;
  font-weight: 700;
  transition: all 0.2s ease;
  display: inline;
}
.kaizen-diff-mark:hover {
  background: rgba(22, 166, 106, 0.26);
  box-shadow: 0 0 12px rgba(22, 166, 106, 0.25);
}
.dark .kaizen-diff-mark {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border-bottom-color: #22c55e;
}
.dark .kaizen-diff-mark:hover {
  background: rgba(34, 197, 94, 0.35);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.35);
}

/* ── Brand Mark & Logo ────────────────────────────────────────────────── */


/* ── Dark Mode — Premium Redesign ──────────────────────────────────────── */

/* Root-level dark tokens */
.dark {
  --background: #080c12;
  --card: #0e1420;
  --border: #1a2236;
  --foreground: #e8eef6;
  --muted-foreground: #6b7a95;
  color-scheme: dark;
}

/* Background: rich dark navy with subtle gradient depth */
.dark body { background: linear-gradient(160deg, #070b11 0%, #080c14 50%, #07100f 100%); }

/* Header — premium glassmorphism */
.dark .site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

/* Cards — elevated surfaces with subtle depth layers */
.dark .desk-frame {
  background: linear-gradient(145deg, #0e1420 0%, #0b1019 100%);
  border-color: #1a2236;
  box-shadow:
    0 24px 64px rgba(0,0,0,0.65),
    0 0 0 1px rgba(255,255,255,0.02) inset,
    0 1px 0 rgba(255,255,255,0.04) inset;
}
.dark .desk-art { opacity: 0.015; }

/* Inputs */
.dark textarea.desk-textarea,
.dark input,
.dark select {
  background: #07090f !important;
  color: #d4dde8 !important;
  border-color: #1a2236 !important;
}
.dark textarea.desk-textarea:focus,
.dark input:focus,
.dark select:focus {
  border-color: #22c55e !important;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.1) !important;
}

/* Chips */
.dark .chip {
  background: #111926;
  border-color: #1e2c42;
  color: #a8b8d0;
}
.dark .chip:hover { border-color: #22c55e; color: #e8eef6; background: #132418; }
.dark .chip.active {
  background: linear-gradient(135deg, #15803d, #22c55e) !important;
  border-color: #22c55e !important;
  color: #050e08 !important;
  font-weight: 700;
}

.dark .tone-cat-filters button { border-color: #1e2c42; color: #6b7a95; }
.dark .tone-cat-filters button.active { background: #132418; color: #4ade80; border-color: #22c55e; }

.dark .demo-row button { background: #111926; border-color: #1e2c42; color: #a8b8d0; }
.dark .demo-row button:hover { background: #15803d; border-color: #22c55e; color: #ffffff; }

.dark .mode-tabs { background: #07090f; border: 1px solid #1a2236; border-radius: var(--radius); }
.dark .mode-tabs button.active { background: #111926; color: #e8eef6; box-shadow: 0 2px 10px rgba(0,0,0,0.5); }

.dark .context-drawer { background: #07090f; border: 1px solid #1a2236; }

/* Output comparison cards */
.dark .comparison article {
  background: linear-gradient(145deg, #0a0f18, #0c1220);
  border-color: #1a2236;
  color: #d4dde8;
}
.dark .comparison article.after {
  background: linear-gradient(145deg, rgba(21,128,61,0.08), rgba(34,197,94,0.06));
  border-color: rgba(34,197,94,0.3);
}

.dark .score-panel { background: linear-gradient(145deg, #0e1420, #0b1019); border: 1px solid #1a2236; }
.dark .notes-panel { background: #0e1420; border-color: #1a2236; }

/* 5S / Feature / Process cards */
.dark .five-s { background: linear-gradient(145deg, #0e1420, #0b1019); border: 1px solid #1a2236; }
.dark .five-s-grid article { background: #07090f; border: 1px solid #1a2236; }
.dark .five-s-grid article:hover { background: #0f1f14; border-color: rgba(34,197,94,0.4); box-shadow: 0 8px 24px rgba(0,0,0,0.5); }

.dark .feature-grid article { background: linear-gradient(145deg, #0e1420, #0b1019); border: 1px solid #1a2236; }
.dark .feature-grid article:hover { border-color: rgba(34,197,94,0.4); box-shadow: 0 16px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(34,197,94,0.15); }

.dark .process-grid > div { background: linear-gradient(145deg, #0e1420, #0b1019); border: 1px solid #1a2236; }
.dark .process-grid > div:hover { border-color: rgba(34,197,94,0.4); box-shadow: 0 12px 32px rgba(0,0,0,0.5); }

.dark .history-item { background: #0a0f18; border-color: #1a2236; color: #d4dde8; }
.dark .history-item:hover { border-color: #22c55e; background: #0e1420; }

/* Mini preview card in hero */
.dark .mini-preview {
  background: linear-gradient(145deg, rgba(14,20,32,0.95), rgba(11,16,25,0.98));
  border: 1px solid #1a2236;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.02) inset;
}
.dark .mini-tabs { background: #07090f; border-bottom: 1px solid #1a2236; }
.dark .mini-tabs span.active { background: #111926; color: #4ade80; border-radius: 6px; }
.dark .mini-preview > p,
.dark .mini-evolved { background: #07090f; border-color: #1a2236; color: #d4dde8; }
.dark .mini-evolved { border-color: rgba(34,197,94,0.35); color: #4ade80; }

/* Modal */
.dark .modal-card {
  background: linear-gradient(145deg, #0e1420, #0b1019);
  border: 1px solid #1a2236;
  box-shadow: 0 48px 96px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.02) inset;
}
.dark .modal-body { background: #07090f; border-color: #1a2236; }

/* Buttons */
.dark .btn-paper { background: #111926; border-color: #1e2c42; color: #d4dde8; }
.dark .btn-paper:hover { background: #162030; border-color: rgba(34,197,94,0.5); color: #ffffff; }
.dark .btn-icon { border-color: #1e2c42; color: #d4dde8; }
.dark .btn-icon:hover { background: #111926; border-color: rgba(34,197,94,0.5); }

.dark .rec-banner { background: rgba(21,128,61,0.1); border-color: rgba(34,197,94,0.35); color: #4ade80; }

.dark .desk-section { background: linear-gradient(180deg, #07090f 0%, #080c14 100%); }
.dark .share-showcase { background: linear-gradient(145deg, #0a0f18 0%, #070b11 100%); }

/* Section backgrounds with subtle differentiation */
.dark .philosophy-section { background: linear-gradient(180deg, #060a10 0%, #08101a 100%); }
.dark .features-section { background: linear-gradient(180deg, #08101a 0%, #070b12 100%); }

/* ── Brand Mark & Hanko Seal ────────────────────────────────────────── */
.brand-mark {
  width: 28px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  background: #c94a36;
  color: #ffffff;
  font-family: "Noto Serif JP", serif;
  font-size: 15px;
  font-weight: 700;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

.hanko-seal {
  position: absolute;
  right: 5%;
  bottom: 5%;
  width: 44px;
  height: 44px;
  border: 2px solid #c94a36;
  color: #c94a36;
  font-family: "Noto Serif JP", serif;
  font-weight: 700;
  font-size: 15px;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(4px);
}

/* ── Share Showcase Section ───────────────────────────────────────────── */
.share-showcase { padding: 80px 0; border-bottom: 1px solid var(--border); }
.share-showcase-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 1.25fr); gap: 40px; align-items: center; }

.showcase-card {
  position: relative;
  aspect-ratio: 1200 / 630;
  width: 100%;
  border-radius: calc(var(--radius) * 2.5);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-align: left;
  background: #f7f7f3;
}
.showcase-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 36px 72px rgba(0, 0, 0, 0.22);
}
.showcase-card > img.showcase-bg-img,
.showcase-card > img:not(.card-logo-icon):first-child {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.showcase-card-overlay {
  position: absolute;
  inset: 0;
  padding: 5% 6%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(247, 247, 243, 0.75) 0%, rgba(247, 247, 243, 0.35) 55%, transparent 100%);
  pointer-events: none;
}
.showcase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 62%;
}
.showcase-brand-lockup {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  white-space: nowrap !important;
  text-decoration: none !important;
  line-height: 1 !important;
}
.showcase-brand-lockup .card-logo-icon {
  position: static !important;
  inset: auto !important;
  height: 24px !important;
  width: 24px !important;
  max-height: 24px !important;
  max-width: 24px !important;
  object-fit: contain !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
  vertical-align: middle !important;
  margin: 0 !important;
  opacity: 1 !important;
  filter: none !important;
}
.showcase-brand-lockup b {
  font-size: 15px !important;
  font-family: var(--font-sans) !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  margin: 0 !important;
  display: inline-block !important;
  vertical-align: middle !important;
  color: #17201c !important;
}
.dark .showcase-brand-lockup b {
  color: #e8eef6 !important;
}

.quote-loader {
  padding: 48px 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.quote-content-fade-in {
  animation: quoteContentFadeIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes quoteContentFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.showcase-version {
  color: #16a66a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.showcase-heading {
  font-family: "Georgia", "Noto Serif JP", serif;
  font-size: clamp(1.1rem, 2.2vw, 2.1rem);
  line-height: 1.05;
  margin: 4px 0 8px;
  color: #17201c;
  font-weight: 400;
  max-width: 62%;
}
.showcase-heading .green-text {
  color: #16a66a;
}
.showcase-body-content {
  max-width: 62%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.showcase-section {
  width: 100%;
}
.showcase-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  color: #6b7280;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}
.showcase-label.showcase-after-label {
  color: #16a66a;
}
.showcase-text {
  font-size: clamp(11px, 1.3vw, 15px);
  color: #17201c;
  margin: 0;
  font-weight: 600;
  line-height: 1.4;
}
.showcase-text.showcase-after-text {
  color: #087443;
  font-weight: 700;
}

/* Dark Mode adaptation for showcase card */
.dark .showcase-card {
  background: #0e1420;
  border-color: #1a2236;
}
.dark .showcase-card > img.showcase-bg-img,
.dark .showcase-card > img:not(.card-logo-icon):first-child {
  filter: brightness(0.4) saturate(0.7);
}
.dark .showcase-card-overlay {
  background: linear-gradient(135deg, rgba(14, 20, 32, 0.88) 0%, rgba(14, 20, 32, 0.45) 55%, transparent 100%);
}
.dark .showcase-heading {
  color: #e8eef6;
}
.dark .showcase-heading .green-text {
  color: #22c55e;
}
.dark .showcase-version {
  color: #22c55e;
}
.dark .showcase-label {
  color: #6b7a95;
}
.dark .showcase-label.showcase-after-label {
  color: #22c55e;
}
.dark .showcase-text {
  color: #d4dde8;
}
.dark .showcase-text.showcase-after-text {
  color: #4ade80;
}
.dark .desk-title span {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* ── Responsive Media Queries ─────────────────────────────────────────── */
@media (max-width: 1280px) {
  .page-shell { width: min(100%, calc(100% - 48px)); }
  .header-nav { gap: 18px; }
  .header-start { display: none; }
  .desk-frame-inner {
    grid-template-columns: minmax(340px, 1fr) minmax(0, 1.25fr);
  }
  .draft-column {
    border-right: 1px solid var(--border);
    border-bottom: none;
  }
  .output-column {
    border-right: none;
    border-bottom: none;
  }
  .desk-marginalia-aside {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .divide-notes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding: 16px 20px;
  }
  .marginalia-note-item {
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding: 0 16px 0 0;
  }
  .marginalia-note-item:last-child {
    border-right: none;
  }
  .how-inner { grid-template-columns: 160px 1fr; gap: 24px; }
  .philosophy-grid { gap: 40px; }
}

@media (max-width: 960px) {
  .hero { min-height: auto; padding-bottom: 40px; }
  .hero-grid { grid-template-columns: 1fr; gap: 32px; padding-block: 24px; min-height: auto; }
  .hero-copy { padding-left: 0; max-width: 100%; }
  .vertical-kaizen { display: none; }
  .mini-preview { width: 100%; max-width: 100%; }

  .section-heading { grid-template-columns: 1fr; gap: 16px; margin-bottom: 24px; }
  .philosophy-grid { grid-template-columns: 1fr; }
  .process-grid, .feature-grid { grid-template-columns: 1fr 1fr; }
  .five-s-grid { grid-template-columns: repeat(5, 1fr); }
  
  /* Header clean stack on tablet and mobile */
  .nav-shell { display: flex !important; justify-content: space-between !important; align-items: center !important; height: 60px; width: 100%; padding-inline: 16px; }
  .nav-links { display: none !important; }
  .nav-start-btn { display: none !important; }
  .nav-gh-btn { display: none !important; }
  .pwa-install-nav-btn { display: none !important; }
  .offline-pill { font-size: 10px; padding: 2px 8px; }
  .mobile-menu-toggle { display: inline-flex !important; }
  .brand-tagline { display: none !important; }
  .share-showcase-grid { grid-template-columns: 1fr; gap: 24px; }
  .quote-header { flex-direction: column; align-items: flex-start; }

  /* Stack desk columns to single-column to eliminate horizontal crunch */
  .desk-frame-inner { grid-template-columns: minmax(0, 1fr) !important; }
  .draft-column { border-right: none; border-bottom: 1px solid var(--border); padding: 20px 16px; }
  .output-column { border-right: none; border-bottom: 1px solid var(--border); padding: 20px 16px; }
  .desk-marginalia-aside { grid-column: auto; border-left: none; border-top: none; }
  .divide-notes { display: flex; flex-direction: column; gap: 0; padding: 0; }
  .marginalia-note-item { border-right: none; border-bottom: 1px solid var(--border); padding: 16px 20px; }

  .showcase-header, .showcase-heading, .showcase-body-content { max-width: 70%; }
}

@media (max-width: 768px) {
  .page-shell { width: calc(100% - 24px); }
  .nav-shell { display: flex; justify-content: space-between; align-items: center; height: 60px; width: 100%; padding-inline: 12px; }
  .nav-actions { gap: 6px; }
  .nav-actions .btn-icon { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; }

  /* Touch hit target optimization & iOS zoom prevention */
  textarea.desk-textarea, input, select, .form-control {
    font-size: 16px !important;
  }
  .btn-hero, .btn-paper, .mode-switch button, .draft-actions > * {
    min-height: 44px;
    touch-action: manipulation;
  }
  .chip, .demo-btn, .tag-btn {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    touch-action: manipulation;
  }

  .hero h1 { font-size: clamp(2rem, 7.5vw, 3.4rem); }
  .hero-lede { font-size: 14px; margin: 16px 0; }
  .hero-actions { flex-direction: column; gap: 10px; }
  .hero-actions .btn-hero, .hero-actions .btn-paper { width: 100%; justify-content: center; min-height: 48px; }

  .desk-section { padding: 40px 0; }
  .desk-frame-inner { grid-template-columns: minmax(0, 1fr) !important; }
  .draft-column { border-right: none; border-bottom: 1px solid var(--border); padding: 18px 14px; }
  .output-column { border-right: none; border-bottom: 1px solid var(--border); padding: 18px 14px; }
  .desk-marginalia-aside { grid-column: auto; border-left: none; border-top: none; }
  .divide-notes { display: flex; flex-direction: column; gap: 0; padding: 0; }
  .marginalia-note-item { border-right: none; border-bottom: 1px solid var(--border); padding: 16px 20px; }

  /* Clean wrapping in draft title and stats bar */
  .desk-title { flex-wrap: wrap; gap: 8px; }
  .draft-stats-bar { width: 100%; justify-content: space-between; margin-top: 4px; }

  /* Clean proof tab bar on mobile */
  .proof-tab-bar { gap: 8px; padding: 10px 12px; }
  .manuscript-tabs { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .manuscript-tab { text-align: center; padding: 8px 4px; font-size: 11px; justify-content: center; }

  .manuscript-paper { padding: 18px 14px 40px; min-height: 220px; font-size: 18px; }
  .result-state { min-height: 220px; padding: 24px 16px; }

  .demo-row { overflow-x: auto; padding-bottom: 6px; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scroll-snap-type: x mandatory; }
  .demo-row button { flex-shrink: 0; scroll-snap-align: start; }

  .chips-wrap { overflow-x: auto; padding-bottom: 6px; flex-wrap: wrap; -webkit-overflow-scrolling: touch; }

  .draft-actions { flex-direction: column; gap: 10px; }
  .draft-actions button { width: 100%; min-height: 48px; }
  .draft-actions #evolveBtn { order: -1; }

  #modelSelectRow { flex-direction: column; align-items: flex-start; gap: 4px; }
  #modelSelect { width: 100%; min-height: 44px; }

  .proof-sidebyside { grid-template-columns: 1fr; gap: 16px; }

  /* Quote card responsive */
  .quote-section { padding: 50px 0 40px; }
  .quote-layout { padding-inline: 12px; }
  .quote-card { padding: 24px 18px; border-radius: 16px; }
  .quote-card__kanji { font-size: clamp(1.4rem, 5vw, 2.4rem); }
  .quote-card__meaning { font-size: 1rem; padding-left: 14px; }
  .quote-card__footer { flex-direction: column; align-items: stretch; gap: 12px; }
  .quote-card__footer .btn-hero { width: 100%; justify-content: center; min-height: 48px; }
  .quote-tags { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .quote-tags .tag-btn { flex-shrink: 0; min-height: 40px; }

  .five-s-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .showcase-header, .showcase-heading, .showcase-body-content { max-width: 80%; }
}

@media (max-width: 600px) {
  .process-grid, .feature-grid { grid-template-columns: 1fr; }
  .control-grid { grid-template-columns: 1fr; }
  .share-showcase-grid { grid-template-columns: 1fr !important; }
  .five-s-grid { grid-template-columns: 1fr; }

  .modal-card { max-width: 96vw; padding: 14px; gap: 10px; }
  .modal-actions { flex-direction: column; gap: 8px; }
  .modal-actions button { width: 100%; }

  .result-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .result-actions #copyResultBtn {
    grid-column: 1 / -1;
  }

  .proof-tab-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .manuscript-tabs { width: 100%; display: flex; }
  .manuscript-tab { flex: 1; text-align: center; padding: 6px 2px; font-size: 11px; }
  .proof-word-stats { text-align: center; }

  .kaizen-hanko-seal { width: 52px; height: 52px; bottom: 10px; right: 10px; }
  .kaizen-hanko-seal span { font-size: 14px; }
  .kaizen-hanko-seal small { font-size: 5px; }

  .quote-card { padding: 20px 14px; }
  .quote-card__kanji { font-size: clamp(1.3rem, 4.8vw, 2.1rem); margin-bottom: 8px; }
  .quote-card__meaning { font-size: 0.95rem; }
  .showcase-header, .showcase-heading, .showcase-body-content { max-width: 90%; }
}

@media (max-width: 360px) {
  .page-shell { width: calc(100% - 16px); }
  .hero h1 { font-size: 32px; }
  .brand-tagline { display: none; }
  .desk-pane, .draft-column, .output-column { padding: 14px 12px; }
  .draft-actions { flex-direction: column-reverse; }
  .proof-tab-bar { padding: 8px; gap: 6px; }
  .manuscript-tab { padding: 4px 6px; font-size: 10px; }
}

.dark .desk-frame {
  background: #10151d;
  border-color: #1e2739;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.02) inset;
}
.dark .desk-art { opacity: 0.02; }

.dark textarea.desk-textarea,
.dark input,
.dark select {
  background: #0b0e14 !important;
  color: #e8edf3 !important;
  border-color: #242c38 !important;
}
.dark textarea.desk-textarea:focus,
.dark input:focus,
.dark select:focus {
  border-color: #22c55e !important;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1) !important;
}

.dark .chip {
  background: #1a202c;
  border-color: #242c38;
  color: #c9d1d9;
}
.dark .chip:hover { border-color: #22c55e; color: #ffffff; background: #1f2d20; }
.dark .chip.active {
  background: linear-gradient(135deg, #16a34a, #22c55e) !important;
  border-color: #22c55e !important;
  color: #0b0e14 !important;
  font-weight: 700;
}

.dark .tone-cat-filters button {
  border-color: #242c38;
  color: #8892a4;
}
.dark .tone-cat-filters button.active {
  background: #162d22;
  color: #4ade80;
  border-color: #22c55e;
}

.dark .demo-row button {
  background: #1a202c;
  border-color: #242c38;
  color: #c9d1d9;
}
.dark .demo-row button:hover {
  background: #16a34a;
  border-color: #22c55e;
  color: #ffffff;
}

.dark .mode-tabs { background: #0b0e14; border: 1px solid #1e2739; border-radius: var(--radius); }
.dark .mode-tabs button.active {
  background: #1a202c;
  color: #e8edf3;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.dark .context-drawer {
  background: #0b0e14;
  border: 1px solid #242c38;
}

.dark .comparison article {
  background: #0d1219;
  border-color: #242c38;
  color: #e8edf3;
}
.dark .comparison article.after {
  background: rgba(22, 163, 74, 0.1);
  border-color: #22c55e;
}

.dark .score-panel {
  background: #10151d;
  border: 1px solid #1e2739;
}
.dark .notes-panel { background: #10151d; }

.dark .five-s {
  background: #10151d;
  border: 1px solid #1e2739;
}
.dark .five-s-grid article {
  background: #0b0e14;
  border: 1px solid #1e2739;
}
.dark .five-s-grid article:hover { background: #162d22; }

.dark .feature-grid article {
  background: #10151d;
  border: 1px solid #1e2739;
}
.dark .feature-grid article:hover {
  border-color: #22c55e;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(34,197,94,0.2);
}

.dark .process-grid > div {
  background: #10151d;
  border: 1px solid #1e2739;
}
.dark .process-grid > div:hover {
  border-color: #22c55e;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.dark .history-item {
  background: #0d1219;
  border-color: #242c38;
  color: #e8edf3;
}
.dark .history-item:hover { border-color: #22c55e; background: #10151d; }

.dark .mini-preview {
  background: rgba(16, 21, 29, 0.92);
  border: 1px solid #1e2739;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}
.dark .mini-tabs { background: #0b0e14; }
.dark .mini-tabs span.active { background: #1a202c; color: #4ade80; }
.dark .mini-preview > p,
.dark .mini-evolved {
  background: #0b0e14;
  border-color: #242c38;
  color: #e8edf3;
}
.dark .mini-evolved { border-color: rgba(34, 197, 94, 0.4); color: #4ade80; }

.dark .modal-card {
  background: #10151d;
  border: 1px solid #1e2739;
  box-shadow: 0 40px 80px rgba(0,0,0,0.7);
}
.dark .modal-body { background: #0b0e14; border-color: #1e2739; }

.dark .btn-paper {
  background: #1a202c;
  border-color: #242c38;
  color: #e8edf3;
}
.dark .btn-paper:hover { background: #1e2739; border-color: #22c55e; }

.dark .btn-icon {
  border-color: #242c38;
  color: #e8edf3;
}
.dark .btn-icon:hover { background: #1a202c; border-color: #22c55e; }

.dark .rec-banner {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

/* Dark desk-section background */
.dark .desk-section { background: #0d1219; }

/* Washi deep dark */
.dark { --washi-deep: #0d1219; }

/* ── Share Showcase Section ───────────────────────────────────────────── */
.share-showcase { padding: 80px 0; border-bottom: 1px solid var(--border); }
.share-showcase-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr); gap: 40px; align-items: center; }
#showcaseImgCard {
  position: relative;
  border-radius: calc(var(--radius) * 2.5);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0,0,0,0.12);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
#showcaseImgCard:hover { transform: translateY(-6px); box-shadow: 0 32px 64px rgba(0,0,0,0.18); }

/* ── Kaizen Toast Notification System ────────────────────────────────── */
.kaizen-toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 40px);
  pointer-events: none;
}

.kaizen-toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: calc(var(--radius) * 1.5);
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.kaizen-toast--success { border-left-color: #16a66a; }
.kaizen-toast--error { border-left-color: var(--hanko); }
.kaizen-toast--info { border-left-color: #3b82f6; }

.kaizen-toast-enter {
  animation: toastSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.kaizen-toast-exit {
  animation: toastSlideOut 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(40px) scale(0.9); }
}

.kaizen-toast__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--primary);
}
.kaizen-toast__icon svg {
  width: 18px;
  height: 18px;
  display: block;
}
.kaizen-toast--error .kaizen-toast__icon { color: var(--hanko); }
.kaizen-toast--info .kaizen-toast__icon { color: #3b82f6; }

.kaizen-toast__content {
  flex: 1;
  min-width: 0;
}

.kaizen-toast__message {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  line-height: 1.4;
  word-break: break-word;
}

.kaizen-toast__close {
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  padding: 4px;
  cursor: pointer;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.kaizen-toast__close:hover {
  color: var(--foreground);
  background: var(--secondary);
}

/* Dark Mode adaptation for Kaizen Toasts */
.dark .kaizen-toast {
  background: rgba(16, 22, 32, 0.94);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(34, 197, 94, 0.12);
}
.dark .kaizen-toast--success { border-left-color: #22c55e; }
.dark .kaizen-toast--error { border-left-color: #e54d38; }
.dark .kaizen-toast--info { border-left-color: #60a5fa; }
.dark .kaizen-toast__close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* ── Hanko Seal & Editorial Stamps ─────────────────────────────────────── */

@keyframes seal-in {
  from { opacity: 0; transform: rotate(-8deg) scale(1.25); }
  to { opacity: 1; transform: rotate(-4deg) scale(1); }
}
.kaizen-hanko-seal {
  position: absolute; bottom: 24px; right: 24px;
  width: 72px; height: 72px;
  border-radius: 50%; border: 2px solid var(--seal);
  display: grid; place-items: center; text-align: center;
  color: var(--seal); transform: rotate(-4deg);
  font-family: var(--font-display);
  animation: seal-in 380ms cubic-bezier(.2,.8,.2,1) both;
  pointer-events: none;
}
.kaizen-hanko-seal span { font-size: 18px; display: block; }
.kaizen-hanko-seal small { font-family: var(--font-mono); font-size: 6px; text-transform: uppercase; letter-spacing: 0.1em; display: block; }

del.manuscript-del { color: var(--seal); opacity: 0.7; text-decoration: line-through; text-decoration-thickness: 1px; background: transparent; padding: 0; }
.manuscript-ins { text-decoration: none; border-left: 3px solid var(--primary); padding-left: 20px; display: block; margin-top: 24px; font-style: normal; }
/* Mobile Nav */
.mobile-nav { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--border); background: var(--card); }
.mobile-nav a { padding: 16px 20px; font-size: 14px; font-weight: 500; text-decoration: none; color: var(--foreground); }
.mobile-nav a:hover { background: var(--secondary); }
.brand-text-wrap { display: flex; flex-direction: column; min-width: 0; }
.mobile-menu-toggle { display: none; }
.hero-copy { position: relative; z-index: 2; }
.brand-tagline { font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--muted-foreground); margin-top: 1px; }
.brand-tagline-footer { font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--muted-foreground); margin-top: 4px; }
.proof-tab-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--secondary); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.proof-word-stats { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted-foreground); white-space: nowrap; }
.proof-sidebyside { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.proof-label { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted-foreground); margin-bottom: 12px; }
.manuscript-clean { font-family: var(--font-display); font-size: 22px; line-height: 1.8; margin: 0; }
.desk-panel-head { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.desk-panel-eyebrow { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted-foreground); }
.desk-panel-title { margin-top: 4px; font-family: var(--font-display); font-size: 20px; font-weight: 400; margin-bottom: 0; }
.marginalia-note-item { padding: 20px; border-bottom: 1px solid var(--border); }
.marginalia-note-num { font-family: var(--font-mono); font-size: 9px; color: var(--seal); margin-bottom: 8px; }
.marginalia-note-title { font-size: 14px; font-weight: 600; margin: 0 0 6px; }
.footer-made { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted-foreground); }

/* ── Studio Tabs & History View ────────────────────────────────────────── */
.studio-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.studio-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: calc(var(--radius) - 2px);
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.studio-tab:hover {
  color: var(--foreground);
}
.studio-tab.selected {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 2px 8px color-mix(in oklab, var(--foreground) 6%, transparent);
}
.history-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  background: var(--secondary);
  border-radius: 10px;
  color: var(--foreground);
}

.history-studio-view {
  margin-top: 24px;
}
.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 1024px) {
  .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .history-grid { grid-template-columns: 1fr; }
}
.history-card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.history-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px color-mix(in oklab, var(--foreground) 4%, transparent);
}
.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}
.history-card-body {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.6;
  color: var(--foreground);
  white-space: pre-wrap;
  word-break: break-word;
}
.history-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.history-empty {
  text-align: center;
  padding: 60px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.history-empty-icon {
  margin-bottom: 12px;
  color: var(--muted-foreground);
  opacity: 0.6;
}
.history-empty h3 {
  font-size: 20px;
  margin-bottom: 6px;
}
.history-empty p {
  color: var(--muted-foreground);
  font-size: 13px;
}
.history-studio-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

/* ── Studio Bottom Bar & Footnote ─────────────────────────────────────── */
.studio-bottom {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 12px;
  color: var(--muted-foreground);
  font-size: 11px;
}
.studio-footnote {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--muted-foreground);
  font-size: 12px;
}

/* ── Marginalia Score Box ─────────────────────────────────────────────── */
.score-box {
  margin: 16px 20px 20px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
}
.score-main {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.score-number {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.score-label {
  font-size: 11px;
  color: var(--muted-foreground);
}
.score-gain {
  display: inline-block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
}
.score-details {
  margin-top: 12px;
  display: grid;
  gap: 6px;
  font-size: 11px;
  color: var(--muted-foreground);
}
.score-details div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: 2px;
  border-bottom: 1px dotted color-mix(in oklab, var(--border) 50%, transparent);
}
.score-details div:last-child {
  border-bottom: none;
}
.score-metric-name {
  text-transform: capitalize;
  font-weight: 500;
}
.score-metric-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--foreground);
}

/* ── Inline Manuscript In-Place Editing ───────────────────────────────── */
.manuscript-edit-area {
  width: 100%;
  min-height: 150px;
  padding: 12px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}
.manuscript-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ── Everyday App & PWA Ergonomics ───────────────────────────────────── */
.offline-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--seal);
  background: color-mix(in oklab, var(--seal) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--seal) 30%, transparent);
}

.offline-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--seal);
  animation: kaizen-pulse 1.8s infinite;
}

.pwa-install-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in oklab, var(--primary) 6%, transparent);
  transition: all 0.2s ease;
}

.pwa-install-nav-btn:hover {
  background: color-mix(in oklab, var(--primary) 14%, transparent);
  transform: translateY(-1px);
}

.mobile-install-row {
  grid-column: span 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: color-mix(in oklab, var(--primary) 8%, transparent);
  border: none;
  border-top: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font-sans);
}

.kbd-hint {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  border-radius: 4px;
  background: color-mix(in oklab, var(--primary-foreground) 20%, transparent);
  color: var(--primary-foreground);
  line-height: 1.2;
  margin-left: 6px;
  border: 1px solid color-mix(in oklab, var(--primary-foreground) 30%, transparent);
}

.draft-stats-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.draft-tool-btn {
  transition: all 0.15s ease;
}

.draft-tool-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.draft-counts {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-foreground);
  white-space: nowrap;
}

/* Safe areas & native-feel adjustments in standalone app mode */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .site-header {
    padding-top: max(0px, env(safe-area-inset-top));
  }
}

.pwa-standalone .nav-gh-btn {
  display: none;
}

/* ── Modern PWA Install Popup (Bottom floating card, no blackout) ─────── */
.pwa-install-popup {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(140%);
  width: min(440px, calc(100% - 32px));
  z-index: 990;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 48px color-mix(in oklab, var(--foreground) 16%, transparent), 0 2px 8px color-mix(in oklab, var(--foreground) 6%, transparent);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  opacity: 0;
  pointer-events: none;
}

.pwa-install-popup.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .pwa-install-popup {
    left: auto;
    right: 28px;
    transform: translateY(140%);
  }
  .pwa-install-popup.show {
    transform: translateY(0);
  }
}

.pwa-popup-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-popup-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--secondary);
  border: 1px solid var(--border);
  padding: 4px;
  flex-shrink: 0;
}

.pwa-popup-info {
  flex: 1;
  min-width: 0;
}

.pwa-popup-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pwa-popup-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-sans);
  color: var(--foreground);
}

.pwa-popup-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 4px;
  background: color-mix(in oklab, var(--seal) 14%, transparent);
  color: var(--seal);
  font-weight: 700;
}

.pwa-popup-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted-foreground);
  line-height: 1.4;
}

.pwa-popup-close-btn {
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s;
  align-self: flex-start;
}

.pwa-popup-close-btn:hover {
  color: var(--foreground);
}

.pwa-popup-actions {
  display: flex;
  gap: 8px;
}

.pwa-popup-install-btn {
  flex: 1;
  min-height: 40px !important;
  font-size: 13px !important;
  justify-content: center;
  padding: 8px 16px !important;
}

.pwa-popup-dismiss-btn {
  min-height: 40px !important;
  font-size: 13px !important;
  justify-content: center;
  padding: 8px 14px !important;
}

.pwa-popup-ios-tip {
  font-size: 12px;
  color: var(--foreground);
  background: var(--secondary);
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  line-height: 1.5;
}

