/* ============================================
   Video Desk — Gemini-style Material Design
   ============================================ */

:root {
    /* Gemini-inspired palette */
    --bg-page: #f8f9fa;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-panel: #ffffff;
    --border-subtle: #e8eaed;
    --border-sidebar: #e8eaed;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #80868b;
    --primary: #1a73e8;
    --primary-hover: #1765cc;
    --primary-light: #e8f0fe;
    --accent: #4796e3;
    --surface-hover: #f1f3f4;
    --shadow-sm: 0 1px 2px 0 rgba(60, 64, 67, 0.08);
    --shadow-md: 0 1px 3px 0 rgba(60, 64, 67, 0.12), 0 4px 8px 0 rgba(60, 64, 67, 0.08);
    --shadow-lg: 0 1px 3px 0 rgba(60, 64, 67, 0.12), 0 8px 24px 0 rgba(60, 64, 67, 0.12);
    --sidebar-width: 64px;
    --header-height: 56px;
    --panel-width: 380px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-page);
    display: flex;
    overflow: hidden;
}

/* ---------- Overlay (Start screen) ---------- */
.overlay {
    position: fixed;
    inset: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: rgba(32, 33, 36, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.overlay-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    padding: 32px;
    text-align: center;
}

.overlay-card-header {
    margin-bottom: 24px;
}

.overlay-icon {
    display: inline-flex;
    width: 56px;
    height: 56px;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    font-size: 24px;
    margin-bottom: 16px;
}

.overlay-card-header h1 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
}

.overlay-card-header p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.overlay-warning {
    margin: 0 0 16px;
    padding: 12px;
    font-size: 13px;
    color: #c5221f;
    background: #fce8e6;
    border-radius: var(--radius-sm);
}

.overlay-help {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    font-size: 12px;
    color: var(--text-secondary);
    text-align: left;
}

.overlay-help summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

.overlay-help p,
.overlay-help ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

.overlay-help code {
    font-size: 11px;
    background: var(--surface-hover);
    padding: 2px 6px;
    border-radius: 4px;
}

.overlay-card-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.overlay-card-actions .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---------- Buttons ---------- */
.btn-primary {
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary);
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* ---------- Sidebar: オーバーレイでメインをフル幅に ---------- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: center;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.logo-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 16px;
}

.logo-text {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 12px;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
    box-sizing: border-box;
}

.nav-item .nav-label {
    display: none;
}

.nav-item:hover {
    background: var(--surface-hover);
}

.nav-item-active,
.nav-item.nav-item-active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.nav-icon {
    font-size: 20px;
    line-height: 1;
    opacity: 0.9;
}

.sidebar-footer {
    padding: 12px 8px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

.sidebar-room-label {
    display: block;
    font-size: 10px;
    color: var(--text-tertiary);
    margin-bottom: 2px;
}

.sidebar-room-value {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
}

.sidebar-logout {
    display: block;
    margin-top: 8px;
    font-size: 11px;
}

/* ---------- Main: 100vh - ヘッダー、スクロールなし。左バー分よけて名前が隠れないように ---------- */
.main-with-panel {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    width: 100%;
    overflow: hidden;
}

.main-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
    flex-wrap: wrap;
    gap: 0;
}

.main-header-compact {
    margin-bottom: 4px;
}

/* 学生はヘッダーにボタンがないため、領域を潰す */
.main-header:not(:has(.btn-icon)) {
    padding: 0;
    min-height: 0;
    margin-bottom: 0;
    overflow: hidden;
}

.main-header-compact .main-title { font-size: 18px; }
.main-header-compact .room-badge,
.main-header-compact .host-badge,
.main-header-compact .role-badge { font-size: 12px; padding: 4px 10px; }

.main-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.main-title {
    margin: 0;
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
}

.room-badge {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--surface-hover);
    padding: 6px 12px;
    border-radius: 20px;
}

.host-badge {
    display: none;
    font-size: 12px;
    color: var(--primary);
    background: var(--primary-light);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.host-badge-sidebar {
    display: none;
}
.host-badge-sidebar[style*="inline-block"] {
    display: inline-block;
}

.sidebar-role-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.sidebar-role-row .role-badge {
    font-size: 11px;
    padding: 3px 8px;
}

.main-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-icon:hover {
    background: var(--surface-hover);
    border-color: var(--text-tertiary);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
    overflow: hidden;
}

/* ---------- Cards: 枠なしでビデオ最大化 ---------- */
.card {
    background: var(--bg-card);
    border-radius: 0;
    box-shadow: none;
    border: none;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.card-header-mini {
    padding: 2px 6px;
    border-bottom: none;
}

.card-header-mini .status-text {
    font-size: 12px;
}

.card-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.status-text {
    font-size: 13px;
    color: var(--text-secondary);
}

.card-body {
    padding: 24px;
}

.card-body-video {
    padding: 0;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-video-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.card-video-main .card-body-video {
    flex: 1;
    min-height: 0;
}

/* ---------- Video grid: 常に2x2、枠なしで最大化 ---------- */
.videos-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

.video-wrapper {
    position: relative;
    background: var(--surface-hover);
    overflow: hidden;
    border-radius: 0;
    min-height: 0;
    border: none;
}

/* 名前は枠なし・映像上に文字のみ（モザイク内に表示） */
.video-wrapper h3 {
    position: absolute;
    bottom: 26px;
    left: 8px;
    right: auto;
    margin: 0;
    padding: 0;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    background: none;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8), 0 0 4px rgba(0,0,0,0.6);
}
.video-wrapper-study-time {
    position: absolute;
    bottom: 8px;
    left: 8px;
    margin: 0;
    padding: 0;
    font-size: 11px;
    color: rgba(255,255,255,0.92);
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8), 0 0 4px rgba(0,0,0,0.6);
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* ボカシのみ（filter 1行・Gemini風ミニマル）
   顔は判別できず、人の存在と動きだけがふんわり伝わるバランス */
.video-mosaic,
.video-wrapper.video-has-mosaic video,
.video-wrapper.video-slot-placeholder video,
.private-video-wrapper video {
    filter: blur(14px) brightness(1.03);
    -webkit-filter: blur(14px) brightness(1.03);
}

.video-connecting-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
}
.video-wrapper.video-slot-placeholder {
    background: var(--surface-hover);
}

/* ビデオ受信前ローディング */
.video-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: video-spin 0.8s linear infinite;
    z-index: 2;
}
.video-loading-spinner.is-hidden {
    display: none;
}
@keyframes video-spin {
    to { transform: rotate(360deg); }
}

/* 空き席: 常にグリッド内の1セル、枠なし */
.video-slot-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8eaed;
    border-radius: 0;
    min-height: 0;
    color: var(--text-tertiary);
    font-size: 13px;
    font-weight: 500;
    border: none;
}

.video-wrapper.video-slot-placeholder {
    display: block;
}

.video-wrapper.video-slot-placeholder h3 {
    position: absolute;
    bottom: 26px;
    left: 8px;
    background: none;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8), 0 0 4px rgba(0,0,0,0.6);
}

/* ---------- Right panel: PC=常時表示 / スマホ=下からドロワー ---------- */
/* ---------- Bottom popup (QR code) ---------- */
.qr-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(32, 33, 36, 0.4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.qr-popup-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.bottom-popup {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
}

.bottom-popup.is-open {
    transform: translateY(0);
}

.bottom-popup-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    padding: 24px 24px 32px;
    padding-bottom: max(32px, env(safe-area-inset-bottom));
    position: relative;
    text-align: center;
}

.bottom-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-popup-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.bottom-popup-desc {
    margin: 0 0 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.room-url-popup {
    font-size: 12px;
    margin: 12px 0 16px;
}

.bottom-popup-content .btn-copy {
    margin: 0 auto;
}

.panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(32, 33, 36, 0.4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.panel-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.panel {
    width: 100%;
    max-width: var(--panel-width);
    min-width: 280px;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-panel);
    box-shadow: -4px 0 24px rgba(60, 64, 67, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    border-left: 1px solid var(--border-subtle);
}

.panel.is-open {
    /* スマホでドロワー表示時は JS で is-open を付与 */
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.panel-title {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}

.panel-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}

.panel-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.panel-view {
    display: none;
}

.panel-view.is-visible {
    display: block;
}

/* Share view */
.share-section {
    text-align: center;
}

.share-desc {
    margin: 0 0 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.qrcode-wrap {
    margin: 0 auto 16px;
    padding: 16px;
    background: #fff;
    border-radius: var(--radius-sm);
    display: inline-block;
    border: 1px solid var(--border-subtle);
}

.qrcode-wrap canvas,
.qrcode-wrap img {
    display: block;
}

.room-url {
    font-size: 12px;
    color: var(--text-tertiary);
    word-break: break-all;
    margin: 0 0 16px;
    padding: 12px;
    background: var(--surface-hover);
    border-radius: var(--radius-sm);
}

.btn-copy {
    width: 100%;
    max-width: 200px;
}

/* Settings view */
.settings-section h4 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-desc {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ---------- Modal (fallback QR) ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal[style*="flex"] {
    background: rgba(32, 33, 36, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 360px;
    width: 100%;
    padding: 24px;
    position: relative;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

.modal-close,
.close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
}

.modal-close:hover,
.close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* ---------- Auth pages (landing / admin_login) ---------- */
.page-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.auth-center {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
    padding: 32px;
}

.auth-card-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo {
    display: inline-flex;
    width: 56px;
    height: 56px;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    font-size: 24px;
    margin-bottom: 16px;
}

.auth-logo-admin {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.auth-card-header h1 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
}

.auth-card-header p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-error {
    margin: 0;
    padding: 10px 12px;
    font-size: 13px;
    color: #c5221f;
    background: #fce8e6;
    border-radius: var(--radius-sm);
}

.auth-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.auth-input {
    font-family: inherit;
    font-size: 14px;
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    background: var(--bg-card);
    transition: border-color 0.2s;
}

.auth-input::placeholder {
    color: var(--text-tertiary);
}

.auth-input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-submit {
    margin-top: 8px;
}

.settings-form .auth-label {
    display: block;
    margin-bottom: 6px;
}
.settings-form .auth-input {
    width: 100%;
    margin-bottom: 16px;
}
.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.settings-actions .btn-secondary,
.settings-actions .btn-primary {
    flex: 0 0 auto;
}
.dashboard-btn-settings {
    display: inline-block;
    text-align: center;
    text-decoration: none;
}

.auth-admin-link {
    margin: 16px 0 0;
    text-align: center;
    font-size: 13px;
}

.auth-admin-link a {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
}

.auth-admin-link a:hover {
    text-decoration: underline;
}

/* ---------- Google Login button ---------- */
.btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: #202124;
    background: #fff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}
.btn-google:hover {
    background: var(--surface-hover);
    box-shadow: var(--shadow-md);
}
.btn-google-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
}

/* ---------- Dashboard (lobby) ---------- */
.page-dashboard {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.dashboard-center {
    width: 100%;
    max-width: 420px;
}
.dashboard-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
    padding: 32px;
}
.dashboard-card-header {
    text-align: center;
    margin-bottom: 24px;
}
.dashboard-card-header .auth-logo {
    margin-bottom: 16px;
}
.dashboard-card-header h1 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
}
.dashboard-card-header p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}
.dashboard-user {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 20px;
}
.dashboard-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.dashboard-avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}
.dashboard-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.dashboard-user-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-user-email {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-stat {
    text-align: center;
    padding: 16px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}
.dashboard-stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.dashboard-stat-value {
    font-size: 20px;
    font-weight: 500;
    color: var(--primary);
}
.dashboard-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dashboard-btn-enter {
    display: block;
    text-align: center;
    text-decoration: none;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 500;
}
.dashboard-admin-link {
    text-align: center;
    margin: 0;
}
.dashboard-btn-logout {
    display: block;
    text-align: center;
    text-decoration: none;
    margin-top: 8px;
}

/* ---------- Room header user icon ---------- */
.header-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.header-user-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-hover);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.header-exit-link {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    padding: 6px 12px;
}
.header-exit-link:hover {
    text-decoration: underline;
}

/* ---------- Control bar (room footer) ---------- */
.control-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 6px 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: transparent;
    border: none;
    margin: 0;
}

.control-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--surface-hover);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.control-btn:hover {
    background: #e8eaed;
    border-color: var(--text-tertiary);
}

.control-btn-hand.is-active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.control-btn-icon {
    font-size: 18px;
}

/* ---------- Hand raise badge on video tile ---------- */
.hand-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    z-index: 3;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s, transform 0.2s;
}

.hand-badge.is-raised {
    opacity: 1;
    transform: scale(1);
}

/* ---------- Toast notifications ---------- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
    pointer-events: none;
}

.toast {
    padding: 14px 18px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
    animation: toast-in 0.3s ease;
}

.toast-exit {
    animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ---------- Role badge in header ---------- */
.role-badge {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.role-badge-student {
    background: var(--primary-light);
    color: var(--primary);
}

.role-badge-admin {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

/* ---------- Sidebar logout link ---------- */
.sidebar-logout {
    display: block;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
}

.sidebar-logout:hover {
    color: var(--primary);
}

/* ---------- メイン / 個別ルームの出し分け ---------- */
body[data-room-context="main"] .private-room-content {
    display: none !important;
}

body[data-room-context="private"] #mainRoomContent {
    display: none !important;
}

/* ---------- Student list (admin): 左バーで名前が隠れないように余白確保 ---------- */
.card-students {
    flex: 0 0 auto;
    overflow: visible;
    margin-left: 0;
}

.card-students .card-header {
    padding: 8px 16px 8px 24px;
}

.card-students .card-body {
    padding: 8px 16px 8px 24px;
    max-height: none;
    overflow: visible;
}

.student-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.student-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0 6px 4px;
    border-bottom: 1px solid var(--border-subtle);
}

.student-item:last-child {
    border-bottom: none;
}

.student-name {
    font-size: 14px;
    color: var(--text-primary);
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.student-raised {
    margin-left: 4px;
}

.btn-start-session {
    flex-shrink: 0;
    font-size: 12px;
    padding: 6px 12px;
}

/* ---------- Private room ---------- */
.private-room-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0;
}

.private-room-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-card);
}

.private-room-body {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 16px;
    padding: 16px;
    overflow: hidden;
}

.private-audio-unlock-banner {
    flex-basis: 100%;
    width: 100%;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    padding: 8px 0;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
}

.private-audio-unlock-banner .btn-primary {
    margin: 0;
}

.private-video-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 320px;
    min-height: 0;
}

/* 個別対応: 横長を上下に、上が相手・下が自分（参加者・管理者共通） */
.private-videos {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.private-video-remote {
    order: 1;
}

.private-video-local {
    order: 2;
}

.private-video-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2d2d2d;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    padding: 16px;
}

.private-video-wrapper {
    position: relative;
    background: #1a1a1a;
    overflow: hidden;
    min-height: 0;
}

/* 個別対応: 名前は白い枠なし・映像上に文字のみ */
.private-video-wrapper h3 {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: auto;
    margin: 0;
    padding: 0;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    background: none;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8), 0 0 4px rgba(0,0,0,0.6);
}

.private-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.private-media-start-banner {
    flex-shrink: 0;
    padding: 16px 20px;
    margin-bottom: 12px;
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    text-align: center;
}

.private-media-start-desc {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--text-primary);
}

.private-media-start-banner .btn-primary {
    margin: 0;
}

.private-voice-meter-wrap {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.private-voice-meter-label {
    display: block;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 4px;
}

.private-voice-meter {
    display: block;
    width: 100%;
    max-width: 200px;
    height: 24px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
}

.private-video-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    flex-shrink: 0;
}

/* 対面ルーム: マイク・カメラはアイコンのみ・Zoom風SVG */
.private-video-controls .control-btn-icon-only .control-btn-label {
    display: none;
}

.private-video-controls .control-btn-icon-only {
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.private-video-controls .control-btn-icon-svg {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.private-video-controls .control-btn-icon-svg svg {
    width: 100%;
    height: 100%;
}

.private-video-controls .control-btn.on .control-btn-icon-svg {
    color: var(--primary);
}

.private-video-controls .control-btn.muted .control-btn-icon-svg {
    color: var(--text-tertiary);
}

.private-volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}
.private-volume-label {
    white-space: nowrap;
}
.private-volume-control input[type="range"] {
    width: 80px;
}

.private-audio-click-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 13px;
    text-align: center;
    border: none;
    cursor: pointer;
}

.private-chat-section {
    flex: 0 0 320px;
    width: 320px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    align-self: stretch;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.private-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
}

.private-chat-msg {
    margin-bottom: 12px;
    font-size: 14px;
    word-break: break-word;
}

.private-chat-name {
    font-weight: 500;
    color: var(--text-secondary);
}

.private-chat-img {
    display: block;
    max-width: 100%;
    max-height: 240px;
    border-radius: var(--radius-sm);
    margin-top: 4px;
}

.private-chat-input-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
    flex-shrink: 0;
}

.private-photo-btn-first {
    order: -1;
    width: 100%;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
}

.private-chat-input-area .auth-input {
    flex: 1;
    min-width: 120px;
}

.private-photo-btn {
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* マイク・カメラ等: オン=青、オフ=グレーで判別 */
.control-btn.on {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}
.control-btn.muted {
    background: var(--surface-hover);
    border-color: var(--border-subtle);
    color: var(--text-tertiary);
    opacity: 0.85;
}

/* ---------- メニューボタン（スマホのみ表示） ---------- */
.menu-drawer-btn {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: background 0.2s;
}

.menu-drawer-btn:hover {
    background: var(--primary-hover);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
    }

    .logo-text,
    .nav-label,
    .sidebar-room-label,
    .sidebar-room-value {
        display: none;
    }

    .sidebar-header {
        padding: 16px;
    }

    .sidebar-logo {
        justify-content: center;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .sidebar-footer {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .main {
        padding: 0;
    }

    .main-with-panel {
        flex-direction: column;
    }

    .panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        height: 70vh;
        max-height: 80vh;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        border-left: none;
        box-shadow: 0 -4px 24px rgba(60, 64, 67, 0.15);
        z-index: 1001;
        transform: translateY(100%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        padding-bottom: env(safe-area-inset-bottom);
        box-sizing: border-box;
    }

    .panel.is-open {
        transform: translateY(0);
    }

    .menu-drawer-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        bottom: max(24px, env(safe-area-inset-bottom));
    }

    /* スマホでも常に2x2グリッドを維持（縦長の2x2） */
    .videos-container {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .video-wrapper {
        min-height: 0;
    }
}

@media (max-width: 600px) {
    .overlay-card {
        padding: 24px;
    }
}
