/* ===========================================================================
   local.  —  shared design system
   ---------------------------------------------------------------------------
   A small token set drives everything. NO BORDERS anywhere: surfaces are
   separated by LAYERED SHADES (bg -> surface -> surface-elevated), SOFT
   SHADOWS for elevation, and faint GRADIENTS. Edit the tokens below to
   re-theme the whole suite (both hub.html and tool-template.html).
   =========================================================================== */

:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 24px;
  --maxw: 1120px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---- Dark theme (default) ------------------------------------------------ */
html[data-theme="dark"] {
  --bg:               oklch(0.165 0.008 274);
  --surface:          oklch(0.205 0.010 274);
  --surface-elevated: oklch(0.238 0.012 274);
  --surface-sunken:   oklch(0.180 0.009 274);

  --text:        oklch(0.965 0.005 274);
  --text-muted:  oklch(0.685 0.012 274);
  --text-faint:  oklch(0.545 0.012 274);

  --accent:           oklch(0.74 0.135 274);
  --accent-strong:    oklch(0.80 0.140 274);
  --accent-grad-from: oklch(0.76 0.140 292);
  --accent-grad-to:   oklch(0.70 0.150 260);
  --accent-soft:      oklch(0.74 0.135 274 / 0.16);
  --accent-tint:      oklch(0.74 0.135 274 / 0.08);
  --on-accent:        oklch(0.16 0.01 274);

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.34);
  --shadow-md: 0 8px 22px oklch(0 0 0 / 0.42), 0 2px 6px oklch(0 0 0 / 0.30);
  --shadow-lg: 0 22px 50px oklch(0 0 0 / 0.50), 0 6px 16px oklch(0 0 0 / 0.36);
  --edge: inset 0 1px 0 oklch(1 0 0 / 0.05);

  /* All gradients share one light direction (overhead: lighter at top). */
  --bg-top: oklch(0.198 0.010 274);
  --grad-bg: linear-gradient(180deg, var(--bg-top), oklch(0.150 0.008 274));
  --grad-hero: radial-gradient(125% 80% at 50% -25%, oklch(0.74 0.135 274 / 0.20), transparent 60%);
  --grad-card: linear-gradient(180deg, oklch(1 0 0 / 0.045), transparent 58%);
  --grad-accent: linear-gradient(180deg, var(--accent-grad-from), var(--accent-grad-to));
  --dot-up: oklch(0.80 0.16 150);
}

/* ---- Light theme --------------------------------------------------------- */
html[data-theme="light"] {
  --bg:               oklch(0.965 0.005 274);
  --surface:          oklch(0.988 0.004 274);
  --surface-elevated: oklch(1 0 0);
  --surface-sunken:   oklch(0.945 0.006 274);

  --text:        oklch(0.255 0.018 274);
  --text-muted:  oklch(0.505 0.018 274);
  --text-faint:  oklch(0.625 0.016 274);

  --accent:           oklch(0.555 0.165 274);
  --accent-strong:    oklch(0.500 0.175 274);
  --accent-grad-from: oklch(0.585 0.165 292);
  --accent-grad-to:   oklch(0.515 0.180 260);
  --accent-soft:      oklch(0.555 0.165 274 / 0.12);
  --accent-tint:      oklch(0.555 0.165 274 / 0.07);
  --on-accent:        oklch(0.99 0 0);

  --shadow-sm: 0 1px 2px oklch(0.45 0.03 274 / 0.10);
  --shadow-md: 0 10px 26px oklch(0.45 0.03 274 / 0.11), 0 2px 6px oklch(0.45 0.03 274 / 0.08);
  --shadow-lg: 0 24px 50px oklch(0.45 0.03 274 / 0.15), 0 6px 16px oklch(0.45 0.03 274 / 0.10);
  --edge: inset 0 1px 0 oklch(1 0 0 / 0.9);

  --bg-top: oklch(0.992 0.003 274);
  --grad-bg: linear-gradient(180deg, var(--bg-top), oklch(0.948 0.006 274));
  --grad-hero: radial-gradient(125% 80% at 50% -25%, oklch(0.555 0.165 274 / 0.13), transparent 60%);
  --grad-card: linear-gradient(180deg, oklch(1 0 0 / 0.65), transparent 60%);
  --grad-accent: linear-gradient(180deg, var(--accent-grad-from), var(--accent-grad-to));
  --dot-up: oklch(0.62 0.17 150);
}

/* Suppress transitions while the theme flips — transitioning an oklch value
   that comes from a custom property can otherwise freeze at the old color. */
html.theme-switching, html.theme-switching * { transition: none !important; }

/* ---- Base ---------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--grad-bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}

a { color: inherit; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);
  border-radius: var(--radius-sm);
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.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;
}

/* ---- Top bar ------------------------------------------------------------- */
/* Opaque and painted with the SAME viewport-fixed gradient as <body>, so the
   bar is pixel-identical to the page beside/below it — no seam at any scroll,
   in either theme. Content simply hides behind it as you scroll. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background-color: var(--bg);
  background-image: var(--grad-bg);
  background-attachment: fixed;
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 16px 24px;
  display: flex; align-items: center; gap: 16px;
}

.brand {
  display: inline-flex; align-items: baseline; gap: 1px;
  font-weight: 650; font-size: 18px; letter-spacing: -0.02em;
  text-decoration: none; color: var(--text); white-space: nowrap;
}
.brand .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--grad-accent);
  align-self: flex-end; margin-bottom: 4px; margin-left: 1px;
  box-shadow: 0 0 0 4px var(--accent-tint);
}
.brand .back { color: var(--text-muted); margin-right: 8px; transition: color .2s; }
.brand:hover .back { color: var(--accent); }

.topbar .spacer { flex: 1; }

.toolname {
  font-weight: 600; font-size: 15px; color: var(--text-muted);
  letter-spacing: -0.01em; white-space: nowrap;
}

.theme-toggle {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border: 0; border-radius: var(--radius-sm);
  background: var(--surface-elevated); color: var(--text-muted);
  box-shadow: var(--shadow-sm), var(--edge); cursor: pointer;
  transition: color .2s, transform .2s var(--ease), box-shadow .2s var(--ease),
              background-color .3s var(--ease);
}
.theme-toggle:hover { color: var(--text); transform: translateY(-1px); box-shadow: var(--shadow-md), var(--edge); }
.theme-toggle:active { transform: translateY(0); }
.theme-toggle svg { width: 19px; height: 19px; }
html[data-theme="dark"] .theme-toggle .i-sun  { display: none; }
html[data-theme="light"] .theme-toggle .i-moon { display: none; }

/* ---- Hero ---------------------------------------------------------------- */
.hero { position: relative; padding: 76px 0 44px; text-align: center; }
.hero::before {
  content: ""; position: absolute; inset: -120px 0 0; z-index: -1;
  background: var(--grad-hero); pointer-events: none;
}
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 550; color: var(--accent);
  background: var(--accent-tint); padding: 6px 13px; border-radius: 999px;
  box-shadow: var(--edge); margin-bottom: 22px;
}
.hero .eyebrow .pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--dot-up);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--dot-up) 24%, transparent);
}
.hero h1 {
  margin: 0 auto; max-width: 16ch;
  font-size: clamp(34px, 6vw, 58px); font-weight: 680;
  letter-spacing: -0.035em; line-height: 1.04; text-wrap: balance;
}
.hero p {
  margin: 20px auto 0; max-width: 56ch;
  font-size: clamp(15px, 1.7vw, 18px); color: var(--text-muted);
  text-wrap: pretty;
}

/* ---- Search -------------------------------------------------------------- */
.searchbar { max-width: 480px; margin: 32px auto 0; position: relative; display: flex; align-items: center; }
.searchbar svg { position: absolute; left: 17px; width: 18px; height: 18px; color: var(--text-faint); pointer-events: none; }
.searchbar input {
  width: 100%; font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface-elevated); border: 0; border-radius: 999px;
  padding: 14px 18px 14px 46px; box-shadow: var(--shadow-md), var(--edge);
  outline: none; transition: box-shadow .2s var(--ease), background-color .3s var(--ease);
}
.searchbar input::placeholder { color: var(--text-faint); }
.searchbar input:focus { box-shadow: var(--shadow-md), var(--edge), 0 0 0 3px var(--accent-soft); }

/* ---- Section headings ---------------------------------------------------- */
.section { margin-top: 52px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 0 6px 18px; }
.section-head h2 {
  margin: 0; font-size: 13px; font-weight: 650; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
}
.section-head .count { font-size: 13px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---- Card grid ----------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }

.card {
  position: relative; display: flex; flex-direction: column; gap: 12px;
  padding: 22px; min-height: 158px; border-radius: var(--radius);
  background: var(--grad-card), var(--surface-elevated);
  box-shadow: var(--shadow-sm), var(--edge);
  text-decoration: none; color: inherit;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg), var(--edge); }
.card:focus-visible { transform: translateY(-4px); }

.glyph {
  display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 13px; color: var(--accent);
  background: var(--accent-tint); box-shadow: var(--edge);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.glyph svg { width: 23px; height: 23px; }
.card:hover .glyph { background: var(--grad-accent); color: var(--on-accent); }

.card .card-name { font-size: 17px; font-weight: 620; letter-spacing: -0.015em; }
.card .card-desc { font-size: 14px; color: var(--text-muted); line-height: 1.45; text-wrap: pretty; }
.card .card-url {
  margin-top: auto; padding-top: 4px; font-family: var(--mono); font-size: 12px;
  color: var(--text-faint); display: inline-flex; align-items: center; gap: 6px;
  transition: color .2s var(--ease);
}
.card .card-url .arrow { opacity: 0; transform: translateX(-3px); transition: opacity .2s var(--ease), transform .2s var(--ease); }
.card:hover .card-url { color: var(--accent); }
.card:hover .card-url .arrow { opacity: 1; transform: translateX(0); }

/* "local only" badge for GPL/AGPL tools (shown only in MODE="local") */
.card .local-badge {
  position: absolute; top: 14px; right: 14px;
  font-family: var(--mono); font-size: 10px; line-height: 1;
  letter-spacing: 0.02em; text-transform: uppercase;
  padding: 4px 7px; border-radius: 6px;
  color: var(--text-faint); background: var(--surface-2, rgba(127,127,127,.12));
  border: 1px solid var(--edge); opacity: .8;
}

/* ---- Empty state --------------------------------------------------------- */
.empty { display: none; text-align: center; padding: 72px 20px; color: var(--text-muted); font-size: 15px; }
.empty.show { display: block; }
.empty code {
  font-family: var(--mono); color: var(--text); background: var(--surface-elevated);
  border-radius: 6px; padding: 2px 7px; box-shadow: var(--edge);
}

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 580; letter-spacing: -0.01em;
  padding: 12px 20px; border: 0; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
              background-color .2s var(--ease), color .2s var(--ease), opacity .2s;
}
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--grad-accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.btn-primary:not(:disabled):hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-primary:not(:disabled):active { transform: translateY(0); }

.btn-ghost { background: var(--surface-elevated); color: var(--text); box-shadow: var(--shadow-sm), var(--edge); }
.btn-ghost:not(:disabled):hover { transform: translateY(-2px); box-shadow: var(--shadow-md), var(--edge); }

/* ---- Panel (elevated content area) --------------------------------------- */
.panel {
  background: var(--grad-card), var(--surface-elevated);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md), var(--edge);
  padding: 28px;
}
.panel-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.panel-head .glyph { width: 46px; height: 46px; }
.panel-head h2 { margin: 0; font-size: 20px; font-weight: 640; letter-spacing: -0.02em; }
.panel-head p { margin: 3px 0 0; font-size: 14px; color: var(--text-muted); }

.slot-note {
  font-size: 12.5px; color: var(--text-faint); font-family: var(--mono);
  background: var(--surface-sunken); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 20px; box-shadow: var(--edge);
}
.slot-note b { color: var(--text-muted); font-weight: 600; }

/* ---- Drop-zone ----------------------------------------------------------- */
.dropzone {
  position: relative; width: 100%; display: grid; place-items: center; text-align: center;
  padding: 48px 24px; border: 0; border-radius: var(--radius); cursor: pointer;
  font: inherit; color: var(--text); -webkit-appearance: none; appearance: none;
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--surface-sunken) 16%, var(--surface-elevated)),
    color-mix(in oklab, var(--surface-sunken) 72%, var(--surface-elevated)));
  transition: background .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.dropzone:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.dropzone:hover {
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--accent) 6%, var(--surface-elevated)),
    color-mix(in oklab, var(--accent) 12%, var(--surface-elevated)));
}
.dropzone.drag {
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--accent) 11%, var(--surface-elevated)),
    color-mix(in oklab, var(--accent) 18%, var(--surface-elevated)));
  transform: scale(1.004);
}
.dropzone .dz-glyph { width: 52px; height: 52px; color: var(--accent); margin-bottom: 14px; }
.dropzone .dz-glyph svg { width: 52px; height: 52px; }
.dropzone .dz-title { font-size: 16px; font-weight: 580; }
.dropzone .dz-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 4px; }
.dropzone .dz-pick { color: var(--accent); font-weight: 600; }

/* ---- Fields -------------------------------------------------------------- */
.options { display: flex; flex-wrap: wrap; gap: 18px 26px; margin: 22px 2px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label { font-size: 13px; font-weight: 560; color: var(--text-muted); }
.field .val { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; }

.select, .field input[type="number"] {
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-sunken); border: 0; border-radius: var(--radius-sm);
  padding: 10px 14px; box-shadow: var(--edge); outline: none; cursor: pointer;
  transition: box-shadow .2s var(--ease), background-color .3s var(--ease);
}
.select:focus, .field input[type="number"]:focus { box-shadow: var(--edge), 0 0 0 3px var(--accent-soft); }
.field input[type="number"] { width: 110px; cursor: text; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 200px; height: 6px;
  background: var(--surface-sunken); border-radius: 999px; box-shadow: var(--edge);
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--grad-accent); box-shadow: var(--shadow-sm); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border: 0; border-radius: 50%;
  background: var(--accent); box-shadow: var(--shadow-sm); cursor: grab;
}
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--shadow-sm), 0 0 0 4px var(--accent-soft); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 6px; }
.actions .hint { font-size: 13px; color: var(--text-faint); }

/* ---- Results ------------------------------------------------------------- */
.results { margin-top: 26px; display: flex; flex-direction: column; gap: 12px; }
.results-empty {
  text-align: center; padding: 30px 20px; color: var(--text-faint); font-size: 14px;
}
.result {
  display: flex; align-items: center; gap: 16px; padding: 14px 16px;
  border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-sm), var(--edge);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.result:hover { transform: translateY(-2px); box-shadow: var(--shadow-md), var(--edge); }
.result .thumb {
  flex: none; width: 52px; height: 52px; border-radius: 11px; object-fit: cover;
  background: var(--surface-sunken); box-shadow: var(--edge);
}
.result .meta { flex: 1; min-width: 0; }
.result .meta .r-name { font-size: 14px; font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .meta .r-sizes { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.result .meta .r-sizes .arrow { color: var(--text-faint); margin: 0 6px; }
.result .save {
  flex: none; font-size: 13px; font-weight: 650; color: var(--dot-up);
  background: color-mix(in oklab, var(--dot-up) 14%, transparent);
  padding: 5px 10px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.result .dl { flex: none; }
.result .dl .btn { padding: 9px 14px; font-size: 13.5px; }

/* ---- Footer -------------------------------------------------------------- */
.footer { margin-top: 80px; padding: 40px 0 56px; }
.footer-inner {
  background: var(--grad-card), var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm), var(--edge);
  padding: 34px 32px; text-align: center;
}
.footer .privacy { font-size: 15px; font-weight: 560; color: var(--text); max-width: 52ch; margin: 0 auto; text-wrap: balance; }
.footer .trust { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }
.footer .badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 550; color: var(--text-muted);
  background: var(--surface-elevated); padding: 8px 14px; border-radius: 999px;
  box-shadow: var(--shadow-sm), var(--edge);
}
.footer .badge svg { width: 15px; height: 15px; color: var(--accent); }
.footer .colophon { margin-top: 24px; font-size: 13px; color: var(--text-faint); }

@media (max-width: 600px) {
  .wrap, .topbar-inner { padding-left: 18px; padding-right: 18px; }
  .hero { padding: 52px 0 32px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .panel { padding: 20px; }
  .toolname { display: none; }
  .options { gap: 16px; }
  input[type="range"] { width: 100%; }
}

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