/* ---------------------------------------------------------------------------
   Shorten URL - self-contained stylesheet.

   No framework and no webfont: the page is one card, and pulling in a full
   design system for it cost ~400KB and forced 'unsafe-inline' into the CSP.
   Colours are tokens so the dark theme is a token swap, not a second sheet.
--------------------------------------------------------------------------- */

:root {
    --bg:            #eef2fb;
    --bg-accent-a:   #6366f1;
    --bg-accent-b:   #0ea5e9;
    --surface:       #ffffff;
    --surface-sunk:  #f6f8fd;
    --border:        #e2e8f4;
    --border-strong: #cbd5e6;
    --text:          #16203a;
    --text-muted:    #64748b;
    --accent:        #4f46e5;
    --accent-hover:  #4338ca;
    --accent-soft:   #eef0ff;
    --success:       #059669;
    --success-soft:  #ecfdf5;
    --danger:        #dc2626;
    --danger-soft:   #fef2f2;
    --focus-ring:    rgba(79, 70, 229, 0.35);
    --shadow:        0 20px 50px -20px rgba(15, 23, 42, 0.35);
    --radius:        16px;
    --radius-sm:     10px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:            #0b1020;
        --bg-accent-a:   #4338ca;
        --bg-accent-b:   #0369a1;
        --surface:       #151c31;
        --surface-sunk:  #1b2440;
        --border:        #2a3453;
        --border-strong: #3a4770;
        --text:          #e8edf9;
        --text-muted:    #94a3c4;
        --accent:        #7c83ff;
        --accent-hover:  #949aff;
        --accent-soft:   #232b4d;
        --success:       #34d399;
        --success-soft:  #10291f;
        --danger:        #f87171;
        --danger-soft:   #2c1618;
        --focus-ring:    rgba(124, 131, 255, 0.4);
        --shadow:        0 24px 60px -24px rgba(0, 0, 0, 0.8);
    }
}

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

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* Two soft blobs instead of a flat gradient - keeps the backdrop from banding
   on wide screens. Fixed so it does not scroll with the content. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(60rem 40rem at 12% -10%, var(--bg-accent-a), transparent 60%),
        radial-gradient(50rem 36rem at 96% 8%,  var(--bg-accent-b), transparent 55%);
    opacity: 0.18;
    pointer-events: none;
}

/* --- layout ------------------------------------------------------------- */

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 16px;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 650;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
}

.brand img { width: 30px; height: 30px; display: block; }

.session-chip {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.82rem;
    color: var(--text-muted);
    max-width: 60vw;
}

.session-chip[data-visible="true"] { display: inline-flex; }

.session-chip strong {
    color: var(--text);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

main {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px 56px;
}

.site-footer {
    padding: 20px 16px 28px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.site-footer a { color: var(--text-muted); }

/* --- card --------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 34px 30px;
}

.card-lede { text-align: center; margin-bottom: 26px; }

.card-lede h1 {
    margin: 0 0 8px;
    font-size: 1.6rem;
    font-weight: 680;
    letter-spacing: -0.02em;
}

.card-lede p { margin: 0; color: var(--text-muted); font-size: 0.94rem; }

.lock-badge {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
}

.lock-badge svg { width: 26px; height: 26px; }

/* --- form --------------------------------------------------------------- */

.field { margin-bottom: 18px; }

.field label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
}

.input-shell {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    background: var(--surface-sunk);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-shell:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.input-shell svg { width: 18px; height: 18px; color: var(--text-muted); flex: none; }

.input-shell input {
    flex: 1;
    min-width: 0;
    padding: 13px 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
}

.input-shell input:focus { outline: none; }
.input-shell input::placeholder { color: var(--text-muted); opacity: 0.8; }

/* --- buttons ------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus-ring); }

.btn-primary { width: 100%; background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-quiet {
    padding: 6px 12px;
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.btn-quiet:hover { color: var(--text); border-color: var(--accent); }

.btn:disabled { opacity: 0.6; cursor: progress; }

/* Spinner shown only while a button is busy. */
.btn .spinner { display: none; width: 16px; height: 16px; }
.btn[data-busy="true"] .spinner { display: block; animation: spin 0.7s linear infinite; }
.btn[data-busy="true"] .btn-label { opacity: 0.75; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .btn .spinner { animation-duration: 2s; }
    * { transition-duration: 0.01ms !important; }
}

/* --- result ------------------------------------------------------------- */

.result {
    margin-top: 24px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--success-soft);
}

.result-label {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--success);
}

.result-label svg { width: 16px; height: 16px; }

.result-row { display: flex; gap: 10px; align-items: stretch; }

.result-row a {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-row a:hover { text-decoration: underline; }

.result-row .btn { flex: none; padding: 11px 16px; background: var(--accent); color: #fff; }
.result-row .btn:hover { background: var(--accent-hover); }

.result-target {
    margin: 10px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- messages ----------------------------------------------------------- */

.message {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid currentColor;
}

.message[data-tone="success"] { background: var(--success-soft); color: var(--success); }
.message svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

[hidden] { display: none !important; }

/* --- history ------------------------------------------------------------ */

.history { margin-top: 26px; }

.history h2 {
    margin: 0 0 12px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.history ul { list-style: none; margin: 0; padding: 0; }

.history li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    margin-bottom: 8px;
}

.history .history-short {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}

.history .history-short:hover { text-decoration: underline; }

.history .history-long {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-copy {
    flex: none;
    padding: 5px 10px;
    font-size: 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    cursor: pointer;
}

.history-copy:hover { color: var(--text); border-color: var(--accent); }

.hint {
    margin: 18px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* --- toast -------------------------------------------------------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translate(-50%, 16px);
    padding: 11px 18px;
    border-radius: 999px;
    background: var(--text);
    color: var(--surface);
    font-size: 0.86rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50;
}

.toast[data-visible="true"] { opacity: 1; transform: translate(-50%, 0); }

/* --- narrow screens ----------------------------------------------------- */

@media (max-width: 560px) {
    .card { padding: 26px 18px; }
    .card-lede h1 { font-size: 1.35rem; }
    .result-row { flex-direction: column; }
    .result-row .btn { width: 100%; }
    .history li { flex-wrap: wrap; }
    .history .history-long { flex-basis: 100%; order: 3; }
}
