:root {
    /* Craft Tech Labs light theme (tokens from crafttech-labs.com) */
    --ink-0: #f4f6fa;      /* paper */
    --ink-1: #ffffff;      /* surface */
    --ink-2: #e9edf4;      /* surface sunk */
    --ink-3: #d3dae6;
    --text: #07101e;       /* ink */
    --mute: #33425a;
    --dim: #5b6a82;
    --mint: #1666e8;       /* accent blue */
    --cyan: #1dd7eb;
    --glow: #0f52c4;       /* accent hover */
    --line: #d3dae6;
    --line-strong: #aeb9cb;
    --danger: #c0262d;
    --surface: #ffffff;
    --radius-card: 14px;
    --radius-ctl: 10px;
    --display: "Geist", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
    --body: "Geist", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
    --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --shadow: 0 1px 2px rgba(7, 16, 30, 0.04), 0 18px 48px rgba(7, 16, 30, 0.08);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: var(--body);
    font-size: 16px;
    line-height: 1.5;
    background:
        radial-gradient(900px 460px at 100% -12%, rgba(22, 102, 232, 0.10), transparent 55%),
        radial-gradient(700px 420px at -12% 110%, rgba(29, 215, 235, 0.10), transparent 52%),
        var(--ink-0);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(7, 16, 30, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(7, 16, 30, 0.035) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse at 50% 15%, #000 20%, transparent 75%);
}

::selection { background: var(--mint); color: #ffffff; }

a { color: var(--mint); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--glow); }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.65; cursor: wait; }

:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--mint);
    outline-offset: 3px;
}

.skip {
    position: absolute;
    left: 12px;
    top: -40px;
    background: var(--mint);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 999px;
    z-index: 30;
}
.skip:focus { top: 12px; }

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

.hp {
    position: absolute;
    left: -9999px;
    height: 0;
    overflow: hidden;
}

.mono { font-family: var(--mono); }

.kicker, .brand-kicker, .stat-k, .preview-kicker {
    margin: 0;
    color: var(--mint);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h1, h2, h3 {
    font-family: var(--display);
    font-weight: 600;
    letter-spacing: -0.045em;
    line-height: 0.96;
    margin: 0;
}

h1 { font-size: clamp(40px, 6vw, 58px); }
h2 { font-size: clamp(26px, 3vw, 34px); }
h3 { font-size: 28px; }

p { margin: 0; }

.lede { color: var(--mute); margin: 12px 0 20px; max-width: 42ch; }
.fine { color: var(--dim); font-size: 13px; margin-top: 16px; overflow-wrap: anywhere; }
.fine a { color: var(--mute); }

.topbar {
    width: min(1120px, calc(100% - 28px));
    margin: 0 auto;
    padding: 22px 0 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
    min-width: 0;
    max-width: 100%;
}

.brand {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    min-width: 0;
    max-width: 100%;
    color: inherit;
    text-decoration: none;
}
.brand > span { min-width: 0; }
.brand-name {
    display: block;
    font-family: var(--display);
    font-size: 22px;
    letter-spacing: -0.04em;
    line-height: 1;
}
.brand-plain { margin-bottom: 18px; }

.mark { width: 36px; height: 36px; display: block; flex: none; }
.mark-logo {
    display: block;
    flex: none;
    height: 40px;
    width: auto;
    max-width: 100%;
}
.brand .brand-name {
    white-space: nowrap;
    padding-left: 12px;
    border-left: 1px solid var(--line);
}
.brand-plain .mark-logo { height: 60px; }
.brand-logo { display: block; flex: none; line-height: 0; }
a.brand-name { color: inherit; text-decoration: none; }
.gate-logo { display: inline-block; line-height: 0; border-radius: 10px; max-width: 100%; }
.gate-logo .mark-logo { height: 68px; }
.gate-logo:focus-visible { outline: 2px solid var(--mint); outline-offset: 6px; }
.gate-logo-row { display: flex; justify-content: center; margin: 32px 0 20px; }
.gate-title {
    margin: 0 0 14px;
    font-family: var(--display);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--mint);
}
.brand-plain .brand-name { font-size: 24px; }
@media (max-width: 380px) {
    .topbar, .shell { width: calc(100% - 16px); }
    .topbar { gap: 8px; padding-top: 14px; }
    .brand { gap: 8px; }
    .brand .brand-name { font-size: 16px; padding-left: 8px; }
    .topbar-side { gap: 6px; }
    .who { max-width: 9.5rem; }
    .mark-logo { height: 34px; }
    .brand-plain .mark-logo { height: 50px; }
    .gate-logo .mark-logo { height: 50px; }
    .brand-plain .brand-name { font-size: 20px; }
}

.topbar-side {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.who {
    color: var(--mute);
    font-size: 14px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell {
    width: min(1120px, calc(100% - 28px));
    max-width: 100%;
    margin: 0 auto;
    padding: 18px 0 72px;
    position: relative;
    z-index: 1;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-head h1 { max-width: 16ch; font-size: clamp(34px, 5vw, 52px); }
.page-head .kicker { margin-bottom: 8px; }

.search { display: flex; gap: 8px; width: min(380px, 100%); }
.search input { flex: 1; min-width: 0; }

.stats {
    display: grid;
    grid-template-columns: 140px 140px minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.stat, .panel, .gate-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
}
.stat { padding: 16px 18px; }
.stat-n {
    margin-top: 6px;
    font-family: var(--display);
    font-size: 36px;
    letter-spacing: -0.04em;
    line-height: 1;
}
.stat-host {
    margin-top: 6px;
    font-family: var(--mono);
    font-size: 14px;
    word-break: break-all;
}
.stat-note { color: var(--dim); font-size: 13px; margin-top: 4px; }

.panel { padding: 22px; margin-bottom: 16px; }
.panel-head { margin-bottom: 16px; }
.panel-head h2 { margin-bottom: 8px; }
.panel-head p, .danger-zone p { color: var(--mute); }

.composer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(180px, 0.7fr) auto;
    gap: 12px;
    align-items: end;
}
.edit-grid { grid-template-columns: minmax(0, 1.5fr) minmax(180px, 0.7fr) auto; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { color: var(--mute); font-size: 13px; }

input[type="url"],
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input:not([type]) {
    width: 100%;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-ctl);
    padding: 12px 14px;
    color: var(--text);
}
input::placeholder { color: var(--dim); }
input:focus-visible {
    outline: none;
    border-color: var(--mint);
    box-shadow: 0 0 0 3px rgba(22, 102, 232, 0.18);
}
input[aria-invalid="true"] { border-color: rgba(192, 38, 45, 0.8); }

.field-error { color: var(--danger); font-size: 13px; }

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 11px 16px;
    font-weight: 600;
    line-height: 1.1;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}
.btn-primary {
    background: var(--mint);
    color: #ffffff;
}
.btn-primary:hover { background: var(--glow); color: #ffffff; }
.btn-ghost {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text);
}
.btn-ghost:hover { border-color: var(--text); background: var(--text); color: #fff; }
.btn-danger {
    background: transparent;
    border-color: rgba(192, 38, 45, 0.45);
    color: var(--danger);
}
.btn-danger:hover { background: rgba(192, 38, 45, 0.08); color: var(--danger); }
.btn-small { padding: 8px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.preview {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    align-items: baseline;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(22, 102, 232, 0.06);
    border: 1px dashed rgba(22, 102, 232, 0.35);
}
.preview-url {
    font-family: var(--mono);
    font-size: 14px;
    word-break: break-all;
}

.created {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(22, 102, 232, 0.1);
    border: 1px solid rgba(22, 102, 232, 0.45);
}
.created[hidden] { display: none; }
.created.is-fresh { animation: created-in 0.45s ease-out; }
@keyframes created-in {
    from { box-shadow: 0 0 0 0 rgba(22, 102, 232, 0.5); }
    to { box-shadow: 0 0 0 10px rgba(22, 102, 232, 0); }
}
.created-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 260px; }
.created-kicker {
    color: var(--mint);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
.created-url {
    font-family: var(--mono);
    font-size: 15px;
    color: var(--text);
    word-break: break-all;
    text-decoration: none;
}
.created-url:hover { color: var(--mint); }
.created-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.is-copied { filter: brightness(1.1); }
.form-error { margin: 12px 0 0; }
.form-error[hidden], .field-error[hidden] { display: none; }
.link-row.is-new { animation: row-in 1.6s ease-out; }
@keyframes row-in {
    from { background: rgba(22, 102, 232, 0.14); }
    to { background: transparent; }
}
@media (max-width: 520px) {
    .created-actions { width: 100%; }
    .created-actions .btn { flex: 1 1 0; }
}
.avail { min-height: 1.4em; margin-top: 8px; color: var(--mute); font-size: 14px; }
.avail[data-state="available"] { color: var(--mint); }
.avail[data-state="taken"],
.avail[data-state="reserved"],
.avail[data-state="invalid"] { color: var(--danger); }

.banner {
    border-radius: 14px;
    padding: 12px 14px;
    margin: 0 0 16px;
    border: 1px solid var(--line);
}
.banner-ok { background: rgba(22, 102, 232, 0.1); color: var(--glow); }
.banner-error { background: rgba(192, 38, 45, 0.07); color: #9b1c22; }
.stack .banner { margin-bottom: 14px; }

.link-table { display: flex; flex-direction: column; }
.link-head, .link-row {
    display: grid;
    grid-template-columns: minmax(160px, 1.15fr) minmax(160px, 1.3fr) 72px minmax(120px, 0.9fr) minmax(120px, 0.9fr) auto;
    gap: 12px;
    align-items: center;
}
.link-head {
    color: var(--dim);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 0 8px 10px;
}
.link-row {
    border-top: 1px solid var(--line);
    padding: 14px 8px;
    min-width: 0;
}
.link-row > div,
.mono {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.link-row:hover { background: rgba(22, 102, 232, 0.04); }

.slug-link {
    color: var(--text);
    text-decoration: none;
    font-family: var(--display);
    font-size: 26px;
    letter-spacing: -0.04em;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.slug-link:hover { color: var(--mint); }
.short-full {
    display: block;
    margin-top: 2px;
    color: var(--dim);
    font-family: var(--mono);
    font-size: 12px;
    word-break: break-all;
    text-decoration: none;
}
.short-full:hover { color: var(--mint); }
.dest-link {
    color: var(--mute);
    text-decoration: none;
    word-break: break-word;
}
.dest-link:hover { color: var(--text); }
.count {
    font-family: var(--display);
    font-size: 24px;
    letter-spacing: -0.04em;
}
.meta { color: var(--mute); font-size: 13px; }
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}
.actions form { margin: 0; }

.empty { padding: 12px 4px 6px; }
.empty h3 { margin-bottom: 8px; }
.empty p { color: var(--mute); max-width: 52ch; }

.back { margin: 0 0 12px; }
.back a { color: var(--mute); text-decoration: none; }
.back a:hover { color: var(--mint); }

.facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 18px;
}
.facts div {
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--ink-0);
    border: 1px solid var(--line);
}
.facts dt { color: var(--dim); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.facts dd { margin: 4px 0 0; font-family: var(--display); font-size: 22px; letter-spacing: -0.04em; }

.edit-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.danger-zone h2 { margin-bottom: 8px; }

.gate {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 32px 16px;
    position: relative;
    z-index: 1;
}
.gate-card {
    width: min(460px, 100%);
    padding: 32px 28px 28px;
    position: relative;
}
.gate-card::before {
    content: "";
    position: absolute;
    left: 28px;
    right: 28px;
    top: 0;
    height: 2px;
    background: linear-gradient(100deg, var(--mint), #257aff 50%, var(--cyan));
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.miss-code {
    margin: 8px 0 0;
    font-family: var(--display);
    font-weight: 600;
    font-size: clamp(88px, 18vw, 148px);
    letter-spacing: -0.07em;
    line-height: 0.8;
    background: linear-gradient(100deg, var(--mint), #257aff 45%, var(--cyan));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.attempt {
    margin: 8px 0 4px;
    color: var(--mute);
    word-break: break-all;
    font-size: 13px;
}
.foot-note { color: var(--dim); font-size: 13px; margin-top: 8px; }

.modal { display: none; }
.modal.is-open {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(7, 16, 30, 0.55);
}
.modal-card {
    width: min(420px, 100%);
    background: var(--ink-1);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    padding: 22px;
}
.modal-card h2 { margin: 6px 0 8px; font-size: 32px; }
.qr-host {
    margin: 14px 0;
    background: #fff;
    border-radius: 16px;
    padding: 12px;
    display: grid;
    place-items: center;
    min-height: 220px;
}
.qr-host canvas, .qr-host img { max-width: 100%; height: auto !important; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.is-public .banner {
    width: min(460px, calc(100% - 32px));
    margin: 24px auto -12px;
    position: relative;
    z-index: 1;
}

@media (max-width: 960px) {
    .stats { grid-template-columns: 1fr 1fr; }
    .stat-wide { grid-column: 1 / -1; }
    .composer-grid, .edit-grid { grid-template-columns: 1fr; }
    .composer-grid .btn, .edit-grid .btn { width: 100%; }
    .link-head { display: none; }
    .link-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 16px 4px 18px;
    }
    .meta::before, .dest::before {
        content: attr(data-label);
        display: block;
        color: var(--dim);
        font-size: 11px;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        margin-bottom: 2px;
    }
    .actions { justify-content: flex-start; }
    .facts { grid-template-columns: 1fr; }
}

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

/* Craft Tech Labs light-theme refinements */
body::before { mask-image: radial-gradient(ellipse at 50% 0%, #000 10%, transparent 65%); }
h1, h2, h3 { letter-spacing: -0.035em; line-height: 1.02; }
.gate-title { font-family: var(--mono); font-weight: 500; letter-spacing: 0.16em; font-size: 13px; }
.gate-card::before { background: linear-gradient(100deg, #1247d8, var(--cyan) 58%, #1f77e8); height: 3px; border-radius: 0 0 3px 3px; }
.miss-code { background: linear-gradient(100deg, #1247d8, var(--cyan) 58%, #1f77e8); -webkit-background-clip: text; background-clip: text; }
.gate-logo .mark-logo.mark-wordmark { height: auto; max-width: 100%; }
.banner-ok { background: rgba(22, 102, 232, 0.08); color: #0f3f9a; border-color: rgba(22, 102, 232, 0.25); }
.banner-error { border-color: rgba(192, 38, 45, 0.25); }
.facts div { background: var(--ink-2); }
.qr-host { border: 1px solid var(--line); }
