/* Recap web theme: matches the desktop app's dark UI and coral logo. */
:root {
    --bg: #111318;
    --bg-raised: #16181f;
    --surface: #1b1d26;
    --border: #2b2e3a;
    --border-strong: #3f4350;
    --text: #f5f7fb;
    --muted: #a4b0c5;
    --faint: #6c7589;
    --coral: #f76b4a;
    --coral-2: #ef4f55;
    --grad: linear-gradient(135deg, #f7804a 0%, #ef4f55 100%);
    --ring: rgba(247, 107, 74, 0.28);
    --error-bg: rgba(205, 64, 77, 0.12);
    --error-border: rgba(255, 124, 115, 0.3);
    --error-text: #ff9b92;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

svg { fill: currentColor; }
a { color: var(--coral); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.brand-row img { border-radius: 10px; }

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

.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}

.showcase {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 48px clamp(32px, 6vw, 88px);
    background:
        radial-gradient(900px 600px at 0% 100%, rgba(239, 79, 85, 0.18), transparent 60%),
        radial-gradient(700px 500px at 100% 0%, rgba(247, 128, 74, 0.12), transparent 60%),
        var(--bg-raised);
    border-right: 1px solid var(--border);
}

/* The Recap aperture, drawn large and faded in the background. */
.aperture {
    position: absolute;
    right: -180px;
    bottom: -180px;
    width: 620px;
    height: 620px;
    background: var(--grad);
    clip-path: polygon(50% 0%, 90% 20%, 100% 62%, 75% 100%, 25% 100%, 0% 62%, 10% 20%);
    -webkit-mask: radial-gradient(circle, transparent 34%, #000 35%);
    mask: radial-gradient(circle, transparent 34%, #000 35%);
    opacity: 0.1;
    animation: turn 60s linear infinite;
}
@keyframes turn { to { transform: rotate(360deg); } }

.showcase-inner { position: relative; max-width: 480px; }

.showcase h1 {
    margin: 56px 0 18px;
    font-size: clamp(2.4rem, 4.4vw, 3.5rem);
    line-height: 1.05;
    font-weight: 700;
    letter-spacing: -0.03em;
}
.grad {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lede { margin: 0 0 36px; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }

.features { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.features li { display: flex; align-items: center; gap: 14px; color: var(--text); font-size: 0.95rem; }
.features svg {
    width: 36px;
    height: 36px;
    padding: 9px;
    flex-shrink: 0;
    color: var(--coral);
    background: rgba(247, 107, 74, 0.1);
    border: 1px solid rgba(247, 107, 74, 0.2);
    border-radius: 10px;
}

.panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    padding: 48px 32px;
    animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.mobile-brand { display: none; }

.form-head { margin-bottom: 28px; }
.form-head h2 { margin: 0 0 6px; font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.form-head p { margin: 0; color: var(--muted); }

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    margin-bottom: 20px;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--error-text);
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: 12px;
    animation: shake 0.35s;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.field { margin-bottom: 18px; }

label { display: block; margin-bottom: 8px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }

.input-wrap { position: relative; }
.input-wrap > svg {
    position: absolute;
    left: 14px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    color: var(--faint);
    pointer-events: none;
    transition: color 0.2s;
}

.input-wrap input {
    width: 100%;
    height: 50px;
    padding: 0 46px 0 44px;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrap input::placeholder { color: var(--faint); }
.input-wrap input:hover { border-color: var(--border-strong); }
.input-wrap input:focus { outline: none; border-color: var(--coral); box-shadow: 0 0 0 4px var(--ring); }
.input-wrap:focus-within > svg { color: var(--coral); }

.toggle-pw {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: var(--faint);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}
.toggle-pw:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.toggle-pw svg { width: 18px; height: 18px; }
.toggle-pw .eye-off,
.toggle-pw[aria-pressed="true"] .eye { display: none; }
.toggle-pw[aria-pressed="true"] .eye-off { display: block; }

.btn-primary {
    width: 100%;
    height: 50px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background: var(--grad);
    border: 0;
    border-radius: 12px;
    box-shadow: 0 12px 28px -12px rgba(239, 79, 85, 0.8);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
.btn-primary svg { width: 18px; height: 18px; transition: transform 0.2s; }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 16px 32px -12px rgba(239, 79, 85, 0.9); }
.btn-primary:hover svg { transform: translateX(3px); }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }

.btn-primary.loading { pointer-events: none; opacity: 0.85; }
.btn-primary.loading svg { display: none; }
.btn-primary.loading::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.switch { margin: 26px 0 0; text-align: center; font-size: 0.9rem; color: var(--muted); }

@media (max-width: 900px) {
    .auth-page { grid-template-columns: 1fr; }
    .showcase { display: none; }
    .auth-page {
        background: radial-gradient(600px 400px at 50% 0%, rgba(239, 79, 85, 0.14), transparent 70%), var(--bg);
    }
    .panel { padding: 40px 20px; }
    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 32px;
        font-size: 1.1rem;
        font-weight: 700;
    }
    .mobile-brand img { border-radius: 9px; }
}

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

.input-wrap input.mono {
    font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}

/* ---------- Dashboard ---------- */

.dash {
    min-height: 100vh;
    background:
        radial-gradient(900px 420px at 15% -10%, rgba(239, 79, 85, 0.12), transparent 70%),
        radial-gradient(700px 380px at 100% 0%, rgba(247, 128, 74, 0.07), transparent 70%),
        var(--bg);
    background-attachment: fixed;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 28px;
    background: rgba(17, 19, 24, 0.75);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.topbar .brand-row { font-size: 1rem; }
.topbar .brand-row img { border-radius: 8px; }

.user-menu { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }
.who { font-weight: 600; }
.avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    background: var(--grad);
    border-radius: 50%;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.btn-ghost svg { width: 16px; height: 16px; color: var(--muted); }
.btn-ghost:hover { border-color: var(--coral); }

.content { max-width: 1160px; margin: 0 auto; padding: 40px 28px 64px; }

.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 28px;
    animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.eyebrow { margin: 0 0 6px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--coral); }
.hero h1 { margin: 0 0 6px; font-size: clamp(1.7rem, 3vw, 2.3rem); letter-spacing: -0.025em; }
.sub { margin: 0; color: var(--muted); }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 999px;
    white-space: nowrap;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-ok { color: #4ade80; background: rgba(74, 222, 128, 0.1); border: 1px solid rgba(74, 222, 128, 0.25); }
.pill-ok i { box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.2); }
.pill-warn { color: #fbbf24; background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.25); }
.pill-warn i { box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2); }

.banner {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
    padding: 14px 18px;
    font-size: 0.9rem;
    color: #fcd34d;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 14px;
}
.banner svg { width: 20px; height: 20px; flex-shrink: 0; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
.stat {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 16px;
    transition: border-color 0.2s, transform 0.2s;
}
.stat:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.stat > div { display: grid; gap: 3px; min-width: 0; }
.stat strong { font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--faint); }
.stat-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    color: var(--coral);
    background: rgba(247, 107, 74, 0.1);
    border: 1px solid rgba(247, 107, 74, 0.2);
    border-radius: 12px;
}
.stat-icon svg { width: 20px; height: 20px; }

.tag {
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--coral);
    background: rgba(247, 107, 74, 0.1);
    border-radius: 999px;
}

.license-body { display: flex; align-items: center; gap: 32px; }

/* License ring: the arc draws in (Settings → License, replayed each time the section opens) while the
   number counts up; coral normally, amber under 25% of the term left, red under 10% or expired. */
.ring { --ring-color: #f76b4a; --ring-glow: rgba(247, 107, 74, 0.45); position: relative; width: 156px; height: 156px; flex-shrink: 0; }
.ring-warn { --ring-color: #fbbf24; --ring-glow: rgba(251, 191, 36, 0.45); }
.ring-full { --ring-color: #ef4444; --ring-glow: rgba(239, 68, 68, 0.5); }
.ring::before {   /* soft halo behind the ring */
    content: "";
    position: absolute;
    inset: 14px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--ring-glow), transparent 70%);
    opacity: 0.35;
    animation: ring-halo 3.2s ease-in-out infinite;
}
.ring svg { position: relative; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 10; }
.ring-track { stroke: var(--surface); }
.ring-fill {
    stroke: url(#ringGrad);
    stroke-linecap: round;
    stroke-dasharray: var(--dash) var(--circ);
    filter: drop-shadow(0 0 6px var(--ring-glow));
    animation: ring-draw 1.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ring-warn .ring-fill, .ring-full .ring-fill { stroke: var(--ring-color); }
@keyframes ring-draw { from { stroke-dasharray: 0 var(--circ); } }
@keyframes ring-halo { 50% { opacity: 0.6; transform: scale(1.04); } }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label strong { font-size: 2.4rem; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ring-label span { margin-top: 5px; font-size: 0.8rem; color: var(--muted); }
.ring-label .ring-expired { font-size: 1.4rem; color: #f87171; }

.details { margin: 0; display: grid; flex: 1; min-width: 0; }
.details > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.details > div:last-child { border-bottom: 0; }
.details dt { font-size: 0.85rem; color: var(--muted); }
.details dd { margin: 0; min-width: 0; font-size: 0.9rem; font-weight: 600; text-align: right; }

.key-row { display: flex; align-items: center; gap: 4px; }
.key-row code {
    padding: 4px 8px;
    font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    font-size: 0.8rem;
    background: var(--surface);
    border-radius: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.icon-btn {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    color: var(--faint);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.done { color: #4ade80; }

.btn-primary:disabled { cursor: default; filter: grayscale(0.6); opacity: 0.6; box-shadow: none; }

.shortcuts { list-style: none; margin: 0; padding: 0; }
.shortcuts li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    font-size: 0.875rem;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.shortcuts li:last-child { border-bottom: 0; }
.keys { display: flex; gap: 4px; }
kbd {
    padding: 3px 8px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
}

.pw-form .field { margin-bottom: 14px; }
.pw-form .input-wrap input { height: 44px; padding-right: 14px; }
.alert-ok { color: #86efac; background: rgba(74, 222, 128, 0.08); border-color: rgba(74, 222, 128, 0.25); animation: none; }

/* Settings → License: enter a new key once the license has expired. */
.renew-license { margin: 0 0 28px; padding: 18px 20px; border: 1px solid rgba(239, 79, 85, 0.3); border-radius: 14px; background: rgba(239, 79, 85, 0.06); }
.renew-license .subhead { margin-top: 0; color: #fca5a5; }
.renew-license .hint { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.renew-license .pw-form { max-width: 460px; }

/* Settings → License: administrator license generator. */
.license-generator { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.license-generator > .subhead { margin: 0 0 6px; }
.license-generator > .hint { margin: 0 0 18px; color: var(--muted); font-size: 0.9rem; }
.admin-license-form { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 0 14px; max-width: 760px; }
.admin-license-form .field { margin-bottom: 18px; }
.admin-license-form .btn-primary { grid-column: 1 / -1; justify-self: start; }
.admin-generated-licenses { max-width: 760px; margin-top: 26px; }
.admin-generated-licenses .subhead { margin: 20px 0 10px; }
.admin-license-key { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 10px 12px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 11px; }
.admin-license-key code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; font-size: 0.85rem; color: var(--text); }
.admin-license-key .btn-ghost { flex: none; height: 34px; padding: 0 12px; }
.admin-license-key .btn-ghost.done { color: #86efac; border-color: rgba(74, 222, 128, 0.4); }
@media (max-width: 560px) {
    .admin-license-form { grid-template-columns: 1fr; }
    .admin-license-key { align-items: stretch; flex-direction: column; }
    .admin-license-key .btn-ghost { width: 100%; }
}

/* Settings → Users: type-999 account manager. */
.user-manager { display: grid; grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr); gap: 24px; align-items: start; }
.user-list, .user-editor { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.user-list .subhead, .user-editor .subhead { margin: 0 0 14px; }
.managed-user { display: flex; align-items: center; gap: 10px; padding: 10px; color: inherit; border: 1px solid transparent; border-radius: 11px; text-decoration: none; }
.managed-user:hover { color: inherit; background: var(--bg-raised); border-color: var(--border); text-decoration: none; }
.managed-user.active { background: rgba(247, 107, 74, 0.1); border-color: rgba(247, 107, 74, 0.28); }
.managed-user .avatar { width: 32px; height: 32px; font-size: 0.78rem; }
.managed-user-name { min-width: 0; flex: 1; display: grid; gap: 2px; }
.managed-user-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.managed-user-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 0.75rem; }
.managed-user-edit { color: var(--coral); font-size: 0.78rem; font-weight: 700; }
.user-editor .hint { margin: -6px 0 18px; color: var(--muted); font-size: 0.85rem; line-height: 1.45; }
.field-optional { font-weight: 400; color: var(--faint); }
.user-edit-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.user-edit-form .field { margin-bottom: 16px; }
.user-edit-form .full-field, .user-edit-form .btn-primary { grid-column: 1 / -1; }
.user-edit-form .btn-primary { justify-self: start; }
.user-editor-empty { color: var(--muted); }
.user-editor-empty p { margin: 0; font-size: 0.9rem; }
@media (max-width: 760px) {
    .user-manager { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .user-edit-form { grid-template-columns: 1fr; }
    .user-edit-form .full-field, .user-edit-form .btn-primary { grid-column: auto; }
}

/* Settings → Devices: where the account is signed in, sign out, and recent sign-ins. */
.device-list { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 10px; }
.device { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.device.is-current { border-color: rgba(74, 222, 128, 0.35); }
.device-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: rgba(247, 128, 74, 0.12); }
.device-icon svg { width: 20px; height: 20px; fill: #f7804a; }
.device-info { flex: 1; min-width: 0; display: grid; gap: 3px; }
.device-info strong { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.device-info span { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.device-info .device-time { color: var(--faint); font-size: 0.8rem; }
.device-info .pill { font-size: 0.72rem; padding: 2px 8px; }
/* "This device": the light green dot pulses to show the session is live. */
.pill-live i { position: relative; color: #bbf7d0; box-shadow: 0 0 6px rgba(187, 247, 208, 0.7); animation: live-dot 1.6s ease-in-out infinite; }
.pill-live i::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: currentColor;
    animation: live-ring 1.6s ease-out infinite;
}
@keyframes live-dot { 50% { opacity: 0.55; } }
@keyframes live-ring { from { transform: scale(1); opacity: 0.7; } to { transform: scale(2.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .pill-live i, .pill-live i::after { animation: none; }
}
.device-note { margin: -8px 0 20px; color: var(--faint); font-size: 0.85rem; }
.signout-others { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border: 1px solid rgba(239, 68, 68, 0.3); border-radius: 14px; background: rgba(239, 68, 68, 0.06); }
.signout-others div { display: grid; gap: 4px; }
.signout-others span { color: var(--muted); font-size: 0.85rem; }
.login-history { list-style: none; margin: 0; padding: 0; }
.login-history li { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.login-history li span:nth-child(2) { color: var(--muted); overflow-wrap: anywhere; }
.login-history time { color: var(--faint); white-space: nowrap; }
@media (max-width: 640px) {
    .signout-others { flex-direction: column; align-items: stretch; }
    .login-history li { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 1000px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .topbar { padding: 12px 16px; }
    .who { display: none; }
    .content { padding: 28px 16px 48px; }
    .hero { flex-direction: column; align-items: flex-start; }
    .stats { gap: 12px; }
    .stat { padding: 14px 16px; }
    .stat-icon { display: none; }
    .stat strong { white-space: normal; font-size: 1rem; }
    .details dt { flex-shrink: 0; }
    .license-body { flex-direction: column; gap: 20px; }
    .details { width: 100%; }
}

/* ---------- Top navigation ---------- */

.topbar-left { display: flex; align-items: center; gap: 28px; min-width: 0; }
a.brand-row { color: var(--text); text-decoration: none; }
a.brand-row:hover { text-decoration: none; }

.tabs { display: flex; gap: 4px; }
.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    border-radius: 10px;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
}
.tab svg { width: 18px; height: 18px; }
.tab:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.tab.active { color: var(--text); background: var(--surface); box-shadow: inset 0 -2px 0 var(--coral); }
.tab.active svg { color: var(--coral); }

@media (max-width: 640px) {
    .topbar-left { gap: 12px; }
    .topbar .brand-row span, .tab span, .btn-label { display: none; }
    .tab { padding: 8px 10px; }
}

/* ---------- Gallery ---------- */

.gallery-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 22px;
}
.gallery-head h1 { margin: 0 0 4px; font-size: clamp(1.6rem, 3vw, 2.1rem); letter-spacing: -0.025em; }
.head-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.btn-upload { width: auto; height: 42px; margin: 0; padding: 0 18px; }
.btn-danger-ghost:hover { color: #fca5a5; border-color: #ef4444; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.search { position: relative; flex: 1 1 220px; }
.search svg { position: absolute; left: 13px; top: 50%; width: 18px; height: 18px; color: var(--faint); transform: translateY(-50%); pointer-events: none; }
.search input,
.toolbar select,
.input-wrap.plain input,
.input-wrap.plain select {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 11px;
}
.search input { padding-left: 40px; }
.toolbar select { width: auto; padding-right: 10px; cursor: pointer; }
.search input:focus,
.toolbar select:focus,
.input-wrap.plain input:focus,
.input-wrap.plain select:focus {
    outline: none;
    border-color: var(--coral);
    box-shadow: 0 0 0 4px var(--ring);
}

/* Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.media-card {
    position: relative;
    min-width: 0;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.media-card:hover { border-color: var(--border-strong); box-shadow: 0 16px 32px -18px rgba(0, 0, 0, 0.8); transform: translateY(-2px); }
.media-card.removing { opacity: 0; transform: scale(0.96); }

/* ---------- Selecting several items ---------- */

.tile-check {
    position: absolute;
    left: 8px;
    top: 8px;
    z-index: 2;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    padding: 0;
    color: transparent;
    background: rgba(17, 19, 24, 0.7);
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.15s, transform 0.15s, background 0.15s, border-color 0.15s;
}
.tile-check svg { width: 16px; height: 16px; }
/* The tick takes the badge's corner while hovering or selecting, so they never overlap. */
.media-card:hover .tile-check, .media-card:focus-within .tile-check,
body.selecting .tile-check, .media-card.selected .tile-check { opacity: 1; transform: none; }
.media-card:hover .tile-badge, .media-card:focus-within .tile-badge,
body.selecting .tile-badge, .media-card.selected .tile-badge { opacity: 0; }
.tile-badge { transition: opacity 0.15s; }
.tile-check:hover { border-color: #fff; }
.media-card.selected .tile-check { color: #fff; background: var(--coral); border-color: var(--coral); }
.media-card.selected { outline: 2px solid var(--coral); outline-offset: -2px; }
.media-card.selected .thumb { opacity: 0.75; }
body.selecting .media-card .thumb { cursor: pointer; }

.select-bar {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    transform: translateX(-50%);
    background: rgba(22, 24, 31, 0.92);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: select-bar-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.select-bar[hidden] { display: none; }
.select-count { padding: 0 6px; font-size: 0.9rem; color: var(--muted); }
.select-count strong { color: var(--text); font-variant-numeric: tabular-nums; }
.select-bar .btn-ghost { height: 38px; }
.select-bar .btn-primary { width: auto; height: 38px; margin: 0; padding: 0 16px; }
.select-bar .btn-primary svg { width: 16px; height: 16px; }
@keyframes select-bar-in { from { opacity: 0; transform: translate(-50%, 14px); } }
@media (max-width: 560px) {
    .select-bar { left: 12px; right: 12px; bottom: 12px; transform: none; justify-content: space-between; }
    @keyframes select-bar-in { from { opacity: 0; transform: translateY(14px); } }
}

.thumb {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    padding: 0;
    background: #0c0d11;
    border: 0;
    cursor: zoom-in;
    overflow: hidden;
}
.thumb img, .thumb video { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; transition: transform 0.35s; }
.media-card:hover .thumb img, .media-card:hover .thumb video { transform: scale(1.04); }
.thumb:focus-visible { outline: 2px solid var(--coral); outline-offset: -2px; }

.play {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    color: #fff;
    background: rgba(17, 19, 24, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: transform 0.2s, background 0.2s;
}
.play svg { width: 22px; height: 22px; margin-left: 3px; }
.media-card:hover .play { background: var(--coral); border-color: transparent; transform: translate(-50%, -50%) scale(1.08); }

.file-art {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 6px;
    color: var(--faint);
    background: radial-gradient(circle at 50% 40%, rgba(167, 139, 250, 0.12), transparent 60%), #0f1116;
}
.kind-video .file-art { background: radial-gradient(circle at 50% 40%, rgba(247, 107, 74, 0.14), transparent 60%), #0f1116; }
.file-art svg { width: 40px; height: 40px; }
.file-art b { font-size: 0.75rem; letter-spacing: 0.08em; color: var(--muted); }

.badge {
    position: absolute;
    left: 10px;
    top: 10px;
    padding: 3px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #fff;
    border-radius: 6px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.badge-image { background: rgba(14, 116, 144, 0.8); }
.badge-video { background: rgba(194, 65, 50, 0.85); }
.badge-file { background: rgba(109, 40, 217, 0.75); }

.card-actions {
    position: absolute;
    right: 8px;
    top: 8px;
    display: flex;
    gap: 2px;
    padding: 3px;
    background: rgba(17, 19, 24, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s;
}
.media-card:hover .card-actions, .media-card:focus-within .card-actions { opacity: 1; transform: none; }
.card-actions .icon-btn { width: 30px; height: 30px; color: var(--muted); }
.card-actions .icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
@media (hover: none) {
    .card-actions { opacity: 1; transform: none; }
}

.meta { display: grid; gap: 3px; padding: 12px 14px 14px; }
.meta .title { overflow: hidden; font-size: 0.9rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.sub-meta { font-size: 0.78rem; color: var(--faint); }

.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 28px; font-size: 0.875rem; color: var(--muted); }
.pager a { text-decoration: none; }

.empty {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 64px 24px;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: 18px;
}
.empty-art {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    color: var(--coral);
    background: rgba(247, 107, 74, 0.1);
    border-radius: 18px;
}
.empty-art svg { width: 30px; height: 30px; }
.empty h2 { margin: 0; font-size: 1.15rem; }
.empty p { max-width: 380px; margin: 0; font-size: 0.9rem; line-height: 1.5; color: var(--muted); }

/* Drop overlay */
.dropzone {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(10, 11, 15, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: none;
}
.dropzone[hidden] { display: none; }
.dropzone > div {
    display: grid;
    justify-items: center;
    gap: 6px;
    width: min(520px, 100%);
    padding: 56px 24px;
    text-align: center;
    background: rgba(247, 107, 74, 0.06);
    border: 2px dashed var(--coral);
    border-radius: 24px;
}
.dropzone svg { width: 48px; height: 48px; margin-bottom: 6px; color: var(--coral); }
.dropzone strong { font-size: 1.3rem; }
.dropzone span { color: var(--muted); }

/* Item menu */
.menu {
    position: fixed;
    z-index: 60;
    min-width: 190px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.7);
}
.menu button {
    display: block;
    width: 100%;
    padding: 9px 12px;
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    color: var(--text);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { outline: none; background: rgba(255, 255, 255, 0.06); }
.menu .danger { color: #fca5a5; }
.menu hr { margin: 6px 4px; border: 0; border-top: 1px solid var(--border); }

/* Dialogs */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(6, 7, 10, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

.modal {
    width: min(420px, calc(100vw - 32px));
    padding: 24px;
    background: var(--bg-raised);
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8);
}
.modal h2 { margin: 0 0 8px; font-size: 1.1rem; overflow-wrap: anywhere; }
.modal p { margin: 0 0 16px; font-size: 0.9rem; line-height: 1.5; color: var(--muted); }
.modal .field { margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions .btn-primary { width: auto; height: 40px; margin: 0; padding: 0 18px; }
.modal-actions .btn-ghost { height: 40px; }
.btn-primary.btn-danger { background: #dc2626; box-shadow: 0 10px 24px -12px rgba(220, 38, 38, 0.8); }

.viewer {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    background: rgba(8, 9, 12, 0.94);
    border: 0;
}
.viewer[open] { display: grid; grid-template-rows: auto 1fr; }
.viewer-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 16px 12px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.viewer-title { display: grid; gap: 2px; min-width: 0; }
.viewer-title strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.viewer-title span { font-size: 0.8rem; color: var(--muted); }
.viewer-actions { display: flex; gap: 4px; }
.viewer-actions .icon-btn { width: 38px; height: 38px; }
.viewer-actions .icon-btn svg { width: 20px; height: 20px; }
.viewer-actions .icon-btn.danger:hover { color: #ff6b6b; background: rgba(255, 107, 107, 0.14); }
.viewer-stage { display: grid; place-items: center; min-height: 0; padding: 20px 72px; }
.viewer-stage img, .viewer-stage video {
    max-width: 100%;
    max-height: calc(100vh - 110px);
    border-radius: 10px;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);
}
.viewer-nav {
    position: fixed;
    top: 50%;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    color: var(--text);
    background: rgba(27, 29, 38, 0.8);
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    cursor: pointer;
    transform: translateY(-50%);
}
.viewer-nav:hover { background: var(--coral); border-color: transparent; }
.viewer-nav svg { width: 24px; height: 24px; }
.viewer-nav.prev { left: 16px; }
.viewer-nav.next { right: 16px; }
.viewer-nav[hidden] { display: none; }
.viewer-file { display: grid; justify-items: center; gap: 8px; max-width: 360px; text-align: center; }
.viewer-file .file-art.big { position: static; width: 120px; height: 140px; margin-bottom: 8px; border: 1px solid var(--border-strong); border-radius: 16px; }
.viewer-file .file-art.big b { font-size: 1rem; }
.viewer-file span { font-size: 0.9rem; color: var(--muted); }
.viewer-file .btn-primary { width: auto; margin-top: 10px; padding: 0 24px; text-decoration: none; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 70;
    max-width: calc(100vw - 32px);
    padding: 11px 18px;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: 0 16px 32px -12px rgba(0, 0, 0, 0.7);
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { color: var(--error-text); border-color: var(--error-border); }

@media (max-width: 640px) {
    .gallery-head { flex-direction: column; align-items: stretch; }
    .head-actions { justify-content: flex-start; }
    .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .meta { padding: 10px; }
    .viewer-stage { padding: 12px; }
    .viewer-nav { top: auto; bottom: 16px; transform: none; }
}

/* ---------- Overview (home) ---------- */

.hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-primary.btn-inline { width: auto; height: 42px; margin: 0; padding: 0 18px; text-decoration: none; }
.license-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
}
.license-chip svg { width: 16px; height: 16px; color: var(--coral); }
.license-chip:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }

a.stat { color: inherit; text-decoration: none; }
a.stat:hover { text-decoration: none; }
.stat-icon.icon-image { color: #38bdf8; background: rgba(56, 189, 248, 0.1); border-color: rgba(56, 189, 248, 0.22); }
.stat-icon.icon-file { color: #a78bfa; background: rgba(167, 139, 250, 0.1); border-color: rgba(167, 139, 250, 0.22); }

.home-section { margin-top: 30px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 1.1rem; }
.section-head a { font-size: 0.875rem; }
.home-section .empty .btn-primary { margin-top: 12px; }


.album-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.album-tile {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    color: #fff;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
}
.album-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s; }
.album-tile:hover { border-color: var(--border-strong); text-decoration: none; }
.album-tile:hover img { transform: scale(1.05); }
.album-tile-empty { display: grid; place-items: center; height: 100%; color: var(--faint); }
.album-tile-empty svg { width: 36px; height: 36px; }
.album-tile-info {
    position: absolute;
    inset: auto 0 0;
    display: grid;
    gap: 2px;
    padding: 28px 12px 10px;
    background: linear-gradient(transparent, rgba(8, 9, 12, 0.88));
}
.album-tile-info strong { overflow: hidden; font-size: 0.9rem; white-space: nowrap; text-overflow: ellipsis; }
.album-tile-info span { font-size: 0.75rem; font-weight: 500; color: rgba(255, 255, 255, 0.7); }

/* ---------- Settings ---------- */

.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; gap: 24px; }

.settings-nav {
    position: sticky;
    top: 84px;
    display: grid;
    gap: 2px;
    padding: 8px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 16px;
}
.settings-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    border-radius: 10px;
    text-decoration: none;
}
.settings-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.settings-nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.settings-nav a.active { color: var(--text); background: rgba(247, 107, 74, 0.1); }
.settings-nav a.active svg { color: var(--coral); }

.settings-panel {
    max-width: 720px;
    padding: 26px 28px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 18px;
    animation: rise 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.settings-panel[hidden] { display: none; }

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0 0 4px; font-size: 1.2rem; letter-spacing: -0.01em; }
.panel-head p { margin: 0; font-size: 0.9rem; color: var(--muted); }

.profile { display: flex; align-items: center; gap: 16px; }
.avatar.avatar-lg { width: 56px; height: 56px; font-size: 1.4rem; }

.settings-rows > div { padding: 14px 0; }

.settings-panel .pw-form { max-width: 420px; }
.settings-panel .pw-form .btn-primary { margin-top: 6px; }

.app-download {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.app-download + .app-download { margin-top: 12px; }
.app-download img { flex-shrink: 0; border-radius: 14px; box-shadow: 0 10px 24px -10px rgba(239, 79, 85, 0.6); }
.app-download > div { display: grid; flex: 1; gap: 4px; min-width: 0; }
.app-download span { font-size: 0.85rem; line-height: 1.5; color: var(--muted); }
.subhead { margin: 26px 0 6px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }


@media (max-width: 800px) {
    .settings-layout { grid-template-columns: 1fr; }
    .settings-nav { position: static; display: flex; overflow-x: auto; scrollbar-width: none; }
    .settings-nav::-webkit-scrollbar { display: none; }
    .settings-nav a { flex-shrink: 0; }
    .settings-panel { max-width: none; padding: 20px; }
}

@media (max-width: 640px) {
    .hero-actions { width: 100%; }
    .app-download { flex-wrap: wrap; }
    .panel-head { flex-wrap: wrap; }
}

/* ---------- Views & expiry ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-variant-numeric: tabular-nums;
}
.chip svg { width: 13px; height: 13px; }
.chip-warn { color: #fcd34d; background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.25); }
.chip-danger { color: #fca5a5; background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); }

label.check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}
label.check input { width: 16px; height: 16px; accent-color: var(--coral); }

/* ---------- Upload dialog ---------- */

button.btn-upload { border: 0; }

.upload-dialog { width: min(600px, calc(100vw - 32px)); padding: 0; }
.upload-dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }

.upload-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 22px 24px 0;
}
.upload-head h2 { margin: 0 0 4px; font-size: 1.2rem; }
.upload-head p { margin: 0; font-size: 0.85rem; color: var(--muted); }
.upload-head .icon-btn { width: 34px; height: 34px; }
.upload-head .icon-btn svg { width: 18px; height: 18px; }

.drop-area {
    display: grid;
    justify-items: center;
    gap: 4px;
    margin: 18px 24px 0;
    padding: 30px 20px;
    text-align: center;
    color: var(--muted);
    background: rgba(247, 107, 74, 0.04);
    border: 2px dashed var(--border-strong);
    border-radius: 16px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, padding 0.2s;
}
.drop-area strong { font-size: 1rem; color: var(--text); }
.drop-area span { font-size: 0.875rem; }
.drop-area u { color: var(--coral); text-decoration: none; font-weight: 600; }
.drop-area:hover, .drop-area.over { border-color: var(--coral); background: rgba(247, 107, 74, 0.08); }
.drop-area.disabled { pointer-events: none; opacity: 0.5; }
.drop-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    margin-bottom: 6px;
    color: var(--coral);
    background: rgba(247, 107, 74, 0.12);
    border-radius: 16px;
}
.drop-icon svg { width: 28px; height: 28px; }
/* Once files are picked, the drop area shrinks so the list has room. */
.upload-dialog.has-files .drop-area { grid-template-columns: auto auto; justify-content: center; align-items: center; gap: 4px 10px; padding: 14px 16px; }
.upload-dialog.has-files .drop-icon { width: 36px; height: 36px; margin: 0; border-radius: 10px; grid-row: span 2; }
.upload-dialog.has-files .drop-icon svg { width: 20px; height: 20px; }
.upload-dialog.has-files .drop-area strong { font-size: 0.9rem; justify-self: start; }
.upload-dialog.has-files .drop-area > span:last-child { justify-self: start; font-size: 0.8rem; }

.upload-queue {
    display: grid;
    gap: 8px;
    min-height: 0;
    margin: 14px 24px 0;
    padding: 0 2px 2px 0;
    overflow-y: auto;
    list-style: none;
}
.q-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 8px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.q-thumb {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    color: var(--faint);
    background: var(--bg);
    border-radius: 8px;
    overflow: hidden;
}
.q-thumb img { width: 100%; height: 100%; object-fit: cover; }
.q-thumb svg { width: 22px; height: 22px; }
.q-info { display: grid; gap: 3px; flex: 1; min-width: 0; }
.q-name { overflow: hidden; font-size: 0.875rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.q-state { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.q-bar { height: 4px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.q-bar i { display: block; width: 0; height: 100%; background: var(--grad); transition: width 0.2s; }
.q-item[data-state="ready"] .q-bar { visibility: hidden; }
.q-item[data-state="done"] .q-state { color: #4ade80; }
.q-item[data-state="done"] .q-bar i { background: #4ade80; }
.q-item[data-state="error"] { border-color: var(--error-border); }
.q-item[data-state="error"] .q-state { color: var(--error-text); }
.q-item[data-state="error"] .q-bar { visibility: hidden; }
.q-remove:disabled { visibility: hidden; }

.upload-options {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr;
    gap: 12px;
    margin: 18px 24px 0;
}
.upload-options .field { margin: 0; }
.upload-options label { font-size: 0.8rem; }
.upload-options .upload-date { grid-column: 1 / -1; }
.upload-options select:disabled, .upload-options input:disabled { opacity: 0.6; }

.upload-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}
#uploadSummary { font-size: 0.85rem; color: var(--muted); }
.upload-foot .btn-primary:disabled { cursor: default; filter: grayscale(0.5); opacity: 0.5; box-shadow: none; }

@media (max-width: 560px) {
    .upload-options { grid-template-columns: 1fr 1fr; }
    .upload-options .field:first-child { grid-column: 1 / -1; }
    .upload-foot { flex-direction: column; align-items: stretch; }
    .upload-foot .modal-actions { justify-content: stretch; }
    .upload-foot .modal-actions > * { flex: 1; }
}


/* ---------- Plans and storage ---------- */

/* Storage bars: a gradient bar that fills in on load, with the percentage beside it.
   Amber from 75% full (meter-warn), red from 90% (meter-full). */
.meter-row { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 10px; }
.meter { display: block; flex: 1; height: 8px; background: var(--surface); border-radius: 99px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04); }
.meter-row .meter { margin: 0; }
.meter i { display: block; height: 100%; min-width: 3px; background: var(--grad); border-radius: 99px; box-shadow: 0 0 10px rgba(247, 107, 74, 0.45); transform-origin: left; animation: meter-fill 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.meter-warn i { background: linear-gradient(90deg, #fbbf24, #f59e0b); box-shadow: 0 0 10px rgba(251, 191, 36, 0.45); }
.meter-full i { background: linear-gradient(90deg, #f87171, #ef4444); box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
.meter-pct { flex: none; min-width: 3.2em; font-size: 0.78rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; color: var(--text); }
.meter-row:has(.meter-warn) .meter-pct { color: #fbbf24; }
.meter-row:has(.meter-full) .meter-pct { color: #f87171; }
@keyframes meter-fill { from { transform: scaleX(0); } }
.stat strong small { font-size: 0.75rem; font-weight: 500; color: var(--faint); }
.stat > div { flex: 1; }
.storage-row dd { display: grid; justify-items: end; min-width: 200px; }
.storage-row .meter-row { width: 100%; }
.plan-tag {
    margin-left: 6px;
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--coral);
    background: rgba(247, 107, 74, 0.1);
    border-radius: 99px;
}
#uploadSummary.error { color: var(--error-text); }

/* ---------- Gallery (modern layout) ---------- */

.gx { max-width: 1320px; }

.gx-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px 24px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.gx-title h1 { margin: 0 0 4px; font-size: clamp(1.7rem, 3vw, 2.3rem); letter-spacing: -0.03em; }
.gx-crumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}
.gx-crumb svg { width: 16px; height: 16px; }
.gx-crumb:hover { color: var(--text); text-decoration: none; }
.gx-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-ghost.icon-only { width: 42px; height: 42px; padding: 0; justify-content: center; }
.btn-ghost.icon-only svg { width: 18px; height: 18px; }

/* Storage ring + "388 KB of 1 GB" + plan name */
.storage-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 42px;
    padding: 0 8px 0 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.storage-pill strong { color: var(--text); }
.storage-pill:hover { border-color: var(--border-strong); text-decoration: none; }
.storage-pill .plan-tag { margin: 0; }
.storage-ring { width: 26px; height: 26px; transform: rotate(-90deg); }
.storage-ring circle { fill: none; stroke-width: 3.5; }
.storage-ring .track { stroke: var(--surface); }
.storage-ring .fill { stroke: var(--coral); stroke-linecap: round; }
.storage-ring.full .fill { stroke: #ef4444; }
.storage-ring.warn .fill { stroke: #fbbf24; }
.storage-pct { padding: 2px 8px; font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--coral); background: rgba(247, 107, 74, 0.12); border-radius: 99px; }
.storage-pct.warn { color: #fbbf24; background: rgba(251, 191, 36, 0.12); }
.storage-pct.full { color: #f87171; background: rgba(239, 68, 68, 0.14); }

/* Album chips */
.album-strip {
    display: flex;
    gap: 8px;
    margin: 0 -4px 18px;
    padding: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.album-strip::-webkit-scrollbar { display: none; }
.album-chip {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 14px 0 6px;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.15s;
}
.album-chip:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.album-chip.active { color: var(--text); background: rgba(247, 107, 74, 0.1); border-color: rgba(247, 107, 74, 0.45); }
.album-chip.add { border-style: dashed; background: transparent; }
.album-chip.add:hover { color: var(--coral); border-color: var(--coral); }
.chip-cover {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 10px;
}
.chip-cover.icon { display: grid; place-items: center; color: var(--faint); background: var(--surface); }
.chip-cover.icon svg { width: 18px; height: 18px; }
.album-chip.active .chip-cover.icon, .album-chip.add .chip-cover.icon { color: var(--coral); }
.album-chip.add .chip-cover.icon { background: rgba(247, 107, 74, 0.1); }
.chip-count {
    min-width: 22px;
    padding: 1px 7px;
    font-size: 0.75rem;
    text-align: center;
    color: var(--faint);
    background: var(--surface);
    border-radius: 99px;
    font-variant-numeric: tabular-nums;
}
.album-chip.active .chip-count { color: var(--coral); background: rgba(247, 107, 74, 0.12); }
.album-chip.drop-target { border-color: var(--coral); border-style: dashed; background: rgba(247, 107, 74, 0.14); transform: scale(1.04); }
.dragging-item .album-chip[data-drop-album] { border-style: dashed; border-color: var(--border-strong); }

/* Sticky filter bar */
.gx-toolbar {
    position: sticky;
    top: 57px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 -12px 8px;
    padding: 10px 12px;
    background: rgba(17, 19, 24, 0.82);
    border-radius: 16px;
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.gx-toolbar .search { flex: 1 1 220px; }
.type-tabs {
    display: flex;
    padding: 4px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.type-tabs a {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    border-radius: 9px;
    transition: color 0.15s, background 0.15s;
}
.type-tabs a b { font-weight: 600; }
.type-tabs a svg { width: 16px; height: 16px; }
.type-tabs a span { font-size: 0.75rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.type-tabs a:hover { color: var(--text); text-decoration: none; }
.type-tabs a.active { color: #fff; background: var(--grad); box-shadow: 0 6px 16px -8px rgba(239, 79, 85, 0.8); }
.type-tabs a.active span { color: rgba(255, 255, 255, 0.8); }
.sort { position: relative; }
.sort svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; color: var(--faint); transform: translateY(-50%); pointer-events: none; }
.gx-toolbar .sort select { padding-left: 36px; }

/* Day groups */
.day-group { margin-top: 18px; }
.day-label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 1rem;
    font-weight: 700;
}
.day-label span { font-size: 0.8rem; font-weight: 500; color: var(--faint); }

/* Photo tiles: title and details over the picture */
.gx-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.tile {
    border-radius: 18px;
    background: #0c0d11;
    aspect-ratio: 4 / 3;
}
.tile .thumb { position: absolute; inset: 0; height: 100%; aspect-ratio: auto; border-radius: inherit; }
.tile .thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, transparent 28%, transparent 50%, rgba(6, 7, 10, 0.88) 100%);
    pointer-events: none;
}
.tile:hover { transform: translateY(-3px); box-shadow: 0 22px 40px -22px rgba(0, 0, 0, 0.9); border-color: rgba(247, 107, 74, 0.35); }
.tile .play { z-index: 1; }
.tile .file-art { background: radial-gradient(circle at 50% 35%, rgba(167, 139, 250, 0.16), transparent 60%), #111319; }
.tile.kind-video .file-art { background: radial-gradient(circle at 50% 35%, rgba(247, 107, 74, 0.18), transparent 60%), #111319; }
.tile.is-limited .thumb img, .tile.is-limited .thumb video { filter: grayscale(0.7) brightness(0.7); }

.tile-badge {
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 2;
    padding: 3px 8px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #fff;
    border-radius: 7px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
}
.tile .card-actions { z-index: 3; }

.tile-info {
    position: absolute;
    inset: auto 0 0;
    z-index: 2;
    display: grid;
    gap: 4px;
    padding: 12px 14px 12px;
    pointer-events: none;
}
.tile-info .title {
    overflow: hidden;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}
.tile-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.72);
}
.tile-meta > span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tile-stats { display: flex; flex-shrink: 0; gap: 5px; }
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 99px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-variant-numeric: tabular-nums;
}
.stat-pill svg { width: 12px; height: 12px; }
.stat-pill.warn { color: #fde68a; background: rgba(245, 158, 11, 0.28); }
.stat-pill.danger { color: #fecaca; background: rgba(239, 68, 68, 0.4); }

.gx-empty { margin-top: 14px; padding: 72px 24px; }
.gx-empty .btn-primary { margin-top: 14px; }

@media (max-width: 760px) {
    .gx-head { align-items: stretch; }
    .gx-actions { width: 100%; }
    .storage-pill { flex: 1; }
    .gx-toolbar { top: 53px; }
    .type-tabs { width: 100%; }
    .type-tabs a { flex: 1; justify-content: center; padding: 0 6px; }
    .type-tabs a b { display: none; }
    .gx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .tile { border-radius: 14px; }
    .tile-meta > span:first-child { display: none; }
    .tile-info { padding: 10px; }
}


/* ---------- Expired license ---------- */

.upload-blocked {
    display: grid;
    justify-items: center;
    gap: 6px;
    margin: 18px 24px 24px;
    padding: 28px 20px;
    text-align: center;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 16px;
}
.upload-blocked .drop-icon { color: #fca5a5; background: rgba(239, 68, 68, 0.12); }
.upload-blocked strong { font-size: 1rem; }
.upload-blocked span { max-width: 380px; font-size: 0.875rem; line-height: 1.5; color: var(--muted); }
.upload-blocked .btn-primary { margin-top: 10px; }
.banner-danger { color: #fca5a5; background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.3); }

.pill-admin { color: #c4b5fd; background: rgba(139, 92, 246, 0.12); border: 1px solid rgba(139, 92, 246, 0.35); }
.pill-admin i { box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2); }
.admin-tag {
    padding: 2px 7px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.15);
    border-radius: 6px;
}

/* ---------- New text file ---------- */

.text-dialog { width: min(560px, calc(100vw - 32px)); }
.text-dialog textarea {
    width: 100%;
    padding: 12px 14px;
    font: inherit;
    font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    resize: vertical;
}
.text-dialog textarea:hover { border-color: var(--border-strong); }
.text-dialog textarea:focus { outline: none; border-color: var(--coral); box-shadow: 0 0 0 4px var(--ring); }

/* ---------- Share via QR code ---------- */

.qr-dialog { width: min(360px, calc(100vw - 32px)); text-align: center; }
.qr-dialog p { margin: 0 0 16px; overflow-wrap: anywhere; }
.qr-code { width: min(240px, 70vw); margin: 0 auto 14px; padding: 10px; background: #fff; border-radius: 16px; }
.qr-code svg { display: block; width: 100%; height: auto; }
.qr-link { display: block; margin: 0 0 18px; padding: 8px 10px; font-size: 0.75rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow-wrap: anywhere; user-select: all; }
.qr-dialog .modal-actions { flex-wrap: wrap; justify-content: center; }

/* ---------- Confirm dialogs (log out) ---------- */

.confirm-dialog { width: min(380px, calc(100vw - 32px)); text-align: center; }
.confirm-dialog h2 { margin: 0 0 6px; }
.confirm-dialog p { margin: 0 0 20px; }
.confirm-dialog .modal-actions { justify-content: center; }
.confirm-dialog .modal-actions > * { flex: 1; }
.confirm-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    margin: 0 auto 14px;
    color: var(--coral);
    background: rgba(247, 107, 74, 0.12);
    border-radius: 16px;
}
.confirm-icon svg { width: 26px; height: 26px; }

.menu button[hidden] { display: none; }

/* ---------- hCaptcha on sign-in ---------- */

.captcha-box {
    display: grid;
    justify-items: center;
    gap: 10px;
    margin: 4px 0 8px;
    padding: 14px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.captcha-box p { margin: 0; font-size: 0.82rem; color: var(--muted); text-align: center; }
.captcha-box .h-captcha { min-height: 78px; }

.remember-me { margin: -4px 0 16px; font-size: 0.875rem; color: var(--muted); }
