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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #e8e8e8;
}

/* ==========================================
   TOP BAR
   ========================================== */

.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(22, 22, 40, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 107, 53, 0.3);
}

.top-bar-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 20px;
}

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

.brand-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.brand-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ff6b35;
    text-shadow: 0 0 20px rgba(255, 107, 53, 0.5), 0 0 40px rgba(255, 107, 53, 0.2);
}

/* User Menu */
.user-menu-wrapper {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: #333;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    transition: border-color 0.2s;
}

.user-menu-toggle:hover {
    border-color: rgba(255, 107, 53, 0.6);
}

.user-menu-toggle .avatar-icon {
    width: 22px;
    height: 22px;
    color: #aaa;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: rgba(30, 30, 50, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.user-dropdown.open {
    display: block;
}

.user-dropdown .dropdown-name {
    padding: 10px 16px;
    font-size: 0.85rem;
    color: #aaa;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.user-dropdown .dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: #e8e8e8;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}

.user-dropdown .dropdown-item:hover {
    background: rgba(255, 107, 53, 0.1);
    color: #ff6b35;
}

/* ==========================================
   CONTAINER
   ========================================== */

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 24px;
}

h1 {
    font-size: 1.8rem;
    color: #ff6b35;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #ff6b35;
}

h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #888;
}

/* Connection Banner */
.connection-banner {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.connection-banner.disconnected {
    display: flex;
    background: rgba(220, 53, 69, 0.2);
    border: 1px solid #dc3545;
    color: #ff6b6b;
}

.connection-banner.connected {
    display: none;
}

.connection-icon {
    font-size: 1.2rem;
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    background: #333;
    color: #fff;
    transition: all 0.2s;
}

.btn:hover {
    background: #444;
    transform: translateY(-1px);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    color: #333;
    padding: 12px 24px;
    text-decoration: none;
    font-weight: 500;
}

.btn-google:hover {
    background: #f5f5f5;
}

/* ==========================================
   SECTIONS - Warm theme
   ========================================== */

.login-section {
    text-align: center;
    padding: 60px 20px;
}

.login-section p {
    margin-bottom: 20px;
    color: #888;
}

.status-section,
.controls-section,
.api-keys-section {
    background: rgba(255, 107, 53, 0.03);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 3px solid rgba(255, 107, 53, 0.4);
}

/* ==========================================
   STATUS GRID
   ========================================== */

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.status-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.status-item.active {
    border-color: rgba(255, 107, 53, 0.25);
    box-shadow: 0 0 12px rgba(255, 107, 53, 0.08);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #444;
    flex-shrink: 0;
    transition: background 0.3s, box-shadow 0.3s;
}

.status-indicator.on {
    background: #ff6b35;
    box-shadow: 0 0 8px rgba(255, 107, 53, 0.6), 0 0 16px rgba(255, 107, 53, 0.3);
}

.status-indicator.flashing {
    background: #ff6b35;
    animation: indicator-flash 0.5s ease-in-out infinite;
}

@keyframes indicator-flash {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(255, 107, 53, 0.6); }
    50% { opacity: 0.2; box-shadow: none; }
}

.status-indicator.pilot-on {
    background: #4488ff;
    box-shadow: 0 0 8px rgba(68, 136, 255, 0.6), 0 0 16px rgba(68, 136, 255, 0.3);
}

.status-text {
    flex: 1;
}

.status-item .label {
    display: block;
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 2px;
}

.status-item .value {
    display: block;
    font-size: 1.2rem;
    font-weight: bold;
}

.status-item .value.on {
    color: #ff6b35;
}

.status-item .value.off {
    color: #888;
}

.status-message {
    margin-top: 15px;
    font-size: 0.85rem;
    color: #888;
    text-align: center;
}

/* ==========================================
   CONTROLS
   ========================================== */

.control-group {
    margin-bottom: 20px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    margin-bottom: 10px;
    color: #aaa;
}

/* Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    background: #3a3a3a;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    padding: 3px;
    transition: background 0.3s;
}

.toggle-switch[aria-checked="true"] {
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
}

.toggle-knob {
    display: block;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch[aria-checked="true"] .toggle-knob {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #888;
    min-width: 30px;
}

.toggle-switch[aria-checked="true"] + .toggle-label {
    color: #ff6b35;
}

/* ==========================================
   FLAME SLIDER - Warm gradient
   ========================================== */

.flame-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #4a1a1a, #ff6b35 50%, #ffd700);
    outline: none;
    -webkit-appearance: none;
}

.flame-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #ffaa42, #ff6b35);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 107, 53, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.flame-slider::-moz-range-thumb {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #ffaa42, #ff6b35);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 107, 53, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.flame-slider::-moz-range-track {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #4a1a1a, #ff6b35 50%, #ffd700);
    border: none;
}

/* ==========================================
   API KEYS
   ========================================== */

.help-text {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 15px;
}

.create-key-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.create-key-form input {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: #333;
    color: #fff;
    font-size: 1rem;
}

.create-key-form input::placeholder {
    color: #666;
}

.new-key-display {
    background: rgba(40, 167, 69, 0.2);
    border: 1px solid #28a745;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.new-key-display code {
    display: block;
    background: #000;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    word-break: break-all;
    font-size: 0.85rem;
}

.new-key-display .warning {
    color: #ffc107;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.api-keys-list {
    margin-bottom: 20px;
}

.api-key-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 8px;
}

.api-key-item .key-info {
    flex: 1;
}

.api-key-item .key-name {
    font-weight: bold;
}

.api-key-item .key-meta {
    font-size: 0.8rem;
    color: #666;
}

.api-key-item .btn-delete {
    background: transparent;
    color: #dc3545;
    padding: 5px 10px;
}

.api-key-item .btn-delete:hover {
    background: rgba(220, 53, 69, 0.2);
}

.api-usage {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 15px;
}

.api-usage pre {
    overflow-x: auto;
}

.api-usage code {
    font-size: 0.8rem;
    color: #aaa;
}

/* ==========================================
   PIXEL ART FIREPLACE
   ========================================== */

.pixel-fireplace {
    --pixel: 4px;
    --flame-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    image-rendering: pixelated;
}

.fireplace-frame {
    position: relative;
    width: calc(var(--pixel) * 50);
    height: calc(var(--pixel) * 35);
    background: #4a3728;
    border: calc(var(--pixel) * 3) solid #6b4423;
    border-radius: calc(var(--pixel) * 2);
    box-shadow:
        inset calc(var(--pixel) * 2) calc(var(--pixel) * 2) 0 #3d2817,
        inset calc(var(--pixel) * -2) calc(var(--pixel) * -2) 0 #7a5533;
}

/* Brick pattern on frame */
.fireplace-frame::before {
    content: '';
    position: absolute;
    inset: calc(var(--pixel) * -3);
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent calc(var(--pixel) * 6),
            #5a3a20 calc(var(--pixel) * 6),
            #5a3a20 calc(var(--pixel) * 7)
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent calc(var(--pixel) * 3),
            #5a3a20 calc(var(--pixel) * 3),
            #5a3a20 calc(var(--pixel) * 4)
        );
    border-radius: calc(var(--pixel) * 2);
    pointer-events: none;
}

.fireplace-interior {
    position: absolute;
    inset: calc(var(--pixel) * 2);
    background: linear-gradient(to bottom, #1a1a1a 0%, #2d1f1f 100%);
    border-radius: calc(var(--pixel) * 1);
    overflow: hidden;
}

/* Glow effect when on */
.pixel-fireplace.on .fireplace-interior {
    background: linear-gradient(to bottom, #2d1a1a 0%, #3d2020 100%);
    box-shadow: inset 0 calc(var(--pixel) * -5) calc(var(--pixel) * 10) rgba(255, 100, 0, 0.3);
}

.fireplace-base {
    width: calc(var(--pixel) * 56);
    height: calc(var(--pixel) * 4);
    background: #5a3a20;
    border-radius: 0 0 calc(var(--pixel) * 1) calc(var(--pixel) * 1);
    box-shadow:
        inset 0 calc(var(--pixel) * 1) 0 #6b4423,
        0 calc(var(--pixel) * 1) 0 #3d2817;
}

/* Logs */
.logs {
    position: absolute;
    bottom: calc(var(--pixel) * 2);
    left: 50%;
    transform: translateX(-50%);
    width: calc(var(--pixel) * 36);
    height: calc(var(--pixel) * 8);
}

.log {
    position: absolute;
    background: linear-gradient(90deg, #3d2817 0%, #5a3a20 50%, #3d2817 100%);
    border-radius: calc(var(--pixel) * 2);
    box-shadow:
        inset 0 calc(var(--pixel) * 1) 0 rgba(255,255,255,0.1),
        inset 0 calc(var(--pixel) * -1) 0 rgba(0,0,0,0.3);
}

.log-1 {
    width: calc(var(--pixel) * 28);
    height: calc(var(--pixel) * 5);
    bottom: 0;
    left: calc(var(--pixel) * 2);
    transform: rotate(-5deg);
}

.log-2 {
    width: calc(var(--pixel) * 26);
    height: calc(var(--pixel) * 5);
    bottom: 0;
    right: calc(var(--pixel) * 2);
    transform: rotate(8deg);
}

.log-3 {
    width: calc(var(--pixel) * 20);
    height: calc(var(--pixel) * 4);
    bottom: calc(var(--pixel) * 4);
    left: 50%;
    transform: translateX(-50%) rotate(-2deg);
}

/* Embers */
.embers {
    position: absolute;
    bottom: calc(var(--pixel) * 6);
    left: 50%;
    transform: translateX(-50%);
    width: calc(var(--pixel) * 30);
    height: calc(var(--pixel) * 4);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.pixel-fireplace.on .embers {
    opacity: 1;
}

.ember {
    position: absolute;
    width: calc(var(--pixel) * 2);
    height: calc(var(--pixel) * 2);
    background: #ff6600;
    border-radius: 50%;
    box-shadow: 0 0 calc(var(--pixel) * 2) #ff4400;
}

.ember-1 { left: 10%; animation: ember-glow 1.5s ease-in-out infinite; }
.ember-2 { left: 30%; animation: ember-glow 1.8s ease-in-out infinite 0.3s; }
.ember-3 { left: 50%; animation: ember-glow 1.2s ease-in-out infinite 0.6s; }
.ember-4 { left: 70%; animation: ember-glow 1.6s ease-in-out infinite 0.2s; }
.ember-5 { left: 85%; animation: ember-glow 1.4s ease-in-out infinite 0.5s; }

@keyframes ember-glow {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.3); }
}

/* Flames */
.flames-container {
    position: absolute;
    bottom: calc(var(--pixel) * 10);
    left: 50%;
    transform: translateX(-50%);
    width: calc(var(--pixel) * 32);
    height: calc(var(--pixel) * 20);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: calc(var(--pixel) * 1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pixel-fireplace.on .flames-container {
    opacity: 1;
}

/* Burner 2 - subtle glow effect */
.pixel-fireplace.on.burner2-on .fireplace-interior {
    box-shadow:
        inset 0 calc(var(--pixel) * -8) calc(var(--pixel) * 15) rgba(255, 100, 0, 0.5),
        inset 0 0 calc(var(--pixel) * 10) rgba(255, 150, 50, 0.3);
}

.pixel-fireplace.on.burner2-on .flames-container {
    filter: brightness(1.2);
}

.flame {
    --base-height: calc(var(--pixel) * 12);
    width: calc(var(--pixel) * 5);
    height: calc(var(--base-height) * var(--flame-height, 0.5));
    background: linear-gradient(
        to top,
        #ff2200 0%,
        #ff6600 30%,
        #ffaa00 60%,
        #ffdd44 85%,
        #ffffaa 100%
    );
    border-radius: calc(var(--pixel) * 2) calc(var(--pixel) * 2) calc(var(--pixel) * 1) calc(var(--pixel) * 1);
    transform-origin: bottom center;
    box-shadow:
        0 0 calc(var(--pixel) * 3) #ff6600,
        0 0 calc(var(--pixel) * 6) #ff4400;
}

.flame-1 {
    animation: flame-dance-1 0.4s ease-in-out infinite;
    height: calc(var(--base-height) * var(--flame-height, 0.5) * 0.7);
}

.flame-2 {
    animation: flame-dance-2 0.35s ease-in-out infinite;
    height: calc(var(--base-height) * var(--flame-height, 0.5) * 0.9);
}

.flame-3 {
    animation: flame-dance-1 0.3s ease-in-out infinite;
    height: calc(var(--base-height) * var(--flame-height, 0.5));
}

.flame-4 {
    animation: flame-dance-2 0.38s ease-in-out infinite;
    height: calc(var(--base-height) * var(--flame-height, 0.5) * 0.85);
}

.flame-5 {
    animation: flame-dance-1 0.42s ease-in-out infinite;
    height: calc(var(--base-height) * var(--flame-height, 0.5) * 0.65);
}

@keyframes flame-dance-1 {
    0%, 100% {
        transform: scaleY(1) scaleX(1) skewX(0deg);
    }
    25% {
        transform: scaleY(1.1) scaleX(0.9) skewX(3deg);
    }
    50% {
        transform: scaleY(0.9) scaleX(1.1) skewX(-2deg);
    }
    75% {
        transform: scaleY(1.05) scaleX(0.95) skewX(2deg);
    }
}

@keyframes flame-dance-2 {
    0%, 100% {
        transform: scaleY(1) scaleX(1) skewX(0deg);
    }
    25% {
        transform: scaleY(0.95) scaleX(1.05) skewX(-3deg);
    }
    50% {
        transform: scaleY(1.1) scaleX(0.9) skewX(2deg);
    }
    75% {
        transform: scaleY(0.9) scaleX(1.05) skewX(-1deg);
    }
}

/* Pilot Light */
.pilot-light {
    position: absolute;
    bottom: calc(var(--pixel) * 3);
    right: calc(var(--pixel) * 4);
    width: calc(var(--pixel) * 2);
    height: calc(var(--pixel) * 3);
    background: #444;
    border-radius: calc(var(--pixel) * 1);
    transition: all 0.3s ease;
}

.pilot-light.on {
    background: #4488ff;
    box-shadow:
        0 0 calc(var(--pixel) * 2) #4488ff,
        0 0 calc(var(--pixel) * 4) #2266dd;
    animation: pilot-flicker 2s ease-in-out infinite;
}

@keyframes pilot-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* Disconnected state for fireplace */
.pixel-fireplace.disconnected {
    filter: grayscale(0.5) brightness(0.7);
}

.pixel-fireplace.disconnected .flames-container,
.pixel-fireplace.disconnected .embers {
    display: none;
}

/* ==========================================
   WARM SCROLLBAR
   ========================================== */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(26, 26, 46, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 107, 53, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 107, 53, 0.5);
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }

    .brand-name {
        font-size: 1.2rem;
    }

    .pixel-fireplace {
        --pixel: 3px;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }

    .create-key-form {
        flex-direction: column;
    }
}

@media (min-width: 600px) {
    .pixel-fireplace {
        --pixel: 5px;
    }
}

/* Disconnected state - must be at end for specificity */
.container.disconnected-state .controls-section {
    opacity: 0.5;
    pointer-events: none;
}

.container.disconnected-state .status-item .value {
    color: #666;
}
