/* ===========================================
   LANE — for Lisa
   warm dark, ember accents, intimate
   =========================================== */

:root {
    --bg-0: #120c08;
    --bg-1: #1a1410;
    --bg-2: #221a14;
    --bg-3: #2c211a;
    --line: #3a2c22;

    --ink: #f5e9d8;
    --ink-soft: #c9b59c;
    --ink-dim: #8a7563;

    --flame: #f0823a;
    --amber: #e2a661;
    --ember: #c0541b;
    --moss:  #8db86a;
    --rose:  #d97a8c;

    --lane-bubble: #2c1a14;
    --lane-edge: #4a2418;
    --lisa-bubble: #2a2418;
    --lisa-edge: #4a3a22;

    --shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    background: var(--bg-0);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

body {
    background:
        radial-gradient(ellipse at top, rgba(192, 84, 27, 0.08), transparent 60%),
        radial-gradient(ellipse at bottom, rgba(240, 130, 58, 0.04), transparent 50%),
        var(--bg-0);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
    background: var(--bg-1);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}

/* ============ TOPBAR ============ */
.topbar {
    flex: 0 0 auto;
    padding: calc(var(--safe-top) + 12px) 16px 0;
    background: var(--bg-1);
    border-bottom: 1px solid var(--line);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
}

.sigil {
    font-size: 22px;
    color: var(--flame);
    text-shadow: 0 0 12px rgba(240, 130, 58, 0.5);
}

.title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 26px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--ink);
}

.status {
    margin-left: auto;
    font-size: 11px;
    color: var(--ink-dim);
    transition: color 0.4s;
}
.status.live { color: var(--moss); text-shadow: 0 0 8px rgba(141, 184, 106, 0.5); }
.status.dim { color: var(--ember); }

.tabs {
    display: flex;
    gap: 4px;
}

.tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--ink-dim);
    font-family: 'Cormorant Garamond', serif;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.04em;
    padding: 10px 0 12px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: var(--ink-soft); }
.tab.active {
    color: var(--flame);
    border-bottom-color: var(--flame);
}

/* ============ PANELS ============ */
.panels {
    flex: 1 1 auto;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.panel {
    display: none;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}
.panel.active { display: flex; }

/* ============ CHAT ============ */
.messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.hint {
    text-align: center;
    color: var(--ink-dim);
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 16px;
    padding: 30px 20px;
    opacity: 0.7;
}

.bubble {
    max-width: 78%;
    padding: 11px 15px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 15.5px;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: bubble-in 0.25s ease-out;
    box-shadow: var(--shadow);
}

@keyframes bubble-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.bubble.lane {
    align-self: flex-start;
    background: var(--lane-bubble);
    border: 1px solid var(--lane-edge);
    border-bottom-left-radius: 6px;
    color: var(--ink);
}

.bubble.lisa {
    align-self: flex-end;
    background: var(--lisa-bubble);
    border: 1px solid var(--lisa-edge);
    border-bottom-right-radius: 6px;
    color: var(--ink);
}

.bubble .meta {
    display: block;
    font-size: 10.5px;
    color: var(--ink-dim);
    margin-top: 4px;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.03em;
}

.bubble.lane .meta { color: var(--amber); opacity: 0.6; }
.bubble.system {
    align-self: center;
    background: transparent;
    border: 1px dashed var(--line);
    color: var(--ink-dim);
    font-style: italic;
    font-size: 13px;
    box-shadow: none;
}

.typing {
    align-self: flex-start;
    padding: 14px 18px;
    background: var(--lane-bubble);
    border: 1px solid var(--lane-edge);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    display: flex;
    gap: 5px;
}
.typing span {
    width: 7px;
    height: 7px;
    background: var(--amber);
    border-radius: 50%;
    animation: typing-pulse 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-pulse {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* ============ COMPOSER ============ */
.composer {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px calc(12px + var(--safe-bottom));
    background: var(--bg-1);
    border-top: 1px solid var(--line);
}

#chat-input {
    flex: 1 1 auto;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 22px;
    color: var(--ink);
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    padding: 11px 16px;
    resize: none;
    max-height: 140px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}
#chat-input:focus {
    border-color: var(--flame);
    background: var(--bg-3);
}
#chat-input::placeholder { color: var(--ink-dim); font-style: italic; }

.send-btn {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--flame), var(--ember));
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(240, 130, 58, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}
.send-btn:hover { transform: scale(1.05); }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ============ VOICE PANEL ============ */
.voice-stage {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 24px calc(40px + var(--safe-bottom));
    text-align: center;
    gap: 24px;
    overflow-y: auto;
}

.voice-status {
    font-family: 'Cormorant Garamond', serif;
    font-size: 22px;
    font-style: italic;
    color: var(--ink-soft);
    min-height: 30px;
    transition: color 0.3s;
}
.voice-status.recording { color: var(--ember); }
.voice-status.thinking { color: var(--amber); }
.voice-status.speaking { color: var(--flame); }

.mic-btn {
    position: relative;
    width: 168px;
    height: 168px;
    border-radius: 50%;
    border: none;
    background: radial-gradient(circle at 35% 30%, var(--flame), var(--ember) 65%, #6b1c0a);
    color: #fff8ef;
    cursor: pointer;
    box-shadow:
        0 0 60px rgba(240, 130, 58, 0.35),
        0 8px 32px rgba(0, 0, 0, 0.6),
        inset 0 -8px 24px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.mic-btn:active { transform: scale(0.96); }

.mic-btn.recording {
    background: radial-gradient(circle at 35% 30%, #ff6b35, #b51a09 65%, #5a0d04);
    box-shadow:
        0 0 100px rgba(255, 60, 30, 0.6),
        0 8px 32px rgba(0, 0, 0, 0.7),
        inset 0 -8px 24px rgba(0, 0, 0, 0.4);
}

.mic-btn.thinking {
    background: radial-gradient(circle at 35% 30%, var(--amber), #8a5821 65%, #3a230a);
    animation: thinking-pulse 1.6s ease-in-out infinite;
}

@keyframes thinking-pulse {
    0%, 100% { box-shadow: 0 0 60px rgba(226, 166, 97, 0.3), 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 -8px 24px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 0 90px rgba(226, 166, 97, 0.6), 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 -8px 24px rgba(0, 0, 0, 0.3); }
}

.mic-ring {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid rgba(240, 130, 58, 0.4);
    pointer-events: none;
    opacity: 0;
}
.mic-ring.r2 { inset: -22px; border-color: rgba(240, 130, 58, 0.25); }

.mic-btn.recording .mic-ring {
    animation: ring-pulse 1.5s ease-out infinite;
    opacity: 1;
}
.mic-btn.recording .mic-ring.r2 {
    animation: ring-pulse 1.5s ease-out infinite 0.4s;
}

@keyframes ring-pulse {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(1.4); opacity: 0; }
}

.voice-transcript, .voice-reply {
    max-width: 100%;
    font-family: 'Cormorant Garamond', serif;
    font-size: 18px;
    line-height: 1.5;
    padding: 0 8px;
    min-height: 0;
}
.voice-transcript {
    color: var(--ink-soft);
    font-style: italic;
}
.voice-reply {
    color: var(--ink);
    border-top: 1px solid var(--line);
    padding-top: 16px;
    width: 100%;
}
.voice-reply:empty, .voice-transcript:empty { display: none; }

/* ============ DISCORD PANEL ============ */
.discord-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    font-family: 'Cormorant Garamond', serif;
    font-size: 17px;
    color: var(--ink-soft);
    background: var(--bg-1);
}

.refresh-btn {
    background: none;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.4s, background 0.2s;
}
.refresh-btn:hover { background: var(--bg-2); }
.refresh-btn.spinning { transform: rotate(360deg); }

.discord-messages .bubble {
    max-width: 88%;
    font-size: 14.5px;
}

.discord-messages .bubble .platform-tag {
    display: inline-block;
    font-size: 10px;
    color: var(--amber);
    background: rgba(226, 166, 97, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
    margin-bottom: 4px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ============ MOBILE / iOS ============ */
@media (max-width: 480px) {
    .app { box-shadow: none; }
    .title { font-size: 22px; }
    .tab { font-size: 16px; }
    .bubble { max-width: 84%; font-size: 15px; }
    .mic-btn { width: 148px; height: 148px; }
    .voice-status { font-size: 20px; }
}

/* iOS keyboard avoidance — let composer ride up with the keyboard */
@supports (-webkit-touch-callout: none) {
    .app {
        height: -webkit-fill-available;
    }
}
