/* ==========================================================================
   JeonseGuard — Korean Residential Lease Trap Simulator
   Reference Lock: Claude Warm Parchment (#F5F4ED / #FAF9F5 / #141413 / #C96442)
                   × Stripe Precision Tabular-Nums Data Hierarchy
   Strict Guarantees:
   - Noto Serif KR weight 500 cap (no bold 700 serif)
   - Terracotta #C96442 single brand accent, Danger #B53333, Safe #108C3D
   - GPU-only motion (transform: scaleX / opacity, zero layout-width animation)
   - Zero border-left warning stripe spam, zero 4-layer nested cards
   - .hl-mark padding: 0 (zero Korean particle separation)
   - Mobile 390px zero horizontal overflow, zero button text clip
   ========================================================================== */

:root {
  --bg-parchment: #F5F4ED;
  --bg-ivory: #FAF9F5;
  --bg-white: #FFFFFF;
  --bg-sand: #E8E6DC;
  --bg-sand-hover: #DFDDD1;
  --bg-near-black: #141413;
  --bg-dark-surface: #30302E;

  --ink-primary: #141413;
  --ink-charcoal: #4D4C48;
  --ink-olive: #5E5D59;
  --ink-stone: #87867F;
  --ink-ivory: #FAF9F5;
  --ink-silver: #B0AEA5;

  --terracotta: #C96442;
  --terracotta-hover: #B55434;
  --terracotta-wash: rgba(201, 100, 66, 0.12);
  --coral: #D97757;

  --danger-crimson: #B53333;
  --danger-wash: rgba(181, 51, 51, 0.10);
  --warn-ochre: #9A5B13;
  --warn-wash: rgba(154, 91, 19, 0.11);
  --safe-green: #108C3D;
  --safe-wash: rgba(16, 140, 61, 0.10);
  --focus-blue: #3898EC;

  --border-cream: #F0EEE6;
  --border-warm: #E8E6DC;
  --ring-warm: #D1CFC5;
  --ring-deep: #C2C0B6;

  --font-serif: 'Noto Serif KR', 'Newsreader', 'AppleMyungjo', serif;
  --font-sans: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --container-max: 1180px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-studio:
    0 0 0 1px rgba(20, 20, 19, 0.08),
    0 4px 24px rgba(0, 0, 0, 0.05);
  --shadow-card:
    0 0 0 1px #E8E6DC,
    0 4px 24px rgba(0, 0, 0, 0.05);
}

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

html {
  background-color: var(--bg-parchment);
  color: var(--ink-primary);
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-parchment);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-feature-settings: "liga" 1, "ss01" 1;
  line-height: 1.6;
  letter-spacing: -0.012em;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea,
select,
a {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus-blue);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--bg-near-black);
  color: var(--ink-ivory);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 16px;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding-inline: clamp(16px, 3.2vw, 36px);
}

.br-mobile {
  display: none;
}

/* ==========================================================================
   TOP SLIM ATTORNEY-AT-LAW ACT ART. 109 DISCLAIMER BAR (<= 36px)
   ========================================================================== */

.legal-slim-bar {
  background-color: var(--bg-sand);
  border-bottom: 1px solid var(--border-warm);
  color: var(--ink-charcoal);
  min-height: 30px;
  max-height: 36px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.legal-slim-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-block: 5px;
}

.legal-slim-icon {
  flex-shrink: 0;
  color: var(--ink-olive);
}

.legal-slim-desktop,
.legal-slim-mobile {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.legal-slim-mobile {
  display: none;
}

/* ==========================================================================
   STICKY EDITORIAL HEADER
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 70;
  background-color: rgba(245, 244, 237, 0.90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-warm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
}

.brand-sep {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ring-deep);
}

.brand-sub {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-olive);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-olive);
  text-decoration: none;
  transition: color 140ms var(--ease-out);
}

.nav-link:hover {
  color: var(--ink-primary);
}

/* ==========================================================================
   BUTTON SYSTEM (TERRACOTTA SINGLE ACCENT, GPU-ONLY MOTION, WRAP SAFE)
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  height: auto;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-decoration: none;
  text-align: center;
  white-space: normal;
  word-break: keep-all;
  transition:
    background-color 150ms var(--ease-out),
    color 150ms var(--ease-out),
    box-shadow 150ms var(--ease-out),
    transform 120ms var(--ease-out),
    opacity 150ms var(--ease-out);
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.btn-wrap {
  white-space: normal;
  height: auto;
  padding: 11px 16px;
}

.btn-terracotta {
  background-color: var(--terracotta);
  color: var(--ink-ivory);
  box-shadow:
    0 0 0 1px var(--terracotta),
    0 8px 20px -10px rgba(201, 100, 66, 0.52);
}

.btn-terracotta:hover:not(:disabled) {
  background-color: var(--terracotta-hover);
  box-shadow:
    0 0 0 1px var(--terracotta-hover),
    0 10px 24px -10px rgba(181, 84, 52, 0.58);
}

.btn-ink {
  background-color: var(--bg-near-black);
  color: var(--ink-ivory);
  box-shadow: 0 0 0 1px var(--bg-near-black);
}

.btn-ink:hover:not(:disabled) {
  background-color: var(--bg-dark-surface);
  box-shadow: 0 0 0 1px var(--bg-dark-surface);
}

.btn-sand {
  background-color: var(--bg-sand);
  color: var(--ink-charcoal);
  box-shadow: 0 0 0 1px var(--ring-warm);
}

.btn-sand:hover:not(:disabled) {
  background-color: var(--bg-sand-hover);
  color: var(--ink-primary);
  box-shadow: 0 0 0 1px var(--ring-deep);
}

.btn-ghost-warm {
  background-color: var(--bg-white);
  color: var(--ink-charcoal);
  box-shadow: 0 0 0 1px var(--ring-warm);
}

.btn-ghost-warm:hover:not(:disabled) {
  background-color: var(--bg-parchment);
  color: var(--ink-primary);
  box-shadow: 0 0 0 1px var(--ring-deep);
}

.btn-sm {
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
}

.text-action-btn {
  border: none;
  background: transparent;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-olive);
  white-space: nowrap;
  transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}

.text-action-btn:hover {
  color: var(--ink-primary);
  background: var(--bg-sand);
}

.inline-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 11px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--ink-charcoal);
  box-shadow: 0 0 0 1px var(--ring-warm);
  font-size: 0.76rem;
  font-weight: 500;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.inline-mini-btn:hover {
  background: var(--bg-sand);
  color: var(--ink-primary);
}

.inline-mini-btn.is-emphasis {
  background: var(--bg-near-black);
  color: var(--ink-ivory);
  box-shadow: 0 0 0 1px var(--bg-near-black);
}

.inline-mini-btn.is-emphasis:hover {
  background: var(--bg-dark-surface);
}

/* ==========================================================================
   CHAPTER 1: EDITORIAL HERO + SINGLE INLINE WORKSPACE
   ========================================================================== */

.hero-section {
  padding-block: clamp(18px, 2.6vw, 32px) clamp(48px, 6vw, 80px);
}

.hero-head {
  margin-bottom: clamp(14px, 2vw, 22px);
}

.hero-kicker {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--terracotta);
  letter-spacing: 0.01em;
  word-break: keep-all;
}

.hero-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: clamp(1.65rem, 2.9vw, 2.55rem);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.025em;
  color: var(--ink-primary);
  word-break: keep-all;
}

.title-accent {
  color: var(--terracotta);
}

.hero-lead {
  margin: 0;
  max-width: 66ch;
  font-size: 0.94rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink-olive);
  word-break: keep-all;
}

/* SCULPTURAL IVORY STUDIO SHELL */
.studio-shell {
  background-color: var(--bg-ivory);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-studio);
  overflow: hidden;
}

/* TOP 1-ROW INSTRUMENT TOOLBAR */
.studio-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 12px 20px;
  background-color: var(--bg-ivory);
  border-bottom: 1px solid var(--border-cream);
}

.studio-selects {
  display: grid;
  grid-template-columns: minmax(126px, 0.52fr) minmax(220px, 1.48fr);
  gap: 8px;
  flex: 1 1 420px;
  min-width: 0;
}

.control-select {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.control-select select {
  width: 100%;
  min-height: 38px;
  padding: 6px 30px 6px 12px;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-parchment);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 1px var(--ring-warm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-primary);
  cursor: pointer;
  transition: background-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}

.control-select select:hover {
  background-color: var(--bg-sand);
}

.control-select select:focus {
  outline: none;
  background-color: var(--bg-white);
  box-shadow: 0 0 0 1.5px var(--focus-blue);
}

.select-chevron {
  position: absolute;
  right: 10px;
  color: var(--ink-olive);
  pointer-events: none;
}

.studio-chips-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.quick-chip {
  min-height: 36px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background-color: var(--bg-parchment);
  color: var(--ink-charcoal);
  box-shadow: 0 0 0 1px var(--border-warm);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  transition:
    background-color 140ms var(--ease-out),
    color 140ms var(--ease-out),
    box-shadow 140ms var(--ease-out);
}

.quick-chip:hover {
  background-color: var(--bg-sand);
  color: var(--ink-primary);
  box-shadow: 0 0 0 1px var(--ring-warm);
}

.quick-chip.is-active {
  background-color: var(--bg-near-black);
  color: var(--ink-ivory);
  box-shadow: 0 0 0 1px var(--bg-near-black);
}

/* 2-COLUMN WORKSPACE DIVIDED BY 1px WARM HAIRLINE GAP */
.studio-body {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(0, 0.92fr);
  gap: 1px;
  background-color: var(--border-warm);
  align-items: stretch;
}

/* LEFT COLUMN: SINGLE INLINE CONTRACT CANVAS */
.editor-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-ivory);
}

.editor-subbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border-cream);
}

.editor-hint {
  font-size: 0.78rem;
  color: var(--ink-stone);
}

.editor-meta-right {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.signal-legend {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.74rem;
  color: var(--ink-olive);
}

.signal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.dot-danger { background: var(--danger-crimson); }
.dot-warn { background: var(--terracotta); }
.dot-safe { background: var(--safe-green); }

.meta-sep {
  color: var(--ring-deep);
}

.mono-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-olive);
  font-variant-numeric: tabular-nums;
}

.mono-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-sand);
  color: var(--ink-charcoal);
  font-variant-numeric: tabular-nums;
}

/* SINGLE OVERLAY INLINE EDITOR (ZERO IME / SCROLL / PARTICLE DRIFT) */
.live-editor-wrap {
  position: relative;
  flex: 1 0 auto;
  min-height: 296px;
  max-height: 410px;
  background: var(--bg-ivory);
  cursor: text;
}

.live-backdrop,
.live-textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 20px 24px 22px;
  border: 0;
  font-family: var(--font-sans);
  font-size: 0.965rem;
  font-weight: 400;
  line-height: 1.88;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  tab-size: 2;
}

.live-backdrop {
  z-index: 1;
  color: var(--ink-primary);
  pointer-events: none;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.live-backdrop::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.live-backdrop::-webkit-scrollbar-track,
.live-backdrop::-webkit-scrollbar-thumb {
  background: transparent;
}

.live-textarea {
  z-index: 2;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--ink-primary);
  resize: none;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 20, 19, 0.22) transparent;
}

.live-textarea::-webkit-scrollbar,
.findings-list::-webkit-scrollbar,
.modal-body-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.live-textarea::-webkit-scrollbar-track,
.findings-list::-webkit-scrollbar-track,
.modal-body-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.live-textarea::-webkit-scrollbar-thumb,
.findings-list::-webkit-scrollbar-thumb,
.modal-body-scroll::-webkit-scrollbar-thumb {
  background: rgba(20, 20, 19, 0.18);
  border-radius: 999px;
}

.live-textarea::placeholder {
  color: var(--ink-stone);
  -webkit-text-fill-color: var(--ink-stone);
}

.live-textarea::selection {
  background: rgba(201, 100, 66, 0.16);
}

.live-editor-wrap:focus-within {
  box-shadow: inset 0 0 0 1.5px rgba(56, 152, 236, 0.42);
}

/* ZERO-PADDING-DRIFT INLINE MARKS (KOREAN PARTICLE SEPARATION = 0) */
.hl-mark {
  display: inline;
  padding: 0;
  margin: 0;
  border: 0;
  font-weight: inherit;
  border-radius: 3px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.hl-danger {
  background: var(--danger-wash);
  color: #9A2626;
  box-shadow: inset 0 -2px 0 var(--danger-crimson);
}

.hl-warn {
  background: var(--terracotta-wash);
  color: #9D4527;
  box-shadow: inset 0 -1.8px 0 var(--terracotta);
}

.hl-safe {
  background: var(--safe-wash);
  color: var(--safe-green);
  box-shadow: inset 0 -1.8px 0 rgba(16, 140, 61, 0.68);
}

/* COMPACT 1-LINE APPLIED STATUS BAR */
.inline-applied-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 22px;
  background: rgba(16, 140, 61, 0.08);
  border-top: 1px solid rgba(16, 140, 61, 0.22);
}

.inline-applied-bar[hidden] {
  display: none;
}

.applied-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--safe-green);
}

.applied-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* EDITOR PRIMARY ACTION BAR */
.editor-footer {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.2fr) auto;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border-cream);
  background: var(--bg-ivory);
}

/* QUIET 2-COLUMN HAIRLINE FOOTNOTE (ZERO NESTED CARDS) */
.editor-footnote-row {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 16px 24px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-cream);
  background: var(--bg-parchment);
}

.footnote-col {
  min-width: 0;
}

.footnote-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.78rem;
  color: var(--ink-primary);
}

.footnote-head.is-between {
  justify-content: space-between;
}

.footnote-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-sand);
  color: var(--ink-charcoal);
}

.mono-micro {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-stone);
}

.addon-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.addon-chip {
  min-height: 32px;
  padding: 5px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-ivory);
  color: var(--ink-charcoal);
  box-shadow: 0 0 0 1px var(--ring-warm);
  font-size: 0.76rem;
  font-weight: 500;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.addon-chip:hover {
  background: var(--bg-sand);
  color: var(--ink-primary);
}

.disclosure-copy {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.54;
  color: var(--ink-olive);
  word-break: keep-all;
}

/* ==========================================================================
   RIGHT COLUMN: SINGLE AUTHORITATIVE VERDICT PANEL
   ========================================================================== */

.inspector-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px 18px;
  background-color: var(--bg-ivory);
}

.inspector-score {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.score-top-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.grade-badge-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.grade-letter {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--bg-sand);
  color: var(--ink-primary);
  box-shadow: 0 0 0 1px var(--ring-warm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.grade-letter.is-danger {
  background: var(--danger-wash);
  color: var(--danger-crimson);
  box-shadow: 0 0 0 1px rgba(181, 51, 51, 0.28);
}

.grade-letter.is-terracotta {
  background: var(--terracotta-wash);
  color: var(--terracotta);
  box-shadow: 0 0 0 1px rgba(201, 100, 66, 0.30);
}

.grade-letter.is-warn {
  background: var(--warn-wash);
  color: var(--warn-ochre);
  box-shadow: 0 0 0 1px rgba(154, 91, 19, 0.28);
}

.grade-letter.is-safe {
  background: var(--safe-wash);
  color: var(--safe-green);
  box-shadow: 0 0 0 1px rgba(16, 140, 61, 0.28);
}

.score-num-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-num-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.score-number {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-primary);
}

.score-denom {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-stone);
  font-variant-numeric: tabular-nums;
}

.score-grade {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.score-summary {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-olive);
  line-height: 1.54;
  word-break: keep-all;
}

/* GPU-ONLY SCORE METER (SCALE-X TRANSFORM ONLY) */
.score-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-sand);
  overflow: hidden;
}

.score-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--danger-crimson);
  transform-origin: left center;
  transform: scaleX(0);
  will-change: transform;
  transition: transform 240ms var(--ease-out), background-color 180ms var(--ease-out);
}

/* HAIRLINE PRECISION METRIC LEDGER (ZERO NESTED BOXES) */
.metric-ledger {
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid var(--border-warm);
  border-bottom: 1px solid var(--border-warm);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 18px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.metric-row dt {
  font-size: 0.76rem;
  color: var(--ink-stone);
}

.metric-row dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

.metric-row dd.is-danger { color: var(--danger-crimson); }
.metric-row dd.is-warn { color: var(--terracotta); }
.metric-row dd.is-safe { color: var(--safe-green); }

/* HAIRLINE DETECTED CLAUSES LIST (ZERO BORDER-LEFT SPAM) */
.findings-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.section-micro-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-olive);
}

.mono-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

.findings-list {
  display: flex;
  flex-direction: column;
  max-height: 318px;
  overflow-y: auto;
  padding-right: 4px;
  border-top: 1px solid var(--border-cream);
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 20, 19, 0.22) transparent;
}

.finding-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-cream);
}

.finding-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.finding-term {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--danger-crimson);
  word-break: keep-all;
}

.finding-item.is-med .finding-term { color: var(--terracotta); }
.finding-item.is-safe .finding-term { color: var(--safe-green); }

.finding-tags {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.finding-statute {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-stone);
}

.finding-badge {
  font-size: 0.69rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 6px;
}

.badge-danger { background: var(--danger-wash); color: var(--danger-crimson); }
.badge-warn { background: var(--terracotta-wash); color: var(--terracotta); }
.badge-safe { background: var(--safe-wash); color: var(--safe-green); }

.finding-reason {
  margin: 0 0 7px;
  font-size: 0.78rem;
  color: var(--ink-olive);
  line-height: 1.52;
  word-break: keep-all;
}

.finding-replace-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-warm);
}

.finding-replace-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.finding-replace-label {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--safe-green);
}

.copy-clause-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 3px 9px;
  border: none;
  border-radius: 6px;
  background: var(--bg-sand);
  color: var(--ink-primary);
  font-size: 0.72rem;
  font-weight: 500;
  transition: background-color 140ms var(--ease-out);
}

.copy-clause-btn:hover {
  background: var(--bg-sand-hover);
}

.finding-replace-text {
  margin: 0;
  font-size: 0.79rem;
  color: var(--ink-primary);
  line-height: 1.5;
  word-break: keep-all;
}

.inspector-cta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.verdict-disclaimer {
  margin: 2px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border-warm);
  font-size: 0.73rem;
  line-height: 1.52;
  color: var(--ink-stone);
  word-break: keep-all;
}

.empty-state {
  margin: 0;
  padding: 14px 0;
  font-size: 0.82rem;
  color: var(--ink-stone);
}

/* ==========================================================================
   CHAPTER 2 (NEAR BLACK #141413): 30-CLAUSE COVERAGE GRID
   ========================================================================== */

.criteria-section {
  padding-block: clamp(56px, 7vw, 88px);
  background: var(--bg-near-black);
  color: var(--ink-ivory);
}

.section-header {
  max-width: 64ch;
  margin-bottom: clamp(24px, 3.4vw, 40px);
}

.section-kicker {
  display: inline-block;
  margin-bottom: 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--terracotta);
  letter-spacing: 0.01em;
}

.section-kicker.is-coral {
  color: var(--coral);
}

.section-title {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(1.55rem, 2.7vw, 2.3rem);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.025em;
  color: var(--ink-primary);
  word-break: keep-all;
}

.section-title.is-on-dark {
  color: var(--ink-ivory);
}

.section-lead {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.62;
  color: var(--ink-olive);
  word-break: keep-all;
}

.section-lead.is-on-dark {
  color: var(--ink-silver);
}

.criteria-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--bg-dark-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--bg-dark-surface);
}

.criteria-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px 22px;
  background: var(--bg-near-black);
  text-align: left;
  border: none;
  color: var(--ink-ivory);
  transition: background-color 160ms var(--ease-out);
}

.criteria-card:hover {
  background: #1D1D1B;
}

.criteria-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--coral);
  font-variant-numeric: tabular-nums;
}

.criteria-name {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.28;
  color: var(--ink-ivory);
  word-break: keep-all;
}

.criteria-summary {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.58;
  color: var(--ink-silver);
  word-break: keep-all;
}

.criteria-action {
  margin-top: auto;
  padding-top: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--coral);
}

/* ==========================================================================
   CHAPTER 3 (PARCHMENT LIGHT): OFFICIAL HELP & KRW 0 PACK PANEL
   ========================================================================== */

.help-section {
  padding-block: clamp(56px, 7vw, 84px);
  background: var(--bg-parchment);
}

.help-split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}

.help-links {
  margin-top: 22px;
  border-top: 1px solid var(--border-warm);
}

.help-link-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border-warm);
}

.help-link-row strong {
  display: block;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.help-link-row span {
  display: block;
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--ink-olive);
}

.mono-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-sand);
  color: var(--ink-primary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.pack-panel {
  padding: 26px 24px;
  background: var(--bg-ivory);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pack-kicker {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--terracotta);
}

.pack-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.32rem;
  font-weight: 500;
  line-height: 1.26;
  color: var(--ink-primary);
  word-break: keep-all;
}

.pack-desc {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink-olive);
  word-break: keep-all;
}

.pack-price-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-parchment);
  box-shadow: 0 0 0 1px var(--border-warm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-charcoal);
  word-break: keep-all;
}

/* ==========================================================================
   WARM EDITORIAL FOOTER
   ========================================================================== */

.site-footer {
  padding-block: 30px 42px;
  border-top: 1px solid var(--border-warm);
  background: var(--bg-parchment);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px 32px;
}

.footer-brand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.footer-brand {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 500;
}

.footer-divider {
  color: var(--ring-deep);
}

.footer-tag {
  font-size: 0.8rem;
  color: var(--ink-stone);
}

.footer-note {
  margin: 8px 0 0;
  max-width: 68ch;
  font-size: 0.77rem;
  line-height: 1.58;
  color: var(--ink-stone);
  word-break: keep-all;
}

.footer-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 0.79rem;
  color: var(--ink-olive);
}

.footer-inquiry-btn {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--ink-primary);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 140ms var(--ease-out);
}

.footer-inquiry-btn:hover {
  color: var(--terracotta);
}

/* ==========================================================================
   MODAL & SINGLE-REPLACEMENT TOAST
   ========================================================================== */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-root[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 19, 0.54);
  backdrop-filter: blur(8px);
}

.modal-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  max-height: min(90vh, 740px);
  display: flex;
  flex-direction: column;
  background: var(--bg-ivory);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px rgba(20, 20, 19, 0.10), 0 32px 64px -18px rgba(20, 20, 19, 0.34);
  overflow: hidden;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-cream);
  flex-shrink: 0;
}

.modal-head-copy {
  min-width: 0;
}

.modal-kicker {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--terracotta);
  margin-bottom: 4px;
  word-break: keep-all;
}

.modal-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.26rem;
  font-weight: 500;
  line-height: 1.28;
  word-break: keep-all;
}

.close-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: var(--bg-sand);
  color: var(--ink-charcoal);
  flex-shrink: 0;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.close-btn:hover {
  background: var(--bg-sand-hover);
  color: var(--ink-primary);
}

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

.modal-body-scroll {
  padding: 18px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  flex: 1;
}

.zero-charge-notice {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-parchment);
  box-shadow: 0 0 0 1px var(--border-warm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-primary);
  line-height: 1.5;
  word-break: keep-all;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-olive);
}

.form-field em {
  font-style: normal;
  color: var(--terracotta);
}

.modal-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.modal-select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  cursor: pointer;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-white);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 1px var(--ring-warm);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--ink-primary);
  transition: box-shadow 140ms var(--ease-out);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  box-shadow: 0 0 0 1.5px var(--focus-blue);
}

.form-feedback {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.54;
  font-weight: 500;
  word-break: keep-all;
}

.form-feedback.is-error {
  background: var(--danger-wash);
  color: var(--danger-crimson);
}

.form-feedback.is-success {
  background: var(--safe-wash);
  color: var(--safe-green);
}

.modal-actions {
  display: flex;
  padding: 14px 24px 18px;
  background: var(--bg-parchment);
  border-top: 1px solid var(--border-warm);
  flex-shrink: 0;
}

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 160;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.toast-item {
  padding: 11px 16px;
  background: var(--bg-near-black);
  color: var(--ink-ivory);
  border-radius: var(--radius-md);
  font-size: 0.83rem;
  font-weight: 500;
  box-shadow: 0 14px 32px rgba(20, 20, 19, 0.28);
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
}

/* ==========================================================================
   RESPONSIVE: 390x844 ABOVE-THE-FOLD, ZERO ELLIPSIS, ZERO OVERFLOW
   ========================================================================== */

@media (max-width: 980px) {
  .studio-body,
  .criteria-grid,
  .help-split,
  .editor-footnote-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .legal-slim-desktop,
  .brand-sep,
  .brand-sub,
  .nav-link,
  .hero-lead,
  .editor-hint,
  .meta-sep,
  .br-desktop {
    display: none;
  }

  .legal-slim-mobile {
    display: block;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
  }

  .br-mobile {
    display: inline;
  }

  .header-inner {
    min-height: 48px;
  }

  .hero-section {
    padding-top: 12px;
    padding-bottom: 40px;
  }

  .hero-head {
    margin-bottom: 12px;
  }

  .hero-kicker {
    margin-bottom: 5px;
    font-size: 0.71rem;
  }

  .hero-title {
    margin-bottom: 0;
    font-size: 1.44rem;
    line-height: 1.22;
  }

  .studio-shell {
    border-radius: 14px;
  }

  .studio-bar {
    padding: 10px 12px;
    gap: 8px;
  }

  .studio-selects {
    grid-template-columns: 1fr;
    gap: 7px;
    flex-basis: 100%;
  }

  .control-select select {
    min-height: 40px;
    font-size: 0.81rem;
    white-space: normal;
  }

  .studio-chips-row {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }

  .quick-chips {
    gap: 5px;
  }

  .quick-chip {
    min-height: 36px;
    padding: 5px 10px;
    font-size: 0.76rem;
  }

  .text-action-btn {
    min-height: 36px;
    padding: 5px 8px;
    font-size: 0.76rem;
  }

  .editor-subbar {
    padding: 7px 14px;
  }

  .editor-meta-right {
    width: 100%;
    justify-content: space-between;
  }

  .live-editor-wrap {
    min-height: 210px;
    max-height: 320px;
  }

  .live-backdrop,
  .live-textarea {
    padding: 13px 14px 15px;
    font-size: 0.87rem;
    line-height: 1.72;
  }

  .inline-applied-bar {
    padding: 9px 14px;
  }

  .editor-footer {
    padding: 10px 12px 12px;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  #jgRunScanBtn {
    grid-column: 1 / -1;
  }

  .editor-footer .btn {
    min-height: 42px;
    padding: 9px 12px;
    font-size: 0.82rem;
  }

  .editor-footnote-row {
    padding: 12px 14px 14px;
    gap: 12px;
  }

  .inspector-column {
    padding: 16px 14px;
  }

  .modal-root {
    padding: 10px;
  }

  .modal-sheet {
    max-height: 92vh;
    border-radius: 16px;
  }

  .modal-head {
    padding: 16px 16px 12px;
  }

  .modal-title {
    font-size: 1.14rem;
  }

  .modal-body-scroll {
    padding: 14px 16px;
    gap: 10px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .modal-actions {
    padding: 12px 16px 14px;
  }

  .footer-right {
    align-items: flex-start;
  }

  .toast-region {
    left: 14px;
    right: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
  }
}
