/* ============================================================
   TEXT DIFF COMPARE — line-level split/unified diff.
   Tokens ported from the PWN-ALL design system (light enterprise palette).
   ============================================================ */
:root {
  /* surfaces */
  --surface-page:   #f6f8fc;
  --surface-card:   #ffffff;
  --surface-sunken: #eef2f8;
  /* text */
  --text-strong: #0b1220;
  --text-body:   #3a4a63;
  --text-muted:  #566480;
  --text-faint:  #7d8aa3;
  /* borders */
  --border-subtle:  #e2e8f1;
  --border-default: #d4dce8;
  --border-focus:   #2f6bff;
  /* accent (emerald) */
  --accent:      #00a878;
  --accent-text: #007152;
  /* threat / safe semantics */
  --danger:      #e02a31;
  --danger-soft: #fdecec;
  --danger-text: #bd1c22;
  --safe:        #00a878;
  --safe-soft:   #e6faf2;
  --safe-text:   #007152;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(11, 18, 32, 0.06);
  --shadow-sm: 0 6px 20px -12px rgba(11, 18, 32, 0.22);
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

/* Auto dark theme — follows the device setting. Derived from the design
   system's ink near-blacks + green-bright accent (dark-only). */
@media (prefers-color-scheme: dark) {
  :root {
    --surface-page:   #0b1220;
    --surface-card:   #121b2d;
    --surface-sunken: #1c283e;
    --text-strong: #f6f8fc;
    --text-body:   #aab6c9;
    --text-muted:  #8a98b3;
    --text-faint:  #6b7892;
    --border-subtle:  #1f2c44;
    --border-default: #2a3a54;
    --border-focus:   #4d8bff;
    --accent:      #00e599;
    --accent-text: #4fd9a1;
    --danger:      #f0595e;
    --danger-soft: #2e1518;
    --danger-text: #ff8589;
    --safe:        #16c585;
    --safe-soft:   #0e2a22;
    --safe-text:   #4fd9a1;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 10px 28px -14px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--surface-page); color: var(--text-strong); font-family: var(--font-sans); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-text); }
button, input, textarea { font: inherit; }
code { font-family: var(--font-mono); font-size: 0.9em; color: var(--accent-text); }
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; border-radius: 6px; }
.ico { width: 15px; height: 15px; flex: none; }
.ico-lg { width: 22px; height: 22px; }

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px clamp(16px, 4vw, 24px);
  background: var(--surface-card); border-bottom: 1px solid var(--border-subtle);
}
.logo-link { display: inline-flex; align-items: center; gap: 11px; color: var(--text-strong); font-weight: 700; }
.logo-link img { display: block; }
.logo-link small { display: block; font-size: 9.5px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.12em; text-transform: uppercase; }
.topbar-div { width: 1px; height: 22px; background: var(--border-default); }
.topbar-title { font-size: 18px; font-weight: 600; color: var(--text-strong); }
.topbar-spacer { flex: 1; }
.lock-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.home-link { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.home-link:hover { color: var(--accent-text); }

.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: clamp(24px, 4vw, 32px) clamp(16px, 4vw, 24px) 64px; }

/* ---- Hero ---- */
.hero { margin-bottom: 28px; }
.eyebrow { margin: 0; color: var(--accent-text); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
h1 { margin: 10px 0 6px; font-size: clamp(28px, 5vw, 39px); line-height: 1.15; letter-spacing: -0.01em; font-weight: 600; color: var(--text-strong); }
.lede { margin: 0; color: var(--text-body); font-size: 18px; line-height: 1.65; max-width: 60ch; }

/* ---- Inputs ---- */
.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.pane { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; }
.pane-label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text-strong); }
.pane-meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-del { background: var(--danger); }
.dot-add { background: var(--safe); }
textarea {
  width: 100%; resize: vertical; min-height: 220px; padding: 14px;
  background: var(--surface-card); color: var(--text-strong);
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs); outline: none;
  font-family: var(--font-mono); font-size: 14px; line-height: 1.6; white-space: pre;
}
textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--border-focus) 16%, transparent); }

/* ---- Toolbar ---- */
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 20px 0; }
.tabs { display: inline-flex; padding: 3px; background: var(--surface-sunken); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); }
.tab { padding: 6px 16px; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.tab.is-active { background: var(--surface-card); color: var(--text-strong); box-shadow: var(--shadow-xs); }
.toolbar-div { width: 1px; height: 24px; background: var(--border-default); }
.toolbar-spacer { flex: 1; }
.check-line { display: inline-flex; align-items: center; gap: 9px; color: var(--text-body); font-size: 14px; cursor: pointer; }
.check-line input { accent-color: var(--accent); width: 16px; height: 16px; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; transition: border-color 0.12s, color 0.12s, background 0.12s; }
.btn-ghost { border: 1px solid transparent; background: transparent; color: var(--text-body); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text-strong); }
.btn-secondary { border: 1px solid var(--border-default); background: var(--surface-card); color: var(--text-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { border-color: var(--danger); color: var(--danger-text); }

/* ---- Result card ---- */
.result-card { border: 1px solid var(--border-subtle); border-radius: var(--radius); background: var(--surface-card); box-shadow: var(--shadow-sm); overflow: hidden; }
.result-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); }
.result-title { font-size: 14px; font-weight: 500; color: var(--text-strong); }
.result-spacer { flex: 1; }
.result-meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }
.badges { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.badge-safe { background: var(--safe-soft); color: var(--safe-text); border-color: color-mix(in srgb, var(--safe) 24%, transparent); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.badge-neutral { background: var(--surface-sunken); color: var(--text-muted); border-color: var(--border-default); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }

.diff-result { display: block; padding: 14px; }
.diff-empty { padding: 48px 24px; text-align: center; color: var(--text-body); font-size: 16px; }
.diff-empty.diff-hint { color: var(--text-faint); }
.diff-empty p { margin: 0; }
.diff-check { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-bottom: 12px; border-radius: 50%; background: var(--safe-soft); color: var(--safe-text); }

/* ---- Diff grid ---- */
.diff-grid { overflow: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); }
.diff-split { display: grid; grid-template-columns: 44px minmax(160px, 1fr) 44px minmax(160px, 1fr); }
.diff-unified { display: grid; grid-template-columns: 44px 44px minmax(0, 1fr); }
.dg {
  user-select: none; text-align: right; padding: 2px 10px;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6; color: var(--text-faint);
  background: var(--surface-card); border-right: 1px solid var(--border-subtle); position: sticky; left: 0;
}
.dc { display: flex; gap: 8px; padding: 2px 12px; background: var(--surface-card); min-width: 0; }
.dc-txt { font-family: var(--font-mono); font-size: 14px; line-height: 1.6; color: var(--text-strong); white-space: pre-wrap; word-break: break-word; min-width: 0; }
.dc-sign { flex: none; font-family: var(--font-mono); font-size: 14px; font-weight: 600; line-height: 1.6; }
.dc-del { background: var(--danger-soft); }
.dc-del .dc-sign { color: var(--danger); }
.dc-add { background: var(--safe-soft); }
.dc-add .dc-sign { color: var(--safe-text); }
.dc-hatch { background: repeating-linear-gradient(45deg, var(--surface-sunken), var(--surface-sunken) 6px, transparent 6px, transparent 12px); }

/* ---- Info / FAQ ---- */
.info { margin-top: 36px; display: grid; gap: 18px; }
.info-intro h2 { margin: 6px 0 8px; font-size: clamp(20px, 3vw, 25px); letter-spacing: -0.01em; font-weight: 600; }
.info-intro p { color: var(--text-body); max-width: 78ch; line-height: 1.65; }
.ins-sample { color: var(--safe-text); background: var(--safe-soft); border-radius: 4px; padding: 1px 5px; font-family: var(--font-mono); font-size: 0.92em; }
.del-sample { color: var(--danger-text); background: var(--danger-soft); border-radius: 4px; padding: 1px 5px; font-family: var(--font-mono); font-size: 0.92em; }
.faq { display: grid; gap: 10px; }
.faq details { border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-card); padding: 14px 16px; }
.faq summary { cursor: pointer; font-weight: 600; color: var(--text-strong); }
.faq summary::marker { color: var(--accent); }
.faq p { margin: 10px 0 0; color: var(--text-body); line-height: 1.6; }

.site-footer { padding: 22px clamp(16px, 4vw, 24px); border-top: 1px solid var(--border-subtle); display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; justify-content: space-between; color: var(--text-faint); font-size: 12px; }
.site-footer nav { display: flex; gap: 18px; }
.site-footer a:hover { color: var(--accent-text); }

@media (max-width: 760px) {
  .inputs { grid-template-columns: 1fr; }
  .topbar-title, .lock-note { display: none; }
  .toolbar-spacer { flex-basis: 100%; height: 0; }
}

/* lang-switcher */
.lang-switcher { position: relative; border: 0; padding: 0; background: none; }
.lang-switcher > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid var(--border-default); border-radius: 999px; background: var(--surface-card); color: var(--text-muted); font-size: 13px; font-weight: 600; }
.lang-switcher > summary::-webkit-details-marker { display: none; }
.lang-switcher > summary::marker { content: ""; }
.lang-switcher > summary:hover { color: var(--accent-text); border-color: var(--accent); }
.lang-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; display: grid; gap: 2px; max-height: 64vh; overflow: auto; min-width: 190px; padding: 8px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--surface-card); box-shadow: var(--shadow-sm); }
.lang-menu a { padding: 7px 10px; border-radius: 8px; color: var(--text-strong); font-size: 13px; font-weight: 600; white-space: nowrap; }
.lang-menu a:hover { background: var(--surface-sunken); color: var(--accent-text); }
@media (max-width: 720px) { .lang-switcher { display: none; } }
