/* =========================================================
   Tool pages — Flip7 components built on the tokens in site.css
   ========================================================= */

/* ============ HERO ============ */
.tool-hero { padding: 32px 0 28px; margin-bottom: 28px; background: var(--teal-bg); border-bottom: 2px dashed var(--border-strong); }
:root[data-theme="dark"] .tool-hero { background: var(--bg-alt); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--fs-small); font-weight: 700; color: var(--neutral); }
.crumbs a { color: var(--link); transition: color var(--ease); }
.crumbs a:hover { color: var(--teal); text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.crumbs [aria-current] { padding: 2px 10px; border-radius: var(--r-round); background: var(--surface); color: var(--text); }
.tool-title { margin-top: 24px; display: flex; align-items: flex-start; gap: 16px; }
.tool-title-icon {
  flex: none; width: 56px; height: 56px; display: grid; place-items: center;
  border-radius: var(--r-lg); border: 2px solid var(--ink); background: var(--gold); color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink); transform: rotate(-4deg);
}
.tool-title h1 { font-size: 38px; line-height: 1.1; }
.tool-title .sub { margin-top: 8px; max-width: 680px; }
.tool-badges { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.tool-badges li {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 14px;
  border-radius: var(--r-round); border: 2px solid var(--border-strong); background: var(--surface);
  font-size: var(--fs-caption); font-weight: 800; color: var(--teal-dark);
}
:root[data-theme="dark"] .tool-badges li { color: var(--chip-text); }
.tool-badges li::before { content: ""; width: 8px; height: 8px; border-radius: var(--r-round); background: var(--success); box-shadow: 0 0 0 3px rgba(39, 174, 96, .18); }

.workspace-section { padding-bottom: 64px; }
.tool-page .section-head { margin-bottom: 40px; }

/* ============ LAYOUT ============ */
.ws { display: grid; gap: 24px; align-items: start; }
.ws-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ws-side { grid-template-columns: minmax(0, 1fr) 320px; }
.stack { display: grid; gap: 16px; align-content: start; }
.stack-sm { display: grid; gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.mt-16 { margin-top: 16px; }
[hidden] { display: none !important; }

/* ============ PANELS ============ */
.panel {
  background: var(--surface); border-radius: var(--r-lg); overflow: hidden; min-width: 0;
  border-inline-start: 4px solid var(--teal-light); box-shadow: var(--shadow-card);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.panel:focus-within { border-inline-start-color: var(--gold); box-shadow: var(--shadow-card), var(--shadow-accent-glow); }
.panel.is-boom { border-inline-start-color: var(--coral); animation: boom-pulse 2s ease-in-out infinite; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  min-height: 56px; padding: 8px 18px; border-bottom: 2px dashed var(--border);
}
.panel-title { font-family: var(--font-body); font-size: 15px; font-weight: 800; letter-spacing: .02em; color: var(--text); }
.panel-meta { font-size: var(--fs-caption); color: var(--text-2); }
.panel-body { padding: 20px; }
.panel-body.flush { padding: 0; }
.panel-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 2px dashed var(--border); background: var(--teal-bg);
}
:root[data-theme="dark"] .panel-foot { background: var(--bg-alt); }

/* ============ DROPZONE ============ */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 300px; padding: 32px 24px; text-align: center; cursor: pointer;
  border: 3px dashed var(--teal-light); border-radius: var(--r-xl);
  background-color: var(--input-bg);
  background-image: radial-gradient(var(--dot) 1.5px, transparent 1.5px);
  background-size: 16px 16px;
  transition: border-color var(--ease), background-color var(--ease), transform var(--ease-bounce), box-shadow var(--ease);
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--gold-dark); box-shadow: var(--shadow-accent-glow); }
.dropzone.is-drag { background-color: var(--gold-light); transform: scale(1.01); }
:root[data-theme="dark"] .dropzone.is-drag { background-color: #3A3A22; }
.dropzone:focus-visible { border-color: var(--teal); }
.dropzone.compact { min-height: 160px; }
.dz-icon {
  width: 60px; height: 60px; display: grid; place-items: center; margin-bottom: 10px;
  border-radius: var(--r-lg); border: 2px solid var(--ink); background: var(--teal); color: #fff;
  box-shadow: 3px 3px 0 var(--ink); transform: rotate(-4deg); transition: transform var(--ease-bounce);
}
.dropzone:hover .dz-icon { transform: rotate(4deg) scale(1.08); }
.dz-title { font-size: 17px; font-weight: 800; color: var(--text); }
.dz-title u { color: var(--link); text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.dz-hint { font-size: var(--fs-small); color: var(--text-2); }

/* ============ FORM CONTROLS ============ */
.field { display: grid; gap: 6px; }
.label { font-size: var(--fs-small); font-weight: 800; color: var(--text); display: flex; justify-content: space-between; gap: 8px; }
.label output { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--text-2); }
.hint { font-size: var(--fs-caption); color: var(--text-2); }

.input, .select, .textarea {
  width: 100%; padding: 10px 14px; font: inherit; font-size: 14px; color: var(--text);
  background-color: var(--input-bg); border: 2px solid var(--border-strong); border-radius: var(--r-md);
  transition: border-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}
.input, .select { height: 40px; padding-block: 0; }
.select {
  appearance: none; padding-inline-end: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231E8C86' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--teal); box-shadow: var(--shadow-focus); background-color: var(--surface); }
.input::placeholder, .textarea::placeholder { color: var(--neutral); }
.input.is-error, .textarea.is-error { border-color: var(--coral); box-shadow: var(--shadow-coral-glow); }
.textarea { display: block; min-height: 220px; resize: vertical; line-height: 1.6; }
.textarea.tall { min-height: 360px; }
.mono, .textarea.mono, .input.mono { font-family: var(--font-mono); font-size: 13px; }
.panel-body.flush > .textarea { border: 0; border-radius: 0; min-height: 320px; }
.panel-body.flush > .textarea:focus { box-shadow: inset 0 0 0 2px var(--teal); }
input[type=color] {
  width: 40px; height: 40px; padding: 3px; border: 2px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--input-bg); cursor: pointer;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 4px; }

input[type=range] { width: 100%; accent-color: var(--primary); cursor: pointer; }

/* Round checkbox */
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 30px; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; user-select: none; }
.check input {
  appearance: none; flex: none; width: 22px; height: 22px; margin: 0; cursor: pointer;
  border-radius: var(--r-round); background: var(--input-bg); border: 2px solid var(--border-strong);
  transition: background-color var(--ease), border-color var(--ease), transform var(--ease-bounce);
}
.check input:active { transform: scale(.88); }
.check input:checked {
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FAFAFA' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12 4 4 8-8'/%3E%3C/svg%3E") center / 12px no-repeat;
  border-color: var(--teal-dark); box-shadow: var(--shadow-teal-glow);
}
.check input:focus-visible { box-shadow: var(--shadow-focus); }

/* Segmented control */
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 4px; border-radius: var(--r-round); background: var(--chip-bg); }
.seg button {
  min-height: 32px; padding: 0 14px; border-radius: var(--r-round);
  font-size: var(--fs-small); font-weight: 800; color: var(--chip-text);
  transition: background-color var(--ease), color var(--ease), transform var(--ease-bounce), box-shadow var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button:active { transform: scale(.95); }
.seg button[aria-pressed="true"] { background: var(--teal-dark); color: #fff; box-shadow: var(--shadow-teal-glow); }
.field > .seg:not(.full) { justify-self: start; }
.seg.full { display: flex; }
.seg.full button { flex: 1; }

.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn.is-done { border-color: var(--success); background: var(--success); color: #fff; box-shadow: 0 2px 10px rgba(39, 174, 96, .35); }
.btn-block { width: 100%; }
.btn svg { flex: none; }
.btn-danger { color: var(--coral-dark); border-color: var(--coral); background: var(--surface); }
.btn-danger:hover { background: var(--coral); color: #fff; box-shadow: var(--shadow-coral-glow); }

/* Counter buttons (+/-): rounded squares, coral minus, teal plus */
.counter { display: flex; align-items: center; gap: 10px; }
.counter input[type=range] { flex: 1; }
.btn-count {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: var(--r-md); border: 2px solid; font-size: 20px; font-weight: 800; line-height: 1;
  transition: transform var(--ease-bounce), background-color var(--ease), color var(--ease), box-shadow var(--ease);
}
.btn-count:active { transform: scale(.9); }
.btn-count.minus { color: var(--coral-dark); border-color: var(--coral); background: #FDEDE8; }
.btn-count.minus:hover { background: var(--coral); color: #fff; box-shadow: var(--shadow-coral-glow); }
.btn-count.plus { color: var(--teal-dark); border-color: var(--teal); background: var(--teal-bg); }
.btn-count.plus:hover { background: var(--teal); color: #fff; box-shadow: var(--shadow-teal-glow); }
:root[data-theme="dark"] .btn-count.minus { background: #3A231E; color: var(--coral-light); }
:root[data-theme="dark"] .btn-count.plus { background: var(--chip-bg); color: var(--teal-light); }

/* ============ PROGRESS ============ */
.progress { display: grid; gap: 8px; }
.progress-row { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-small); color: var(--text-2); }
.progress-pct { font-family: var(--font-mono); font-size: var(--fs-caption); font-weight: 700; color: var(--link); }
.progress-bar { position: relative; height: 10px; border-radius: var(--r-round); background: var(--chip-bg); overflow: hidden; box-shadow: inset 0 1px 2px rgba(23, 59, 57, .12); }
.progress-bar > span {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; transition: width 200ms ease;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .22) 0 6px, transparent 6px 12px),
    linear-gradient(90deg, var(--teal), var(--teal-light));
}
.progress.is-indeterminate .progress-bar > span { width: 35% !important; animation: indeterminate 1.1s ease-in-out infinite; }
@keyframes indeterminate { from { left: -35%; } to { left: 100%; } }

/* ============ NOTICES ============ */
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px;
  border-radius: var(--r-md); border-inline-start: 4px solid var(--sky); background: rgba(93, 173, 226, .1);
  font-size: var(--fs-small); color: var(--text-2); line-height: 1.5;
}
.notice svg { flex: none; margin-top: 2px; color: var(--sky); }
.notice strong { color: var(--text); font-weight: 800; }
.notice.warn { border-inline-start-color: var(--gold-dark); background: rgba(255, 210, 63, .16); }
.notice.warn svg { color: var(--gold-dark); }
.notice.error { border-inline-start-color: var(--coral); background: rgba(239, 108, 74, .1); }
.notice.error svg { color: var(--coral); }

/* ============ IMAGE STAGE ============ */
.stage {
  position: relative; display: grid; place-items: center; min-height: 320px; padding: 16px;
  background: var(--bg-alt);
}
.stage canvas, .stage img { max-width: 100%; max-height: 68vh; width: auto; height: auto; border-radius: var(--r-sm); }
.checker {
  background-color: #FFFFFF;
  background-image:
    linear-gradient(45deg, #E8E8EC 25%, transparent 25%), linear-gradient(-45deg, #E8E8EC 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #E8E8EC 75%), linear-gradient(-45deg, transparent 75%, #E8E8EC 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
:root[data-theme="dark"] .checker {
  background-color: #1C1C21;
  background-image:
    linear-gradient(45deg, #26262C 25%, transparent 25%), linear-gradient(-45deg, #26262C 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #26262C 75%), linear-gradient(-45deg, transparent 75%, #26262C 75%);
}

/* Layered canvases (image + interactive overlay) */
.layers { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.layers > canvas:first-child { display: block; max-width: 100%; max-height: 68vh; width: auto; height: auto; }
.layers > .overlay { position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-height: none; touch-action: none; }

/* Before / after comparison */
.compare { --pos: 50%; position: relative; display: inline-block; max-width: 100%; line-height: 0; user-select: none; }
.compare > * { max-width: 100%; max-height: 68vh; }
.compare .after { position: absolute; inset: 0; width: 100%; height: 100%; clip-path: inset(0 0 0 var(--pos)); }
.compare .before { display: block; width: auto; height: auto; clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.compare.is-single .before { clip-path: none; }
.compare.is-single .after, .compare.is-single .compare-handle, .compare.is-single .compare-labels,
.compare.is-single input, .compare.is-single::after { display: none; }
.compare::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-inline-start: -1px;
  background: #FAFAFA; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); pointer-events: none;
}
.compare input[type=range] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize;
}
.compare-handle {
  position: absolute; top: 50%; left: var(--pos); z-index: 2; width: 32px; height: 32px; margin: -16px 0 0 -16px;
  display: grid; place-items: center; border-radius: var(--r-round);
  background: var(--gold); color: var(--ink); border: 2px solid var(--ink); box-shadow: var(--shadow-accent-glow); pointer-events: none;
}
.compare-labels { position: absolute; inset: 12px 12px auto; display: flex; justify-content: space-between; pointer-events: none; }
.compare-labels span {
  padding: 2px 10px; border-radius: var(--r-round); background: rgba(23, 59, 57, .75); color: #fff;
  font-size: 11px; line-height: 18px; font-weight: 800; letter-spacing: .06em;
}

/* ============ STATS ============ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat {
  padding: 14px 16px; background: var(--surface); min-width: 0;
  border-radius: var(--r-lg); border-inline-start: 4px solid var(--teal-light); box-shadow: var(--shadow-card);
}
.stat:nth-child(4n + 2) { border-inline-start-color: var(--gold); }
.stat:nth-child(4n + 3) { border-inline-start-color: var(--coral); }
.stat:nth-child(4n + 4) { border-inline-start-color: var(--sky); }
.stat-label { font-size: var(--fs-caption); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.stat-value { margin-top: 2px; font-family: var(--font-display); font-weight: 800; font-size: 24px; color: var(--text); overflow-wrap: break-word; }
.stat-sub { font-size: var(--fs-caption); color: var(--neutral); }

/* ============ LISTS & TABLES ============ */
.list { display: grid; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; border-bottom: 2px dashed var(--border); transition: background-color var(--ease);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--bg-alt); }

.table-wrap { overflow: auto; max-height: 520px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  text-align: start; padding: 10px 16px; border-bottom: 2px solid var(--border-strong);
  font-size: var(--fs-overline); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--link);
}
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--bg-alt); }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }

/* Status chips */
.status {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-round);
  font-size: var(--fs-caption); font-weight: 800; white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; }
.status.pos { color: #1E8449; background: rgba(39, 174, 96, .14); }
.status.neu { color: var(--text-2); background: var(--chip-bg); }
.status.neg { color: var(--coral-dark); background: rgba(239, 108, 74, .14); }
:root[data-theme="dark"] .status.pos { color: #58D68D; }
:root[data-theme="dark"] .status.neg { color: var(--coral-light); }

/* Horizontal bars */
.bar-row { display: grid; grid-template-columns: 120px 1fr 52px; align-items: center; gap: 12px; font-size: var(--fs-small); }
.bar-row .bar { height: 10px; border-radius: var(--r-round); background: var(--chip-bg); overflow: hidden; }
.bar-row .bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--teal-light)); }
.bar-row:first-child .bar > span { background: linear-gradient(90deg, var(--gold-dark), var(--gold)); }
.bar-row .val { text-align: end; font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--text-2); }

/* ============ OUTPUT ============ */
.output {
  min-height: 220px; padding: 16px 20px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 15px; line-height: 1.7; color: var(--text);
}
.output.mono { font-size: 13px; line-height: 1.6; }
.placeholder { color: var(--neutral); }
pre.code {
  margin: 0; padding: 16px 20px; overflow: auto; max-height: 520px;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6; white-space: pre; color: var(--text);
}
mark { background: rgba(255, 210, 63, .45); color: inherit; border-radius: 3px; padding: 0 2px; }

.empty-state { display: grid; place-items: center; gap: 6px; min-height: 220px; padding: 24px; text-align: center; color: var(--text-2); font-size: 14px; }
.empty-state svg { color: var(--neutral); }

/* Key-value fields */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; align-items: center; }
.kv .k { font-size: var(--fs-small); color: var(--text-2); }

/* Swatches */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.swatch { border: 2px solid var(--ink); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); text-align: start; box-shadow: 3px 3px 0 var(--ink); transition: transform var(--ease-bounce), box-shadow var(--ease); }
.swatch:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: 4px 5px 0 var(--ink); }
.swatch:active { transform: scale(.95); }
.swatch-color { height: 88px; }
.swatch-info { padding: 10px 12px; display: grid; gap: 2px; }
.swatch-hex { font-family: var(--font-mono); font-size: 13px; color: var(--text); }
.swatch-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }

/* Strength meter */
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.meter span { height: 8px; border-radius: var(--r-round); background: var(--chip-bg); transition: background-color var(--ease); }

/* Keyword / token chips */
.tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.token { padding: 3px 12px; border-radius: var(--r-round); background: var(--chip-bg); color: var(--chip-text); font-size: var(--fs-caption); font-weight: 800; }

/* Tabs that switch panels */
.tabs-bar { display: flex; gap: 4px; border-bottom: 2px dashed var(--border); padding: 0 8px; }
.tabs-bar button {
  position: relative; height: 48px; padding: 0 14px; font-size: 14px; font-weight: 800; color: var(--text-2);
  transition: color var(--ease);
}
.tabs-bar button:hover { color: var(--text); }
.tabs-bar button[aria-selected="true"] { color: var(--text); }
.tabs-bar button[aria-selected="true"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -2px; height: 4px; border-radius: 4px 4px 0 0; background: var(--gold); }

/* Regex: pattern input and highlighted textarea */
.regex-input {
  display: flex; align-items: center; gap: 4px; height: 46px; padding: 0 14px;
  background: var(--input-bg); border: 2px solid var(--border-strong); border-radius: var(--r-md);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.regex-input:focus-within { border-color: var(--teal); box-shadow: var(--shadow-focus); }
.regex-input.is-error { border-color: var(--coral); box-shadow: var(--shadow-coral-glow); }
.regex-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; color: var(--text); font-size: 15px; }
.regex-input input:focus-visible { box-shadow: none; }
.hl-wrap { position: relative; }
.hl-backdrop, .hl-input {
  margin: 0; padding: 16px 20px; font-family: var(--font-mono); font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word; tab-size: 4; overflow-y: scroll;
}
.hl-backdrop { position: absolute; inset: 0; color: transparent; pointer-events: none; }
.hl-backdrop mark { color: transparent; background: rgba(255, 210, 63, .5); padding: 0; border-radius: 2px; }
.hl-backdrop mark.alt { background: rgba(93, 173, 226, .35); }
.hl-input {
  position: relative; display: block; width: 100%; min-height: 280px; resize: vertical;
  border: 0; outline: none; background: transparent; color: var(--text); caret-color: var(--text);
}
.hl-input:focus-visible { box-shadow: none; }

/* JSON syntax colors and tree */
.j-key { color: var(--teal-dark); }
.j-str { color: #1E8449; }
.j-num { color: #A07F00; }
.j-lit { color: var(--coral-dark); }
:root[data-theme="dark"] .j-key { color: var(--teal-light); }
:root[data-theme="dark"] .j-str { color: #58D68D; }
:root[data-theme="dark"] .j-num { color: var(--gold); }
:root[data-theme="dark"] .j-lit { color: var(--coral-light); }
.tree { overflow: auto; padding: 16px 20px; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; }
.tree summary { cursor: pointer; list-style: none; border-radius: 4px; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--neutral); transition: transform var(--ease); }
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary:hover { background: var(--bg-alt); }
.tree-children { padding-inline-start: 18px; border-inline-start: 2px dashed var(--border); margin-inline-start: 5px; }
.tree-leaf { padding-inline-start: 14px; overflow-wrap: anywhere; }

/* Password generator */
.pw-main { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--input-bg); }
.pw-text { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 22px; line-height: 1.4; overflow-wrap: anywhere; color: var(--text); }
.pw-d { color: var(--teal-dark); font-weight: 700; }
.pw-s { color: var(--coral-dark); font-weight: 700; }
:root[data-theme="dark"] .pw-d { color: var(--teal-light); }
:root[data-theme="dark"] .pw-s { color: var(--coral-light); }

/* Rendered Markdown */
.prose { padding: 20px 24px; font-size: 15px; line-height: 1.7; color: var(--text); overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: 1.4em 0 .5em; letter-spacing: -0.02em; line-height: 1.25; }
.prose h1 { font-size: 30px; } .prose h2 { font-size: 24px; } .prose h3 { font-size: 19px; }
.prose p, .prose ul, .prose ol, .prose pre, .prose blockquote, .prose table { margin: 0 0 1em; }
.prose ul, .prose ol { padding-inline-start: 1.4em; list-style: revert; }
.prose li + li { margin-top: .25em; }
.prose a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.prose code { font-family: var(--font-mono); font-size: .88em; background: var(--chip-bg); padding: 1px 5px; border-radius: var(--r-tag); }
.prose pre { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--r-panel); padding: 14px 16px; overflow: auto; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { padding: 8px 16px; border-inline-start: 4px solid var(--teal-light); background: var(--bg-alt); border-radius: 0 var(--r-md) var(--r-md) 0; color: var(--text-2); }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 12px; text-align: start; }
.prose th { background: var(--bg); font-weight: 500; }
.prose img { max-width: 100%; border-radius: var(--r-panel); }
.prose hr { border: 0; border-top: 2px dashed var(--border-strong); margin: 2em 0; }
.prose input[type=checkbox] { margin-inline-end: 6px; accent-color: var(--teal); }
.md-toolbar .btn { padding: 0 10px; }

/* Microphone button (speech to text) */
.mic {
  width: 88px; height: 88px; display: grid; place-items: center; border-radius: var(--r-round);
  border: 3px solid var(--ink); background: linear-gradient(180deg, var(--teal-light), var(--teal)); color: #fff;
  box-shadow: var(--shadow-teal-glow);
  transition: background-color var(--ease), color var(--ease), transform var(--ease-bounce), box-shadow var(--ease);
}
.mic:hover { transform: translateY(-2px) scale(1.04); }
.mic:active { transform: scale(.95); }
/* Recording uses the BOOM state: coral fill + pulse */
.mic.is-on { background: linear-gradient(180deg, var(--coral-light), var(--coral)); border-color: var(--coral-dark); color: #fff; animation: boom-pulse 2s ease-in-out infinite; }
.mic:disabled { opacity: .5; pointer-events: none; }

/* Changed words (paraphraser) and their popover */
.chg {
  color: var(--link); cursor: pointer; border-radius: 2px;
  text-decoration: underline dotted; text-underline-offset: 4px; text-decoration-thickness: 1.5px;
  transition: background-color var(--ease);
}
.chg { text-decoration-color: var(--gold-dark); }
.chg:hover, .chg:focus-visible { background: rgba(255, 210, 63, .3); outline: none; box-shadow: none; }
.popover {
  position: absolute; z-index: 150; min-width: 160px; max-width: 280px; padding: 4px;
  background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  display: grid;
}
.popover button {
  display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: var(--r-control);
  font-size: 14px; text-align: start; color: var(--text);
}
.popover button:hover, .popover button:focus-visible { background: var(--bg-alt); outline: none; box-shadow: none; }
.popover button[aria-current="true"] { font-weight: 800; color: var(--link); background: var(--bg-alt); }

/* ============ ABOUT / GUIDE ============ */
.about-tool { background: var(--bg-alt); border-block: 2px dashed var(--border-strong); }
.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: start; }
.about-body {
  padding: 36px 40px; background: var(--surface); border-radius: var(--r-lg);
  border-inline-start: 4px solid var(--teal-light); box-shadow: var(--shadow-card);
  font-size: 16px; line-height: 1.75; color: var(--text-2);
}
.about-body > .h-section { margin-bottom: 8px; color: var(--text); }
.about-body h3 {
  margin: 32px 0 12px; padding-bottom: 8px; font-size: 20px; line-height: 1.25; color: var(--text);
  border-bottom: 2px dashed var(--border-strong);
}
.about-body p { margin: 0 0 1em; }
.about-body p.intro { font-size: 18px; color: var(--text); }
.about-body strong { color: var(--text); font-weight: 800; }
.about-body code { font-family: var(--font-mono); font-size: .88em; background: var(--chip-bg); color: var(--chip-text); padding: 1px 6px; border-radius: var(--r-sm); }
.about-body ul { display: grid; gap: 10px; margin: 0 0 1em; }
.about-body ul li { position: relative; padding-inline-start: 32px; }
.about-body ul li::before {
  content: "✓"; position: absolute; inset-inline-start: 0; top: 3px; width: 22px; height: 22px;
  display: grid; place-items: center; border-radius: var(--r-sm);
  background: var(--teal-bg); color: var(--teal-dark); font-size: 13px; font-weight: 800; line-height: 1;
}
.about-body ul.tips li::before { content: "★"; background: var(--cream); color: var(--gold-dark); border: 1px solid var(--gold); }
.about-body .callout {
  margin: 24px 0 0; padding: 16px 20px; border-radius: var(--r-md);
  background: var(--cream); border-inline-start: 4px solid var(--gold); color: var(--ink); font-size: 15px;
}
.about-body .callout strong { color: var(--ink); }
:root[data-theme="dark"] .about-body ul li::before { background: rgba(60, 196, 189, .15); color: var(--teal-light); }
:root[data-theme="dark"] .about-body ul.tips li::before { background: rgba(255, 210, 63, .12); color: var(--gold); }

.glance {
  position: sticky; top: 96px; padding: 24px; background: var(--surface);
  border-radius: var(--r-lg); border-inline-start: 4px solid var(--gold); box-shadow: var(--shadow-card);
}
.glance-title { font-size: 18px; margin-bottom: 12px; }
.glance dl { display: grid; margin-bottom: 20px; }
.glance dl > div { padding: 10px 0; border-bottom: 2px dashed var(--border); }
.glance dl > div:last-child { border-bottom: 0; }
.glance-guide {
  margin-top: 12px; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  border-radius: var(--r-md); background: var(--cream); border: 2px dashed var(--gold);
  color: var(--ink); font-size: 14px; font-weight: 800; line-height: 1.35;
  transition: transform var(--ease-bounce), border-color var(--ease);
}
.glance-guide:hover { transform: translateY(-2px); border-style: solid; }
.glance-guide small { display: block; margin-bottom: 2px; font-size: var(--fs-caption); letter-spacing: .06em; text-transform: uppercase; color: #7A5C00; }
.glance dt { font-size: var(--fs-caption); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--neutral); }
.glance dd { margin: 2px 0 0; font-size: 15px; font-weight: 700; color: var(--text); }

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .ws-side { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; gap: 24px; }
  .glance { position: static; order: -1; }
}
@media (max-width: 820px) {
  .ws-2 { grid-template-columns: 1fr; }
  .tool-title h1 { font-size: 32px; }
}
@media (max-width: 640px) {
  .tool-hero { padding: 24px 0 16px; }
  .tool-title { gap: 12px; }
  .tool-title-icon { width: 46px; height: 46px; }
  .tool-title h1 { font-size: 26px; }
  .panel-body { padding: 16px; }
  .dropzone { min-height: 220px; }
  .kv { grid-template-columns: 1fr; gap: 4px 0; }
  .bar-row { grid-template-columns: 90px 1fr 44px; }
  .workspace-section { padding-bottom: 32px; }
  .about-body { padding: 24px 20px; font-size: 15px; }
  .about-body p.intro { font-size: 16px; }
}
