/* ============================================================
   TOOLWAY - tool shell
   Built on the saacho.css tokens. Editorial rules apply: flat
   surfaces, hairline rules, --radius-sm chips, --radius-md
   controls, no gradients as decoration, no glass, no glow.
   Buttons/cards/labels reuse the shared classes and are not
   redefined here.
   ============================================================ */

.tw-wrap { max-width: 940px; margin: 0 auto; }
.tw-narrow { max-width: 720px; margin: 0 auto; }

/* ── Page head ─────────────────────────────────────────────── */
.tw-head { padding: 2.25rem 0 1.25rem; border-bottom: var(--hairline); }
.tw-head h1 {
  font-family: var(--saacho-serif);
  font-size: 1.9rem; font-weight: 700; line-height: 1.2;
  margin: 0 0 .35rem;
}
.tw-head .tw-ne {
  display: block; font-size: 1.05rem; font-weight: 600;
  color: var(--ink-dim); margin-bottom: .5rem;
}
.tw-head p.lede { color: var(--ink-dim); margin: 0 0 .9rem; max-width: 62ch; line-height: 1.6; }

/* ── Meta row ──────────────────────────────────────────────── */
.tw-meta { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.tw-meta .tag { background: var(--brand-light); color: var(--brand-dark); }
.tw-meta .tag.privacy { background: var(--success-soft); color: var(--success); }
.tw-meta .tag.engine  { background: var(--accent-soft); color: var(--accent); }

/* ── Hub grid ──────────────────────────────────────────────── */
.tw-cat { margin: 2rem 0 0; }
.tw-cat > h2 {
  font-family: var(--saacho-serif); font-size: 1.15rem; font-weight: 700;
  margin: 0 0 .2rem; padding-bottom: .45rem; border-bottom: var(--hairline);
  display: flex; align-items: baseline; gap: .5rem;
}
.tw-cat > h2 .ne { font-size: .85rem; font-weight: 500; color: var(--ink-dim); }
.tw-grid {
  display: grid; gap: .85rem; margin-top: .9rem;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.tw-card { display: block; color: inherit; }
.tw-card:hover { text-decoration: none; border-color: var(--brand); }
.tw-card h3 { font-size: .95rem; font-weight: 700; margin: 0 0 .3rem; line-height: 1.35; }
.tw-card .ne { display: block; font-size: .82rem; color: var(--ink-dim); margin-bottom: .35rem; }
.tw-card p { font-size: .82rem; line-height: 1.55; color: var(--ink-dim); margin: 0; }

/* ── Dropzone ──────────────────────────────────────────────── */
.tw-drop {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  padding: 2.25rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tw-drop:hover, .tw-drop.over { border-color: var(--brand); background: var(--brand-light); }
.tw-drop.over { border-style: solid; }
.tw-drop svg { color: var(--brand); margin-bottom: .6rem; }
.tw-drop strong { display: block; font-size: .95rem; margin-bottom: .25rem; }
.tw-drop span { font-size: .82rem; color: var(--ink-dim); }
.tw-drop .ne { display: block; font-size: .78rem; color: var(--ink-dim); margin-top: .3rem; }

/* ── File list ─────────────────────────────────────────────── */
.tw-files { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.tw-file {
  display: flex; align-items: center; gap: .75rem;
  border: var(--hairline); border-radius: var(--radius-md);
  background: var(--card-bg); padding: .6rem .8rem;
}
.tw-file .thumb {
  width: 46px; height: 46px; flex: 0 0 46px;
  border: var(--hairline); border-radius: var(--radius-sm);
  object-fit: cover; background: var(--bg);
}
.tw-file .info { flex: 1; min-width: 0; }
.tw-file .name {
  font-size: .85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tw-file .sub { font-size: .75rem; color: var(--ink-dim); }
.tw-file .delta { font-size: .78rem; font-weight: 700; white-space: nowrap; }
.tw-file .delta.good { color: var(--success); }
.tw-file .delta.warn { color: var(--warning); }
.tw-file .rm {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--ink-dim); cursor: pointer; font-size: 1rem; line-height: 1;
  padding: .3rem .45rem;
}
.tw-file .rm:hover { border-color: var(--danger); color: var(--danger); }
.tw-file .grip { cursor: grab; color: var(--ink-dim); font-size: 1.1rem; user-select: none; }
.tw-file.dragging { opacity: .5; }
.tw-file.over-top { box-shadow: inset 0 2px 0 var(--brand); }

/* ── Controls ──────────────────────────────────────────────── */
.tw-field { margin: 1.1rem 0 0; }
.tw-field > label,
.tw-label {
  display: block; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-dim); margin-bottom: .35rem;
}
.tw-field input[type="text"], .tw-field input[type="number"], .tw-field select {
  width: 100%; max-width: 260px;
}
.tw-field .hint { font-size: .76rem; color: var(--ink-dim); margin-top: .3rem; line-height: 1.5; }
.tw-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }

/* Preset chips: --radius-sm, hairline, flat. Selected state is a solid
   brand fill, not a glow. */
.tw-presets { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .15rem; }
.tw-preset {
  border: 1px solid var(--border); background: var(--card-bg);
  border-radius: var(--radius-sm); padding: .45rem .7rem;
  cursor: pointer; text-align: left; line-height: 1.3;
}
.tw-preset:hover { border-color: var(--brand); }
.tw-preset.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tw-preset b { display: block; font-size: .82rem; font-weight: 700; }
.tw-preset span { display: block; font-size: .68rem; opacity: .78; }
.tw-preset.on span { opacity: .92; }

/* ── Actions ───────────────────────────────────────────────── */
.tw-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 1.35rem 0 0; }
.tw-actions .grow { flex: 1; }

/* ── Progress / status ─────────────────────────────────────── */
.tw-status { margin: 1.1rem 0 0; font-size: .85rem; color: var(--ink-dim); min-height: 1.3em; }
.tw-bar { height: 4px; background: var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-top: .5rem; }
.tw-bar > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

/* ── Result ────────────────────────────────────────────────── */
.tw-result { margin-top: 1.5rem; border-top: var(--hairline); padding-top: 1.25rem; }
.tw-result h2 { font-size: 1rem; font-weight: 700; margin: 0 0 .7rem; }

/* ── Notices ───────────────────────────────────────────────── */
.tw-note {
  border: var(--hairline); border-left: 3px solid var(--info);
  border-radius: var(--radius-sm); background: var(--info-soft);
  padding: .7rem .9rem; font-size: .8rem; line-height: 1.6; margin: 1.1rem 0 0;
}
.tw-note.warn { border-left-color: var(--warning); background: var(--warning-soft); }
.tw-note.err  { border-left-color: var(--danger);  background: var(--danger-soft); color: var(--danger); }
.tw-note code { font-size: .95em; background: rgba(0,0,0,.05); padding: .05rem .25rem; border-radius: 2px; }

/* ── Text tools ────────────────────────────────────────────── */
.tw-io { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .tw-io.two { grid-template-columns: 1fr 1fr; } }
.tw-io textarea {
  width: 100%; min-height: 220px; font-size: .9rem; line-height: 1.65;
  font-family: var(--pico-font-family-monospace);
}
.tw-io .out {
  min-height: 220px; padding: .8rem; font-size: .95rem; line-height: 1.8;
  border: var(--hairline); border-radius: var(--radius-sm);
  background: var(--bg); white-space: pre-wrap; word-break: break-word;
}
.tw-io .out:empty::before { content: attr(data-placeholder); color: var(--ink-dim); }

/* ── Status + file-row deltas ───────────────────────────────── */
.tw-status.tw-ok   { color: var(--success); font-weight: 600; }
.tw-status.tw-err  { color: var(--danger);  font-weight: 600; }
.tw-status.tw-warn { color: var(--warning); font-weight: 600; }
.tw-file .delta {
  font-size: .74rem; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: .15rem .4rem; border-radius: var(--radius-sm); white-space: nowrap;
}
.tw-file .delta.good { color: var(--success); background: var(--success-soft); }
.tw-file .delta.warn { color: var(--warning); background: var(--warning-soft); }
.tw-row.grow { flex: 1 1 100%; }

/* ── Cropper host ──────────────────────────────────────────── */
.tw-crop-box { max-width: 100%; height: 380px; margin: 1rem 0 0; background: var(--bg); }
.tw-previews { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1rem; }
.tw-previews figure { margin: 0; }
.tw-previews img { border: var(--hairline); border-radius: var(--radius-sm); background: var(--card-bg); }
.tw-previews figcaption { font-size: .72rem; color: var(--ink-dim); margin-top: .3rem; }

/* ── Footer note ───────────────────────────────────────────── */
.tw-foot { margin: 2.5rem 0 0; padding-top: 1.1rem; border-top: var(--hairline); font-size: .8rem; color: var(--ink-dim); line-height: 1.65; }
.tw-foot a { color: var(--brand); }

/* ── AdSense slots ───────────────────────────────────────────── */
.tw-ad-slot,
.story-ad-slot,
.cv-ad-slot,
.mh-ad-slot {
  text-align: center;
  min-height: 90px; /* Reserve space to prevent layout shift */
}

.tw-ad-slot ins,
.story-ad-slot ins,
.cv-ad-slot ins,
.mh-ad-slot ins {
  display: block;
  min-height: 90px;
}

@media (min-width: 768px) {
  .tw-ad-slot ins,
  .story-ad-slot ins,
  .cv-ad-slot ins,
  .mh-ad-slot ins {
    min-height: 200px;
  }
}

/* Dark theme: tokens are redefined by the layout's theme_toggle block, so
   only the few hardcoded surfaces need a nudge. */
html.theme-dark .tw-drop { background: var(--card-bg); }
html.theme-dark .tw-io textarea { background: var(--bg); color: var(--ink); }
html.theme-dark .tw-io .out { background: var(--bg); color: var(--ink); }
html.theme-dark .tw-note code { background: rgba(255,255,255,.08); }

@media (prefers-reduced-motion: reduce) {
  .tw-bar > i { transition: none; }
  .tw-drop, .tw-card, .btn-brand, .btn-outline { transition: none; }
}
