/* ─────────────────────────────────────────────────────────────
   LLM Watermarking Playground
   ───────────────────────────────────────────────────────────── */

:root {
  --bg: #f6f7f9;
  --bg-accent: radial-gradient(1200px 500px at 20% -10%, #dcfce7 0%, transparent 60%),
               radial-gradient(1000px 450px at 85% -10%, #fee2e2 0%, transparent 60%);
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #16181d;
  --text-muted: #5b6472;
  --border: #e2e6eb;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --green-border: #86efac;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --red-border: #fca5a5;
  --accent: #16a34a;
  --accent-ink: #ffffff;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 8px 24px rgb(16 24 40 / 0.06);
  --radius: 14px;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Sora", var(--font-body);
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --bg-accent: radial-gradient(1200px 500px at 20% -10%, rgba(22, 163, 74, 0.16) 0%, transparent 60%),
                 radial-gradient(1000px 450px at 85% -10%, rgba(220, 38, 38, 0.14) 0%, transparent 60%);
    --surface: #171b22;
    --surface-2: #1f242d;
    --text: #e8eaee;
    --text-muted: #9aa3b0;
    --border: #2a303a;
    --green: #4ade80;
    --green-bg: rgba(34, 197, 94, 0.16);
    --green-border: rgba(74, 222, 128, 0.45);
    --red: #f87171;
    --red-bg: rgba(239, 68, 68, 0.16);
    --red-border: rgba(248, 113, 113, 0.45);
    --accent: #22c55e;
    --accent-ink: #06210f;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-accent), var(--bg);
  background-attachment: fixed;
}

a { color: var(--green); text-underline-offset: 2px; }
em.g { color: var(--green); font-style: normal; font-weight: 600; }
em.r { color: var(--red); font-style: normal; font-weight: 600; }

/* ── Header ── */
.site-header { padding: 18px 20px 8px; }
.header-inner { max-width: 1400px; margin: 0 auto; }
.header-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; margin-bottom: 4px; }
.repo-link { display: inline-block; font-size: 14px; font-weight: 600; }
.page-version {
  font-size: 12.5px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 1px;
}
.page-version:hover,
.page-version:focus-visible { color: var(--text); border-bottom-color: var(--accent); }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px;
}

h1 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 8px 0 6px;
}
.intro {
  max-width: none;
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}
.intro-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.intro-panel { padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.intro-panel h2 { margin: 0 0 5px; font: 600 1rem/1.35 var(--font-display); }
.model-guide { margin-top: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.model-guide h3 { margin: 0 0 9px; font-size: 15px; }
.model-guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.model-guide h4 { margin: 0 0 5px; font-size: 13px; }
.model-guide ul, .model-guide ol { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.45; }
.model-guide li + li { margin-top: 4px; }
.model-guide-note { margin: 8px 0 0; font-size: 12px; color: var(--text-muted); }
@media (max-width: 760px) {
  .intro-grid, .model-guide-grid { grid-template-columns: 1fr; gap: 10px; }
}

.grad {
  background: linear-gradient(90deg, var(--green) 0%, #ca8a04 55%, var(--red) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle { max-width: 780px; color: var(--text-muted); margin: 0 0 8px; }

/* ── Layout ── */
.layout {
  max-width: 1440px;
  margin: 16px auto 0;
  padding: 0 20px 40px;
  display: grid;
  grid-template-columns: minmax(320px, 10fr) minmax(340px, 12fr) minmax(230px, 6fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(320px, 5fr) minmax(340px, 6fr); }
  .detect-card { grid-column: 1 / -1; }
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* ── Fields ── */
.field { margin-bottom: 14px; }
.field > label, .param > label, legend {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}
.optional { font-weight: 400; color: var(--text-muted); }

textarea, input[type="text"], input[type="number"], select {
  position: relative;
  z-index: 2;
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 64px; }
textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent);
}
input:disabled { opacity: 0.45; cursor: not-allowed; }
[hidden] { display: none !important; }

.hint { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 0; }

/* tooltip */
.tip {
  font-family: inherit;
  position: relative;
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  vertical-align: 1px;
}
.tip:hover, .tip:focus-visible, .tip[aria-expanded="true"] { color: var(--text); border-color: var(--accent); }
.field-heading { display: flex; align-items: center; gap: 6px; }
.field-heading label { margin: 0; }
.tip::after, .hover-tip::after, .btn-tip::after { content: none; }

/* Hover hint. On a wrapper, not a disabled button: disabled controls do not receive hover. */
.hover-tip, .btn-tip { position: relative; }
.btn-tip { display: flex; }
.btn-tip .btn { width: 100%; }
.btn-tip button:disabled, .hover-tip button:disabled { pointer-events: none; }
#hint-pop {
  position: fixed;
  z-index: 80;
  max-width: min(420px, calc(100vw - 16px));
  max-height: min(50vh, calc(100vh - 16px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  white-space: pre-line;
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.segmented label.hover-tip { display: inline-flex; }
h1.hover-tip { display: inline-block; }
.seg-tip { margin-left: 8px; vertical-align: middle; }

.linklike {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--green); text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}

/* segmented control */
.segmented { display: inline-flex; flex-wrap: wrap; margin-top: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 3px; }
.detect-card .segmented { display: flex; width: 100%; }
.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.segmented span {
  display: inline-block; padding: 5px 14px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }

/* params */
.params { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.params[open] { padding-bottom: 12px; }
.params summary {
  font-weight: 600; font-size: 13px;
  cursor: pointer; user-select: none;
  color: var(--text);
}
.params summary::marker { color: var(--text-muted); }
.params[open] summary { margin-bottom: 8px; }
.params .field { margin: 10px 0 0; }
.param-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px 10px; }
.param > label { margin-bottom: 3px; white-space: nowrap; }
.param input { padding: 6px 9px; font-size: 14px; }

/* model status */
.active-model { margin-top: 9px; font-size: 13px; font-weight: 600; color: var(--text); }
.model-status { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 12.5px; color: var(--text-muted); }
.model-actions { display: flex; gap: 8px; margin-top: 8px; }
.model-actions .btn { flex: 1; padding: 9px 10px; }
.cached-models { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.cached-models h3 { margin: 0 0 7px; font-size: 13px; font-weight: 600; }
.cached-models-note { margin: 0 0 9px; color: var(--text-muted); font-size: 12px; line-height: 1.4; }
.cached-model-list { display: grid; gap: 6px; color: var(--text-muted); font-size: 12px; }
.cached-model-row { display: flex; align-items: flex-start; flex-direction: column; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.cached-model-row > span { overflow-wrap: anywhere; color: var(--text); font-weight: 500; }
.cached-model-actions { display: flex; flex: none; flex-wrap: wrap; gap: 6px; }
.cached-model-actions .btn { flex: none; }
@media (max-width: 480px) {
  .cached-model-actions .btn { flex: 1; }
}
.backend-badge {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  border: 1px solid var(--green-border); color: var(--green); background: var(--green-bg);
  padding: 1px 7px; border-radius: 999px;
}
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--green), #4ade80); border-radius: 999px; transition: width 0.2s; }

/* ── Buttons ── */
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.action-row { display: flex; align-items: center; gap: 10px; }
.btn-hint { margin: 0; }
.btn {
  font: inherit; font-weight: 600; font-size: 14px;
  border-radius: 10px; padding: 10px 20px; cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.06s, filter 0.15s, background 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); flex: 1; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.secondary:hover:not(:disabled) { border-color: var(--green); }
.btn.ghost { background: transparent; color: var(--red); border-color: var(--red-border); }

/* ── Output ── */
.output-card, .detect-card { position: sticky; top: 16px; }
@media (max-width: 860px) { .output-card, .detect-card { position: static; } }

.output-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.output-tools { display: flex; align-items: center; gap: 14px; margin-left: auto; min-height: 18px; }
.color-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.color-toggle input { width: auto; margin: 0; }
.output-head h2 { font-family: var(--font-display); font-size: 17px; margin: 0; }

/* Compact icon button (copy actions in card headers). */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover:not(:disabled),
.icon-btn:focus-visible:not(:disabled) { color: var(--text); border-color: var(--accent); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn .ico-check { display: none; color: var(--green); }
.icon-btn.copied .ico-copy { display: none; }
.icon-btn.copied .ico-check { display: block; }

/* Local watermark strength chart under the stats table. */
.strength-chart { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.strength-chart-head { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.strength-chart svg { display: block; width: 100%; height: auto; }
.strength-chart .sc-band { fill: var(--surface-2); opacity: 0.8; }
.strength-chart .sc-grid { stroke: var(--border); stroke-width: 1; }
.strength-chart .sc-axis { stroke: var(--text-muted); stroke-width: 1.5; }
.strength-chart .sc-axis-text { fill: var(--text); font-size: 20px; font-family: var(--font-body); }
.strength-chart .sc-axis-title { fill: var(--text); font-size: 20px; font-weight: 600; font-family: var(--font-body); }
.strength-chart .sc-null {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.65;
}
.strength-chart .sc-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}
.strength-chart .sc-guide { stroke: var(--text-muted); stroke-width: 1; opacity: 0.7; }
.strength-chart .sc-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.strength-chart .sc-tip {
  fill: var(--text);
  font-size: 22px;
  font-weight: 600;
  font-family: var(--font-body);
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 5px;
  stroke-linejoin: round;
}

.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-muted); min-width: 196px; justify-content: flex-end; }
.legend.is-off { visibility: hidden; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.swatch.green { background: var(--green-bg); border: 1px solid var(--green-border); }
.swatch.red { background: var(--red-bg); border: 1px solid var(--red-border); }

.output {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 2;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-height: 200px;
  max-height: calc(100vh - 210px);
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  letter-spacing: 0;
  word-spacing: normal;
  cursor: text;
}
.placeholder { color: var(--text-muted); font-family: var(--font-body); }
.prompt-echo { color: var(--text-muted); }
.seed-line { margin: 0 0 10px; font-size: 13px; color: var(--text-muted); }
input[readonly] { background: var(--surface-2); color: var(--text-muted); cursor: default; }
.seed-line strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* Highlight must not change glyph metrics. Padding and border on each token
   were adding a few pixels between subwords, which looked like letter-spacing
   once the chips were painted. */
.tokens { letter-spacing: 0; word-spacing: normal; }
.tok {
  display: inline;
  padding: 0;
  margin: 0;
  border: 0;
  letter-spacing: 0;
  word-spacing: normal;
  border-radius: 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.tok.green { background: var(--green-bg); box-shadow: inset 0 -2px 0 var(--green-border); }
.tok.red { background: var(--red-bg); box-shadow: inset 0 -2px 0 var(--red-border); }

.detect-key label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}


.detect-key { margin-top: 0; }
.detect-row { margin-top: 14px; display: flex; align-items: center; gap: 8px; }
.detect-row .btn-tip { flex: 1; }
.detect-row .btn { width: 100%; }


/* ── Verdict ── */
.verdict {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}
.verdict-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.verdict-conf { margin-left: auto; }
.verdict-note-line { display: flex; align-items: flex-start; gap: 8px; }
.verdict-note-line .tip { flex: none; margin-top: 5px; }
.verdict-label { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.verdict-label.pos { color: var(--green); }
.verdict-label.mid { color: #ca8a04; }
.verdict-label.neg { color: var(--text-muted); }
.verdict-conf { font-size: 13px; color: var(--text-muted); }

.meter { height: 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.meter-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #9ca3af, #ca8a04 55%, var(--green));
  transition: width 0.4s ease;
}

.stats { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 0; }
.stats div { margin: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.stats dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); white-space: nowrap; }
.stats dt .tip { text-transform: none; letter-spacing: normal; vertical-align: middle; margin-left: 5px; }
.stats dd { margin: 0; font-family: var(--font-mono); font-size: 14px; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
#verdict-note { margin-top: 12px; }

/* ── status levels, notes & diagnostics ── */
.status-warn { color: #ca8a04; }
.status-error { color: var(--red); }
.status-note { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 0; }
.diagnostics { margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.diagnostics summary { cursor: pointer; user-select: none; font-weight: 600; }
.diagnostics .diag-actions { margin: 6px 0; }
.diagnostics pre {
  font-family: var(--font-mono); font-size: 11px; line-height: 1.45; color: var(--text);
  max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; margin: 0;
}
.btn.small { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
