/* ========================================================================
   Listen Together — "Afterglow"
   Late-night listening lounge: ink black, molten amber, mint-live, glass.
   ===================================================================== */

:root {
    --ink:        #07070b;
    --ink-1:      #0d0d14;
    --panel:      rgba(20, 20, 29, 0.62);
    --panel-2:    rgba(28, 28, 39, 0.66);
    --raised:     #1a1a24;
    --line:       rgba(255, 255, 255, 0.085);
    --line-soft:  rgba(255, 255, 255, 0.05);

    --text:       #ededf2;
    --muted:      #9a9aab;
    --faint:      #6a6a79;

    --amber:      #ff8a3d;
    --amber-2:    #ffb65c;
    --amber-glow: rgba(255, 138, 61, 0.45);
    --mint:       #46e0a0;
    --rose:       #ff5c7a;

    --display: "Bricolage Grotesque", "Hanken Grotesk", sans-serif;
    --body:    "Hanken Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
    --mono:    "JetBrains Mono", ui-monospace, monospace;

    --r:   16px;
    --r-lg: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--body);
    color: var(--text);
    background: var(--ink);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Atmosphere: warm amber bloom top-left, cool depth bottom-right */
.aurora {
    position: fixed; inset: 0; z-index: -2; pointer-events: none;
    background:
        radial-gradient(60vw 50vh at 12% -8%, rgba(255, 138, 61, 0.18), transparent 60%),
        radial-gradient(50vw 50vh at 100% 8%, rgba(70, 224, 160, 0.10), transparent 55%),
        radial-gradient(80vw 70vh at 80% 110%, rgba(60, 70, 140, 0.16), transparent 60%),
        var(--ink);
}
/* Fine grain for texture */
.grain {
    position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.4;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
    mix-blend-mode: overlay;
}

.app {
    max-width: 1240px;
    margin: 0 auto;
    padding: 22px 22px 40px;
}

/* ===================== Top bar ===================== */
.topbar {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 22px; flex-wrap: wrap;
    animation: fade-down 0.6s ease both;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    display: flex; align-items: flex-end; gap: 3px; height: 26px; padding: 0 2px;
}
.brand-mark .wave {
    width: 4px; border-radius: 3px; background: linear-gradient(var(--amber-2), var(--amber));
    box-shadow: 0 0 10px var(--amber-glow);
    animation: bar 1.1s ease-in-out infinite;
}
.brand-mark .wave:nth-child(1) { height: 10px; animation-delay: 0s; }
.brand-mark .wave:nth-child(2) { height: 22px; animation-delay: 0.2s; }
.brand-mark .wave:nth-child(3) { height: 14px; animation-delay: 0.4s; }
.brand-name {
    font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.4px;
}
.brand-name em { font-style: normal; color: var(--amber); }

.room-chip {
    display: flex; align-items: center; gap: 10px;
    background: var(--panel); border: 1px solid var(--line);
    padding: 7px 8px 7px 14px; border-radius: 999px; backdrop-filter: blur(12px);
}
.live {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--mint);
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rose); transition: all .3s; }
.sync-dot.live { background: var(--mint); box-shadow: 0 0 10px var(--mint); animation: pulse 2s infinite; }
.room-sep { width: 1px; height: 16px; background: var(--line); }
.room-label { font-size: 12px; color: var(--faint); }
.room-chip code {
    font-family: var(--mono); font-size: 13px; color: var(--amber-2);
    background: rgba(255,138,61,.10); padding: 3px 9px; border-radius: 8px;
}
.ghost {
    background: transparent; border: 1px solid var(--line); color: var(--muted);
    padding: 6px 13px; border-radius: 999px; cursor: pointer; font-size: 12.5px;
    font-family: var(--body); transition: all .15s;
}
.ghost:hover { color: var(--text); border-color: var(--amber); background: rgba(255,138,61,.08); }

.presence-wrap { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.roster { display: flex; }
.roster .avatar {
    width: 32px; height: 32px; border-radius: 50%; margin-left: -8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #15151c; font-family: var(--display);
    border: 2px solid var(--ink-1); box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.roster .avatar.more { background: var(--raised); color: var(--muted); }
.presence { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ===================== Cards ===================== */
.card {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    backdrop-filter: blur(16px);
    box-shadow: 0 24px 60px -28px rgba(0,0,0,0.8);
}
.card::before {
    content: ""; position: absolute; inset: 0 0 auto; height: 1px; border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
}

/* ===================== Layout ===================== */
.layout {
    display: grid; grid-template-columns: 1.85fr 1fr; gap: 20px;
    animation: fade-up 0.6s ease 0.05s both;
}
.stage { padding: 26px; }

/* Now playing */
.now-playing { display: flex; gap: 18px; align-items: center; margin-bottom: 22px; }
.art {
    position: relative; width: 104px; height: 104px; border-radius: 20px; flex-shrink: 0;
    background: linear-gradient(145deg, #2a1c12, #140d09);
    border: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; color: var(--amber);
    box-shadow: inset 0 0 30px rgba(255,138,61,.12), 0 10px 30px -10px rgba(0,0,0,.6);
}
.art .note { width: 42px; height: 42px; opacity: .9; transition: opacity .3s; }
.art .eq { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; gap: 5px; padding: 24px; opacity: 0; transition: opacity .3s; }
.art .eq span { width: 6px; border-radius: 3px; background: linear-gradient(var(--amber-2), var(--amber)); height: 20%; }
.art.spinning .note { opacity: 0; }
.art.spinning .eq { opacity: 1; }
.art.spinning .eq span { animation: bar 0.9s ease-in-out infinite; }
.art.spinning .eq span:nth-child(1) { animation-delay: 0s; }
.art.spinning .eq span:nth-child(2) { animation-delay: .15s; }
.art.spinning .eq span:nth-child(3) { animation-delay: .3s; }
.art.spinning .eq span:nth-child(4) { animation-delay: .45s; }
.art.spinning .eq span:nth-child(5) { animation-delay: .6s; }

.np-kicker { font-size: 10.5px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--amber); font-weight: 700; margin-bottom: 6px; }
.track-name { font-family: var(--display); font-weight: 700; font-size: 23px; letter-spacing: -0.4px; line-height: 1.15; }
.track-sub { color: var(--muted); font-size: 13.5px; margin-top: 6px; max-width: 46ch; }

/* YouTube embed */
.yt-wrap {
    position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 14px;
    overflow: hidden; margin-bottom: 20px; background: #000; border: 1px solid var(--line);
}
.yt-wrap iframe, .yt-wrap > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Control dock */
.dock {
    display: flex; align-items: center; gap: 14px;
    background: rgba(0,0,0,.28); border: 1px solid var(--line-soft);
    border-radius: 999px; padding: 10px 16px; margin-bottom: 18px;
}
.play {
    width: 46px; height: 46px; border-radius: 50%; border: none; flex-shrink: 0; cursor: pointer;
    background: linear-gradient(140deg, var(--amber-2), var(--amber));
    color: #1a1006; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 22px -4px var(--amber-glow); transition: transform .12s;
}
.play svg { width: 20px; height: 20px; margin-left: 1px; }
.play:hover:not(:disabled) { transform: scale(1.07); }
.play:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.time { font-family: var(--mono); font-size: 11px; color: var(--muted); width: 38px; text-align: center; }

input[type=range] {
    -webkit-appearance: none; appearance: none; height: 5px; border-radius: 4px;
    background: rgba(255,255,255,.12); outline: none; cursor: pointer;
}
.seek { flex: 1; }
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
    background: var(--amber); box-shadow: 0 0 10px var(--amber-glow);
}
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: var(--amber); }
input[type=range]:disabled { opacity: .4; }
.vol-wrap { display: flex; align-items: center; gap: 7px; }
.vol-ico { font-size: 13px; opacity: .8; }
.vol { width: 64px; }
.icon-btn {
    background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--muted);
    width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 15px; flex-shrink: 0;
    transition: all .15s;
}
.icon-btn:hover { color: var(--amber); border-color: var(--amber); }

/* Add a track */
.add-row { display: flex; gap: 10px; align-items: center; }
.upload-btn {
    display: inline-flex; align-items: center; gap: 7px;
    background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--text);
    padding: 10px 15px; border-radius: 12px; cursor: pointer; font-size: 13.5px; font-weight: 600; white-space: nowrap;
    transition: all .15s;
}
.upload-btn svg { width: 16px; height: 16px; }
.upload-btn:hover { border-color: var(--amber); color: var(--amber-2); }
.add-row #ytUrl {
    flex: 1; min-width: 0; background: rgba(0,0,0,.3); border: 1px solid var(--line);
    border-radius: 12px; padding: 10px 14px; color: var(--text); font-size: 13.5px; font-family: var(--body);
}
.add-row #ytUrl:focus { outline: none; border-color: var(--amber); }
.yt-btn {
    background: var(--text); color: #14141b; border: none; border-radius: 12px;
    padding: 10px 18px; cursor: pointer; font-size: 13.5px; font-weight: 700; font-family: var(--body);
}
.yt-btn:hover { background: #fff; }
.upload-status { font-size: 12.5px; color: var(--muted); margin-top: 9px; min-height: 16px; }

/* Control permission */
.control-bar {
    display: flex; align-items: center; gap: 12px; margin-top: 12px;
    background: rgba(255,138,61,.08); border: 1px solid rgba(255,138,61,.25); border-radius: 12px; padding: 10px 14px;
}
.control-bar #controlMsg { flex: 1; font-size: 13px; color: var(--amber-2); }
.req-control {
    background: var(--amber); border: none; color: #1a1006; border-radius: 9px;
    padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 700; white-space: nowrap; font-family: var(--body);
}
.req-control:hover:not(:disabled) { background: var(--amber-2); }
.req-control:disabled { opacity: .5; cursor: default; }

/* ===================== Chat ===================== */
.chat-card { padding: 20px; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.chat-title { font-family: var(--display); font-weight: 700; font-size: 16px; }
.name-input {
    margin-left: auto; width: 130px; background: rgba(0,0,0,.3); border: 1px solid var(--line);
    border-radius: 10px; padding: 8px 12px; color: var(--text); font-size: 13px; font-family: var(--body);
}
.name-input:focus { outline: none; border-color: var(--amber); }
.chat {
    flex: 1; min-height: 300px; max-height: 420px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 9px; padding: 4px 2px; margin-bottom: 12px;
}
.chat .line { font-size: 13.5px; line-height: 1.45; animation: fade-up .25s ease both; }
.chat .line .who { color: var(--amber-2); font-weight: 700; }
.chat .line.system { color: var(--faint); font-style: italic; font-size: 12.5px; }
.chat-form { display: flex; gap: 9px; }
.chat-form input {
    flex: 1; min-width: 0; background: rgba(0,0,0,.3); border: 1px solid var(--line);
    border-radius: 12px; padding: 10px 14px; color: var(--text); font-size: 13.5px; font-family: var(--body);
}
.chat-form input:focus { outline: none; border-color: var(--amber); }
.chat-form button {
    background: linear-gradient(140deg, var(--amber-2), var(--amber)); border: none; color: #1a1006;
    border-radius: 12px; width: 44px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.chat-form button svg { width: 18px; height: 18px; }
.chat-form button:hover { filter: brightness(1.08); }
.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ===================== Video call ===================== */
.call { padding: 24px; margin-top: 20px; animation: fade-up 0.6s ease 0.1s both; }
.call-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.call-head h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 19px; display: flex; align-items: center; gap: 8px; }
.role-badge { font-size: 10px; font-weight: 800; letter-spacing: 1px; padding: 3px 9px; border-radius: 7px; }
.role-badge.is-host { background: var(--amber); color: #1a1006; }
.call-actions { display: flex; align-items: center; gap: 10px; }
.join-call, .leave-call {
    border: none; border-radius: 999px; padding: 10px 20px; cursor: pointer;
    font-size: 13.5px; font-weight: 700; font-family: var(--body);
}
.join-call { background: linear-gradient(140deg, var(--mint), #2cc488); color: #042016; box-shadow: 0 6px 20px -6px rgba(70,224,160,.5); }
.join-call:hover:not(:disabled) { filter: brightness(1.06); }
.join-call:disabled { opacity: .5; cursor: default; box-shadow: none; }
.leave-call { background: rgba(255,92,122,.14); border: 1px solid rgba(255,92,122,.4); color: var(--rose); }
.leave-call:hover { background: rgba(255,92,122,.22); }

.pending { display: flex; flex-direction: column; gap: 8px; }
.pending:not(:empty) { margin-bottom: 12px; }
.pending-row {
    display: flex; align-items: center; gap: 10px; font-size: 13.5px;
    background: rgba(255,138,61,.08); border: 1px solid rgba(255,138,61,.25); border-radius: 12px; padding: 9px 13px;
}
.pending-row span { flex: 1; }
.pending-row .approve { background: var(--mint); border: none; color: #042016; border-radius: 8px; padding: 6px 13px; cursor: pointer; font-weight: 700; font-family: var(--body); }
.pending-row .deny { background: rgba(255,92,122,.16); border: 1px solid rgba(255,92,122,.4); color: var(--rose); border-radius: 8px; padding: 6px 13px; cursor: pointer; font-family: var(--body); }

/* Theater */
.call-area {
    display: grid; grid-template-columns: minmax(0,1fr) minmax(0,2.4fr) minmax(0,1fr);
    gap: 12px; align-items: start; max-height: 70vh;
}
.cam-rail { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.stage-main { display: flex; align-items: center; justify-content: center; min-height: 0; border-radius: 14px; }
.stage-main:empty { min-height: 230px; border: 1px dashed var(--line); }
.stage-main:empty::before { content: "🖥  Screen share appears here"; color: var(--faint); font-size: 13.5px; }
.tile {
    position: relative; aspect-ratio: 4/3; background: #000; border-radius: 14px; overflow: hidden;
    width: 100%; border: 1px solid var(--line); box-shadow: 0 8px 24px -12px rgba(0,0,0,.7);
}
.tile.on-stage { aspect-ratio: 16/9; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile.on-stage video { object-fit: contain; background: #000; }
.tile.local video { transform: scaleX(-1); }
.tile.local.on-stage video { transform: none; }
.tile-name {
    position: absolute; left: 9px; bottom: 9px; font-size: 11.5px; font-weight: 600;
    background: rgba(0,0,0,.6); backdrop-filter: blur(4px); padding: 3px 9px; border-radius: 7px;
}
.call-area:fullscreen { max-height: none; height: 100vh; width: 100vw; background: var(--ink); padding: 16px; }
.call-area:fullscreen .tile.on-stage { max-height: 92vh; }

.call-controls { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.pill {
    background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--text);
    border-radius: 999px; padding: 10px 17px; cursor: pointer; font-size: 13.5px; font-weight: 600; font-family: var(--body);
    transition: all .15s;
}
.pill:hover { border-color: var(--amber); }
.pill-amber { background: rgba(255,138,61,.14); border-color: rgba(255,138,61,.35); color: var(--amber-2); }
.pill.muted { background: rgba(255,92,122,.16); border-color: rgba(255,92,122,.4); color: var(--rose); }
.pill.sharing { background: rgba(255,92,122,.16); border-color: rgba(255,92,122,.4); color: var(--rose); }
.pill.off { color: var(--rose); border-color: rgba(255,92,122,.4); }
.call-status { font-size: 13px; color: var(--muted); }
.call-hint { font-size: 13px; color: var(--muted); margin-top: 14px; line-height: 1.55; }
.call-hint b { color: var(--text); }
.cam-emoji { filter: grayscale(.1); }

.foot { text-align: center; color: var(--faint); font-size: 12px; margin-top: 28px; }

/* ===================== Animations ===================== */
@keyframes bar { 0%,100% { height: 20%; } 50% { height: 90%; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

/* ===================== Responsive ===================== */
@media (max-width: 920px) {
    .layout { grid-template-columns: 1fr; }
    .chat .chat { max-height: 320px; }
    .presence-wrap { width: 100%; margin-left: 0; justify-content: flex-end; }
}
@media (max-width: 680px) {
    .app { padding: 16px 14px 32px; }
    .topbar { gap: 10px; }
    .room-chip { order: 3; width: 100%; justify-content: center; }
    .brand-name { font-size: 19px; }
    .now-playing { flex-direction: row; }
    .art { width: 76px; height: 76px; }
    .track-name { font-size: 19px; }
    .call-area { grid-template-columns: 1fr; max-height: none; }
    .cam-rail { flex-direction: row; flex-wrap: wrap; }
    .cam-rail .tile { width: calc(50% - 5px); }
    .stage-main { order: -1; }
    .dock { flex-wrap: wrap; gap: 10px; }
    .seek { order: 5; flex-basis: 100%; }
}
