:root {
    --whyble-bg: #09090b;
    --whyble-panel: #18181b;
    --whyble-surface: #27272a;
    --whyble-border: #3f3f46;
    --whyble-accent: #0ea5e9;
    --whyble-success: #22c55e;
    --whyble-warning: #f59e0b;
    --whyble-danger: #ef4444;
    --whyble-text: #fafafa;
    --whyble-muted: #a1a1aa;
    --whyble-radius-sm: 8px;
    --whyble-radius-md: 16px;
    --whyble-radius-pill: 999px;
    --whyble-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --scale: 1.0;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--whyble-bg);
    color: var(--whyble-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    font-size: calc(16px * var(--scale));
}

.app {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(12px * var(--scale)) calc(16px * var(--scale));
    background: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--whyble-border);
    z-index: 10;
    flex: 0 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--scale));
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: calc(16px * var(--scale));
}

.brand-dot {
    width: calc(8px * var(--scale));
    height: calc(8px * var(--scale));
    background: var(--whyble-accent);
    border-radius: 50%;
    box-shadow: 0 0 calc(8px * var(--scale)) var(--whyble-accent);
}

.room-info {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--scale));
    color: var(--whyble-muted);
    font-size: calc(12px * var(--scale));
}

.room-badge {
    padding: calc(4px * var(--scale)) calc(8px * var(--scale));
    background: var(--whyble-panel);
    border: 1px solid var(--whyble-border);
    border-radius: var(--whyble-radius-pill);
    font-family: 'SF Mono', monospace;
    color: var(--whyble-text);
}

.main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(16px * var(--scale));
    position: relative;
    overflow: hidden;
}

.grid {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(calc(240px * var(--scale)), 1fr));
    gap: calc(16px * var(--scale));
    max-width: 100%;
    max-height: 100%;
}

.tile {
    background: var(--whyble-panel);
    border: 1px solid var(--whyble-border);
    border-radius: var(--whyble-radius-md);
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    transition: transform 0.2s, border-color 0.2s;
}

.tile:hover {
    border-color: var(--whyble-surface);
}

.tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    display: none;
}

.tile.speaking {
    border-color: var(--whyble-success);
    box-shadow: 0 0 calc(20px * var(--scale)) rgba(34, 197, 94, 0.5);
}

.tile-avatar {
    width: calc(64px * var(--scale));
    height: calc(64px * var(--scale));
    border-radius: 50%;
    background: var(--whyble-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(28px * var(--scale));
}

.tile-label {
    position: absolute;
    bottom: calc(12px * var(--scale));
    left: calc(12px * var(--scale));
    display: flex;
    align-items: center;
    gap: calc(6px * var(--scale));
    padding: calc(6px * var(--scale)) calc(10px * var(--scale));
    background: rgba(9, 9, 11, 0.7);
    border-radius: var(--whyble-radius-sm);
    font-size: calc(14px * var(--scale));
    font-weight: 500;
}

.tile-status {
    font-size: calc(11px * var(--scale));
    color: var(--whyble-muted);
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: calc(12px * var(--scale));
    padding: calc(14px * var(--scale));
    background: rgba(9, 9, 11, 0.9);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--whyble-border);
    z-index: 10;
    flex: 0 0 auto;
}

.control-btn {
    width: calc(52px * var(--scale));
    height: calc(52px * var(--scale));
    border-radius: var(--whyble-radius-pill);
    border: none;
    background: var(--whyble-surface);
    color: var(--whyble-text);
    font-size: calc(20px * var(--scale));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.control-btn svg {
    width: calc(22px * var(--scale));
    height: calc(22px * var(--scale));
}

.control-btn:hover {
    background: var(--whyble-border);
}

.control-btn.off {
    background: var(--whyble-danger);
}

.control-btn.danger {
    background: var(--whyble-danger);
}

.control-btn.danger:hover {
    background: #dc2626;
}

.permission-prompt {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(16px * var(--scale));
    background: rgba(9, 9, 11, 0.95);
    z-index: 100;
    text-align: center;
    padding: calc(24px * var(--scale));
}

.permission-prompt.hidden { display: none; }

.permission-prompt h2 {
    margin: 0;
    font-size: calc(26px * var(--scale));
    font-weight: 700;
}

.permission-prompt p {
    margin: 0;
    color: var(--whyble-muted);
    max-width: calc(360px * var(--scale));
    font-size: calc(15px * var(--scale));
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: calc(12px * var(--scale));
    width: 100%;
    max-width: calc(340px * var(--scale));
}

.join-form input {
    width: 100%;
    padding: calc(14px * var(--scale)) calc(18px * var(--scale));
    background: var(--whyble-panel);
    border: 1px solid var(--whyble-border);
    border-radius: var(--whyble-radius-pill);
    color: var(--whyble-text);
    font-size: calc(16px * var(--scale));
    text-align: center;
}

.join-btn {
    padding: calc(14px * var(--scale)) calc(28px * var(--scale));
    border: none;
    border-radius: var(--whyble-radius-pill);
    background: var(--whyble-accent);
    color: white;
    font-size: calc(16px * var(--scale));
    font-weight: 600;
    cursor: pointer;
}

.toast {
    position: fixed;
    top: calc(60px * var(--scale));
    left: 50%;
    transform: translateX(-50%);
    padding: calc(10px * var(--scale)) calc(18px * var(--scale));
    background: var(--whyble-panel);
    border: 1px solid var(--whyble-border);
    border-radius: var(--whyble-radius-sm);
    box-shadow: var(--whyble-shadow);
    display: none;
    z-index: 1000;
    font-size: calc(14px * var(--scale));
    white-space: nowrap;
}

.toast.show { display: block; }

@media (max-width: 640px) {
    .header { padding: calc(10px * var(--scale)) calc(14px * var(--scale)); }
    .brand { font-size: calc(14px * var(--scale)); }
    .room-info { display: none; }
    .grid { grid-template-columns: 1fr; gap: calc(10px * var(--scale)); padding: 0; }
    .tile { min-height: 0; }
    .controls { gap: calc(10px * var(--scale)); padding: calc(12px * var(--scale)); }
    .control-btn { width: calc(48px * var(--scale)); height: calc(48px * var(--scale)); font-size: calc(18px * var(--scale)); }
}
