:root {
    --bg: #ffffff;
    --soft: #f6f6f7;
    --ink: #111113;
    --ink-2: #55585e;
    --ink-3: #8b8f96;
    --line: #e4e4e7;
    --line-2: #d4d4d8;
    --link: #2253d8;
    --ok: #127a43;
    --danger: #c42b1c;
    --r: 8px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    display: flex; flex-direction: column; min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.015em; }
p { margin: 0; }
.container { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 20px; }
.container.wide { max-width: 1080px; }

/* Header / footer */
.header { border-bottom: 1px solid var(--line); }
.header .container { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; background: var(--ink); display: grid; place-items: center; }
.brand-mark svg { width: 14px; height: 14px; }
.header-nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.header-nav a { color: var(--ink-2); }
.footer { border-top: 1px solid var(--line); padding: 18px 0; color: var(--ink-3); font-size: 13px; }
.footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Forms */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.input, .textarea {
    width: 100%; height: 42px; padding: 0 12px;
    font: inherit; color: var(--ink); background: #fff;
    border: 1px solid var(--line-2); border-radius: var(--r);
}
.textarea { height: auto; min-height: 92px; padding: 10px 12px; font: 13px/1.5 ui-monospace, Consolas, monospace; resize: vertical; }
.input:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 42px; padding: 0 18px;
    font: inherit; font-weight: 600; font-size: 14.5px;
    color: #fff; background: var(--ink);
    border: 1px solid var(--ink); border-radius: var(--r);
    cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #2b2b30; text-decoration: none; }
.btn:disabled { background: #e9e9ec; border-color: #e9e9ec; color: var(--ink-3); cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--soft); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; font-weight: 500; }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--line-2); }
.btn.danger:hover { background: #fdf3f2; }

.alert { margin-top: 12px; padding: 10px 12px; border-radius: var(--r); font-size: 14px; }
.alert.error { background: #fdf3f2; color: #9c2015; border: 1px solid #f3d3cf; }
.alert.success { background: #effaf3; color: #0e6236; border: 1px solid #cdebd9; }

/* Home */
.intro { padding: 56px 0 22px; }
.intro h1 { font-size: 30px; }
.intro p { color: var(--ink-2); margin-top: 6px; }
.shorten {
    display: flex; align-items: center;
    border: 1px solid var(--line-2); border-radius: 10px; padding: 5px; background: #fff;
}
.shorten:focus-within { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.shorten input { flex: 1; min-width: 0; border: 0; outline: 0; height: 44px; padding: 0 10px; font: inherit; font-size: 16px; background: transparent; color: var(--ink); }
.shorten .btn { height: 44px; padding: 0 22px; }
.alias-toggle { margin-top: 10px; font-size: 13.5px; }
.alias-toggle button { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.alias-box { margin-top: 10px; display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--r); background: #fff; max-width: 420px; }
.alias-box:focus-within { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.alias-box span { padding-left: 12px; color: var(--ink-3); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.alias-box input { flex: 1; min-width: 0; border: 0; outline: 0; height: 40px; padding: 0 12px 0 1px; font: inherit; font-size: 14px; background: transparent; }

.links-list { margin-top: 28px; }
.links-list h2 { font-size: 13px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.link-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.link-row:last-child { border-bottom: 1px solid var(--line); }
.link-row .info { flex: 1; min-width: 0; }
.link-row .s { font-weight: 600; font-size: 15px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row .o { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row.new { background: linear-gradient(90deg, #f3f7ff, #fff 70%); margin: 0 -12px; padding: 12px; border-radius: var(--r); border: 1px solid #dbe5fb !important; }

/* Ad slots: invisible wrapper, hidden when empty */
.slot { margin: 22px auto; text-align: center; overflow: hidden; max-width: 100%; }
.slot:empty { display: none; }

/* Redirect page */
.gate { max-width: 520px; margin: 0 auto; padding: 36px 0 8px; text-align: center; }
.gate h1 { font-size: 22px; }
.gate .sub { color: var(--ink-2); margin-top: 6px; font-size: 15px; }
.gate .sub b { font-variant-numeric: tabular-nums; color: var(--ink); }
.bar { height: 4px; background: var(--soft); border-radius: 4px; overflow: hidden; margin: 22px auto 0; max-width: 320px; }
.bar > div { height: 100%; width: 0; background: var(--ink); }
.gate .btn { margin-top: 24px; height: 48px; min-width: 220px; font-size: 15.5px; }
.panel { border: 1px solid var(--line); border-radius: 12px; padding: 30px 24px; }
.hidden { display: none !important; }

/* Admin */
.admin-top { padding: 28px 0 18px; }
.admin-top h1 { font-size: 22px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 22px; }
.stat { padding: 14px 18px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat .k { font-size: 13px; color: var(--ink-3); }
.stat .v { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 9px 12px; color: var(--ink-3); font-weight: 500; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 20px; background: #fff; }
.card + .card { margin-top: 18px; }
.card-title { font-size: 15px; font-weight: 650; margin-bottom: 14px; }
.toolbar { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 8px; }
.toolbar .input { height: 34px; width: 230px; font-size: 14px; }
.table-wrap { overflow-x: auto; margin: 0 -20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--ink-3); padding: 8px 20px; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); background: #fafafa; }
td { padding: 11px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.url { color: var(--ink-2); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; }
td.date { color: var(--ink-3); white-space: nowrap; font-size: 13px; }
td.act { text-align: right; white-space: nowrap; }
td.act form { display: inline; }
.empty { text-align: center; color: var(--ink-3); padding: 36px 0; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pager a, .pager span { min-width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; color: var(--ink-2); }
.pager span { background: var(--ink); color: #fff; border-color: var(--ink); }
.section-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin: 6px 0 14px; }
.section-label ~ .section-label { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 8px; }
.login { max-width: 360px; margin: 80px auto; }

@media (max-width: 640px) {
    .intro { padding: 36px 0 18px; }
    .intro h1 { font-size: 25px; }
    .shorten { flex-direction: column; align-items: stretch; padding: 6px; gap: 6px; }
    .shorten input { height: 44px; }
    .input-row { flex-direction: column; }
    .input-row .input { flex: none !important; }
    .stats { grid-template-columns: 1fr; }
    .stat + .stat { border-left: 0; border-top: 1px solid var(--line); }
    .table-wrap { margin: 0 -20px; }
    .toolbar form, .toolbar .input { width: 100%; }
    .gate .btn { width: 100%; }
    .panel { padding: 26px 18px; }
    .footer .container { justify-content: center; }
}
