/* ==========================================================================
   MN Tools Hub — Premium Design System  (v3)
   Palette: teal/emerald primary + amber accent, deep-charcoal canvas.
   Supports dark (default) + light theme, glassmorphism, smooth motion.
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  --brand-50:  #eafaf5;
  --brand-100: #cdf3e6;
  --brand-200: #9ee7cf;
  --brand-300: #63d5b4;
  --brand-400: #2fbd98;
  --brand-500: #14a37f;
  --brand-600: #0b8367;
  --brand-700: #0b6853;
  --brand-800: #0b5243;
  --brand-900: #0a4437;

  --accent-400: #fbbf24;
  --accent-500: #f59e0b;
  --accent-600: #d97706;

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius:    16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --font-sans: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, "Noto Sans Bengali", "Hind Siliguri", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, SFMono-Regular, Menlo,
               Consolas, monospace;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
  --dur-fast: .16s;
  --dur: .26s;
  --dur-slow: .45s;

  --header-h: 62px;
  --shell-pad: 16px;
}

/* dark theme (default) */
:root,
html[data-theme="dark"] {
  --bg-0: #07110f;
  --bg-1: #0b1917;
  --bg-2: #102220;
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .075);
  --surface-solid: #12211f;
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .17);
  --text: #eaf6f2;
  --text-dim: #9fb5b0;
  --text-faint: #93aca7;
  --brand: var(--brand-400);
  --brand-ink: #04231c;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .32);
  --shadow: 0 12px 34px rgba(0, 0, 0, .42);
  --shadow-lg: 0 26px 70px rgba(0, 0, 0, .55);
  --glow: 0 0 0 1px rgba(47, 189, 152, .28), 0 10px 40px rgba(20, 163, 127, .26);
  --glass-blur: 18px;
  --scrim: rgba(4, 10, 9, .72);
  color-scheme: dark;
}

/* light theme */
html[data-theme="light"] {
  --bg-0: #f2f7f5;
  --bg-1: #e9f2ef;
  --bg-2: #dfece8;
  --surface: rgba(255, 255, 255, .68);
  --surface-2: rgba(255, 255, 255, .88);
  --surface-solid: #ffffff;
  --border: rgba(9, 46, 38, .12);
  --border-strong: rgba(9, 46, 38, .22);
  --text: #0a1f1a;
  --text-dim: #47615b;
  --text-faint: #5d7a75;
  --brand: var(--brand-600);
  --brand-ink: #ffffff;
  --shadow-sm: 0 2px 8px rgba(9, 46, 38, .07);
  --shadow: 0 12px 30px rgba(9, 46, 38, .11);
  --shadow-lg: 0 24px 60px rgba(9, 46, 38, .16);
  --glow: 0 0 0 1px rgba(11, 131, 103, .18), 0 10px 34px rgba(11, 131, 103, .17);
  --glass-blur: 16px;
  --scrim: rgba(240, 247, 245, .8);
  color-scheme: light;
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ambient animated background */
body::before {
  content: "";
  position: fixed;
  inset: -30%;
  z-index: -2;
  background:
    radial-gradient(58% 46% at 14% 6%, rgba(20, 163, 127, .34), transparent 62%),
    radial-gradient(52% 44% at 88% 12%, rgba(245, 158, 11, .19), transparent 64%),
    radial-gradient(64% 56% at 52% 104%, rgba(11, 104, 83, .34), transparent 66%);
  filter: blur(14px);
  animation: drift 26s var(--ease) infinite alternate;
  pointer-events: none;
}
html[data-theme="light"] body::before {
  background:
    radial-gradient(58% 46% at 14% 6%, rgba(20, 163, 127, .26), transparent 62%),
    radial-gradient(52% 44% at 88% 12%, rgba(245, 158, 11, .2), transparent 64%),
    radial-gradient(64% 56% at 52% 104%, rgba(11, 131, 103, .2), transparent 66%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 0%, transparent 78%);
  opacity: .5;
  pointer-events: none;
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(2.5%, -2%, 0) scale(1.06); }
  100% { transform: translate3d(-2%, 2.5%, 0) scale(1.02); }
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.18; letter-spacing: -.022em; font-weight: 800; }
p { margin: 0; }
::selection { background: var(--brand); color: var(--brand-ink); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--brand); background-clip: content-box; }

/* ---------------------------------------------------------------- helpers */
.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;
}
.glass {
  background: var(--surface);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--border);
}
.mono { font-family: var(--font-mono); font-size: .86em; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--shell-pad);
  background: color-mix(in srgb, var(--bg-0) 78%, transparent);
  backdrop-filter: blur(20px) saturate(170%);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  border-bottom: 1px solid var(--border);
}
.app-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
}
.brand-mark {
  width: 36px; height: 36px;
  flex: 0 0 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-700));
  box-shadow: var(--glow);
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .45) 48%, transparent 62%);
  transform: translateX(-120%);
  animation: sheen 4.5s var(--ease) infinite;
}
@keyframes sheen {
  0%, 62% { transform: translateX(-120%); }
  100%    { transform: translateX(120%); }
}
.brand-text { min-width: 0; }
.brand-text b {
  display: block;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text span {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 600;
}

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform var(--dur-fast) var(--ease-bounce),
              color var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.92); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color var(--dur-fast), background var(--dur-fast);
  max-width: 180px;
}
.user-chip:hover { border-color: var(--brand); background: var(--surface-2); }
.user-chip img,
.user-chip .avatar-fallback {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-700));
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--brand-ink);
}
.user-chip .uname {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- layout */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--shell-pad) 96px;
}

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative;
  margin-top: 18px;
  padding: 26px 22px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--brand-700) 82%, transparent), color-mix(in srgb, var(--bg-2) 88%, transparent));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  isolation: isolate;
}
html[data-theme="light"] .hero {
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--brand-600) 90%, transparent), color-mix(in srgb, var(--brand-800) 94%, transparent));
}
.hero::before {
  content: "";
  position: absolute;
  width: 320px; height: 320px;
  right: -110px; top: -150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 191, 36, .38), transparent 68%);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  width: 260px; height: 260px;
  left: -100px; bottom: -140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .18), transparent 70%);
  pointer-events: none;
}
.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #eafff8;
  margin-bottom: 12px;
}
.hero__eyebrow .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-400);
  box-shadow: 0 0 0 0 rgba(251, 191, 36, .7);
  animation: pulse-dot 2.2s infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(251, 191, 36, .65); }
  70%  { box-shadow: 0 0 0 9px rgba(251, 191, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}
.hero h1 {
  font-size: clamp(24px, 6.4vw, 40px);
  color: #ffffff;
  text-shadow: 0 3px 22px rgba(0, 0, 0, .28);
}
.hero h1 .grad {
  background: linear-gradient(96deg, var(--accent-400), #fff 62%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  margin-top: 9px;
  font-size: 13.5px;
  color: rgba(255, 255, 255, .84);
  max-width: 62ch;
}
.hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.hero__stat {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.hero__stat b {
  display: block;
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
}
.hero__stat span {
  font-size: 10.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .72);
  font-weight: 600;
}

/* ---------------------------------------------------------------- toolbar */
.toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  margin-top: 16px;
  padding: 10px 0;
  background: color-mix(in srgb, var(--bg-0) 82%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap .s-icon {
  position: absolute;
  left: 14px;
  font-size: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 42px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  font-size: 14.5px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.search-input::placeholder { color: var(--text-faint); }
.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--glow);
  background: var(--surface-2);
}
.search-clear {
  position: absolute;
  right: 8px;
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--text-faint);
  transition: color var(--dur-fast), background var(--dur-fast);
}
.search-clear:hover { color: var(--text); background: var(--surface-2); }

/* category chips */
.chips {
  display: flex;
  gap: 7px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-bounce),
              color var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip:active { transform: scale(.95); }
.chip.is-active {
  color: var(--brand-ink);
  background: linear-gradient(140deg, var(--brand-300), var(--brand-500));
  border-color: transparent;
  box-shadow: var(--glow);
}
.chip .n {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, .18);
  font-weight: 700;
}
.chip.is-active .n { background: rgba(0, 0, 0, .2); }

/* ---------------------------------------------------------------- section head */
.sec-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 22px 2px 12px;
}
.sec-head h2 { font-size: 16px; letter-spacing: -.02em; }
.sec-head .count {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-faint);
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ---------------------------------------------------------------- tool grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 10px;
  align-content: start;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px 14px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  text-align: left;
  overflow: hidden;
  transition: transform var(--dur) var(--ease),
              border-color var(--dur), background var(--dur), box-shadow var(--dur);
  animation: card-in var(--dur-slow) var(--ease) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--brand-400) 22%, transparent), transparent 62%);
  opacity: 0;
  transition: opacity var(--dur);
  pointer-events: none;
}
.card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--brand) 55%, transparent);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.card:hover::before { opacity: 1; }
.card:active { transform: translateY(-1px) scale(.99); }
.card__icon {
  width: 42px; height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: linear-gradient(140deg, color-mix(in srgb, var(--brand-400) 30%, transparent), color-mix(in srgb, var(--brand-700) 40%, transparent));
  border: 1px solid var(--border-strong);
  transition: transform var(--dur) var(--ease-bounce);
}
.card:hover .card__icon { transform: scale(1.08) rotate(-5deg); }
.card__name {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: -.015em;
  position: relative;
  z-index: 1;
}
.card__desc {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.45;
  position: relative;
  z-index: 1;
}
.card__foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
  position: relative;
  z-index: 1;
}
.tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 2.5px 8px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, transparent);
}
.card__uses { font-size: 10.5px; color: var(--text-faint); font-weight: 600; }
.card.is-disabled { opacity: .5; pointer-events: none; filter: grayscale(.5); }

/* skeleton */
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 11px; }
.sk-card {
  height: 148px;
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.5s linear infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer {
  from { background-position: 180% 0; }
  to   { background-position: -80% 0; }
}

/* empty */
.empty {
  text-align: center;
  padding: 54px 20px;
  color: var(--text-dim);
}
.empty .em { font-size: 40px; margin-bottom: 12px; }
.empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--text); }
.empty p { font-size: 13px; }

/* ---------------------------------------------------------------- tool view */
.tool-view { margin-top: 18px; animation: view-in var(--dur-slow) var(--ease) both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.tool-view__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px 0 12px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  transition: transform var(--dur-fast) var(--ease-bounce),
              color var(--dur-fast), border-color var(--dur-fast);
}
.back-btn:hover { color: var(--text); border-color: var(--border-strong); }
.back-btn:active { transform: translateX(-3px); }

.tool-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}
.tool-head__icon {
  width: 52px; height: 52px;
  flex: 0 0 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-size: 25px;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-700));
  box-shadow: var(--glow);
}
.tool-head h2 { font-size: 19px; }
.tool-head p { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

.panel {
  margin-top: 14px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}
.panel + .panel { margin-top: 12px; }

.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 7px;
}
.input, .textarea, .select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  border: 1px solid var(--border);
  font-size: 14.5px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
html[data-theme="light"] .input,
html[data-theme="light"] .textarea,
html[data-theme="light"] .select { background: #fff; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--glow);
}
.textarea { min-height: 118px; resize: vertical; line-height: 1.6; }
.select { appearance: none; padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
                    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% + 2px), calc(100% - 14px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
textarea.no-resize { resize: none; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 150px; min-width: 0; }
.row.tight > * { flex: 0 1 auto; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.01em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-bounce),
              background var(--dur-fast), border-color var(--dur-fast),
              box-shadow var(--dur-fast), opacity var(--dur-fast);
}
.btn:hover { border-color: var(--border-strong); background: var(--surface); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn--primary {
  background: linear-gradient(140deg, var(--brand-300), var(--brand-600));
  border-color: transparent;
  color: var(--brand-ink);
  box-shadow: var(--glow);
}
.btn--primary:hover { filter: brightness(1.07); }
.btn--ghost { background: transparent; }
.btn--danger {
  background: linear-gradient(140deg, #f87171, #dc2626);
  border-color: transparent;
  color: #fff;
}
.btn--block { width: 100%; }
.btn--sm { height: 36px; padding: 0 13px; font-size: 12.5px; border-radius: 10px; }

/* copy button inside result */
.copy-btn {
  position: absolute;
  top: 9px; right: 9px;
  height: 28px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}
.copy-btn:hover { color: var(--brand); border-color: var(--brand); }
.copy-btn:active { transform: scale(.93); }

/* output */
.output-wrap { position: relative; }
.output {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
  animation: view-in var(--dur) var(--ease) both;
}
html[data-theme="light"] .output { background: #fff; }
.output:empty { display: none; }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 9px; margin-top: 12px; }
.kv__i {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  border: 1px solid var(--border);
}
html[data-theme="light"] .kv__i { background: #fff; }
.kv__i b { display: block; font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.kv__i span {
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  background: color-mix(in srgb, var(--brand) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
  color: var(--brand);
}
.badge--warn {
  background: rgba(245, 158, 11, .15);
  border-color: rgba(245, 158, 11, .32);
  color: var(--accent-500);
}

/* strength meter */
.meter { height: 7px; border-radius: var(--radius-pill); background: var(--bg-2); overflow: hidden; margin-top: 10px; }
.meter i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width var(--dur-slow) var(--ease), background var(--dur);
}

/* range */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-2);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--brand-300), var(--brand-600));
  border: 2px solid var(--bg-0);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-bounce);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--bg-0);
  cursor: pointer;
}

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 44px; height: 25px;
  border-radius: var(--radius-pill);
  background: var(--bg-2);
  border: 1px solid var(--border);
  position: relative;
  transition: background var(--dur), border-color var(--dur);
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform var(--dur) var(--ease-bounce), background var(--dur);
}
.switch input:checked + .track { background: color-mix(in srgb, var(--brand) 32%, transparent); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(19px); background: var(--brand); }
.switch .lbl { font-size: 13.5px; font-weight: 600; }

/* progress */
.progress {
  height: 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-2);
  overflow: hidden;
  margin-top: 12px;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand-400), var(--accent-400));
  border-radius: inherit;
  transition: width var(--dur) var(--ease);
}
.progress.indeterminate i {
  width: 40% !important;
  animation: indet 1.15s var(--ease) infinite;
}
@keyframes indet {
  0%   { transform: translateX(-105%); }
  100% { transform: translateX(255%); }
}

/* spinner */
.spin {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor;
  animation: rot .7s linear infinite;
  display: inline-block;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* video result */
.vid {
  display: flex;
  gap: 13px;
  margin-top: 14px;
  padding: 13px;
  border-radius: var(--radius);
  background: var(--bg-1);
  border: 1px solid var(--border);
  animation: view-in var(--dur) var(--ease) both;
}
html[data-theme="light"] .vid { background: #fff; }
.vid__thumb {
  width: 128px; height: 74px;
  flex: 0 0 128px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-2);
}
.vid__meta { min-width: 0; flex: 1; }
.vid__meta h4 {
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vid__meta .sm { font-size: 11.5px; color: var(--text-dim); }

.fmt-list { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; max-height: 300px; overflow: auto; }
.fmt {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}
html[data-theme="light"] .fmt { background: #fff; }
.fmt:hover { border-color: var(--border-strong); transform: translateX(3px); }
.fmt.is-sel { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 11%, transparent); }
.fmt input { accent-color: var(--brand); width: 17px; height: 17px; flex: 0 0 17px; }
.fmt__t { flex: 1; min-width: 0; }
.fmt__t b { font-size: 13px; font-weight: 700; display: block; }
.fmt__t span { font-size: 11px; color: var(--text-faint); }

/* qr preview */
.qr-box {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-radius: var(--radius);
  background: #fff;
  animation: view-in var(--dur) var(--ease) both;
}
.qr-box canvas, .qr-box img { max-width: 100%; height: auto; image-rendering: pixelated; }

/* swatch */
.swatch {
  width: 100%;
  height: 96px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm) inset;
  transition: background var(--dur);
}

/* stopwatch digits */
.digits {
  font-family: var(--font-mono);
  font-size: clamp(34px, 12vw, 54px);
  font-weight: 700;
  letter-spacing: -.02em;
  text-align: center;
  padding: 16px 0;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(140deg, var(--text), var(--brand));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------------------------------------------------------------- toast */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 15px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px) saturate(170%);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  font-size: 13.5px;
  font-weight: 600;
  animation: toast-in var(--dur) var(--ease-bounce) both;
}
.toast.out { animation: toast-out var(--dur-fast) var(--ease) both; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(22px) scale(.94); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(12px) scale(.96); }
}
.toast .ic { font-size: 16px; flex: 0 0 auto; }
.toast--ok    .ic { color: var(--brand); }
.toast--err   .ic { color: #f87171; }
.toast--info  .ic { color: var(--accent-500); }

/* ---------------------------------------------------------------- modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--scrim);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fade-in var(--dur) var(--ease) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal__box {
  width: min(480px, 100%);
  max-height: 84vh;
  overflow: auto;
  padding: 22px;
  border-radius: var(--radius-xl);
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  animation: view-in var(--dur) var(--ease-bounce) both;
}
.modal__box h3 { font-size: 17px; margin-bottom: 6px; }
.modal__box p { font-size: 13px; color: var(--text-dim); }

/* ---------------------------------------------------------------- footer */
.footer {
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}
.footer a { font-weight: 700; }
.footer .links { display: flex; gap: 14px; justify-content: center; margin-bottom: 9px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- announce */
.announce {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 14px;
  padding: 13px 15px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent-500) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-500) 30%, transparent);
  font-size: 13px;
  animation: view-in var(--dur) var(--ease) both;
}

/* ---------------------------------------------------------------- maintenance */
.maint {
  text-align: center;
  padding: 60px 22px;
}
.maint .em { font-size: 52px; margin-bottom: 14px; }
.maint h2 { font-size: 21px; margin-bottom: 8px; }
.maint p { font-size: 13.5px; color: var(--text-dim); max-width: 46ch; margin: 0 auto; }

/* ---------------------------------------------------------------- reveal */
.reveal { animation: view-in var(--dur-slow) var(--ease) both; }

/* ---------------------------------------------------------------- responsive */
@media (min-width: 640px) {
  :root { --shell-pad: 22px; --header-h: 66px; }
  .grid, .skeleton-grid { grid-template-columns: repeat(auto-fill, minmax(182px, 1fr)); gap: 13px; }
  .hero { padding: 34px 30px; margin-top: 22px; }
  .panel { padding: 22px; }
  .tool-head { padding: 22px; }
}

@media (min-width: 900px) {
  .grid, .skeleton-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .hero { padding: 44px 40px; }
  .hero__stats { gap: 11px; }
}

@media (max-width: 400px) {
  .grid, .skeleton-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .card { padding: 13px 12px; border-radius: var(--radius); }
  .card__icon { width: 37px; height: 37px; font-size: 18px; border-radius: 11px; }
  .card__name { font-size: 12.5px; }
  .brand-text span { display: none; }
  .user-chip .uname { display: none; }
  .user-chip { padding: 4px; }
  .hero__stat { padding: 7px 11px; }
  .hero__stat b { font-size: 15px; }
}

/* ---------------------------------------------------------------- motion pref */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------- polish */
/* keep the last row of cards clear of the toast layer */
.shell { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

/* stat tiles: numbers and labels vertically centred + baseline aligned */
.kv__i, .hero__stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2px;
  min-height: 62px;
}
.kv__i b, .hero__stat b { line-height: 1.15; }
.kv__i span, .hero__stat span { line-height: 1.2; }

/* search field: keep the clear button and placeholder from colliding */
.search-input::placeholder { color: var(--text-faint); opacity: 1; }
.search-input::-webkit-input-placeholder { color: var(--text-faint); opacity: 1; }
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }

/* footer fine print needs readable contrast on light themes */
.footer { color: var(--text-dim); }
.footer div { color: var(--text-dim); }

/* ---------------------------------------------------------------- print */
@media print {
  .app-header, .toolbar, .toasts, .footer, .back-btn { display: none !important; }
  body::before, body::after { display: none; }
}
