:root {
  color-scheme: dark;
  --bg: #2d2f3a;
  --bg-raised: #32343f;
  --bg-sunken: #272930;
  --surface: #32343f;
  --surface-hover: #383a47;
  --text: #e0e2ea;
  --text-secondary: #9a9db0;
  --muted: #9498ab;
  --accent: #00e5c8;
  --accent-dim: rgba(0, 229, 200, .12);
  --accent-glow: rgba(0, 229, 200, .2);
  --accent-strong: #00bfa5;
  --primary: #7a97ff;
  --primary-dim: rgba(122, 151, 255, .12);
  --primary-glow: rgba(122, 151, 255, .2);
  --warning: #ffb347;
  --warning-dim: rgba(255, 179, 71, .12);
  --danger: #ff6b6b;
  --danger-dim: rgba(255, 107, 107, .12);
  --success: #4ecdc4;
  --success-dim: rgba(78, 205, 196, .12);
  --shadow-dark: #1e1f26;
  --shadow-light: #3c3e4a;
  --neu-raised: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
  --neu-raised-sm: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
  --neu-raised-lg: 10px 10px 20px var(--shadow-dark), -10px -10px 20px var(--shadow-light);
  --neu-inset: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
  --neu-inset-sm: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
  --neu-flat: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
  --btn-glow: 4px 4px 10px var(--shadow-dark), -3px -3px 8px var(--shadow-light), 0 0 16px var(--accent-glow);
  --btn-glow-hover: 5px 5px 14px var(--shadow-dark), -4px -4px 10px var(--shadow-light), 0 0 24px var(--accent-glow);
  --btn-pressed: inset 3px 3px 6px #0000004d, inset -2px -2px 4px #ffffff1a;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --font: Inter, system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

:root[data-theme=light] {
  color-scheme: light;
  --bg: #e0e5ec;
  --bg-raised: #e6eaf1;
  --bg-sunken: #d1d6dd;
  --surface: #e6eaf1;
  --surface-hover: #ebedf3;
  --text: #2d3748;
  --text-secondary: #5a6178;
  --muted: #505a6e;
  --accent: #00695c;
  --accent-dim: rgba(0, 105, 92, .1);
  --accent-glow: rgba(0, 105, 92, .15);
  --accent-strong: #005448;
  --primary: #2f4fd6;
  --primary-dim: rgba(47, 79, 214, .1);
  --primary-glow: rgba(47, 79, 214, .15);
  --warning: #8a5510;
  --warning-dim: rgba(138, 85, 16, .1);
  --danger: #b83434;
  --danger-dim: rgba(184, 52, 52, .1);
  --success: #246b6c;
  --success-dim: rgba(36, 107, 108, .1);
  --shadow-dark: #b8bec7;
  --shadow-light: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

[hidden] { display: none !important; }

a { color: var(--accent); }

::selection { background: var(--accent-dim); }

.mono { font-family: var(--mono); }

.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; }

.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Navigation ---------- */

.top-nav { position: sticky; top: 0; z-index: 200; background: var(--bg); box-shadow: 0 4px 10px var(--shadow-dark); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1200px; margin: 0 auto; padding: 0 20px; height: 52px; }
.nav-brand {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -.3px;
  text-decoration: none;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-link {
  padding: 7px 16px;
  border: none;
  border-radius: 20px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--bg);
  cursor: pointer;
  transition: all .2s ease;
}
.nav-link:hover { color: var(--text); box-shadow: var(--neu-raised-sm); }
.nav-link:active, .nav-link.active { color: var(--accent); box-shadow: var(--neu-inset-sm); }

.theme-toggle {
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--neu-raised-sm);
  transition: all .2s ease;
}
.theme-toggle:hover { color: var(--accent); box-shadow: var(--neu-flat); }
.theme-toggle:active { box-shadow: var(--neu-inset-sm); }

/* ---------- Layout ---------- */

.app-shell { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px; display: grid; gap: 16px; align-content: start; flex: 1; }

.status-bar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--bg); border-radius: var(--radius); box-shadow: var(--neu-raised); }
.status-bar .brand { font-weight: 800; font-size: 16px; letter-spacing: -.5px; }
.status-bar .spacer { flex: 1; }
.live-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent-glow); animation: pulse 2s ease-in-out infinite; }
.status-text { font-size: 11px; color: var(--muted); font-family: var(--mono); font-weight: 500; background: var(--bg-sunken); padding: 4px 12px; border-radius: 20px; box-shadow: var(--neu-inset-sm); }

.metrics-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.metric-cell { display: flex; flex-direction: column; gap: 3px; padding: 16px; background: var(--bg); border-radius: var(--radius); box-shadow: var(--neu-raised); text-align: center; transition: box-shadow .2s ease; }
.metric-cell:hover { box-shadow: var(--neu-raised-lg); }
.metric-value { font-size: 26px; font-weight: 700; font-family: var(--mono); letter-spacing: -.5px; line-height: 1; }
.metric-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.metric-cell.accent .metric-value { color: var(--accent); }
.metric-cell.primary .metric-value { color: var(--primary); }
.metric-cell.warning .metric-value { color: var(--warning); }
.metric-cell.success .metric-value { color: var(--success); }
.metric-cell.danger .metric-value { color: var(--danger); }

.hero-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 24px; background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--neu-raised-lg); }
.hero-card h1 { font-size: 26px; font-weight: 800; letter-spacing: -.5px; line-height: 1.2; }
.hero-card.hero-big h1 { font-size: clamp(30px, 5vw, 44px); }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.hero-copy { color: var(--text-secondary); font-size: 13px; max-width: 480px; margin-top: 6px; }
.hero-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

.content-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 14px; align-items: start; }

.panel { background: var(--bg); border-radius: var(--radius-lg); padding: 24px; display: grid; gap: 14px; box-shadow: var(--neu-raised); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.panel-heading h2 { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }

.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 20px; background: var(--bg); color: var(--accent); font-size: 11px; font-weight: 600; font-family: var(--mono); box-shadow: var(--neu-inset-sm); white-space: nowrap; }
.status-pill.warning { color: var(--warning); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; background: var(--bg); color: var(--primary); font-size: 10px; font-weight: 600; box-shadow: var(--neu-inset-sm); }

.detail-copy { color: var(--text-secondary); font-size: 13px; }
.detail-copy code, .help-code { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--bg); box-shadow: var(--neu-inset-sm); color: var(--accent); }

.steps-list { display: grid; gap: 10px; padding: 0 0 0 18px; }
.steps-list li { font-size: 13px; color: var(--text-secondary); }
.steps-list li strong { color: var(--text); }

.why-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.why-grid article { padding: 16px; border-radius: var(--radius); background: var(--bg); box-shadow: var(--neu-inset); }
.why-grid article h3 { font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.why-grid article p { font-size: 12px; color: var(--text-secondary); }

/* ---------- Forms ---------- */

.stack { display: grid; gap: 14px; }
.form-group { display: grid; gap: 5px; }
.form-group label, .label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-secondary); }

.input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: none;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  box-shadow: var(--neu-inset);
  transition: box-shadow .2s;
}
.input:focus { box-shadow: var(--neu-inset), 0 0 0 2px var(--accent-dim); }
.input::placeholder { color: var(--muted); }
.input:disabled { opacity: .5; cursor: not-allowed; }
.input-mono { font-family: var(--mono); }
.input-code { font-family: var(--mono); font-size: 26px; letter-spacing: .5em; text-align: center; padding: 12px 14px 12px calc(14px + .5em); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  background: var(--bg);
  color: var(--text-secondary);
  box-shadow: var(--neu-flat);
  transition: all .2s ease;
}
.btn:hover:not(:disabled) { color: var(--text); box-shadow: var(--neu-raised-sm); }
.btn:active:not(:disabled) { box-shadow: var(--neu-inset-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--bg);
  font-weight: 700;
  box-shadow: var(--btn-glow);
}
.btn-primary:hover:not(:disabled) { color: var(--bg); box-shadow: var(--btn-glow-hover); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); box-shadow: var(--btn-pressed), 0 0 12px var(--accent-glow); }

.btn-danger:hover:not(:disabled) { color: var(--danger); }
.btn-block { width: 100%; }
.btn-big { padding: 14px 24px; font-size: 14px; }
.btn-small { padding: 7px 14px; font-size: 12px; border-radius: 20px; box-shadow: var(--neu-raised-sm); }

.btn-link {
  justify-self: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-link:hover { color: var(--accent); }

.hint, .status-msg { font-size: 12px; color: var(--text-secondary); }

.alert { font-size: 12px; color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); background: var(--bg); box-shadow: var(--neu-inset); }
.alert.ok { color: var(--success); }

.warning-box { display: flex; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--bg); box-shadow: var(--neu-inset); color: var(--warning); font-size: 13px; }
.warning-box strong { white-space: nowrap; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--bg); border-radius: var(--radius); box-shadow: var(--neu-raised-sm); cursor: pointer; }
.toggle-label { font-size: 12px; color: var(--text-secondary); }
.toggle-switch { position: relative; width: 46px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg); border-radius: 999px; cursor: pointer; transition: all .25s ease; box-shadow: var(--neu-inset); }
.toggle-slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: all .25s ease; box-shadow: 2px 2px 4px var(--shadow-dark), -1px -1px 3px var(--shadow-light); }
.toggle-switch input:checked + .toggle-slider::before { background: var(--accent); transform: translateX(22px); box-shadow: 2px 2px 4px var(--shadow-dark), -1px -1px 3px var(--shadow-light), 0 0 10px var(--accent-glow); }
.toggle-switch input:focus-visible + .toggle-slider { box-shadow: var(--neu-inset), 0 0 0 2px var(--accent); }

.inline-form { display: flex; gap: 10px; align-items: center; }
.inline-form .input { min-width: 0; width: 220px; }

/* ---------- Stamp machine ---------- */

.machine { position: relative; height: 220px; border-radius: var(--radius); background: var(--bg); box-shadow: var(--neu-inset); overflow: hidden; }
.machine-head { position: absolute; inset: 0 0 auto 0; height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 16px; z-index: 3; background: var(--bg); box-shadow: 0 4px 8px var(--shadow-dark); }
.machine-light { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.machine.working .machine-light { background: var(--accent); box-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent-glow); animation: pulse .4s ease-in-out infinite; }
.machine-label { font-size: 11px; color: var(--muted); font-weight: 500; }

.stamper { position: absolute; top: 42px; left: 50%; width: 84px; margin-left: -42px; display: flex; flex-direction: column; align-items: center; z-index: 2; transform: translateY(-30px); }
.stamper-arm { width: 14px; height: 50px; border-radius: 0 0 6px 6px; background: var(--bg); box-shadow: var(--neu-flat); }
.stamper-block { width: 84px; height: 40px; display: grid; place-items: center; font-weight: 800; font-size: 18px; color: var(--bg); border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--accent), var(--primary)); box-shadow: var(--btn-glow); }
.machine.stamping .stamper { animation: stamp .55s cubic-bezier(.6, -.3, .4, 1.4); }

.belt { position: absolute; inset: auto 12px 12px 12px; height: 62px; border-radius: var(--radius-sm); background: var(--bg-sunken); box-shadow: var(--neu-inset-sm); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.belt::before { content: ""; position: absolute; inset: auto 0 6px 0; height: 2px; background: repeating-linear-gradient(90deg, var(--muted) 0 8px, transparent 8px 16px); opacity: .4; }
.machine.working .belt::before { animation: belt .35s linear infinite; }

.paper { position: relative; max-width: 86%; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--bg); color: var(--text-secondary); box-shadow: var(--neu-raised-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; transition: max-width .35s cubic-bezier(.5, 1.6, .5, 1), font-size .35s, color .3s; }
.machine.feeding .paper { animation: feed .5s ease-out; }
.paper.squished { max-width: 60%; font-size: 17px; font-weight: 600; color: var(--accent); box-shadow: var(--neu-raised-sm), 0 0 16px var(--accent-glow); animation: squish .4s ease-out; }

.minified { display: grid; gap: 8px; padding: 16px; border-radius: var(--radius); background: var(--bg); box-shadow: var(--neu-inset); animation: pop .35s cubic-bezier(.5, 1.8, .5, 1); }
.minified-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.minified-link { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--accent); text-decoration: none; word-break: break-all; }
.minified-link:hover { text-decoration: underline; }

/* ---------- Links list ---------- */

.links { list-style: none; display: grid; gap: 8px; }
.link-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius); background: var(--bg); box-shadow: var(--neu-inset); transition: box-shadow .2s ease; }
.link-item.new { animation: pop .4s cubic-bezier(.5, 1.8, .5, 1); }
.link-item.expired { opacity: .55; }
.link-code { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent); padding: 5px 12px; border-radius: 20px; background: var(--bg); box-shadow: var(--neu-raised-sm); text-decoration: none; }
.link-item.expired .link-code { color: var(--muted); text-decoration: line-through; box-shadow: none; }
.link-meta { min-width: 0; display: grid; gap: 2px; }
.link-long { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 600; color: var(--text); }
.link-sub { font-size: 11px; font-family: var(--mono); color: var(--muted); }
.link-sub.warning-state { color: var(--warning); }
.link-actions { display: flex; align-items: center; gap: 8px; }
.link-hits { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--primary); padding: 4px 10px; border-radius: 20px; box-shadow: var(--neu-inset-sm); white-space: nowrap; }
.empty { text-align: center; padding: 24px; font-size: 13px; color: var(--muted); border-radius: var(--radius); box-shadow: var(--neu-inset); }

/* ---------- Misc ---------- */

.h2 { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }

.center-panel { max-width: 480px; width: 100%; margin: 48px auto; text-align: center; justify-items: center; }
.big-icon { display: grid; place-items: center; width: 72px; height: 72px; font-size: 30px; border-radius: 50%; background: var(--bg); box-shadow: var(--neu-raised); }

.footer { max-width: 1200px; width: 100%; margin: 0 auto; padding: 8px 20px 24px; text-align: center; font-size: 11px; font-family: var(--mono); color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 10px 18px; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--bg-raised); border-radius: 20px; box-shadow: var(--neu-raised-lg); z-index: 1000; animation: pop .3s cubic-bezier(.5, 1.8, .5, 1); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 999; }

@keyframes pulse { 0%, to { opacity: 1; } 50% { opacity: .4; } }
@keyframes stamp { 0% { transform: translateY(-30px); } 45% { transform: translateY(34px); } 60% { transform: translateY(28px); } 100% { transform: translateY(-30px); } }
@keyframes feed { from { transform: translateX(-140%); } to { transform: translateX(0); } }
@keyframes squish { 0% { transform: scale(1.3, .5); } 60% { transform: scale(.9, 1.15); } 100% { transform: scale(1); } }
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes belt { to { background-position: 16px 0; } }

@media (max-width: 800px) {
  .content-grid, .metrics-strip, .why-grid { grid-template-columns: 1fr; }
  .metrics-strip { grid-template-columns: 1fr 1fr; }
  .hero-card { flex-direction: column; align-items: flex-start; }
  .hero-actions { align-items: flex-start; }
  .link-item { grid-template-columns: 1fr; }
  .status-bar .status-text { display: none; }
}

@media (max-width: 600px) {
  .app-shell { padding: 12px; }

  /* The nav must never overflow the viewport on a phone. Let it wrap onto a
     second row instead of clipping, and make every control a reachable tap
     target. */
  .nav-inner { padding: 8px 12px; height: auto; flex-wrap: wrap; row-gap: 8px; }
  .nav-links { flex-wrap: wrap; justify-content: flex-end; row-gap: 8px; gap: 6px; }
  .nav-link { padding: 8px 13px; font-size: 12px; min-height: 36px; display: inline-flex; align-items: center; }

  /* The sign-in call to action is the primary action: make it unmissable and
     full-width on the smallest screens instead of a cramped pill. */
  .nav-links .btn-primary { padding: 10px 18px; font-size: 13px; min-height: 40px; }

  .inline-form { flex-wrap: wrap; }
}

@media (max-width: 400px) {
  .nav-brand { font-size: 14px; }
  .nav-links { gap: 5px; }
  .nav-link { padding: 7px 10px; }
  .nav-links .btn-primary { flex: 1 1 100%; justify-content: center; order: 10; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------- prose --- */
.panel-copy { font-size: 13px; color: var(--text-secondary); line-height: 1.65; max-width: 68ch; }
.panel-copy + .panel-copy { margin-top: 10px; }
.panel-copy code, .prose-list code { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.panel-more {
  margin-top: 14px; font-size: 13px; display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; justify-content: space-between;
}
.panel-more a { color: var(--primary); text-decoration: none; font-weight: 600; }
.panel-more a:hover { color: var(--accent); }
.prose-list { display: grid; gap: 8px; padding-left: 18px; }
.prose-list li { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.prose-list li strong { color: var(--text); }
.prose-h3 {
  font-size: 13px; font-weight: 700; color: var(--text); margin-top: 16px;
  padding-left: 10px; border-left: 2px solid var(--accent);
}
.prose-h3:first-of-type { margin-top: 4px; }
.footer-links a { color: var(--text-secondary); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

/* --------------------------------------------------------------- modal --- */
body.modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(16, 17, 22, .62);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: modal-fade .16s ease-out;
}
.modal-overlay[hidden] { display: none; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%; max-width: 420px; max-height: calc(100vh - 40px);
  overflow-y: auto; padding: 24px; display: grid; gap: 16px;
  border-radius: var(--radius-lg); background: var(--surface);
  box-shadow: var(--neu-raised-lg);
  animation: modal-rise .2s cubic-bezier(.2, .8, .3, 1);
}
@keyframes modal-rise { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-header h2 { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.modal-close {
  flex: none; width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: var(--surface); color: var(--text-secondary);
  font-size: 20px; line-height: 1; cursor: pointer; box-shadow: var(--neu-raised-sm);
}
.modal-close:hover:not(:disabled) { color: var(--text); }
.modal-close:active:not(:disabled) { box-shadow: var(--neu-inset-sm); }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.modal-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: var(--radius); background: var(--bg); box-shadow: var(--neu-inset-sm); }
.modal-tab {
  border: 0; padding: 9px 10px; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-secondary); font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.modal-tab:hover:not(:disabled) { color: var(--text); }
.modal-tab.is-active { color: var(--accent); background: var(--surface); box-shadow: var(--neu-raised-sm); }
.modal-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.modal-foot { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.5; }

@media (max-width: 800px) {
  .panel-more { justify-content: flex-start; }
  .modal-card { max-height: calc(100vh - 24px); padding: 20px; }
}
