html, body { min-height: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--text);
    background: radial-gradient(900px 480px at 50% -12%, var(--bg-2), transparent 70%), var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

main {
    flex: 1;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: var(--s4) var(--s5) var(--s7);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.hero { text-align: center; margin: var(--s4) 0 var(--s5); }
.hero h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    line-height: var(--lh-tight);
    letter-spacing: -0.025em;
    font-weight: 800;
    color: var(--text);
}
.hero h1 .grad { color: var(--brand); }
.hero .subtitle { margin: var(--s3) auto 0; color: var(--muted); font-size: var(--fs-md); max-width: 640px; line-height: var(--lh-body); font-weight: 500; }

@media (min-width: 761px) {
    .hero h1 { font-size: var(--fs-3xl); }
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--s5);
}
.auth-prompt { text-align: center; margin-top: var(--s4); padding-top: var(--s6); padding-bottom: var(--s6); }
#shortenPanel { margin-top: var(--s4); }
.auth-prompt .prompt-title { margin: 0 0 var(--s3); font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.02em; }
.auth-prompt .prompt-text { margin: 0 auto var(--s5); color: var(--muted); max-width: 400px; line-height: var(--lh-body); }
.gsi-prompt { display: flex; justify-content: center; }
.gsi-prompt > div { margin: 0 auto !important; }
select.input { cursor: pointer; }
.field { margin-bottom: var(--s4); }
.field.optional .field-label { color: var(--muted); font-weight: 500; }
.field.optional .field-label span { color: var(--muted); font-weight: 400; opacity: 0.75; }
.field.optional .input { background: var(--bg); }
.form-actions { display: flex; }
.submit-btn { flex: 1; height: 52px; font-size: var(--fs-base); font-weight: 700; }
.status { margin-top: var(--s3); font-size: var(--fs-sm); color: var(--muted); min-height: 18px; text-align: center; }
/* Small spinner in front of the "Creating short URL…" status while shortening */
#status.creating::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 7px;
    vertical-align: -2px;
    border: 2px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result {
    display: none; margin-top: var(--s4);
    border: 1px solid var(--ok-line); background: var(--ok-bg);
    border-radius: var(--r-md); padding: var(--s4);
}
.result-head { display: flex; align-items: center; gap: var(--s2); color: var(--ok-text); font-weight: 700; font-size: var(--fs-sm); }
.result a {
    display: block; margin: var(--s2) 0 var(--s4); color: var(--brand); font-weight: 700;
    word-break: break-all; text-decoration: none; font-size: var(--fs-md);
}
.result-actions { display: flex; gap: var(--s2); }
.result-actions .btn { flex: 1; padding: 12px; font-size: var(--fs-sm); }

.recent {
    margin-top: var(--s5);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--s4);
}
.recent-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
    padding: var(--s1) var(--s2) var(--s3);
}
.recent-title {
    margin: 0; font-family: var(--font-display); font-size: var(--fs-base);
    font-weight: 700; letter-spacing: -0.01em;
}
.recent-sub { margin: 2px 0 0; color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
.recent-clear {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    min-height: 30px; padding: 0 10px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--card); color: var(--muted);
    font: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.recent-clear:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.recent-clear:active { transform: translateY(1px); }
.recent-list { display: grid; gap: var(--s2); }
.recent-item {
    display: grid; grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center; gap: var(--s3);
    padding: var(--s3); border-radius: var(--r-md); background: var(--bg);
    transition: background 0.15s ease;
}
.recent-item:hover { background: var(--brand-soft); }
.recent-favicon {
    width: 38px; height: 38px; border-radius: var(--r-sm);
    display: grid; place-items: center;
    background: var(--card); border: 1px solid var(--line);
    color: var(--brand); font-family: var(--font-display);
    font-size: var(--fs-sm); font-weight: 700;
}
.recent-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.recent-short {
    color: var(--text); font-weight: 600; font-size: var(--fs-sm);
    text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent-short:hover { color: var(--brand); }
.recent-original {
    color: var(--muted); font-size: var(--fs-xs); line-height: 1.4;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.recent-copy {
    border: 1px solid var(--line); background: var(--card); color: var(--text);
    border-radius: var(--r-sm); font: inherit; font-size: var(--fs-xs); font-weight: 600;
    min-height: 30px; min-width: 62px; padding: 0 10px; cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.recent-copy:hover { border-color: var(--brand); color: var(--brand); }
.recent-copy:active { transform: translateY(1px); }
.recent-time { color: var(--muted); font-size: 0.6875rem; line-height: 1; }
.recent-empty {
    border: 1px dashed var(--line); border-radius: var(--r-md);
    padding: var(--s5) var(--s4); text-align: center; background: var(--bg);
}
.recent-empty-title { display: block; font-weight: 600; font-size: var(--fs-sm); }
.recent-empty-text { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }

footer { text-align: center; color: var(--muted); font-size: var(--fs-sm); padding: var(--s5) var(--s4) calc(var(--s6) + env(safe-area-inset-bottom, 0px)); line-height: var(--lh-body); }

@media (min-width: 560px) {
    main { padding: var(--s5) var(--s5) var(--s7); }
    .panel { padding: var(--s6); }
}
