/* Unicode Inspector — own lightweight brand. No external CSS, no web fonts,
   no network. Light + dark themes via [data-theme] on <html>. */

:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f7f9fd;
  --ink: #14181f;
  --ink-soft: #4a5566;
  --muted: #6b7688;
  --line: #dde3ee;
  --line-strong: #c4cddd;
  --accent: #3a5bd9;
  --accent-ink: #ffffff;
  --accent-soft: #eaefff;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* class colors (light) */
  --c-zero: #b4008f; --c-zero-bg: #fbe6f6;
  --c-bidi: #b23b00; --c-bidi-bg: #ffe7d8;
  --c-nbsp: #007a86; --c-nbsp-bg: #d8f5f7;
  --c-soft: #6a5b00; --c-soft-bg: #f6efc8;
  --c-var:  #4b41b8; --c-var-bg:  #e7e4fb;
  --c-inter:#7a4600; --c-inter-bg:#f6e6d4;
  --c-ctl:  #8a1030; --c-ctl-bg:  #fadfe6;
  --c-conf: #a05a00; --c-conf-bg: #fdefd6;

  --warn: #9a5a00; --warn-bg: #fff4e2; --warn-line: #f0c98a;
  --clean: #1f7a4d; --clean-bg: #e7f6ee; --clean-line: #bfe6cf;
}

/* Dark palette: applied by the manual toggle (html[data-theme="dark"]) OR, when
   the user has made no explicit choice, by the OS preference via the media
   query at the bottom of this file (html:not([data-theme])). */
html[data-theme="dark"] {
  --bg: #0e1117;
  --panel: #161b24;
  --panel-2: #1b212c;
  --ink: #e8edf5;
  --ink-soft: #b3bdcc;
  --muted: #8895a8;
  --line: #262e3b;
  --line-strong: #35404f;
  --accent: #6d8bff;
  --accent-ink: #0e1117;
  --accent-soft: #1d2740;

  --c-zero: #ff7fe0; --c-zero-bg: #3a1030;
  --c-bidi: #ffa06b; --c-bidi-bg: #3a1c0c;
  --c-nbsp: #5fdce8; --c-nbsp-bg: #093034;
  --c-soft: #e8d066; --c-soft-bg: #302a08;
  --c-var:  #b3aaff; --c-var-bg:  #201b40;
  --c-inter:#f0b070; --c-inter-bg:#33230f;
  --c-ctl:  #ff8aa4; --c-ctl-bg:  #3a0f1c;
  --c-conf: #ffc061; --c-conf-bg: #362405;

  --warn: #ffc061; --warn-bg: #2a2008; --warn-line: #5a4410;
  --clean: #6fd79b; --clean-bg: #0f2a1c; --clean-line: #23503a;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.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 {
  position: absolute; left: -999px; top: 0; background: var(--accent);
  color: var(--accent-ink); padding: .5rem .8rem; z-index: 20; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem clamp(1rem, 4vw, 2.5rem);
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; }
.brand-mark {
  font-family: var(--mono); font-weight: 700; color: var(--accent-ink);
  background: var(--accent); padding: .12rem .4rem; border-radius: 6px; font-size: .95rem;
}
.brand-name { letter-spacing: -.01em; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.pill {
  font-family: var(--mono); font-size: .78rem; color: var(--ink-soft);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: .28rem .6rem; border-radius: 999px; white-space: nowrap;
}

/* ---- layout ---- */
.wrap {
  max-width: 1100px; margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 2.5rem) 3rem;
  display: flex; flex-direction: column; gap: 1.1rem;
}
.intro { margin-bottom: .2rem; }
.intro h1 {
  font-size: clamp(1.5rem, 3.4vw, 2.1rem); line-height: 1.15;
  margin: 0 0 .5rem; letter-spacing: -.02em;
}
.lede { margin: 0 0 .8rem; color: var(--ink-soft); max-width: 68ch; }
.trust {
  display: flex; align-items: flex-start; gap: .55rem; margin: 0;
  background: var(--clean-bg); border: 1px solid var(--clean-line);
  color: var(--ink); padding: .6rem .8rem; border-radius: 10px; font-size: .92rem;
  max-width: 72ch;
}
.trust b { color: var(--clean); }
.trust-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--clean);
  margin-top: .45rem; flex: 0 0 auto; box-shadow: 0 0 0 3px var(--clean-bg);
}

/* ---- panels ---- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 1rem clamp(.9rem, 2vw, 1.3rem) 1.15rem;
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .7rem;
}
.panel-head h2 { font-size: 1.05rem; margin: 0; letter-spacing: -.01em; }
.panel-actions { display: flex; gap: .5rem; }
.hint { color: var(--muted); font-size: .82rem; max-width: 46ch; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }

/* ---- inputs ---- */
.input {
  width: 100%; min-height: 150px; resize: vertical;
  font-family: var(--mono); font-size: .95rem; line-height: 1.5;
  color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: .8rem;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.input.clean { min-height: 110px; }
.field-label { display: block; font-size: .82rem; color: var(--ink-soft); margin: .8rem 0 .35rem; font-weight: 600; }

/* ---- buttons ---- */
.btn {
  font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--ink);
  padding: .45rem .8rem; border-radius: 8px; transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; }

/* ---- annotated view ---- */
.annotated {
  font-family: var(--mono); font-size: .95rem; line-height: 2.1;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: .8rem; min-height: 90px; max-height: 340px; overflow: auto;
}
.annotated:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.anno-empty { color: var(--muted); font-family: var(--sans); }

.anno {
  border-radius: 5px; padding: 0 .12em; margin: 0 .04em; cursor: help;
  outline: none; text-decoration: none;
}
.anno:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.anno-glyph {
  font-size: .72em; font-weight: 700; letter-spacing: .02em;
  padding: 0 .25em; border-radius: 4px; vertical-align: baseline;
}
/* hidden-char chips: colored pill with hex */
.anno-zero-width  { background: var(--c-zero-bg); color: var(--c-zero); box-shadow: inset 0 0 0 1px var(--c-zero); }
.anno-bidi-control{ background: var(--c-bidi-bg); color: var(--c-bidi); box-shadow: inset 0 0 0 1px var(--c-bidi); }
.anno-nbsp        { background: var(--c-nbsp-bg); color: var(--c-nbsp); box-shadow: inset 0 0 0 1px var(--c-nbsp); }
.anno-soft-hyphen { background: var(--c-soft-bg); color: var(--c-soft); box-shadow: inset 0 0 0 1px var(--c-soft); }
.anno-variation-selector { background: var(--c-var-bg); color: var(--c-var); box-shadow: inset 0 0 0 1px var(--c-var); }
.anno-interlinear-annotation { background: var(--c-inter-bg); color: var(--c-inter); box-shadow: inset 0 0 0 1px var(--c-inter); }
.anno-other-control-format { background: var(--c-ctl-bg); color: var(--c-ctl); box-shadow: inset 0 0 0 1px var(--c-ctl); }
/* confusable: keep the real glyph visible, underline-highlight it */
.anno-confusable {
  background: var(--c-conf-bg); color: var(--c-conf);
  box-shadow: inset 0 0 0 1px var(--c-conf); text-decoration: underline wavy;
  text-underline-offset: 3px;
}

/* ---- legend ---- */
.legend {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .7rem;
  font-size: .78rem; color: var(--ink-soft);
}
.legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-zero-width { background: var(--c-zero); }
.sw-bidi-control { background: var(--c-bidi); }
.sw-nbsp { background: var(--c-nbsp); }
.sw-soft-hyphen { background: var(--c-soft); }
.sw-variation-selector { background: var(--c-var); }
.sw-other-control-format { background: var(--c-ctl); }
.sw-confusable { background: var(--c-conf); }

/* ---- tables ---- */
.summary { margin: 0 0 .6rem; color: var(--ink-soft); font-size: .9rem; }
.tbl-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th, .tbl td {
  text-align: left; padding: .4rem .55rem; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.tbl th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line-strong);
  position: sticky; top: 0; background: var(--panel);
}
.tbl td.num { font-family: var(--mono); color: var(--ink-soft); width: 3.5rem; }
.tbl td.mono, .mono { font-family: var(--mono); }
.tbl td.note { color: var(--ink-soft); }
.glyph-cell { font-size: 1.1rem; text-align: center; }

.tag {
  display: inline-block; font-size: .72rem; font-weight: 600;
  padding: .08rem .45rem; border-radius: 999px; white-space: nowrap;
}
.tag-zero-width  { background: var(--c-zero-bg); color: var(--c-zero); }
.tag-bidi-control{ background: var(--c-bidi-bg); color: var(--c-bidi); }
.tag-nbsp        { background: var(--c-nbsp-bg); color: var(--c-nbsp); }
.tag-soft-hyphen { background: var(--c-soft-bg); color: var(--c-soft); }
.tag-variation-selector { background: var(--c-var-bg); color: var(--c-var); }
.tag-interlinear-annotation { background: var(--c-inter-bg); color: var(--c-inter); }
.tag-other-control-format { background: var(--c-ctl-bg); color: var(--c-ctl); }

/* ---- callout ---- */
.callout { border-radius: 10px; padding: .8rem .9rem; font-size: .9rem; border: 1px solid; }
.callout strong { display: block; margin-bottom: .3rem; }
.callout-clean { background: var(--clean-bg); border-color: var(--clean-line); }
.callout-clean strong { color: var(--clean); }
.callout-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.callout-warn strong { color: var(--warn); }
.callout-line { margin: .3rem 0 .6rem; color: var(--ink-soft); }

/* ---- strip ---- */
.classes {
  border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem;
  margin: 0 0 .8rem; display: flex; flex-wrap: wrap; gap: .5rem 1.1rem;
}
.chk { display: inline-flex; align-items: center; gap: .4rem; font-size: .86rem; cursor: pointer; }
.chk input { width: 1rem; height: 1rem; accent-color: var(--accent); }
.strip-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.copy-status { font-size: .82rem; color: var(--clean); }

.audit { margin-top: 1rem; }
.audit-title { font-size: .95rem; margin: 0 0 .5rem; }
.audit-h { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .9rem 0 .4rem; }
.muted { color: var(--muted); font-size: .88rem; }

/* ---- footer ---- */
.foot {
  max-width: 1100px; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 2.5rem;
  color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line);
}
.foot p { margin: .2rem 0; max-width: 72ch; }
.foot-sub { color: var(--muted); }

/* OS dark preference when the user has made no explicit toggle choice. Keep
   these values byte-identical to html[data-theme="dark"] above. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #0e1117;
    --panel: #161b24;
    --panel-2: #1b212c;
    --ink: #e8edf5;
    --ink-soft: #b3bdcc;
    --muted: #8895a8;
    --line: #262e3b;
    --line-strong: #35404f;
    --accent: #6d8bff;
    --accent-ink: #0e1117;
    --accent-soft: #1d2740;
    --c-zero: #ff7fe0; --c-zero-bg: #3a1030;
    --c-bidi: #ffa06b; --c-bidi-bg: #3a1c0c;
    --c-nbsp: #5fdce8; --c-nbsp-bg: #093034;
    --c-soft: #e8d066; --c-soft-bg: #302a08;
    --c-var:  #b3aaff; --c-var-bg:  #201b40;
    --c-inter:#f0b070; --c-inter-bg:#33230f;
    --c-ctl:  #ff8aa4; --c-ctl-bg:  #3a0f1c;
    --c-conf: #ffc061; --c-conf-bg: #362405;
    --warn: #ffc061; --warn-bg: #2a2008; --warn-line: #5a4410;
    --clean: #6fd79b; --clean-bg: #0f2a1c; --clean-line: #23503a;
  }
}

/* ---- responsive ---- */
@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; }
  .hint { max-width: none; }
  .topbar { padding: .6rem 1rem; flex-wrap: wrap; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; }
  .pill { font-size: .72rem; white-space: normal; }
  .wrap { padding-top: 1rem; gap: 1rem; }
  .input { min-height: 120px; }
  .classes { gap: .5rem .8rem; }
}
