/* ─── TOKENS (giacomo.fi design system) ───────────────────── */
:root {
    /* Dark (default) */
    --bg: #0b0d12;
    --bg-soft: #11141b;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-strong: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.09);
    --text: #f2f4f8;
    --text-muted: #9aa4b2;
    --text-faint: #5c6672;
    --accent: #6ee7ff;
    --accent-2: #a78bfa;
    --accent-3: #f0abfc;
    --glow: 0 0 40px rgba(110, 231, 255, 0.25);
    --radius: 18px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --font-body: "Inter", system-ui, -apple-system, sans-serif;
    --font-display: "Space Grotesk", sans-serif;
    --font-mono: "JetBrains Mono", monospace;

    /* Status colours (dark) */
    --red:    #fb7185; --red-glow:    rgba(251,113,133,0.45); --red-dim:    rgba(251,113,133,0.12);
    --yellow: #fbbf24; --yellow-glow: rgba(251,191,36,0.45);  --yellow-dim: rgba(251,191,36,0.12);
    --green:  #34d399; --green-glow:  rgba(52,211,153,0.45);   --green-dim:  rgba(52,211,153,0.12);
}

[data-theme="light"] {
    --bg: #f7f8fb;
    --bg-soft: #eef1f6;
    --surface: rgba(15, 18, 28, 0.03);
    --surface-strong: rgba(15, 18, 28, 0.05);
    --border: rgba(15, 18, 28, 0.1);
    --text: #10131a;
    --text-muted: #545c6b;
    --text-faint: #939cab;
    --accent: #0891b2;
    --accent-2: #7c3aed;
    --accent-3: #c026d3;
    --glow: 0 0 40px rgba(8, 145, 178, 0.18);

    --red:    #e11d48; --red-glow:    rgba(225,29,72,0.4);  --red-dim:    rgba(225,29,72,0.08);
    --yellow: #d97706; --yellow-glow: rgba(217,119,6,0.4);  --yellow-dim: rgba(217,119,6,0.08);
    --green:  #059669; --green-glow:  rgba(5,150,105,0.4);   --green-dim:  rgba(5,150,105,0.08);
}

/* ─── BASE ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    min-height: 100dvh;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    transition: background 0.5s var(--ease), color 0.5s var(--ease);
    padding-bottom: 3rem;
}

::selection { background: var(--accent); color: #04121a; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ─── BACKGROUND CANVAS + VIGNETTE ─────────────────────────── */
#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    opacity: 0.9;
}
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(120% 90% at 50% -10%, transparent 40%, var(--bg) 100%);
}

/* ─── CUSTOM CURSOR ────────────────────────────────────────── */
.cursor-dot, .cursor-ring {
    position: fixed;
    top: 0; left: 0;
    border-radius: 50%;
    pointer-events: none;
    z-index: 300;
    transform: translate(-50%, -50%);
    mix-blend-mode: difference;
}
.cursor-dot { width: 6px; height: 6px; background: #fff; }
.cursor-ring {
    width: 34px; height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: width 0.25s var(--ease), height 0.25s var(--ease), background 0.25s var(--ease);
}
.cursor-ring.is-hover { width: 56px; height: 56px; background: rgba(255, 255, 255, 0.08); }
@media (hover: none), (pointer: coarse) {
    .cursor-dot, .cursor-ring { display: none; }
}

/* ─── HEADER / NAV ─────────────────────────────────────────── */
header {
    width: 100%;
    max-width: 900px;
    padding: 1.1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 90;
    transition: background 0.4s var(--ease), backdrop-filter 0.4s var(--ease);
}
header.is-scrolled {
    background: color-mix(in srgb, var(--bg) 70%, transparent);
    backdrop-filter: blur(14px) saturate(160%);
    border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 0.7rem; }
.logo-mark {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--accent);
    transition: border-color 0.3s var(--ease), color 0.3s var(--ease);
}
.logo:hover .logo-mark { border-color: var(--accent); }
.logo-name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    line-height: 1.1;
}
.logo-sub {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.header-controls { display: flex; align-items: center; gap: 0.5rem; }

/* Theme toggle (ported from giacomo.fi) */
.theme-toggle, .icon-btn {
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s var(--ease), transform 0.3s var(--ease), color 0.3s var(--ease), background 0.3s var(--ease);
}
.theme-toggle:hover, .icon-btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.icon-btn:hover { color: var(--accent); }
.theme-toggle:active, .icon-btn:active { transform: scale(0.94); }
.theme-toggle svg { position: absolute; transition: transform 0.5s var(--ease), opacity 0.4s var(--ease); }
.theme-toggle__sun  { transform: rotate(0) scale(1); opacity: 1; }
.theme-toggle__moon { transform: rotate(-90deg) scale(0); opacity: 0; }
[data-theme="light"] .theme-toggle__sun  { transform: rotate(90deg) scale(0); opacity: 0; }
[data-theme="light"] .theme-toggle__moon { transform: rotate(0) scale(1); opacity: 1; }

/* ─── APPS MENU ────────────────────────────────────────────── */
.apps-wrapper { position: relative; }
.apps-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 300px;
    background: color-mix(in srgb, var(--bg-soft) 90%, transparent);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 30px 80px -30px rgba(0,0,0,0.55);
    backdrop-filter: blur(16px) saturate(150%);
    padding: 1.25rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: calc(100vw - 2rem);
    max-height: calc(100dvh - 5.5rem);
    overflow-y: auto;
    z-index: 200;
    /* Hidden via visibility (not display) so it can animate both ways;
       visibility:hidden also keeps the items out of the tab order. */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px) scale(0.97);
    transform-origin: top right;
    /* visibility flips instantly on open (so focus() is accepted right away)
       and is held back until the close animation has finished. */
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0s linear 0.2s;
}
.apps-dropdown.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0s linear 0s;
}
.apps-dropdown-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    padding: 0 0.5rem;
}
.apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.25rem; }
.app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 0.5rem;
    border-radius: 14px;
    transition: background 0.25s var(--ease), transform 0.25s var(--ease);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}
.app-item:active { transform: scale(0.96); }
.app-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 1.2rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: color 0.25s var(--ease), border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.app-item:focus-visible .app-icon {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
    box-shadow: 0 0 18px -4px color-mix(in srgb, var(--accent) 65%, transparent);
}
/* Hover effects only where a real pointer exists — otherwise they stick
   on touch devices after a tap. */
@media (hover: hover) {
    .app-item:hover { background: var(--surface-strong); transform: translateY(-2px); }
    .app-item:hover .app-icon {
        color: var(--accent);
        border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
        box-shadow: 0 0 18px -4px color-mix(in srgb, var(--accent) 65%, transparent);
    }
}
.app-label {
    font-size: 0.72rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-muted);
    line-height: 1.2;
}
.apps-divider { height: 1px; background: var(--border); margin: 0 0.25rem; }
.apps-footer-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.65rem;
    border-radius: 12px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--accent);
    border: 1px solid var(--border);
    width: 100%;
    transition: background 0.25s var(--ease), border-color 0.25s var(--ease), opacity 0.25s var(--ease);
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
    .apps-footer-link:hover { background: var(--surface-strong); border-color: var(--accent); }
}
.apps-footer-link:active { transform: scale(0.98); }
.apps-footer-link[disabled] { cursor: progress; opacity: 0.75; }
.apps-footer-link.is-loading i { animation: apps-spin 0.8s linear infinite; }
@keyframes apps-spin { to { transform: rotate(360deg); } }

/* Keyboard focus — the menu is fully operable without a mouse. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app-item:focus-visible, .apps-footer-link:focus-visible { outline-offset: -2px; }

/* ─── MAIN ─────────────────────────────────────────────────── */
main {
    width: 100%;
    max-width: 480px;
    padding: 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.5rem;
}

.status-card {
    background: color-mix(in srgb, var(--bg-soft) 55%, transparent);
    border: 1px solid var(--border);
    border-radius: 26px;
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(16px) saturate(150%);
    padding: 2.25rem 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    position: relative;
    overflow: hidden;
}
.status-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--card-ambient, transparent);
    transition: background 0.8s ease;
    pointer-events: none;
    border-radius: inherit;
}

.card-heading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    text-align: center;
    position: relative;
}
.card-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}
.card-eyebrow .live-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 0 var(--green-glow);
    animation: pulse 2.4s infinite;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 var(--green-glow); }
    70%  { box-shadow: 0 0 0 9px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}
.card-title {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 4vw, 1.7rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* ─── TRAFFIC LIGHT ────────────────────────────────────────── */
.light-array {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    align-items: center;
    position: relative;
}
.bulb-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    cursor: default;
}
.bulb {
    width: 72px; height: 72px;
    border-radius: 50%;
    position: relative;
    transition: opacity 0.5s ease, box-shadow 0.5s ease, transform 0.5s ease;
    opacity: 0.12;
    border: 1px solid var(--border);
}
.bulb::after {
    content: '';
    position: absolute;
    top: 16%; left: 20%;
    width: 26%; height: 16%;
    background: rgba(255,255,255,0.32);
    border-radius: 50%;
    transform: rotate(-30deg);
}
.bulb.red    { background: radial-gradient(circle at 38% 35%, #ff9aa8, #e11d48); }
.bulb.yellow { background: radial-gradient(circle at 38% 35%, #ffd97a, #d97706); }
.bulb.green  { background: radial-gradient(circle at 38% 35%, #6ee7b7, #059669); }
.bulb.active { opacity: 1; }
.bulb.active.red    { box-shadow: 0 0 22px 6px var(--red-glow),    0 0 60px 16px var(--red-dim); }
.bulb.active.yellow { box-shadow: 0 0 22px 6px var(--yellow-glow), 0 0 60px 16px var(--yellow-dim); }
.bulb.active.green  { box-shadow: 0 0 22px 6px var(--green-glow),  0 0 60px 16px var(--green-dim); }

.bulb-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.5s ease, box-shadow 0.5s ease;
}
.bulb-wrap.active-red    .bulb-dot { background: var(--red);    box-shadow: 0 0 6px 2px var(--red-glow); }
.bulb-wrap.active-yellow .bulb-dot { background: var(--yellow); box-shadow: 0 0 6px 2px var(--yellow-glow); }
.bulb-wrap.active-green  .bulb-dot { background: var(--green);  box-shadow: 0 0 6px 2px var(--green-glow); }

.light-array::before {
    content: '';
    position: absolute;
    top: 36px; left: 36px; right: 36px;
    height: 2px;
    background: var(--border);
    z-index: 0;
}
.bulb, .bulb-dot, .bulb-wrap { position: relative; z-index: 1; }

@keyframes bulb-pulse {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.12); }
    100% { transform: scale(1); }
}
.bulb.pulse { animation: bulb-pulse 0.55s cubic-bezier(0.34,1.56,0.64,1); }

/* ─── STATUS TEXT ──────────────────────────────────────────── */
.status-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    position: relative;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.1rem;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 600;
    border: 1px solid var(--border);
    transition: background 0.5s ease, color 0.5s ease, border-color 0.5s ease;
    background: var(--surface);
    color: var(--text-muted);
}
.status-badge.red    { background: var(--red-dim);    color: var(--red);    border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.status-badge.yellow { background: var(--yellow-dim); color: var(--yellow); border-color: color-mix(in srgb, var(--yellow) 35%, transparent); }
.status-badge.green  { background: var(--green-dim);  color: var(--green);  border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-dot.pulse-dot { animation: dot-blink 1.8s ease infinite; }
@keyframes dot-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.status-updated {
    font-size: 0.72rem;
    color: var(--text-faint);
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
    transition: color 0.3s var(--ease);
}
.status-updated.is-stale { color: var(--red); }

/* ─── METRICS ──────────────────────────────────────────────── */
.metrics-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
    width: 100%;
}
.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 0.875rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: border-color var(--transition, 0.25s var(--ease)), transform 0.25s var(--ease), background 0.25s var(--ease);
}
.metric-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); transform: translateY(-2px); background: var(--surface-strong); }
.metric-icon { font-size: 1.1rem; line-height: 1; margin-bottom: 0.15rem; }
.metric-value {
    font-size: 1.15rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1;
}
.metric-label {
    font-size: 0.66rem;
    font-weight: 500;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ─── INFO CARD ────────────────────────────────────────────── */
.info-card {
    background: color-mix(in srgb, var(--bg-soft) 55%, transparent);
    border: 1px solid var(--border);
    border-radius: 22px;
    backdrop-filter: blur(16px) saturate(150%);
    padding: 1.35rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.info-row { display: flex; align-items: flex-start; gap: 0.85rem; }
.info-icon {
    width: 34px; height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}
.info-row.green  .info-icon { color: var(--green);  border-color: color-mix(in srgb, var(--green) 35%, var(--border)); }
.info-row.yellow .info-icon { color: var(--yellow); border-color: color-mix(in srgb, var(--yellow) 35%, var(--border)); }
.info-row.red    .info-icon { color: var(--red);    border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.info-text strong {
    display: block;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.15rem;
}
.info-text span { font-size: 0.78rem; color: var(--text-muted); line-height: 1.45; }

/* ─── FOOTER ───────────────────────────────────────────────── */
footer {
    margin-top: auto;
    padding-top: 2.5rem;
    text-align: center;
    font-size: 0.74rem;
    color: var(--text-faint);
    font-family: var(--font-mono);
    line-height: 1.8;
}
footer a { color: var(--text-muted); transition: color 0.25s var(--ease); }
footer a:hover { color: var(--accent); }

/* ─── LOADING ──────────────────────────────────────────────── */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-strong) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: 999px;
    color: transparent;
    user-select: none;
}

/* ─── OVERLAY ──────────────────────────────────────────────── */
/* Must stay BELOW the header (z-index 90). The header is a sticky,
   z-indexed element, so it forms its own stacking context and the
   dropdown inside it can never paint above a higher backdrop — at
   z-index 150 this transparent layer sat on top of the menu and
   swallowed every click on it. */
.apps-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    visibility: hidden;
}
.apps-backdrop.open { visibility: visible; }

/* ─── REVEAL ───────────────────────────────────────────────── */
.reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
    transition-delay: calc(var(--i, 0) * 0.08s);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ─── MOBILE ───────────────────────────────────────────────── */
@media (max-width: 480px) {
    header { padding: 1rem; }
    main { padding: 0 1rem; }
    .status-card { padding: 1.85rem 1.35rem; gap: 1.75rem; }
    .bulb { width: 60px; height: 60px; }
    .light-array { gap: 1.25rem; }
    .light-array::before { top: 30px; left: 30px; right: 30px; }
    .apps-dropdown { width: min(320px, calc(100vw - 2rem)); }
    .metric-value { font-size: 1rem; }
}
@media (max-width: 360px) { .metrics-row { grid-template-columns: 1fr 1fr; } }

/* ─── REDUCED MOTION ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
/* ─── SHARE TRIGGER ────────────────────────────────────────── */
.share-launch { display: flex; justify-content: center; margin-top: 1.4rem; }
.share-launch__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 0.7rem 1.3rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-soft) 55%, transparent);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: color 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.share-launch__btn:hover {
    color: var(--text);
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
    transform: translateY(-2px);
    box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--accent) 55%, transparent);
}

/* ─── SHARE SHEET (advanced modal) ─────────────────────────── */
.share-modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    visibility: hidden;
    pointer-events: none;
}
.share-modal.is-open { visibility: visible; pointer-events: auto; }
@media (min-width: 560px) { .share-modal { align-items: center; } }

.share-modal__backdrop {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--bg) 55%, transparent);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.35s var(--ease);
}
.share-modal.is-open .share-modal__backdrop { opacity: 1; }

.share-sheet {
    position: relative;
    width: 100%;
    max-width: 440px;
    padding: 1.4rem clamp(1.1rem, 4vw, 1.5rem) calc(1.5rem + env(safe-area-inset-bottom, 0px));
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 26px 26px 0 0;
    background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
    backdrop-filter: blur(22px) saturate(160%);
    box-shadow: 0 -30px 80px -30px rgba(0, 0, 0, 0.6);
    transform: translateY(102%);
    transition: transform 0.5s var(--ease);
}
.share-modal.is-open .share-sheet { transform: translateY(0); }
@media (min-width: 560px) {
    .share-sheet {
        border: 1px solid var(--border);
        border-radius: 24px;
        box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.7);
        transform: translateY(16px) scale(0.96);
        opacity: 0;
        transition: transform 0.45s var(--ease), opacity 0.45s var(--ease);
    }
    .share-modal.is-open .share-sheet { transform: translateY(0) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .share-sheet { transition: none; } }

.share-sheet__handle {
    display: block;
    width: 40px;
    height: 4px;
    margin: -0.4rem auto 1.1rem;
    border-radius: 999px;
    background: var(--border);
}
@media (min-width: 560px) { .share-sheet__handle { display: none; } }

.share-sheet__close {
    position: absolute;
    top: 1.1rem;
    right: 1.1rem;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.3s var(--ease);
}
.share-sheet__close:hover { color: var(--text); border-color: var(--accent); transform: rotate(90deg); }

/* preview header */
.share-preview {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
    padding-right: 2.5rem;
}
.share-preview__avatar {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.share-preview__avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.share-preview__fallback { font-size: 1.3rem; }
.share-preview__avatar.is-empty { background: var(--surface-strong); }
.share-preview__meta { display: flex; flex-direction: column; min-width: 0; }
.share-preview__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.share-preview__url { font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-muted); }

/* segmented control */
.share-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
    padding: 0.3rem;
    margin-bottom: 1.15rem;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface);
}
.share-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0.5rem 0.6rem;
    border: none;
    border-radius: 9px;
    background: transparent;
    cursor: pointer;
    transition: color 0.3s var(--ease), background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.share-tab:hover { color: var(--text); }
.share-tab.is-active {
    color: var(--text);
    background: var(--surface-strong);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05), 0 6px 16px -10px rgba(0, 0, 0, 0.6);
}

/* panels */
.share-panel[hidden] { display: none; }
.share-panel { animation: sharePanelIn 0.35s var(--ease); }
@keyframes sharePanelIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .share-panel { animation: none; } }

/* copy link row */
.share-copy {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.4rem 0.4rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    transition: border-color 0.3s var(--ease);
}
.share-copy:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.share-copy__icon { flex: 0 0 auto; color: var(--accent); font-size: 0.9rem; }
.share-copy__field {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    padding: 0.35rem 0;
    outline: none;
}
.share-copy__btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    color: #06121a;
    padding: 0.5rem 0.95rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    cursor: pointer;
    transition: transform 0.25s var(--ease), box-shadow 0.3s var(--ease), background 0.3s var(--ease);
}
.share-copy__btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}
.share-copy__btn.is-done { background: linear-gradient(120deg, #34d399, #10b981); }

/* divider */
.share-divider {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 1.25rem 0 1rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-faint);
    text-transform: lowercase;
    letter-spacing: 0.02em;
}
.share-divider::before, .share-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* social tiles */
.share-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.55rem; }
@media (max-width: 400px) { .share-grid { grid-template-columns: repeat(3, 1fr); } }
.share-tile {
    --brand: var(--accent);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    padding: 0.85rem 0.4rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: transform 0.3s var(--ease), border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.share-tile:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--brand) 50%, var(--border));
    background: var(--surface-strong);
}
.share-tile__icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    transition: color 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.share-tile:hover .share-tile__icon {
    color: var(--brand);
    border-color: color-mix(in srgb, var(--brand) 55%, var(--border));
    box-shadow: 0 0 20px -4px color-mix(in srgb, var(--brand) 65%, transparent);
}
.share-tile__label { font-family: var(--font-mono); font-size: 0.68rem; transition: color 0.3s var(--ease); }
.share-tile:hover .share-tile__label { color: var(--text); }
.share-tile[data-native] { --brand: var(--accent); }

/* QR code */
.share-qr { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0.3rem 0 0.2rem; }
.share-qr__frame {
    width: clamp(158px, 46vw, 196px);
    padding: 15px;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 16px 44px -16px rgba(0, 0, 0, 0.55);
}
.share-qr__code { display: block; width: 100%; height: auto; }
.share-qr__hint { margin-top: 1.1rem; font-size: 0.85rem; line-height: 1.55; color: var(--text-muted); }
.share-qr__hint b { color: var(--text); font-family: var(--font-mono); font-weight: 500; }
.share-qr__download {
    margin-top: 1.15rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 0.55rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    transition: color 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.3s var(--ease);
}
.share-qr__download:hover { color: var(--text); border-color: var(--accent); transform: translateY(-2px); }

/* ─── TOAST ────────────────────────────────────────────────── */
.toast {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    transform: translate(-50%, 20px);
    z-index: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    padding: 0.7rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-soft) 85%, transparent);
    backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast i { color: var(--green); }
.toast.is-error { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); }
.toast.is-error i { color: var(--red); }
