/* TextKit — "editor / typewriter": warm sepia + terracotta accent, editorial type,
   large monospace counter numbers. Light default; dark via prefers-color-scheme. RTL aware. */

:root {
  /* light (warm paper) */
  --bg: #f7f2e9;
  --bg-2: #efe7d6;
  --panel: #fffcf5;
  --panel-2: #f4ecdc;
  --line: #e0d4bd;
  --line-strong: #c8b896;
  --ink: #2b211a;
  --ink-soft: #6a5a48;
  --ink-faint: #9a8a72;
  --accent: #c0532e;          /* terracotta */
  --accent-deep: #9c3f20;
  --accent-soft: rgba(192, 83, 46, 0.12);
  --accent-glow: rgba(192, 83, 46, 0.24);
  --gold: #b08533;
  --err: #b23b2a;
  --ok: #4a7c4a;
  --radius: 14px;
  --radius-sm: 10px;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Source Serif 4", "Iowan Old Style", "Apple SD Gothic Neo", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
}
/* ===== 3-way theme (Light/Dark/System) — base :root above = native LIGHT. Opposite (dark) WCAG-aware auto-generated (contrast-solving ink/accent vs worst-case surface). ===== */
:root[data-theme="dark"]{
  --bg: #1e1b15;
  --bg-2: #090806;
  --panel: #363227;
  --panel-2: #0f0e0b;
  --line: rgba(255,255,255,0.12);
  --line-strong: rgba(255,255,255,0.12);
  --ink: #d1bfb2;
  --ink-soft: #ac9a85;
  --ink-faint: #8d7d65;
  --accent: #d26945;
  --accent-deep: #d8653f;
  --accent-soft: #d26945;
  --accent-glow: rgba(0,0,0,0.40);
  --gold: #aa8031;
  --err: #d76454;
  --ok: #599559;
}












@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1410;
    --bg-2: #211a14;
    --panel: #2a211a;
    --panel-2: #322619;
    --line: #3d3225;
    --line-strong: #524432;
    --ink: #f0e6d2;
    --ink-soft: #b8a98f;
    --ink-faint: #8a7a62;
    --accent: #e07a4f;          /* lighter terracotta for dark */
    --accent-deep: #f59669;
    --accent-soft: rgba(224, 122, 79, 0.16);
    --accent-glow: rgba(224, 122, 79, 0.32);
    --gold: #d4a55a;
    --err: #e5705f;
    --ok: #7eb87e;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background:
    radial-gradient(900px 520px at 88% -8%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 460px at -4% 108%, var(--accent-soft), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
b, h1, h2, h3 { font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }

/* i18n switcher theming */
.i18n-switch {
  --i18n-switch-bg: var(--panel-2);
  --i18n-switch-border: var(--line);
  --i18n-switch-fg: var(--ink);
  --i18n-switch-active-bg: var(--accent-soft);
  --i18n-switch-active-fg: var(--accent);
  --i18n-switch-menu-bg: var(--panel);
  --i18n-switch-menu-border: var(--line);
}

/* ── topbar ─────────────────────────────────────────────── */
.topbar {
  max-width: 920px;
  margin: 0 auto;
  padding: 22px clamp(16px, 5vw, 32px) 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  color: #fff8ec;
  font-family: var(--serif);
  font-weight: 700;
  font-style: italic;
  font-size: 24px;
  box-shadow: 0 8px 22px -10px var(--accent-glow);
  letter-spacing: -.04em;
}
.brand h1 {
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: -.01em;
  line-height: 1.1;
}
.brand p { font-size: 12.5px; color: var(--ink-soft); }
.brand .accent { color: var(--accent); font-style: italic; }

.offline-badge {
  display: none; /* shown on >= 760px */
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: .02em;
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.offline-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ── search + chips ─────────────────────────────────────── */
.head {
  max-width: 920px;
  margin: 0 auto;
  padding: 6px clamp(16px, 5vw, 32px) 0;
}
.searchbar {
  position: relative;
  margin: 8px 0 12px;
}
.searchbar input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  padding: 11px 14px 11px 38px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.searchbar input::placeholder { color: var(--ink-faint); }
.searchbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbar .ico {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); font-size: 16px; pointer-events: none;
}

.chips {
  display: flex; gap: 7px; overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: thin;
}
.chips::-webkit-scrollbar { height: 6px; }
.chips::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.chip {
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.is-active {
  background: var(--accent);
  color: #fff8ec;
  border-color: var(--accent);
  box-shadow: 0 4px 14px -6px var(--accent-glow);
}
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── workspace card ─────────────────────────────────────── */
.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 4px clamp(16px, 5vw, 32px) 40px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.tool-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.005em;
}
.hint {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: right;
  max-width: 62%;
  line-height: 1.5;
}

.card-body { padding: 18px 20px 20px; }

/* shared editor textarea */
.editor {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.6;
  padding: 14px 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor::placeholder { color: var(--ink-faint); font-style: italic; }
.editor.is-output {
  background: var(--panel-2);
  font-family: var(--serif);
}

/* row of action buttons */
.actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .12s ease;
}
.btn:hover { border-color: var(--line-strong); background: var(--panel); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8ec;
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover { color: var(--ink); background: var(--panel-2); }
.btn-mini {
  font-size: 12px;
  padding: 6px 11px;
}

/* ── COUNT tool: big mono metric grid ───────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.metric {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 14px 12px;
}
.metric .num {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.metric .lbl {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-soft);
  letter-spacing: .01em;
}
.cjk-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-faint);
  font-style: italic;
}

/* ── READTIME tool ──────────────────────────────────────── */
.rt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.rt-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.rt-card .rt-label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.rt-card .rt-big {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.02em;
  margin-top: 6px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.rt-card .rt-unit { font-size: 14px; color: var(--ink-soft); margin-left: 4px; }
.rt-card .rt-sub { font-size: 12px; color: var(--ink-faint); margin-top: 6px; font-family: var(--mono); }

.rt-controls {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin-top: 14px;
  align-items: center;
}
.rt-controls label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--ink-soft);
}
.rt-controls input[type="range"] {
  width: 160px;
  accent-color: var(--accent);
}
.rt-controls .rt-val {
  font-family: var(--mono); color: var(--accent); font-weight: 700;
}

/* ── LOREM tool ─────────────────────────────────────────── */
.lorem-controls {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
}
.lorem-controls .field { display: flex; flex-direction: column; gap: 4px; }
.lorem-controls label { font-size: 12px; color: var(--ink-soft); }
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel-2);
}
.seg button {
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: all .12s ease;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.is-on {
  background: var(--accent);
  color: #fff8ec;
}
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.num-input {
  width: 84px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  padding: 8px 10px;
  outline: none;
}
.num-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.opt-check {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.opt-check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ── CASE tool ──────────────────────────────────────────── */
.case-buttons {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 12px;
}

/* ── REPLACE tool ───────────────────────────────────────── */
.replace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.replace-grid .field { display: flex; flex-direction: column; gap: 5px; }
.replace-grid label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.txt-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.txt-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.replace-opts {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin: 4px 0 12px;
}
.replace-count {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent);
  margin-left: auto;
  align-self: center;
}

/* ── DEDUPE tool ────────────────────────────────────────── */
.dedupe-controls {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.dedupe-controls select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  cursor: pointer;
  outline: none;
}
.dedupe-controls select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dedupe-stats {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-left: auto;
}
.dedupe-stats b { color: var(--accent); }

/* ── STATS tool ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.freq-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.freq-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.freq-row .word {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.freq-row .bar-wrap { display: flex; align-items: center; gap: 8px; }
.freq-bar {
  height: 6px;
  background: var(--accent);
  border-radius: 3px;
  min-width: 4px;
}
.freq-count {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 700;
  min-width: 32px;
  text-align: right;
}

/* ── two-pane input/output layout (case/replace/reverse/trim/dedupe/lorem-out) */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.pane-label {
  font-size: 11.5px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
  font-weight: 600;
}

/* ── ad slots (money-lab pattern) ───────────────────────── */
.ad-slot { display: none; margin: 24px 0; }
.ad-slot.is-live, .ad-slot.is-preview { display: block; }
.ad-label {
  display: block;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  opacity: .8;
  margin-bottom: 5px;
  text-align: center;
}
.ad-ph {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--ink-faint);
  font-size: 12px;
  text-align: center;
}
.ad-slot.is-preview .ad-ph { display: flex; }
.ad-slot.is-preview .adsbygoogle { display: none !important; }
.ad-slot.is-live .ad-ph { display: none; }

/* ── info / FAQ ─────────────────────────────────────────── */
.info {
  margin-top: 28px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}
.info h2 {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink);
  margin: 22px 0 8px;
}
.info > h2:first-child { margin-top: 0; }
.info p { margin-bottom: 8px; }
.info b { color: var(--ink); }
.faq { margin: 4px 0 8px; }
.faq dt { color: var(--ink); font-weight: 600; margin-top: 12px; }
.faq dd { margin: 4px 0 0; }

.disclaimer {
  margin-top: 22px;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.65;
  text-align: center;
  padding: 0 8px;
}
.disclaimer b { color: var(--ink); }

/* ── footer ─────────────────────────────────────────────── */
.foot {
  max-width: 920px;
  margin: 0 auto;
  padding: 8px clamp(16px, 5vw, 32px) 80px;
  text-align: center;
}
.foot a { color: var(--ink-faint); font-size: 12px; }
.foot a:hover { color: var(--accent); }

/* ── toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-err { background: var(--err); color: #fff; }
.toast.is-ok { background: var(--ok); color: #fff; }

/* ── RTL ────────────────────────────────────────────────── */
[dir="rtl"] .searchbar input { padding: 11px 38px 11px 14px; }
[dir="rtl"] .searchbar .ico { left: auto; right: 13px; }
[dir="rtl"] .hint { text-align: left; }
[dir="rtl"] .replace-count,
[dir="rtl"] .dedupe-stats { margin-left: 0; margin-right: auto; }

/* ── responsive ─────────────────────────────────────────── */
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; padding-top: 18px; }
  .brand h1 { font-size: 19px; }
  .split { grid-template-columns: 1fr; }
  .replace-grid { grid-template-columns: 1fr; }
  .hint { display: none; }
  .tool-title { font-size: 17px; }
  .offline-badge { display: none !important; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 14px 16px 16px; }
  .metric .num { font-size: 26px; }
  .rt-card .rt-big { font-size: 28px; }
}

@media (min-width: 760px) {
  .offline-badge { display: inline-flex; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
