/* ============================================================
   AI WATERMARK CLEANER — WARM TERMINAL / TEXT FORENSICS
   Bone paper, hairline rules, mono labels, one burnt-orange
   accent. Dot-matrix (Doto) display for headline + numerals.
   ============================================================ */

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/space-mono-400.woff2") format("woff2");
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/space-mono-700.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bone: #ECE8DD;
  --paper: #F7F5EE;
  --field: #FBFAF5;
  --ink: #1C1A16;
  --muted: #777264;
  --hair: #D5D0C2;
  --accent: #C2410C;
  --accent-deep: #9A3412;
  --accent-fill: #A63A10;
  --radius-sm: 6px;
  --radius-md: 8px;
  --font-mono: "Space Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --font-body: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body { overflow-x: clip; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background-color: var(--bone);
  background-image:
    linear-gradient(to right, rgba(28, 26, 22, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(28, 26, 22, 0.045) 1px, transparent 1px);
  background-size: 72px 72px;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--ink);
  color: var(--bone);
}

button, textarea { font: inherit; }

button { color: inherit; }

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- shell / topbar ---------- */

.shell {
  width: min(1360px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--hair);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.logo-mark { display: block; flex-shrink: 0; }

.local-note {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.local-note::before {
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--accent);
  content: "";
}

/* ---------- hero ---------- */

.hero {
  padding: 40px 0 24px;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 18px;
  padding: 8px 14px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0 auto 16px;
  font-family: var(--font-mono);
  font-size: clamp(30px, 6.4vw, 84px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.05;
  text-transform: uppercase;
}

.hero-line { display: block; }

.hero-line--outline { color: var(--accent-deep); }

.intro-copy {
  max-width: 540px;
  margin: 0 auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
}

.spec-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.spec-chip {
  padding: 8px 12px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.spec-chip strong {
  color: var(--ink);
  font-weight: 700;
}

/* ---------- ticker ---------- */

.ticker {
  display: flex;
  width: 100vw;
  margin: 16px calc(50% - 50vw) 22px;
  overflow: hidden;
  border-block: 1px solid var(--hair);
  background: var(--paper);
}

.ticker-track {
  flex-shrink: 0;
  min-width: 100%;
  padding-block: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  animation: ticker 48s linear infinite;
}

.ticker:hover .ticker-track { animation-play-state: paused; }

@keyframes ticker {
  to { transform: translateX(-100%); }
}

/* ---------- notice ---------- */

.notice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 22px;
  padding: 18px 20px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.75;
}

.notice-icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  margin-top: 1px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.notice strong {
  display: inline-block;
  margin-bottom: 7px;
  padding-bottom: 3px;
  border-bottom: 2px solid var(--accent);
  color: var(--ink);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

.workspace {
  overflow: hidden;
  border: 1px solid var(--hair);
  border-radius: var(--radius-md);
  background: var(--paper);
}

.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--hair);
}

.auto-label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-fade 2.4s ease-in-out infinite;
}

@keyframes pulse-fade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.mode-switch {
  display: grid;
  grid-template-columns: auto auto;
  overflow: hidden;
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
}

.mode-button {
  min-width: 128px;
  padding: 9px 14px;
  border: 0;
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-button + .mode-button { border-left: 1px solid var(--hair); }

.mode-button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

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

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.editor-panel {
  min-width: 0;
  padding: 20px;
}

.editor-panel + .editor-panel { border-left: 1px solid var(--hair); }

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-step {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--hair);
  border-radius: 4px;
  color: var(--accent-deep);
  font-size: 10px;
}

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

.text-action {
  padding: 8px 11px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background-color 130ms ease, border-color 130ms ease;
}

.text-action:hover {
  background: var(--bone);
  border-color: #BFB9A9;
}

.text-action.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.text-action.primary:hover {
  background: #33302A;
  border-color: #33302A;
}

.editor-wrap { position: relative; }

textarea {
  display: block;
  width: 100%;
  min-height: 330px;
  resize: vertical;
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  padding: 16px 16px 42px;
  transition: border-color 130ms ease;
}

textarea:hover { border-color: #BFB9A9; }

textarea:focus {
  outline: none;
  border-color: var(--ink);
}

textarea[readonly] { background: #F6F4E8; }

textarea::placeholder { color: #A29D8F; }

.char-count {
  position: absolute;
  right: 11px;
  bottom: 11px;
  padding: 3px 7px;
  border: 1px solid var(--hair);
  border-radius: 4px;
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--hair);
}

.stat {
  min-width: 0;
  padding: 26px 22px 22px;
}

.stat + .stat { border-left: 1px solid var(--hair); }

.stat-value {
  display: block;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: clamp(38px, 4.4vw, 64px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-value.danger { color: var(--accent-deep); }
.stat-value.accent { color: var(--ink); }
.stat-value.blue { color: var(--ink); }

.stat-pop { animation: stat-pop 260ms steps(3, end); }

@keyframes stat-pop {
  0% { opacity: 0.15; }
  60% { opacity: 1; }
}

.stat-label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------- details ---------- */

.details {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(420px, 0.75fr);
  gap: 22px;
  margin-top: 22px;
}

.detail-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--hair);
  border-radius: var(--radius-md);
  background: var(--paper);
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 19px 20px 15px;
  border-bottom: 1px solid var(--hair);
}

.detail-title {
  display: inline-block;
  margin: 0 0 7px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.detail-subtitle {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.6;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.legend i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

.legend .removed { background: var(--accent-fill); }
.legend .changed { background: var(--ink); }
.legend .flagged { background: transparent; border: 1px dashed var(--ink); }

/* ---------- diff view ---------- */

.diff-view {
  min-height: 304px;
  max-height: 460px;
  overflow: auto;
  padding: 18px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 2.1;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-placeholder,
.empty-table {
  display: grid;
  min-height: 264px;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
}

.diff-token {
  display: inline-block;
  margin: 0 3px;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: help;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.8;
  text-transform: uppercase;
  vertical-align: 1px;
  animation: token-pop 180ms steps(2, end);
}

@keyframes token-pop {
  0% { opacity: 0.2; }
}

.diff-token.remove {
  background: var(--accent-fill);
  color: #fff;
}

.diff-token.normalize {
  background: var(--ink);
  color: var(--paper);
}

.diff-token.preserve {
  border: 1px dashed var(--ink);
  color: var(--ink);
}

/* ---------- character log ---------- */

.table-wrap {
  max-height: 430px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--hair);
  vertical-align: top;
}

.char-name {
  font-weight: 700;
  font-size: 11.5px;
}

.positions {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.code {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--hair);
  border-radius: 4px;
  background: var(--field);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.result {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.result.remove { color: var(--accent-deep); }
.result.normalize { color: var(--ink); }
.result.preserve { color: var(--muted); }

/* ---------- footnote ---------- */

.footnote {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 40px;
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px solid var(--hair);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.75;
}

.footnote p { margin: 0; max-width: 620px; }

.footnote strong { color: var(--ink); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 10;
  padding: 11px 17px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 12px 32px rgba(28, 26, 22, 0.28);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- noscript ---------- */

.noscript-note {
  width: min(1360px, calc(100% - 48px));
  margin: 24px auto 0;
  padding: 16px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--accent-deep);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* ---------- fx (added by fx.js only) ---------- */

.reveal-init {
  opacity: 0;
  transform: translateY(22px);
}

.reveal-in {
  opacity: 1;
  transform: none;
  transition: opacity 460ms ease, transform 460ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* ---------- responsive ---------- */

@media (max-width: 1040px) {
  .details { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat + .stat { border-left: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--hair); }
  .stat:nth-child(n+3) { border-top: 1px solid var(--hair); }
}

@media (max-width: 800px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-panel + .editor-panel {
    border-left: 0;
    border-top: 1px solid var(--hair);
  }
  .workspace-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .hero { padding-top: 32px; }
}

@media (max-width: 520px) {
  .shell { width: calc(100% - 32px); }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .editor-panel { padding: 16px; }
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
  .panel-actions { justify-content: flex-start; }
  textarea { min-height: 260px; }
  .detail-head { flex-direction: column; gap: 12px; }
  .legend { justify-content: flex-start; }
}

@media (max-width: 460px) {
  .stats { grid-template-columns: 1fr; }
  .stat:nth-child(even) { border-left: 0; }
  .stat:nth-child(n+2) { border-top: 1px solid var(--hair); }
}

/* ---------- reduced motion: single kill-switch ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .ticker-track { transform: none !important; }
  .reveal-init {
    opacity: 1 !important;
    transform: none !important;
  }
}
