:root {
  --bg: #f7f8fc;
  --bg-alt: #eef0fb;
  --card: #ffffff;
  --text: #12142b;
  --muted: #646a8a;
  --border: #e3e6f3;
  --primary: #6d5dfc;
  --primary-2: #22c3ee;
  --primary-ink: #ffffff;
  --danger: #e5484d;
  --ok: #18a058;
  --shadow: 0 10px 30px -12px rgba(40, 40, 120, .25);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0d1a;
    --bg-alt: #121428;
    --card: #171a33;
    --text: #eceefe;
    --muted: #9aa0c3;
    --border: #272b4d;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.02em; }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.truncate { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.row { display: flex; gap: 10px; align-items: center; }
.gap { flex-wrap: wrap; margin-top: 14px; }
[hidden] { display: none !important; }

/* Nav */
.nav { position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); background: color-mix(in srgb, var(--bg) 80%, transparent); border-bottom: 1px solid var(--border); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); font-size: .95rem; }
.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-links a:not(.btn) { text-decoration: none; color: var(--muted); font-weight: 500; }
.nav-links a:not(.btn):hover { color: var(--text); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 12px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .08s, filter .15s, background .15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #8b5cf6); color: var(--primary-ink); box-shadow: 0 6px 18px -6px rgba(109, 93, 252, .7); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-alt); }
.btn-sm { padding: 7px 12px; font-size: .9rem; }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg-alt); color: var(--text); }

/* Hero */
.hero { padding: 72px 0 56px; text-align: center; background:
  radial-gradient(600px 300px at 15% 0%, rgba(109, 93, 252, .18), transparent 70%),
  radial-gradient(600px 300px at 85% 10%, rgba(34, 195, 238, .16), transparent 70%); }
.pill { display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); font-size: .85rem; color: var(--muted); margin-bottom: 20px; }
.hero h1 { font-size: clamp(2rem, 5.5vw, 3.6rem); font-weight: 800; max-width: 820px; margin: 0 auto 16px; }
.grad { background: linear-gradient(90deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 620px; margin: 0 auto 32px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.shorten-card, .result-card { max-width: 820px; margin: 0 auto; padding: 18px; text-align: left; }
.result-card { margin-top: 18px; animation: pop .25s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

input[type=text], input[type=password], input[type=search], input[type=datetime-local] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.main-row input { font-size: 1.05rem; padding: 14px 16px; }

.options-toggle { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { font: inherit; font-size: .88rem; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--primary); }
.chip.active { background: color-mix(in srgb, var(--primary) 14%, var(--card)); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chip.is-static { cursor: default; color: var(--muted); }
.chip.is-static:hover { border-color: var(--border); }

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.options:has(.opt:not([hidden])) { margin-top: 14px; }
.opt { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 600; }
.prefix-input { display: flex; align-items: stretch; }
.prefix { display: flex; align-items: center; padding: 0 10px; background: var(--bg-alt); border: 1px solid var(--border); border-right: 0; border-radius: 12px 0 0 12px; color: var(--muted); font-weight: 500; font-size: .85rem; white-space: nowrap; max-width: 50%; overflow: hidden; text-overflow: ellipsis; }
.prefix-input input { border-radius: 0 12px 12px 0; }
.hint { font-weight: 400; color: var(--muted); }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--danger); }
.error { color: var(--danger); font-weight: 500; margin: 12px 0 0; }

.result-main { display: flex; gap: 20px; align-items: center; justify-content: space-between; }
.result-text { min-width: 0; flex: 1; }
.result-link { display: block; font-size: 1.5rem; font-weight: 700; color: var(--primary); text-decoration: none; margin: 4px 0; word-break: break-all; }
.result-link:hover { text-decoration: underline; }
.result-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.badge { font-size: .75rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--bg-alt); color: var(--muted); }
.badge.warn { background: color-mix(in srgb, var(--danger) 14%, var(--card)); color: var(--danger); }
.qr { flex-shrink: 0; padding: 10px; background: #fff; border-radius: 12px; border: 1px solid var(--border); line-height: 0; }
.qr img, .qr canvas { width: 132px; height: 132px; }

.trust { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: center; margin-top: 28px; color: var(--muted); font-size: .9rem; }

/* Sections */
.section { padding: 64px 0; }
.section.alt { background: var(--bg-alt); }
.section h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.search { max-width: 260px; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; min-width: 0; }
.stat-num { font-size: 1.6rem; font-weight: 800; }
.small-num { font-size: 1rem; padding: 6px 0; }

.table-card { padding: 6px; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.links { list-style: none; margin: 0; padding: 0; }
.link-item { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 12px; cursor: pointer; }
.link-item + .link-item { border-top: 1px solid var(--border); }
.link-item:hover { background: var(--bg-alt); }
.link-info { min-width: 0; }
.link-short { font-weight: 700; color: var(--primary); text-decoration: none; }
.link-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.link-clicks { text-align: right; font-weight: 700; }
.link-clicks span { display: block; font-size: .75rem; font-weight: 500; color: var(--muted); }
.link-actions { display: flex; gap: 2px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-top: 32px; }
.feature { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.feature h3 { font-size: 1.1rem; margin-top: 12px; }
.feature p { margin: 0; color: var(--muted); }
.ficon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; font-size: 1.3rem; background: color-mix(in srgb, var(--primary) 14%, var(--card)); }

.footer { padding: 28px 0; text-align: center; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--border); }

/* Modal */
.modal { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--border); border-radius: 20px; padding: 22px; background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(10, 12, 30, .55); backdrop-filter: blur(3px); }
.modal-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head > div { min-width: 0; }
.modal h3 { color: var(--primary); margin-bottom: 2px; word-break: break-all; }
.modal h4 { font-size: .9rem; color: var(--muted); font-weight: 600; margin: 18px 0 10px; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding: 8px 0 22px; position: relative; }
.chart .bar { flex: 1; background: linear-gradient(180deg, var(--primary), var(--primary-2)); border-radius: 6px 6px 2px 2px; min-height: 3px; position: relative; opacity: .9; }
.chart .bar:hover { opacity: 1; }
.chart .bar::after { content: attr(data-label); position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: .65rem; color: var(--muted); white-space: nowrap; }
.chart .bar[data-n]:hover::before { content: attr(data-n); position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: .75rem; font-weight: 700; }
.breakdowns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 24px; }
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: .88rem; }
.bars .track { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--bg-alt); overflow: hidden; }
.bars .fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 99px; }
.bars .none { color: var(--muted); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); z-index: 50; animation: pop .2s ease-out; }

/* Gate pages (password / expired / 404) */
body.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; background:
  radial-gradient(600px 300px at 20% 10%, rgba(109, 93, 252, .18), transparent 70%), var(--bg); }
.gate-card { width: min(440px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
.gate-card .brand { margin-bottom: 22px; }
.gate-card h1 { font-size: 1.5rem; }
.gate-form { display: grid; gap: 10px; margin-top: 16px; }

@media (max-width: 640px) {
  .nav-links a:not(.btn) { display: none; }
  .main-row { flex-direction: column; align-items: stretch; }
  .result-main { flex-direction: column-reverse; align-items: flex-start; }
  .stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-num { font-size: 1.25rem; }
  .link-item { grid-template-columns: 1fr auto; }
  .link-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .breakdowns { grid-template-columns: 1fr; }
  .search { max-width: none; }
}
