:root {
    --bg-space: #050608;
    --hal-red: #ff1e27;
    --hal-red-glow: rgba(255, 30, 39, 0.55);
    --hal-green: #00ff88;
    --hal-green-glow: rgba(0, 255, 136, 0.6);
    --text-main: #e2e8f0;
    --text-dim: #64748b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background-color: var(--bg-space);
    background-image: radial-gradient(circle at 50% 42%, #0f131d 0%, #050608 70%);
    color: var(--text-main);
    font-family: 'JetBrains Mono', 'Consolas', 'Inter', monospace;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* Main Stage */
.hal-stage {
    position: relative;
    width: 460px;
    height: 460px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 500px) {
    .hal-stage {
        width: 340px;
        height: 340px;
    }
}

/* Canvas for 360-degree vibrating shockwaves around the lens */
#halCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* HAL 9000 Metallic Lens Button */
.hal-button {
    position: relative;
    z-index: 2;
    width: 156px;
    height: 156px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    outline: none;
    padding: 12px;
    /* Brushed aluminum outer bezel */
    background: conic-gradient(
        from 135deg,
        #2a2f3a 0deg,
        #525b6e 45deg,
        #181b22 120deg,
        #3b4252 200deg,
        #646f85 260deg,
        #1a1d24 320deg,
        #2a2f3a 360deg
    );
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.9),
        0 0 40px var(--hal-red-glow),
        inset 0 2px 4px rgba(255, 255, 255, 0.25);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hal-button:hover {
    transform: scale(1.04);
}

.hal-button:active {
    transform: scale(0.97);
}

/* Inner dark chamber */
.hal-chamber {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, #1a0305 0%, #050507 75%, #000000 100%);
    box-shadow:
        inset 0 8px 22px rgba(0, 0, 0, 0.95),
        inset 0 0 12px rgba(255, 30, 39, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border: 2px solid #1e232d;
    transition: all 0.45s ease;
}

/* Glowing Core Iris (Red when idle, Green when recording) */
.hal-iris {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: radial-gradient(
        circle at 50% 50%,
        #fff5f5 0%,
        #ff6b6b 18%,
        #ff1e27 48%,
        #8a0006 80%,
        transparent 100%
    );
    box-shadow:
        0 0 25px #ff1e27,
        0 0 55px #ff1e27,
        0 0 90px rgba(255, 30, 39, 0.7);
    transition: background 0.4s ease, box-shadow 0.4s ease, transform 0.06s linear;
    animation: idle-breathe 3.2s ease-in-out infinite;
}

@keyframes idle-breathe {
    0%, 100% { transform: scale(0.96); opacity: 0.9; }
    50% { transform: scale(1.06); opacity: 1; }
}

/* Glass lens reflection arc */
.hal-reflection {
    position: absolute;
    top: 8%;
    left: 16%;
    width: 68%;
    height: 36%;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

/* ACTIVE / RECORDING STATE (GREEN HAL 9000) */
.hal-button.recording {
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.9),
        0 0 55px var(--hal-green-glow),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.hal-button.recording .hal-chamber {
    background: radial-gradient(circle at 50% 50%, #022414 0%, #040806 75%, #000000 100%);
    box-shadow:
        inset 0 8px 22px rgba(0, 0, 0, 0.95),
        inset 0 0 18px rgba(0, 255, 136, 0.45);
}

.hal-button.recording .hal-iris {
    animation: none;
    background: radial-gradient(
        circle at 50% 50%,
        #ffffff 0%,
        #a7f3d0 20%,
        #00ff88 50%,
        #059669 82%,
        transparent 100%
    );
    box-shadow:
        0 0 28px #00ff88,
        0 0 65px #00ff88,
        0 0 110px rgba(0, 255, 136, 0.85);
}

/* Minimal HUD Readout below HAL Eye */
.hud-panel {
    margin-top: -12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 3;
    text-align: center;
}

.hud-timer {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--text-main);
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
    transition: color 0.3s ease;
}

.hud-timer.recording {
    color: var(--hal-green);
    text-shadow: 0 0 18px rgba(0, 255, 136, 0.45);
}

.hud-status {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-dim);
}

/* Nguồn đang thu: Meet / Zalo / Mic */
.hud-sources {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.src-chip {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    transition: all 0.3s ease;
}

.src-chip.on {
    color: var(--hal-green);
    border-color: rgba(0, 255, 136, 0.4);
    background: rgba(0, 255, 136, 0.08);
}

.meet-btn {
    font-family: inherit;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
}

.meet-btn:hover {
    border-color: var(--hal-green);
    color: var(--hal-green);
}

/* Minimalist Saved Files Drawer at Bottom */
.saved-drawer {
    margin-top: 28px;
    width: 100%;
    max-width: 480px;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 3;
}

.rec-pill {
    background: rgba(15, 20, 30, 0.78);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.78rem;
}

.rec-pill audio {
    height: 28px;
    flex: 1;
    min-width: 140px;
}

.rec-dl {
    color: var(--hal-green);
    text-decoration: none;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 255, 136, 0.12);
    border: 1px solid rgba(0, 255, 136, 0.3);
    white-space: nowrap;
}

.rec-dl:hover {
    background: rgba(0, 255, 136, 0.24);
}

.rec-del {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 6px;
}

.rec-del:hover {
    color: #ef4444;
}

[hidden] { display: none !important; }
body { padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
button, input, select { font: inherit; }
button:disabled { opacity: 0.45; cursor: wait; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--hal-green); outline-offset: 4px; }
.app-header { position: absolute; top: 24px; left: 0; width: 100%; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; letter-spacing: 0.15em; color: #94a3b8; font-size: 0.85rem; }
.app-header strong { color: #e2e8f0; }
main { display: flex; flex-direction: column; align-items: center; width: 100%; }
.hud-panel { max-width: 640px; width: 100%; }
.hud-status { min-height: 36px; line-height: 1.8; letter-spacing: 0.08em; padding: 0 12px; }
.hud-sources { flex-wrap: wrap; justify-content: center; }
.source-label { font-size: 0.72rem; color: #94a3b8; }
select, input { color: var(--text-main); background: #111721; border: 1px solid #334155; border-radius: 8px; padding: 8px 10px; }
select { max-width: 240px; font-size: 0.75rem; }
a.meet-btn { text-decoration: none; }
.source-note, .storage-status { font-size: 0.7rem; color: #94a3b8; line-height: 1.8; margin: 10px 0 0; max-width: 520px; }
.storage-status { color: #8ebba8; min-height: 32px; overflow-wrap: anywhere; }
.library-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; justify-content: center; }
.import-btn { cursor: pointer; }
.library { width: 100%; max-width: 620px; margin-top: 32px; text-align: center; }
h1 { font-size: 0.8rem; font-weight: 400; letter-spacing: 0.1em; color: #94a3b8; }
.saved-drawer { margin-top: 16px; max-width: none; padding: 0; }
.rec-pill { border-radius: 16px; padding: 16px; flex-direction: column; align-items: stretch; text-align: left; gap: 10px; }
.rec-title { color: #cbd5e1; font-size: 0.75rem; overflow-wrap: anywhere; user-select: text; }
.rec-meta { color: #94a3b8; font-size: 0.68rem; line-height: 1.6; }
.rec-pill audio { width: 100%; height: 34px; flex: auto; }
.rec-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rec-actions a, .rec-actions button { font-size: 0.7rem; }
.empty-state { color: #64748b; font-size: 0.75rem; padding: 20px; }
.login-panel { width: min(360px, 100%); display: flex; flex-direction: column; gap: 18px; text-align: center; padding: 32px 20px; border: 1px solid #24303b; border-radius: 16px; background: #0b1018; }
.login-panel label { font-size: 0.85rem; }
.login-panel button { cursor: pointer; padding: 10px; }
.login-panel p { color: #fda4af; font-size: 0.75rem; line-height: 1.6; }
#loadMoreBtn { margin-top: 18px; }
@media (max-width: 500px) { body { padding-top: 0; } .hal-stage { width: min(340px, 100vw - 32px); height: 340px; } .hud-timer { font-size: 1.5rem; } .hud-status { font-size: 0.7rem; } }
@media (prefers-reduced-motion: reduce) { .hal-iris { animation: none; } }

.local-library { width: min(100%, 460px); margin: 28px 0 24px; }
#recordingsList { max-height: 260px; overflow-y: auto; scrollbar-width: thin; }
.local-recording { padding: 13px 14px; margin-top: 8px; background: rgba(15, 20, 30, 0.78); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; }
.local-recording-meta { font-size: .7rem; line-height: 1.6; color: #94a3b8; }
.local-recording-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.library-button { font: inherit; font-size: .72rem; color: #a7f3d0; background: rgba(0,255,136,.06); border: 1px solid rgba(0,255,136,.22); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.library-button:hover { background: rgba(0,255,136,.12); }
.library-delete { margin-left: auto; color: #94a3b8; border-color: rgba(148,163,184,.2); background: transparent; }
.library-delete:hover { color: #fda4af; border-color: #fda4af; background: rgba(244,63,94,.06); }
.local-recording audio { display: block; width: 100%; height: 34px; margin-top: 12px; }
.library-notice { color: #fbbf24; font-size: .72rem; line-height: 1.7; padding: 10px 0; }
@media (max-width: 500px) { .library-button { min-height: 40px; padding: 8px 14px; } }

/* Immediate click feedback is distinct from actual recording. */
.hal-button, .hal-button .hal-chamber, .hal-button .hal-iris { transition-duration: 80ms; }
.hal-button.starting:disabled { opacity: 1; cursor: progress; }
.hal-button.starting { box-shadow: 0 18px 50px rgba(0,0,0,.9), 0 0 28px rgba(251,191,36,.45); }
.hal-button.starting .hal-iris { background: radial-gradient(circle, #fff9d8 0%, #fbbf24 22%, #d97706 52%, #78350f 80%, transparent 100%); box-shadow: 0 0 25px #d97706, 0 0 55px rgba(251,191,36,.5); animation: none; }

/* Crisp, resolution-independent lens and numerals. */
@font-face { font-family: 'HAL Timer'; src: url('/fonts/roboto-mono-700.woff2') format('woff2'); font-style: normal; font-weight: 700; font-display: swap; }
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.hal-button {
    --eye-bright: #ffd2d7; --eye-main: #ff263e; --eye-deep: #780416; --eye-chamber: #300814;
    width: 192px; height: 192px; padding: 0; background: none; border: 0;
    box-shadow: 0 14px 26px rgba(0,0,0,.65); transform: none;
    transition: box-shadow 80ms ease;
}
.hal-button:hover { transform: none; box-shadow: 0 14px 26px rgba(0,0,0,.65), 0 0 0 2px rgba(194,204,219,.2); }
.hal-button:active { transform: none; }
.hal-eye { display: block; width: 100%; height: 100%; shape-rendering: geometricPrecision; pointer-events: none; }
.eye-bright-color { stop-color: var(--eye-bright); }
.eye-main-color { stop-color: var(--eye-main); }
.eye-deep-color { stop-color: var(--eye-deep); }
.eye-chamber-color { stop-color: var(--eye-chamber); }
.eye-ring-color { stroke: var(--eye-main); }
.hal-button.recording {
    --eye-bright: #d1ffe5; --eye-main: #19ed8d; --eye-deep: #036642; --eye-chamber: #052e20;
    box-shadow: 0 14px 26px rgba(0,0,0,.65), 0 0 16px rgba(25,237,141,.12);
}
.hal-button.starting { --eye-bright: #fff2c4; --eye-main: #ffc43b; --eye-deep: #805010; --eye-chamber: #34230a; box-shadow: 0 14px 26px rgba(0,0,0,.65); }
.hud-timer {
    font-family: 'HAL Timer', ui-monospace, monospace; font-size: 36px; font-style: normal; font-weight: 700;
    font-synthesis: none; font-variant-numeric: tabular-nums; line-height: 1.35; letter-spacing: .08em;
    color: #f7f9ff; text-shadow: none; transform: none; filter: none;
}
.hud-timer.recording { color: #29f59c; text-shadow: none; }
.local-recording-meta { font-size: 12px; font-weight: 500; color: #b7c1d1; }
.library-button { font-size: 13px; font-weight: 600; }
@media (max-width: 500px) { .hal-button { width: 180px; height: 180px; } .hud-timer { font-size: 32px; } }
@media (min-width: 1920px) { .hal-button { width: 208px; height: 208px; } .hud-timer { font-size: 44px; } }
