/* FTLink public frontend. Mobile-first; light & dark follow the device setting. */

:root {
    --bg: #f6f7fb;
    --bg-hero: radial-gradient(1200px 500px at 50% -120px, #e0e7ff 0%, rgba(224, 231, 255, 0) 70%);
    --surface: #ffffff;
    --surface-2: #f1f3f9;
    --text: #0f172a;
    --text-2: #475569;
    --muted: #64748b;
    --border: #e2e8f0;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef2ff;
    --accent-text: #ffffff;
    --success: #059669;
    --danger: #dc2626;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 12px 32px -12px rgba(15, 23, 42, .18);
    --radius: 14px;
    --radius-sm: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1020;
        --bg-hero: radial-gradient(1200px 500px at 50% -120px, #1e1b4b 0%, rgba(30, 27, 75, 0) 70%);
        --surface: #121831;
        --surface-2: #1a2140;
        --text: #e2e8f0;
        --text-2: #b6c2d6;
        --muted: #8b98b0;
        --border: #26304f;
        --accent: #818cf8;
        --accent-hover: #a5b4fc;
        --accent-soft: #1e2250;
        --accent-text: #0b1020;
        --success: #34d399;
        --danger: #f87171;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -12px rgba(0, 0, 0, .6);
        color-scheme: dark;
    }
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 var(--font);
    -webkit-font-smoothing: antialiased;
}

main { flex: 1; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.02em; }
h1 { font-size: clamp(2rem, 6vw, 3.25rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 3.5vw, 1.75rem); font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 6px; }

.icon {
    width: 1.15em; height: 1.15em; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.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;
}
.skip { position: absolute; left: -999px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }

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

/* Header */
.site-header {
    position: sticky; top: 0; z-index: 5;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }
.brand:hover { color: var(--text); }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
    background: var(--accent); color: var(--accent-text);
}
.site-nav { display: flex; gap: 4px; }
.site-nav a {
    padding: 8px 12px; border-radius: 999px; text-decoration: none;
    color: var(--text-2); font-weight: 600; font-size: .95rem; white-space: nowrap;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

/* Hero */
.hero { background: var(--bg-hero); padding: 48px 0 32px; text-align: center; }
.hero-compact { padding-bottom: 56px; }
.accent { color: var(--accent); }
.lead { color: var(--text-2); font-size: clamp(1rem, 2.4vw, 1.15rem); max-width: 620px; margin: 0 auto 28px; }
.fine-print { color: var(--muted); font-size: .8rem; margin: 16px auto 0; max-width: 560px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    text-align: left;
    max-width: 760px;
    margin: 0 auto;
}

/* Form */
.field-row { display: flex; flex-direction: column; gap: 10px; }
.input-wrap { position: relative; flex: 1; display: flex; align-items: center; }
.input-wrap > .icon { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
input[type="url"], input[type="text"] {
    width: 100%; min-width: 0; height: 52px;
    padding: 0 14px 0 44px;
    font: inherit; font-size: 1rem; /* 16px avoids iOS zoom on focus */
    color: var(--text); background: var(--surface-2);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .15s, background .15s;
}
input::placeholder { color: var(--muted); }
input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 16px;
    font: inherit; font-weight: 650; font-size: .95rem;
    border-radius: var(--radius-sm); border: 1.5px solid transparent;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-lg { height: 52px; padding: 0 24px; font-size: 1rem; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-text); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.is-done { background: var(--success); color: #fff; }
.btn[disabled] { opacity: .7; cursor: progress; }

.spinner {
    display: none; width: 18px; height: 18px; border-radius: 50%;
    border: 2.5px solid currentColor; border-right-color: transparent;
    animation: spin .7s linear infinite;
}
.is-loading .spinner { display: inline-block; }
.is-loading .btn-text { opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

.alias { margin-top: 12px; }
.alias summary {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    color: var(--text-2); font-weight: 600; font-size: .925rem; list-style: none;
    padding: 4px 0;
}
.alias summary::-webkit-details-marker { display: none; }
.alias summary:hover { color: var(--accent); }
.alias-row {
    display: flex; align-items: stretch; margin-top: 8px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
    background: var(--surface-2);
}
.alias-row:focus-within { border-color: var(--accent); background: var(--surface); }
.alias-prefix {
    display: flex; align-items: center; padding: 0 4px 0 14px;
    color: var(--muted); font-size: .95rem; white-space: nowrap;
    max-width: 55%; overflow: hidden; text-overflow: ellipsis;
}
.alias-row input { border: 0; background: transparent; padding-left: 2px; height: 46px; }
.alias-row input:focus { background: transparent; }

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

.form-error { color: var(--danger); font-weight: 600; font-size: .925rem; margin: 10px 0 0; }
.form-error:empty { display: none; }

/* Result */
.result {
    margin-top: 16px; padding: 16px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
    animation: rise .25s ease-out;
}
.result:focus { outline: none; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.result-label { display: flex; align-items: center; gap: 6px; color: var(--success); font-weight: 650; font-size: .9rem; margin: 0 0 8px; }
.result-main { display: flex; flex-direction: column; gap: 10px; }
.result-short {
    font-size: clamp(1.2rem, 4.5vw, 1.5rem); font-weight: 800; letter-spacing: -.01em;
    text-decoration: none; word-break: break-all;
}
.result-main .btn { height: 48px; }
.result-long {
    color: var(--text-2); font-size: .875rem; margin: 10px 0 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-long span { color: var(--muted); }
.result-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }

.share-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.share-links a {
    padding: 6px 12px; border-radius: 999px; font-size: .875rem; font-weight: 600;
    background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text);
}
.share-links a:hover { border-color: var(--accent); color: var(--accent); }

.qr-panel { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 14px; }
.qr-canvas { width: 200px; height: 200px; background: #fff; border-radius: 12px; padding: 10px; border: 1px solid var(--border); }

/* Recent */
.recent { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { margin: 0; }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 4px; }
.recent-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.recent-item {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 10px 10px 14px;
}
.recent-text { flex: 1; min-width: 0; }
.recent-text a { display: block; font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-text span { display: block; color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .btn { height: 38px; padding: 0 12px; }

/* Features */
.features, .steps { margin-top: 56px; }
.features h2, .steps h2 { text-align: center; margin-bottom: 24px; }
.feature-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.feature {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px;
}
.feature p { color: var(--text-2); margin: 0; font-size: .95rem; }
.feature-icon {
    display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 12px;
    border-radius: 12px; background: var(--accent-soft); color: var(--accent);
}
.feature-icon .icon { width: 22px; height: 22px; }

.step-list { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 12px; }
.step-list li {
    counter-increment: step; position: relative;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 18px 18px 64px; color: var(--text-2);
}
.step-list li::before {
    content: counter(step); position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
    width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent); color: var(--accent-text); font-weight: 800;
}
.step-list strong { color: var(--text); }

/* Click counter */
.stats { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 20px; }
.stat-number { display: flex; align-items: baseline; gap: 10px; justify-content: center; margin-bottom: 16px; }
.stat-number strong { font-size: clamp(2.75rem, 10vw, 4rem); line-height: 1; color: var(--accent); letter-spacing: -.03em; }
.stat-number span { color: var(--text-2); font-weight: 600; font-size: 1.1rem; }
.stat-meta { margin: 0; display: grid; gap: 10px; }
.stat-meta div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; }
.stat-meta dt { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-meta dd { margin: 2px 0 0; font-weight: 600; }
.break { word-break: break-all; }

/* Report form */
.report-form { display: grid; gap: 16px; }
.field label { display: block; font-weight: 650; font-size: .925rem; margin-bottom: 6px; }
.field label .muted { font-weight: 400; }
.field > input[type="email"], select, textarea {
    width: 100%; min-width: 0;
    font: inherit; font-size: 1rem;
    color: var(--text); background: var(--surface-2);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px 14px;
}
select { height: 52px; padding-top: 0; padding-bottom: 0; }
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
select:focus, textarea:focus, .field > input[type="email"]:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.report-form .form-error { margin: 0; }
.btn-block { width: 100%; }

/* Notices (report sent, link disabled) */
.notice-card { text-align: center; padding: 8px 4px; }
.card.notice-card { padding: 32px 20px; }
.notice-card h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
.notice-card h2 { margin-bottom: .4em; }
.notice-card .lead { margin-bottom: 24px; }
.notice-icon {
    display: inline-grid; place-items: center; width: 56px; height: 56px; margin-bottom: 16px;
    border-radius: 50%; background: var(--accent-soft); color: var(--accent);
}
.notice-icon .icon { width: 28px; height: 28px; }
.stat-warning {
    display: flex; align-items: center; gap: 8px; justify-content: center;
    color: var(--danger); font-weight: 650; margin: 0 0 16px;
}
.stat-report { text-align: center; margin: 16px 0 0; font-size: .875rem; }
.stat-report a { color: var(--muted); }

/* Legal pages */
.legal { max-width: 760px; padding-top: 40px; }
.legal-head { border-bottom: 1px solid var(--border); margin-bottom: 24px; padding-bottom: 12px; }
.legal-head h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); margin-bottom: .25em; }
.prose { color: var(--text-2); }
.prose h2 { color: var(--text); font-size: 1.2rem; margin: 2em 0 .6em; }
.prose h3 { color: var(--text); font-size: 1rem; margin: 1.5em 0 .5em; }
.prose ul { padding-left: 1.25em; margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.prose a { overflow-wrap: anywhere; }
.prose .summary {
    background: var(--accent-soft); border-radius: var(--radius-sm);
    padding: 14px 16px; color: var(--text);
}

/* Developer docs */
.lead-left { color: var(--text-2); font-size: 1.05rem; margin: 0; }
.toc {
    display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px;
}
.toc a {
    padding: 6px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-2); text-decoration: none;
}
.toc a:hover { border-color: var(--accent); color: var(--accent); }
.docs h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; scroll-margin-top: 76px; }
.docs h2 code, .prose td code { overflow-wrap: anywhere; }
.method {
    font-family: var(--mono); font-size: .75rem; font-weight: 800; letter-spacing: .04em;
    padding: 3px 8px; border-radius: 6px; color: #fff;
}
.method.post { background: #059669; }
.method.get { background: #2563eb; }
.method.patch { background: #b45309; }
.code { margin: 0 0 1.25em; }
.code figcaption { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.code pre {
    margin: 0; padding: 14px 16px; overflow-x: auto;
    background: #0f172a; color: #e2e8f0; border-radius: var(--radius-sm);
    font: .85rem/1.6 var(--mono); border: 1px solid var(--border);
}
.code pre code { background: none; padding: 0; font-size: inherit; color: inherit; }
.callout {
    border-left: 4px solid var(--accent); background: var(--accent-soft);
    padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text);
}
.table-wrap { overflow-x: auto; margin: 0 0 1.25em; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table-wrap th, .table-wrap td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table-wrap th { background: var(--surface-2); color: var(--text); font-weight: 700; }
.table-wrap tr:last-child td { border-bottom: 0; }

/* Business portal */
.portal { padding-top: 24px; }
.portal-bar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
    padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--border);
}
.portal-who { display: flex; flex-direction: column; min-width: 0; }
.portal-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.portal-nav a {
    padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: .925rem;
}
.portal-nav a:hover { background: var(--surface-2); color: var(--text); }
.portal-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.portal-nav form { margin: 0 0 0 4px; }
.portal-title { font-size: clamp(1.5rem, 4vw, 2rem); margin-bottom: 16px; }
.flash { background: var(--accent-soft); color: var(--text); border-radius: var(--radius-sm); padding: 12px 16px; font-weight: 600; }
.panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; margin: 0 0 16px;
}
.panel h2 { font-size: 1.15rem; margin: 0 0 10px; }
.panel .section-head { margin-bottom: 8px; }
.panel .section-head h2 { margin: 0; }
ul.panel { padding: 0; }
.two-col { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.two-col .panel { margin: 0; }
.two-col + .panel, .two-col { margin-bottom: 16px; }

.stat-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0 0 12px; }
.stat-card {
    display: flex; flex-direction: column; gap: 2px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
}
.stat-card strong { font-size: 1.9rem; line-height: 1.15; letter-spacing: -.02em; }
.stat-card .stat-date { font-size: 1.3rem; }
.stat-label { color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.meter {
    -webkit-appearance: none; appearance: none; width: 100%; height: 8px; margin-top: 8px;
    border: 0; border-radius: 999px; background: var(--surface-2); overflow: hidden;
}
.meter::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
.meter::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.meter::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

.key-reveal {
    border: 2px solid var(--success); background: color-mix(in srgb, var(--success) 10%, var(--surface));
    border-radius: var(--radius); padding: 16px 18px; margin: 0 0 16px;
}
.key-reveal h2 { font-size: 1.1rem; margin: 0 0 6px; }
.key-row { display: flex; flex-direction: column; gap: 10px; }
.key-value {
    display: block; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface);
    border: 1px solid var(--border); font-size: .95rem; word-break: break-all; user-select: all;
}
.create-key { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.create-key input { padding-left: 14px; height: 46px; }
.create-key .btn { height: 46px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: .85rem; }
.inline-form { display: inline; margin: 0; }
.right { text-align: right; }
tr.is-off td { color: var(--muted); }
.badge-off {
    display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
    background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-size: .75rem; font-weight: 700;
}

.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--border); }
.link-list li:first-child { border-top: 0; }
.panel .link-list li, ul.panel li { padding: 12px 18px; }
section.panel .link-list li { padding: 12px 0; }
.link-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
.link-main strong { color: var(--accent); }
.link-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: .875rem; }
.link-main:hover strong { text-decoration: underline; }
.link-clicks { font-weight: 800; font-size: 1.1rem; white-space: nowrap; text-align: right; }
.link-clicks small { display: block; color: var(--muted); font-weight: 600; font-size: .7rem; text-transform: uppercase; }
.link-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.link-head > div { min-width: 0; flex: 1; }
.link-head .portal-title { margin-bottom: 4px; word-break: break-all; }

.range-nav { display: flex; gap: 4px; }
.range-nav a {
    padding: 4px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; text-decoration: none;
    color: var(--text-2); border: 1px solid var(--border);
}
.range-nav a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chart { display: block; width: 100%; height: auto; margin: 8px 0; }
.chart-bar { fill: var(--accent); }
.chart-bar:hover { fill: var(--accent-hover); }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--muted); font: 12px var(--font); }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.rank-list li:first-child { border-top: 0; }
.rank-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 16px 0; }

/* Auth pages (login, sign-up, reset) */
.auth { max-width: 480px; margin: 24px auto 0; }
.auth-card { padding: 24px 20px; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.auth-after { text-align: center; margin-top: 16px; color: var(--text-2); }
.stack-form { display: grid; gap: 14px; margin-top: 16px; }
.stack-form .field input:not([type="checkbox"]), .create-key input {
    width: 100%; min-width: 0; height: 48px; padding: 0 14px;
    font: inherit; font-size: 1rem; color: var(--text); background: var(--surface-2);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.stack-form .field input:focus, .create-key input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.stack-form .form-error, .stack-form .form-ok { margin: 0; }
.form-ok { color: var(--success); font-weight: 600; font-size: .925rem; margin: 10px 0 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .925rem; color: var(--text-2); }
.check input { width: 18px; height: 18px; margin-top: 3px; flex: none; accent-color: var(--accent); }
.static { margin: 0; padding: 10px 0 0; font-weight: 600; }

/* Footer */
.site-footer { margin-top: 64px; border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; }
.footer-inner p { margin: 0; }
.footer-inner nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; }
.footer-inner a { color: var(--text-2); text-decoration: none; }
.footer-inner a:hover { color: var(--accent); }

/* Small phones: keep the header on one line */
@media (max-width: 480px) {
    .header-inner { gap: 8px; }
    .site-nav { gap: 2px; }
    .site-nav a { padding: 8px 9px; font-size: .9rem; }
}
@media (max-width: 360px) {
    .brand-name { display: none; }
}

/* Tablet and up */
@media (min-width: 640px) {
    .hero { padding: 72px 0 40px; }
    .card { padding: 20px; }
    .field-row { flex-direction: row; }
    .result-main { flex-direction: row; align-items: center; justify-content: space-between; }
    .result-actions { display: flex; flex-wrap: wrap; }
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-meta { grid-template-columns: 1fr 2fr 1fr; }
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .key-row, .create-key { flex-direction: row; align-items: center; }
    .key-row .key-value { flex: 1; }
    .create-key input { flex: 1; }
    .auth-card { padding: 32px; }
    .footer-inner { flex-direction: row; justify-content: space-between; text-align: left; }
}

/* Laptop and desktop */
@media (min-width: 960px) {
    .hero { padding: 96px 0 48px; }
    .card { padding: 24px; }
    .feature-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
    .step-list { grid-template-columns: repeat(3, 1fr); }
    .step-list li { padding: 64px 20px 20px; }
    .step-list li::before { top: 20px; left: 20px; transform: none; }
}

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

.cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }

/* Plans: quota line, upgrade prompt, Pro badge */
.quota { margin: 14px 0 0; font-size: .875rem; color: var(--text-2); text-align: center; }
.quota strong { color: var(--accent); }
.badge-pro {
    display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px;
    background: var(--accent); color: var(--accent-text); font-size: .7rem; font-weight: 800; letter-spacing: .03em;
}
.upgrade-box {
    display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; padding: 16px;
    border-radius: var(--radius-sm); background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.upgrade-box > .icon { color: var(--accent); width: 24px; height: 24px; margin-top: 2px; }
.upgrade-box p { margin: 0 0 10px; font-weight: 700; color: var(--text); }
.upgrade-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Pricing */
.pricing { margin-top: -24px; }
.billing-toggle {
    display: flex; width: max-content; max-width: 100%; margin: 0 auto 24px; padding: 4px; gap: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.billing-toggle label { padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: .925rem; cursor: pointer; color: var(--text-2); }
.billing-toggle .save { font-size: .75rem; color: var(--success); margin-left: 4px; }
#period-month:checked ~ .billing-toggle label[for="period-month"],
#period-year:checked ~ .billing-toggle label[for="period-year"] { background: var(--accent); color: var(--accent-text); }
#period-year:checked ~ .billing-toggle label[for="period-year"] .save { color: var(--accent-text); }
#period-month:focus-visible ~ .billing-toggle label[for="period-month"],
#period-year:focus-visible ~ .billing-toggle label[for="period-year"] { outline: 3px solid var(--accent); outline-offset: 2px; }
#period-month:checked ~ .plans .py, #period-year:checked ~ .plans .pm { display: none; }

.plans { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.plan-card {
    position: relative; display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 20px;
}
.plan-card.is-featured { border: 2px solid var(--accent); box-shadow: var(--shadow); }
.plan-flag {
    position: absolute; top: -12px; left: 20px; padding: 2px 10px; border-radius: 999px;
    background: var(--accent); color: var(--accent-text); font-size: .75rem; font-weight: 800;
}
.plan-card h2 { margin: 0; }
.price { margin: 12px 0 0; }
.price strong { font-size: 2.2rem; letter-spacing: -.03em; }
.price span { color: var(--muted); font-weight: 600; }
.price-note { margin: 0 0 12px; }
.plan-features { list-style: none; padding: 0; margin: 8px 0 20px; flex: 1; }
.plan-features li { padding: 7px 0 7px 26px; position: relative; border-top: 1px solid var(--border); font-size: .925rem; }
.plan-features li::before { content: "✓"; position: absolute; left: 4px; color: var(--success); font-weight: 800; }
.plan-features li.no { color: var(--muted); text-decoration: line-through; }
.plan-features li.no::before { content: "–"; color: var(--muted); }
.is-current { cursor: default; opacity: .8; }
.center { text-align: center; }
.faq { max-width: 760px; margin-top: 40px; }
.faq h2 { text-align: center; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 8px; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { margin: 10px 0 0; color: var(--text-2); }

@media (min-width: 860px) {
    .plans { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
}

/* Dashboard: create link */
.create-link { display: flex; flex-direction: column; gap: 10px; }
.create-link input { width: 100%; min-width: 0; height: 46px; padding: 0 14px; font: inherit; font-size: 1rem; color: var(--text); background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); }
.create-link input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.create-link .btn { height: 46px; }
.created { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.created a { font-weight: 800; word-break: break-all; }
@media (min-width: 640px) {
    .create-link { flex-direction: row; }
    .create-link input[name="url"] { flex: 2; }
    .create-link input[name="alias"] { flex: 1; }
}

/* Contact page */
.contact-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 24px; }
.contact-grid .panel { margin: 0; }
.contact-grid h2 { margin-top: 0 !important; }
@media (min-width: 760px) { .contact-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Billing: plan choice and checkout */
.plan-pick { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.plan-pick legend { font-weight: 650; font-size: .925rem; margin-bottom: 6px; padding: 0; }
.plan-option {
    display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; cursor: pointer;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.plan-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.plan-option input { margin-top: 4px; accent-color: var(--accent); flex: none; }
.plan-option span { display: flex; flex-direction: column; gap: 2px; }
.plan-option em { font-style: normal; font-weight: 700; color: var(--text); }
.stack-form h3 { margin: 8px 0 0; font-size: 1rem; }
.checkout { border: 2px solid var(--accent); }
.checkout .btn { margin: 4px 0 8px; }
@media (min-width: 640px) { .plan-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Two-factor setup */
.totp-setup { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin: 12px 0; }
.totp-qr { width: 180px; height: 180px; background: #fff; border-radius: 10px; padding: 6px; border: 1px solid var(--border); image-rendering: pixelated; }
.totp-secret { font-size: 1rem; letter-spacing: .06em; word-break: break-all; }
.backup-codes { font: 1.05rem/1.7 var(--mono); columns: 2; max-width: 320px; margin: 8px 0 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ok-text { color: var(--success); }
#two-factor details > summary { list-style: none; display: inline-flex; margin: 4px 0; cursor: pointer; }
#two-factor details > summary::-webkit-details-marker { display: none; }

/* Settings: danger zone */
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.danger-zone details > summary { list-style: none; display: inline-flex; cursor: pointer; }
.danger-zone details > summary::-webkit-details-marker { display: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); color: #fff; }

/* Dashboard: API key restrictions */
.new-key { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.new-key h3 { margin: 0; }
.key-edit { display: inline-block; text-align: left; }
.key-edit > summary { list-style: none; display: inline-flex; cursor: pointer; }
.key-edit > summary::-webkit-details-marker { display: none; }
.key-edit[open] .stack-form { position: absolute; right: 16px; z-index: 3; width: min(320px, 85vw); padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); }

/* Link options (create, bulk import, link settings) */
.link-options { margin-top: 12px; }
.link-options > summary { cursor: pointer; font-weight: 650; font-size: .925rem; color: var(--accent); }
.options-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); margin-top: 12px; }
.options-grid .wide, .options-grid fieldset { grid-column: 1 / -1; }
.options-grid .field input:not([type="checkbox"]), .options-grid select {
    width: 100%; min-width: 0; height: 44px; padding: 0 12px;
    font: inherit; font-size: .95rem; color: var(--text); background: var(--surface-2);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.options-grid .field input:focus, .options-grid select:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.options-grid input:disabled { opacity: .55; cursor: not-allowed; }
.options-grid .check { margin-top: 8px; }
.options-grid p { margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 650; font-size: .925rem; margin-bottom: 4px; padding: 0; }
.utm .options-grid { margin-top: 6px; }
@media (min-width: 640px) {
    .options-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .utm .options-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Link settings panel */
.link-settings > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.link-settings > summary::-webkit-details-marker { display: none; }
.link-settings > summary h2 { margin: 0; }
.link-settings > summary h2::after { content: " ▾"; color: var(--muted); font-size: .9rem; }
.link-settings[open] > summary h2::after { content: " ▴"; }
.link-tags { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700;
    background: var(--accent-soft); color: var(--accent); vertical-align: middle;
}
.link-main strong .tag { margin-left: 6px; }

/* Status pills (domains, webhooks) */
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.status-active { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.status-pending { background: color-mix(in srgb, #d97706 18%, transparent); color: #b45309; }
.status-error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.flash-warn { background: color-mix(in srgb, #d97706 16%, var(--surface)); }
.dns-table code { word-break: break-all; font-size: .85rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.inline-fields { margin-top: 12px; }
.inline-fields label { display: block; font-weight: 650; font-size: .925rem; margin-bottom: 6px; }
.field-inline { display: flex; gap: 8px; }
.field-inline input {
    flex: 1; min-width: 0; height: 40px; padding: 0 12px; font: inherit; font-size: .95rem; color: var(--text);
    background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.field-inline .btn { height: 40px; }
.stack-form textarea { min-height: 120px; }

/* Password-protected link */
.password-form { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px auto 0; max-width: 420px; }
.password-form input {
    flex: 1 1 200px; min-width: 0; height: 48px; padding: 0 14px; font: inherit; font-size: 1rem; color: var(--text);
    background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.password-form .btn { height: 48px; }
.panel h3 { margin: 18px 0 6px; }
.select-sm { height: 34px; padding: 0 8px; font-size: .85rem; width: auto; }
.team-list li { flex-wrap: wrap; }
.member-actions { margin-top: 0; }

/* Analytics */
.stat-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 860px) { .stat-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat-card .muted.small { display: block; margin-top: 2px; }
.rank-list li { flex-wrap: wrap; row-gap: 4px; }
.rank-bar { flex-basis: 100%; width: 100%; height: 6px; }
.chart-hours { margin-top: 4px; }

/* QR designer */
.qr-layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.qr-stage { display: flex; justify-content: center; }
.qr-preview { width: 260px; height: 260px; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.qr-controls input[type="color"] { width: 100%; height: 44px; padding: 2px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
@media (min-width: 760px) { .qr-layout { grid-template-columns: 280px minmax(0, 1fr); } }

/* Link-in-bio pages */
.bio-accent-indigo { --bio: #4f46e5; } .bio-accent-blue { --bio: #2563eb; } .bio-accent-teal { --bio: #0d9488; } .bio-accent-green { --bio: #16a34a; }
.bio-accent-orange { --bio: #ea580c; } .bio-accent-pink { --bio: #db2777; } .bio-accent-red { --bio: #dc2626; } .bio-accent-slate { --bio: #334155; }
.bio-body { min-height: 100vh; background: linear-gradient(180deg, color-mix(in srgb, var(--bio) 14%, var(--bg)) 0%, var(--bg) 60%); }
.bio-page { max-width: 560px; margin: 0 auto; padding: 48px 16px 32px; text-align: center; }
.bio-head h1 { font-size: 1.6rem; margin: 14px 0 6px; }
.bio-head p { color: var(--text-2); margin: 0 auto; max-width: 440px; }
.bio-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; display: inline-block; border: 3px solid var(--surface); box-shadow: var(--shadow); }
.bio-initials { display: inline-flex; align-items: center; justify-content: center; background: var(--bio); color: #fff; font-size: 2rem; font-weight: 800; }
.bio-links { list-style: none; margin: 28px 0; padding: 0; display: grid; gap: 12px; }
.bio-link {
    display: block; padding: 15px 18px; border-radius: 14px; background: var(--bio); color: #fff; font-weight: 700; text-decoration: none;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--bio) 30%, transparent); transition: transform .12s ease;
}
.bio-link:hover, .bio-link:focus-visible { transform: translateY(-2px); color: #fff; }
.bio-foot { font-size: .85rem; color: var(--muted); }
.bio-foot a { color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; border-radius: 999px; border: 1.5px solid var(--border); cursor: pointer; font-size: .875rem; }
.swatch::before { content: ""; width: 16px; height: 16px; border-radius: 50%; background: var(--bio); }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch:has(input:checked) { border-color: var(--bio); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bio) 30%, transparent); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.bio-row { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); margin-bottom: 8px; }
.bio-row input, .bio-row select { height: 44px; padding: 0 12px; }
.bio-form .bio-row input { width: 100%; min-width: 0; font: inherit; color: var(--text); background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); }
.prefix-input { align-items: center; }
.prefix-input span { white-space: nowrap; }
@media (min-width: 640px) { .bio-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); } }
.trial-note { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0; }
.trial-flag { display: inline-block; margin: 6px 0 0; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); font-size: .8rem; font-weight: 700; }

/* Status page */
.status-wrap { max-width: 760px; }
.status-banner { display: flex; flex-direction: column; gap: 2px; padding: 18px 20px; border-radius: var(--radius); color: #fff; margin-bottom: 16px; }
.status-banner strong { font-size: 1.25rem; }
.status-banner.status-ok { background: var(--success); }
.status-banner.status-degraded, .status-banner.status-maintenance { background: #d97706; }
.status-banner.status-major { background: var(--danger); }
.status-list { list-style: none; margin: 0 0 16px; padding: 0; }
.status-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.status-list li:first-child { border-top: 0; }
.uptime { display: grid; grid-template-columns: repeat(90, minmax(0, 1fr)); gap: 2px; height: 34px; }
.uptime-day { border-radius: 2px; background: var(--border); }
.uptime-day.day-ok { background: var(--success); }
.uptime-day.day-degraded { background: #f59e0b; }
.uptime-day.day-major { background: var(--danger); }
.uptime-legend { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.incident { border-left: 4px solid #d97706; }
.status-wrap .panel { text-align: left; }
.rank-bar::-webkit-meter-optimum-value { background: var(--accent); }
.rank-bar::-moz-meter-bar { background: var(--accent); }
.rank-bar::-webkit-meter-bar { background: var(--surface-2); border: 0; border-radius: 3px; }
