/**
 * V2 ネイティブ UI（ミライチャット トンマナ）
 */
:root {
  --v2-bg: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
  --v2-bg-solid: #f0f4ff;
  --v2-glass-bg: rgba(255, 255, 255, 0.72);
  --v2-glass-border: rgba(255, 255, 255, 0.85);
  --v2-glass-blur: 14px;
  --v2-surface: rgba(255, 255, 255, 0.92);
  --v2-border: rgba(226, 232, 240, 0.9);
  --v2-primary: #4f46e5;
  --v2-primary-dark: #7c3aed;
  --v2-primary-hover: #4338ca;
  --v2-text: #1e293b;
  --v2-text-muted: #64748b;
  --v2-radius: 12px;
  --v2-radius-lg: 20px;
  --v2-shadow: 0 8px 32px rgba(79, 70, 229, 0.1);
  --v2-shadow-primary: 0 8px 32px rgba(79, 70, 229, 0.25);
  --v2-info-bg: rgba(254, 249, 195, 0.85);
  --v2-info-border: #fde68a;
  --v2-info-text: #92400e;
  --v2-code-bg: linear-gradient(135deg, rgba(219, 234, 254, 0.9) 0%, rgba(191, 219, 254, 0.9) 100%);
  --v2-code-border: #3b82f6;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

html.v2-html-student {
  height: 100%;
  height: 100dvh;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--v2-bg-solid);
  background-image: var(--v2-bg);
  color: var(--v2-text);
  line-height: 1.6;
  margin: 0;
  min-height: 100vh;
}

body.v2-body-glass {
  background: linear-gradient(145deg, #eef2ff 0%, #f5f3ff 45%, #fce7f3 100%);
  background-attachment: fixed;
  position: relative;
}

body.v2-body-glass::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 8% 12%, rgba(129, 140, 248, 0.35) 0%, transparent 42%),
    radial-gradient(circle at 92% 78%, rgba(192, 132, 252, 0.28) 0%, transparent 38%),
    radial-gradient(circle at 55% 35%, rgba(244, 114, 182, 0.18) 0%, transparent 32%);
}

body.v2-body-glass > header,
body.v2-body-glass > main,
body.v2-body-glass > footer {
  position: relative;
  z-index: 1;
}

.v2-glass-main {
  min-height: calc(100vh - 8rem);
}

.v2-container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem;
}

.v2-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.v2-page-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.v2-page-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.v2-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.v2-card-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--v2-border);
}

.v2-card-head-title {
  font-weight: 600;
}

.v2-card-head-title .fa-folder {
  color: var(--v2-primary);
  margin-right: 0.5rem;
}

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

.v2-list-item-row {
  justify-content: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.v2-list-item-main {
  flex: 1;
  min-width: 0;
}

.v2-list-item-title {
  font-weight: 500;
}

.v2-empty-state p {
  color: var(--v2-text-muted);
  margin: 0;
  text-align: center;
}

.v2-login-page .v2-login-lang {
  margin-bottom: 0.25rem;
}

.v2-check-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 2px solid var(--v2-border);
  border-radius: var(--v2-radius);
  background: rgba(255, 255, 255, 0.35);
}

.v2-drag-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--v2-glass-border);
  border-radius: 12px;
  cursor: move;
}

.v2-drag-card--inner {
  padding: 0.5rem;
  margin-bottom: 0.35rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.65);
}

.v2-drag-remove {
  border: none;
  background: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 0.75rem;
}

.v2-drag-unassign {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(224, 231, 255, 0.9);
  color: var(--v2-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.v2-drag-unassign:hover {
  background: var(--v2-primary);
  color: #fff;
  transform: translateX(-2px);
}

.v2-drag-unassign i {
  font-size: 0.7rem;
}

.v2-group-box {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px dashed rgba(129, 140, 248, 0.45);
  border-radius: 16px;
  padding: 0.85rem;
  min-height: 8rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Group assignment page ── */
.v2-group-assign-page {
  max-width: 64rem;
}

.v2-group-waiting-badge {
  margin-left: auto;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--v2-primary);
  background: rgba(224, 231, 255, 0.85);
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
}

.v2-subnav-title {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-group-assign-card {
  display: flex;
  flex-direction: column;
  min-height: min(70vh, 640px);
}

.v2-group-assign-card .v2-card-body {
  padding: 0;
}

.v2-group-toolbar {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--v2-border);
  background: rgba(255, 255, 255, 0.35);
}

.v2-group-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.v2-group-size-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--v2-text-muted);
}

.v2-group-size-input {
  width: 3.5rem;
  padding: 0.35rem 0.5rem;
  text-align: center;
}

.v2-group-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  min-height: 0;
}

@media (min-width: 768px) {
  .v2-group-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  }
}

.v2-group-pool,
.v2-group-groups {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 1rem;
}

.v2-group-pool {
  border-bottom: 1px solid var(--v2-border);
}

@media (min-width: 768px) {
  .v2-group-pool {
    border-bottom: none;
    border-right: 1px solid var(--v2-border);
  }
}

.v2-group-section-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.v2-group-section-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}

.v2-group-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--v2-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.v2-group-pool-hint {
  margin: 0 0 0.65rem;
  font-size: 0.8125rem;
  color: var(--v2-text-muted);
}

.v2-group-pool-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 10rem;
  padding: 0.65rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.25);
  border: 2px dashed rgba(148, 163, 184, 0.45);
  overflow-y: auto;
}

.v2-group-empty {
  margin: auto;
  text-align: center;
  font-size: 0.875rem;
  color: var(--v2-text-muted);
  padding: 1rem;
}

.v2-group-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  flex: 1;
  align-content: start;
  overflow-y: auto;
  min-height: 10rem;
}

@media (min-width: 640px) {
  .v2-group-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

.v2-group-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.v2-group-box-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--v2-text-muted);
}

.v2-group-box-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.v2-drag-grip {
  color: #94a3b8;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.v2-drag-name {
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-group-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--v2-border);
  background: rgba(255, 255, 255, 0.35);
  display: flex;
  justify-content: flex-end;
}

.v2-group-start {
  min-width: 10rem;
  padding: 0.75rem 1.5rem;
}

@media (max-width: 767px) {
  .v2-group-start {
    width: 100%;
    justify-content: center;
  }

  .v2-group-waiting-badge {
    display: none;
  }
}

.v2-container-narrow {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1rem;
}

.v2-card {
  background: var(--v2-glass-bg);
  backdrop-filter: blur(var(--v2-glass-blur));
  -webkit-backdrop-filter: blur(var(--v2-glass-blur));
  border: 1px solid var(--v2-glass-border);
  border-radius: var(--v2-radius-lg);
  box-shadow: var(--v2-shadow);
  overflow: hidden;
}

.v2-hero {
  background: linear-gradient(135deg, var(--v2-primary) 0%, var(--v2-primary-dark) 100%);
  border-radius: var(--v2-radius-lg);
  box-shadow: var(--v2-shadow-primary);
  color: #fff;
  padding: 1rem 1.25rem;
}

.v2-info-bar {
  background: var(--v2-info-bg);
  border: 1px solid var(--v2-info-border);
  border-radius: var(--v2-radius);
  color: var(--v2-info-text);
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.v2-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--v2-radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.v2-btn-primary {
  background: linear-gradient(135deg, var(--v2-primary) 0%, var(--v2-primary-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.v2-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.v2-btn-success {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.v2-btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.v2-btn-danger:hover {
  transform: translateY(-1px);
}

.v2-btn-ghost {
  background: transparent;
  color: var(--v2-text-muted);
}

.v2-btn-ghost:hover {
  background: #f1f5f9;
  color: var(--v2-text);
}

.v2-btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.v2-btn-icon {
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
  border: none;
  cursor: pointer;
}

.v2-btn-icon:hover {
  background: rgba(255, 255, 255, 0.35);
}

.v2-header {
  background: var(--v2-glass-bg);
  backdrop-filter: blur(var(--v2-glass-blur));
  -webkit-backdrop-filter: blur(var(--v2-glass-blur));
  border-bottom: 1px solid var(--v2-glass-border);
  padding: 0.75rem 1rem;
}

.v2-header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.v2-header-user {
  font-size: 0.875rem;
  color: var(--v2-text-muted);
}

.v2-lang-switch {
  display: inline-flex;
  border: 1px solid var(--v2-border);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
}

.v2-lang-btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--v2-text-muted);
  line-height: 1.4;
}

.v2-lang-btn.is-active {
  background: linear-gradient(135deg, var(--v2-primary), var(--v2-primary-dark));
  color: #fff;
}

.v2-glass-footer {
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--v2-glass-border);
}

.v2-header-inner {
  max-width: 80rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.v2-header-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--v2-text);
}

.v2-subnav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.v2-list-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--v2-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

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

.v2-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--v2-text-muted);
  font-size: 0.9375rem;
}

.v2-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 6px;
}

.v2-badge-draft { background: #f1f5f9; color: #475569; }
.v2-badge-wait { background: #dbeafe; color: #1d4ed8; }
.v2-badge-active { background: #dcfce7; color: #15803d; }
.v2-badge-ended { background: #fef2f2; color: #b91c1c; }

.v2-form-input,
.v2-form-textarea,
.v2-form-select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 2px solid var(--v2-border);
  border-radius: var(--v2-radius);
  font-size: 1rem;
  box-sizing: border-box;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.v2-form-input:focus,
.v2-form-textarea:focus,
.v2-form-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  outline: none;
}

.v2-form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.375rem;
}

.v2-form-group {
  margin-bottom: 1rem;
}

.v2-radio-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.v2-radio-row label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.9375rem;
  cursor: pointer;
}

.v2-grid-2,
.v2-grid-3 {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .v2-grid-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .v2-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .v2-room-grid--2 { grid-template-columns: repeat(2, 1fr); }
}

.v2-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.v2-btn-lg {
  padding: 0.875rem 2.5rem;
  font-size: 1.0625rem;
}

.v2-btn-icon-danger {
  background: rgba(220, 38, 38, 0.85) !important;
}

/* ── ルーム管理画面 ── */
/* タブレット以下: 一画面・スクロール抑制 */
body.v2-body-compact {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.v2-body-compact main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* PC: 通常スクロール可 */
@media (min-width: 1024px) {
  body.v2-body-compact {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  body.v2-body-compact main {
    flex: 1 0 auto;
    min-height: auto;
    overflow: visible;
  }
}

.v2-room-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

@media (min-width: 1024px) {
  .v2-room-page {
    flex: 1 0 auto;
    min-height: auto;
    overflow-x: clip;
    overflow-y: visible;
    padding: 0 0 1.5rem;
  }
}

.v2-room-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 80rem;
  margin: 0 auto;
  width: 100%;
  padding: 0.5rem 0.75rem 0.75rem;
  min-height: 0;
  box-sizing: border-box;
  overflow-x: clip;
}

.v2-room-top {
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}

.v2-room-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--v2-primary) 0%, var(--v2-primary-dark) 100%);
  border-radius: var(--v2-radius-lg);
  box-shadow: var(--v2-shadow-primary);
  color: #fff;
  padding: 0.65rem 1rem;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.v2-room-hero-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
}

.v2-room-hero-sub {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  opacity: 0.9;
}

.v2-room-hero-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.v2-room-reception {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
}

.v2-info-bar-compact {
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

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

@media (min-width: 1024px) {
  .v2-room-main {
    flex: 1 0 auto;
    min-height: auto;
    overflow-x: clip;
    overflow-y: visible;
  }
}

.v2-room-columns {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.v2-room-columns--draft {
  max-width: 36rem;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 768px) {
  .v2-room-columns--active {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  }
}

.v2-room-panel {
  background: var(--v2-glass-bg);
  backdrop-filter: blur(var(--v2-glass-blur));
  -webkit-backdrop-filter: blur(var(--v2-glass-blur));
  border: 1px solid var(--v2-glass-border);
  border-radius: var(--v2-radius-lg);
  box-shadow: var(--v2-shadow);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.v2-room-panel-join {
  grid-column: 1;
  min-width: 0;
}

.v2-room-panel-waiters {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

@media (min-width: 768px) {
  .v2-room-columns--active .v2-room-panel-waiters {
    grid-column: 2;
  }
}

.v2-room-panel-wide {
  margin-top: 0.5rem;
  flex-shrink: 0;
  max-height: 8rem;
  overflow-y: auto;
}

.v2-room-panel-title {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.v2-room-panel-title .fa-qrcode { color: #2563eb; }
.v2-room-panel-title .fa-sliders-h { color: #ea580c; }
.v2-room-panel-title .fa-users { color: #16a34a; }
.v2-room-panel-title .fa-user-plus { color: #ea580c; }

.v2-room-count {
  color: #16a34a;
}

.v2-join-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  width: 100%;
  justify-content: flex-start;
  overflow: hidden;
}

.v2-join-code-compact {
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.v2-join-code-status {
  font-size: 0.6875rem;
  color: #2563eb;
  margin: 0.35rem 0 0;
}

.v2-join-url-box {
  padding: 0.4rem 0.6rem;
  background: #f8fafc;
  border-radius: var(--v2-radius);
  font-size: 0.6875rem;
  word-break: break-all;
  line-height: 1.4;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

.v2-join-qr-wrap {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.v2-join-url-label {
  color: var(--v2-text-muted);
  margin-right: 0.25rem;
}

.v2-join-url-link {
  color: var(--v2-primary);
  text-decoration: none;
}

.v2-join-url-link:hover {
  text-decoration: underline;
}

.v2-qr-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--v2-border);
  border-radius: var(--v2-radius);
  background: #fff;
  box-sizing: border-box;
}

.v2-room-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.v2-form-input-sm,
.v2-form-textarea-sm {
  font-size: 0.9375rem;
  padding: 0.5rem 0.625rem;
}

.v2-form-input-narrow {
  max-width: 7rem;
}

.v2-form-hint {
  font-weight: 400;
  color: var(--v2-text-muted);
}

.v2-form-divider {
  border-top: 1px solid #f1f5f9;
  margin: 0.25rem 0 0.75rem;
}

.v2-form-group-last {
  margin-bottom: 0;
}

.v2-waiter-list {
  background: #f8fafc;
  border-radius: var(--v2-radius);
  padding: 0.4rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.v2-waiter-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 0.3rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.v2-waiter-item i {
  color: #94a3b8;
}

.v2-room-panel-actions {
  margin-top: 0.65rem;
  flex-shrink: 0;
}

.v2-btn-block {
  width: 100%;
  justify-content: center;
}

.v2-room-empty-text {
  text-align: center;
  color: var(--v2-text-muted);
  font-size: 0.8125rem;
  padding: 1rem 0;
  margin: 0;
}

.v2-room-footer-hint {
  margin: 0.4rem 0 0;
  font-size: 0.75rem;
  color: var(--v2-text-muted);
  text-align: center;
}

.v2-late-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.v2-late-row:last-child {
  border-bottom: none;
}

.v2-late-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.v2-form-input[type="number"] {
  max-width: 8rem;
}

.v2-join-code {
  background: var(--v2-code-bg);
  border: 2px solid var(--v2-code-border);
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
}

.v2-join-code-value {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #1e40af;
}

.v2-form-textarea {
  min-height: 5rem;
  resize: vertical;
}

.v2-scroll {
  overflow-y: auto;
  max-height: 280px;
}

.v2-scroll::-webkit-scrollbar { width: 6px; }
.v2-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.v2-history-sessions { list-style: none; margin: 0; padding: 0; }
.v2-history-sessions li {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--v2-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.v2-history-sessions li:last-child { border-bottom: none; }

.v2-msg-list { padding: 0.75rem; max-height: 60vh; overflow-y: auto; }

.v2-chat-immersive {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: max(0.4rem, env(safe-area-inset-top, 0px)) max(0.65rem, env(safe-area-inset-right, 0px)) 0 max(0.65rem, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  overflow: hidden;
}

.v2-chat-immersive > .v2-student-bg {
  z-index: 0;
}

.v2-chat-wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.v2-chat-lang {
  align-self: flex-end;
  margin-bottom: 0.25rem;
  flex-shrink: 0;
  transform: scale(0.9);
  transform-origin: top right;
}

.v2-chat-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  background: var(--v2-glass-bg);
  backdrop-filter: blur(var(--v2-glass-blur));
  -webkit-backdrop-filter: blur(var(--v2-glass-blur));
  border: 1px solid var(--v2-glass-border);
  border-radius: 22px;
  box-shadow: 0 16px 48px rgba(79, 70, 229, 0.18);
  overflow: hidden;
}

.v2-chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--v2-border);
  background: rgba(255, 255, 255, 0.35);
  min-height: 0;
}

.v2-chat-header-btn,
.v2-chat-icon-btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--v2-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.8125rem;
}

.v2-chat-header-btn:hover,
.v2-chat-icon-btn:hover {
  background: #eef2ff;
  color: var(--v2-primary);
}

.v2-chat-icon-btn--send {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}

.v2-chat-header-main {
  flex: 1;
  min-width: 0;
}

.v2-chat-header-title {
  font-weight: 700;
  font-size: 0.8125rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-chat-header-topic {
  margin-top: 0.1rem;
  font-size: 0.6875rem;
  color: var(--v2-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-chat-header-topic .fa-lightbulb {
  color: #f59e0b;
  font-size: 0.625rem;
}

.v2-chat-header-badges {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.v2-chat-pill {
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 999px;
  white-space: nowrap;
  background: #e0e7ff;
  color: #3730a3;
}

.v2-chat-pill--time {
  background: #fef3c7;
  color: #b45309;
}

.v2-chat-pill--ended {
  background: #fee2e2;
  color: #b91c1c;
}

.v2-chat-header-stats {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.6875rem;
  color: var(--v2-text-muted);
  background: rgba(255, 255, 255, 0.22);
  border-bottom: 1px solid var(--v2-border);
}

.v2-chat-header-stats i {
  opacity: 0.65;
  margin-right: 0.15rem;
  font-size: 0.625rem;
}

.v2-chat-messages-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.v2-chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0.65rem 0.35rem;
  background: rgba(255, 255, 255, 0.15);
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.v2-chat-typing[hidden],
.v2-chat-ai-thinking[hidden],
.v2-chat-ai[hidden],
.v2-chat-input-ghost[hidden],
.v2-chat-trace-panel[hidden] {
  display: none !important;
}

.v2-chat-typing {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem 0.35rem;
  font-size: 0.6875rem;
  color: var(--v2-text-muted);
}

.v2-chat-typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.v2-chat-typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--v2-primary);
  animation: v2-typing-bounce 1.2s infinite ease-in-out;
}

.v2-chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.v2-chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

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

.v2-chat-scroll-down {
  position: absolute;
  right: 0.65rem;
  bottom: 0.5rem;
  z-index: 3;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.v2-chat-scroll-down:hover {
  transform: translateY(-1px);
}

.v2-chat-empty {
  margin: 2rem auto;
  text-align: center;
  color: var(--v2-text-muted);
  font-size: 0.8125rem;
}

.v2-msg-row {
  display: flex;
  margin-bottom: 0.4rem;
}

.v2-msg-row-mine { justify-content: flex-end; }
.v2-msg-row-other { justify-content: flex-start; }
.v2-msg-row-center { justify-content: center; }

.v2-msg {
  max-width: min(78%, 20rem);
  padding: 0.45rem 0.65rem;
  font-size: 0.875rem;
  line-height: 1.45;
  word-break: break-word;
}

.v2-msg-mine {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.v2-msg-user {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--v2-text);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.v2-msg-broadcast {
  max-width: 92%;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 12px;
  text-align: center;
  font-size: 0.8125rem;
}

.v2-msg-teacher {
  max-width: 92%;
  background: #e0e7ff;
  color: #3730a3;
  border-radius: 12px;
  font-size: 0.8125rem;
}

.v2-msg-name {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--v2-text-muted);
  margin-bottom: 0.15rem;
}

.v2-msg-time {
  font-size: 0.5625rem;
  opacity: 0.55;
  margin-top: 0.15rem;
  text-align: right;
}

.v2-msg-user .v2-msg-time { text-align: left; }

.v2-msg-mine .v2-msg-time {
  color: rgba(255, 255, 255, 0.75);
  text-align: right;
}

.v2-chat-composer {
  flex-shrink: 0;
  border-top: 1px solid var(--v2-border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translateY(calc(var(--v2-kb-offset, 0px) * -1));
}

.v2-chat-composer-inner {
  padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
}

.v2-chat-composer .v2-chat-ai,
.v2-chat-composer .v2-chat-ai-thinking {
  margin: 0 0 0.35rem;
}

.v2-chat-form {
  padding: 0;
}

.v2-chat-trace-panel {
  margin-bottom: 0.35rem;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  background: rgba(224, 231, 255, 0.85);
  border: 1px solid rgba(199, 210, 254, 0.9);
}

.v2-chat-trace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.v2-chat-trace-label {
  color: #4338ca;
  font-size: 0.6875rem;
  font-weight: 600;
}

.v2-chat-trace-label i {
  margin-right: 0.25rem;
}

.v2-chat-trace-text {
  margin: 0;
  color: #475569;
  font-size: 0.8125rem;
  line-height: 1.45;
  font-style: italic;
  word-break: break-word;
}

.v2-chat-trace-clear {
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  padding: 0.1rem 0.25rem;
  font-size: 0.75rem;
}

.v2-chat-input-shell {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.v2-chat-input-ghost {
  position: absolute;
  left: 0.65rem;
  right: 0.65rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  line-height: 2rem;
  color: rgba(100, 116, 139, 0.35);
  font-style: italic;
  pointer-events: none;
  z-index: 0;
}

.v2-chat-input-shell .v2-chat-input {
  position: relative;
  z-index: 1;
  width: 100%;
  background: rgba(255, 255, 255, 0.78);
}

.v2-chat-form-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0;
}

.v2-chat-input {
  flex: 1;
  min-width: 0;
  height: 2rem;
  padding: 0 0.65rem;
  font-size: 0.875rem;
  border-radius: 999px;
}

.v2-chat-input-shell .v2-chat-input {
  flex: 1;
}

.v2-chat-ai-toggle.is-on {
  color: var(--v2-primary);
  background: rgba(224, 231, 255, 0.95);
}

.v2-chat-ai,
.v2-chat-ai-thinking {
  max-height: 8rem;
  overflow-y: auto;
  padding: 0.45rem 0.55rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #c7d2fe;
}

.v2-chat-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--v2-primary);
  margin-bottom: 0.3rem;
}

.v2-chat-ai-close {
  border: none;
  background: none;
  color: var(--v2-text-muted);
  cursor: pointer;
  padding: 0.15rem;
}

.v2-chat-ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.v2-chat-ai-chip {
  border: 1px solid #a5b4fc;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
  max-width: 100%;
  text-align: left;
}

.v2-chat-ai-thinking {
  font-size: 0.75rem;
  color: var(--v2-text-muted);
  text-align: center;
}

/* history / monitor message list */
.v2-msg-list .v2-msg {
  max-width: 88%;
  margin-bottom: 0.55rem;
  border-radius: 14px;
}

.v2-msg-list .v2-msg-mine {
  margin-left: auto;
}

.v2-msg-list .v2-msg-user {
  margin-right: auto;
}

.v2-msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.v2-teacher-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 0.85rem;
  padding: 0.25rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--v2-glass-border);
  border-radius: 14px;
}

.v2-teacher-tabs--bar {
  margin: 0 0 1rem;
}

.v2-teacher-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--v2-text-muted);
  transition: background 0.15s, color 0.15s;
}

.v2-teacher-tab:hover {
  color: var(--v2-primary);
  background: rgba(224, 231, 255, 0.55);
}

.v2-teacher-tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
}

.v2-join-card { max-width: 400px; margin: 0 auto; padding: 1.5rem; }
.v2-wait-pulse { animation: v2-pulse 1.5s ease-in-out infinite; }
@keyframes v2-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.v2-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.v2-modal {
  background: var(--v2-glass-bg);
  backdrop-filter: blur(var(--v2-glass-blur));
  -webkit-backdrop-filter: blur(var(--v2-glass-blur));
  border: 1px solid var(--v2-glass-border);
  border-radius: var(--v2-radius-lg);
  padding: 1.5rem;
  max-width: 24rem;
  width: 100%;
  box-shadow: var(--v2-shadow);
}

.v2-modal-wide {
  max-width: 32rem;
  max-height: min(90vh, 560px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.v2-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--v2-border);
  flex-shrink: 0;
}

.v2-modal-header h3 {
  margin: 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.v2-modal-close {
  background: none;
  border: none;
  color: var(--v2-text-muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1rem;
  line-height: 1;
}

.v2-modal-wide .v2-room-form {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.v2-modal-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--v2-border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.v2-group-box {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px dashed rgba(129, 140, 248, 0.45);
  border-radius: 16px;
  min-height: 180px;
  padding: 1rem;
}

.v2-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 0.75rem;
  font-weight: 600;
}

.v2-timeup-backdrop {
  z-index: 200;
}

.v2-timeup-modal {
  max-width: 22rem;
  padding: 1.5rem 1.25rem;
}

.v2-timeup-icon {
  font-size: 2.5rem;
  color: #ca8a04;
  margin-bottom: 0.75rem;
}

.v2-timeup-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.v2-timeup-stats {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
  color: var(--v2-text-muted);
  font-size: 0.9375rem;
}

.v2-timeup-stats strong {
  color: var(--v2-text);
}

.v2-timeup-note {
  margin: 0 0 1.25rem;
  font-size: 0.8125rem;
  color: var(--v2-text-muted);
}

.v2-timeup-home {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
}

.v2-timeup-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.v2-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--v2-radius);
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}
.v2-alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.v2-alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

.v2-toggle {
  background: #9ca3af;
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.v2-toggle.is-on { background: #22c55e; }

.v2-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.v2-card-body { padding: 1.25rem; }

.v2-full-height-page {
  min-height: calc(100vh - 120px);
}

.v2-site-footer {
  padding: 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--v2-text-muted);
  border-top: 1px solid var(--v2-border);
  margin-top: 2rem;
  flex-shrink: 0;
}

/* ルーム管理・タブレット以下のみフッター非表示（一画面用） */
@media (max-width: 1023px) {
  .v2-site-footer--room-compact {
    display: none;
  }
}

@media (min-width: 1024px) {
  .v2-site-footer--room-compact {
    margin-top: 0;
  }
}

/* ── 生徒向け 参加・待機（没入・一画面） ── */
body.v2-body-student {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
  background: #eef2ff;
}

body.v2-body-student main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

body.v2-body-student main.v2-glass-main {
  min-height: 0;
}

.v2-student-page {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: 100%;
  padding: 1rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(145deg, #eef2ff 0%, #f5f3ff 45%, #fce7f3 100%);
}

.v2-student-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.v2-student-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: v2-student-float 8s ease-in-out infinite;
}

.v2-student-orb--1 {
  width: 220px;
  height: 220px;
  background: #818cf8;
  top: -40px;
  left: -30px;
}

.v2-student-orb--2 {
  width: 180px;
  height: 180px;
  background: #c084fc;
  bottom: 10%;
  right: -20px;
  animation-delay: -3s;
}

.v2-student-orb--3 {
  width: 140px;
  height: 140px;
  background: #f472b6;
  top: 35%;
  right: 20%;
  animation-delay: -5s;
}

@keyframes v2-student-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(12px, -16px) scale(1.06); }
}

.v2-student-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 26rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.v2-student-brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--v2-primary);
  flex-shrink: 0;
}

.v2-student-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  box-shadow: 0 16px 48px rgba(79, 70, 229, 0.18);
  padding: 1.5rem 1.35rem;
  text-align: center;
  box-sizing: border-box;
  animation: v2-student-pop 0.55s ease-out;
  max-height: calc(100dvh - 4rem);
  overflow-y: auto;
  overflow-x: hidden;
}

@keyframes v2-student-pop {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.v2-student-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #fff;
}

.v2-student-icon--join {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.v2-student-icon--ready {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
  animation: v2-student-bounce 2s ease-in-out infinite;
}

@keyframes v2-student-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.v2-student-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f59e0b;
}

.v2-student-kicker--wait {
  color: var(--v2-primary);
}

.v2-student-title {
  margin: 0 0 0.35rem;
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--v2-text);
}

.v2-student-lead {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  color: var(--v2-text-muted);
  line-height: 1.5;
}

.v2-student-task {
  text-align: left;
  background: linear-gradient(135deg, #eff6ff, #f5f3ff);
  border: 1px solid #c7d2fe;
  border-radius: 14px;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.v2-student-task--compact {
  margin-bottom: 0.75rem;
  max-height: 5rem;
  overflow-y: auto;
}

.v2-student-task-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--v2-primary);
  margin-bottom: 0.25rem;
}

.v2-student-task p {
  margin: 0;
  color: var(--v2-text);
}

.v2-student-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  text-align: left;
}

.v2-student-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--v2-text-muted);
}

.v2-student-input-code {
  letter-spacing: 0.12em;
  text-align: center;
  font-size: 1.0625rem;
  font-weight: 600;
}

.v2-student-input-name {
  font-size: 1.0625rem;
  text-align: center;
}

.v2-student-btn-go {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1.0625rem;
  border-radius: 14px;
  margin-top: 0.25rem;
}

.v2-student-btn-pulse {
  animation: v2-student-pulse-btn 2s ease-in-out infinite;
}

@keyframes v2-student-pulse-btn {
  0%, 100% { box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35); }
  50% { box-shadow: 0 6px 28px rgba(79, 70, 229, 0.55); transform: translateY(-1px); }
}

.v2-student-foot {
  margin: 1rem 0 0;
  font-size: 0.8125rem;
}

.v2-student-foot a {
  color: var(--v2-primary);
  text-decoration: none;
}

.v2-student-foot a:hover {
  text-decoration: underline;
}

/* 待機画面 */
.v2-student-wait-ring {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.v2-student-wait-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--v2-primary);
  animation: v2-student-dot 1.2s ease-in-out infinite;
}

.v2-student-wait-dot:nth-child(2) { animation-delay: 0.2s; }
.v2-student-wait-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes v2-student-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.2); opacity: 1; }
}

.v2-student-name-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #dbeafe, #e0e7ff);
  border: 2px solid #a5b4fc;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  margin: 0.5rem 0 0.75rem;
  font-weight: 700;
  font-size: 0.9375rem;
  color: #3730a3;
}

.v2-student-name-badge i {
  color: var(--v2-primary);
}

.v2-student-wait-msg {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--v2-text);
  min-height: 1.5em;
  transition: opacity 0.3s;
}

.v2-student-cancel {
  margin-top: 0.5rem;
}

.v2-student-cancel .v2-btn {
  font-size: 0.8125rem;
  color: var(--v2-text-muted);
}

/* Monitor / History */
.v2-monitor-page,
.v2-history-page {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.v2-monitor-hero {
  background: linear-gradient(135deg, var(--v2-primary) 0%, var(--v2-primary-dark) 100%);
  border-radius: 20px;
  padding: 1.25rem 1.5rem;
  color: #fff;
  margin-bottom: 1rem;
  box-shadow: 0 8px 32px rgba(79, 70, 229, 0.25);
}

.v2-monitor-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.v2-monitor-back {
  color: rgba(255, 255, 255, 0.9) !important;
  margin-bottom: 0.35rem;
}

.v2-monitor-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.v2-monitor-sub {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  opacity: 0.85;
}

.v2-monitor-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.v2-monitor-hero-actions .v2-btn-ghost {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.v2-monitor-timer-bar {
  margin-top: 1rem;
}

.v2-monitor-timer-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}

.v2-monitor-timer-fill {
  height: 100%;
  background: #fff;
  border-radius: 999px;
  transition: width 1s linear;
}

.v2-monitor-timer-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
  font-size: 0.8125rem;
  opacity: 0.9;
}

.v2-monitor-timer-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.v2-monitor-alert {
  background: rgba(254, 226, 226, 0.9);
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  text-align: center;
}

.v2-monitor-section {
  margin-bottom: 1rem;
}

.v2-monitor-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.v2-monitor-section-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.v2-monitor-export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.v2-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .v2-stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.v2-stat-card {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid var(--v2-border);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  text-align: center;
}

.v2-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.v2-stat-label {
  font-size: 0.75rem;
  color: var(--v2-text-muted);
  margin-top: 0.15rem;
}

.v2-stat-card--blue .v2-stat-value { color: #2563eb; }
.v2-stat-card--orange .v2-stat-value { color: #ea580c; }
.v2-stat-card--green .v2-stat-value { color: #059669; }
.v2-stat-card--purple .v2-stat-value { color: #7c3aed; }

.v2-dropdown {
  position: relative;
}

.v2-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 10rem;
  background: #fff;
  border: 1px solid var(--v2-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 50;
  overflow: hidden;
}

.v2-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
  color: var(--v2-text);
  text-decoration: none;
}

.v2-dropdown-item:hover {
  background: #f8fafc;
}

.v2-dropdown-menu--wide {
  min-width: 12rem;
}

.v2-dropdown-section {
  padding: 0.4rem 0.85rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--v2-text-muted);
}

.v2-dropdown-section:not(:first-child) {
  border-top: 1px solid var(--v2-border);
  margin-top: 0.25rem;
  padding-top: 0.55rem;
}

.v2-monitor-broadcast {
  margin-bottom: 1rem;
}

.v2-monitor-broadcast-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.v2-monitor-broadcast-row textarea {
  flex: 1;
  min-width: 200px;
}

.v2-monitor-info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (min-width: 768px) {
  .v2-monitor-info-grid {
    grid-template-columns: 1fr 1.4fr;
  }
}

.v2-monitor-join {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.v2-monitor-qr {
  width: 100px;
  height: 100px;
  border-radius: 10px;
  background: #fff;
  padding: 4px;
}

.v2-monitor-join-meta {
  flex: 1;
  min-width: 140px;
  font-size: 0.8125rem;
}

.v2-monitor-join-code strong {
  font-family: ui-monospace, monospace;
  font-size: 1rem;
}

.v2-monitor-join-url {
  display: block;
  margin-top: 0.35rem;
  color: var(--v2-primary);
  word-break: break-all;
  font-size: 0.75rem;
}

.v2-monitor-waiters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 2.5rem;
}

.v2-monitor-waiter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--v2-border);
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.8125rem;
  cursor: pointer;
}

.v2-monitor-waiter-chip:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.v2-monitor-groups-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.v2-monitor-group-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .v2-monitor-group-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.v2-monitor-group-card {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid var(--v2-border);
  border-radius: 16px;
  padding: 1rem 1.1rem;
}

.v2-monitor-group-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.v2-monitor-group-head h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--v2-primary);
}

.v2-monitor-group-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--v2-text-muted);
}

.v2-monitor-member-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  font-size: 0.875rem;
}

.v2-monitor-member-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.v2-monitor-member-meta {
  font-size: 0.75rem;
  color: var(--v2-text-muted);
  white-space: nowrap;
}

.v2-monitor-group-send {
  display: flex;
  gap: 0.35rem;
}

.v2-monitor-group-send input {
  flex: 1;
}

.v2-monitor-late {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--v2-border);
}

.v2-monitor-late-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--v2-text-muted);
  margin-bottom: 0.35rem;
}

.v2-monitor-late-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.v2-monitor-chat-log {
  max-height: 50vh;
  overflow-y: auto;
}

.v2-monitor-teacher-compose {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--v2-border);
}

.v2-monitor-teacher-compose textarea {
  flex: 1;
}

/* History page */
.v2-history-page {
  padding-bottom: 1.5rem;
}

.v2-history-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid var(--v2-border);
  border-radius: 14px;
}

.v2-history-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.v2-history-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--v2-text);
  text-decoration: none;
  flex-shrink: 0;
  font-size: 0.8125rem;
}

.v2-history-icon-btn:hover {
  background: #e2e8f0;
}

.v2-history-toolbar-title {
  min-width: 0;
}

.v2-history-toolbar-title h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}

.v2-history-toolbar-title p {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--v2-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-history-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.v2-history-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.v2-history-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--v2-border);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--v2-text-muted);
}

.v2-history-chip i {
  font-size: 0.6875rem;
  opacity: 0.7;
}

.v2-history-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  margin-bottom: 0.75rem;
  scrollbar-width: thin;
}

.v2-history-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-width: 6.5rem;
  padding: 0.55rem 0.75rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--v2-border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.v2-history-tab:hover {
  background: rgba(255, 255, 255, 0.85);
}

.v2-history-tab.is-active {
  background: #eef2ff;
  border-color: #c7d2fe;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.15);
}

.v2-history-tab-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--v2-primary);
}

.v2-history-tab-meta {
  font-size: 0.6875rem;
  color: var(--v2-text-muted);
}

.v2-history-tab-badge {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
}

.v2-history-tab-badge.is-ended {
  background: #fee2e2;
  color: #991b1b;
}

.v2-history-panel {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid var(--v2-border);
  border-radius: 16px;
  overflow: hidden;
}

.v2-history-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--v2-border);
  background: rgba(248, 250, 252, 0.6);
}

.v2-history-panel-head h2 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}

.v2-history-panel-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--v2-text-muted);
}

.v2-history-panel-times i {
  margin-right: 0.2rem;
  opacity: 0.65;
}

.v2-history-mini-stats {
  display: flex;
  gap: 0.5rem;
}

.v2-history-mini-stats div {
  text-align: center;
  min-width: 3.25rem;
  padding: 0.35rem 0.5rem;
  background: #fff;
  border: 1px solid var(--v2-border);
  border-radius: 10px;
}

.v2-history-mini-stats strong {
  display: block;
  font-size: 1rem;
  line-height: 1.2;
  color: var(--v2-primary);
}

.v2-history-mini-stats span {
  display: block;
  font-size: 0.625rem;
  color: var(--v2-text-muted);
  margin-top: 0.1rem;
}

.v2-history-members {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--v2-border);
}

.v2-history-member-chip {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.4rem 0.65rem;
  background: #f8fafc;
  border: 1px solid var(--v2-border);
  border-radius: 10px;
  min-width: 7rem;
}

.v2-history-member-name {
  font-size: 0.8125rem;
  font-weight: 600;
}

.v2-history-member-stat {
  font-size: 0.6875rem;
  color: var(--v2-text-muted);
}

.v2-history-log {
  padding: 0.75rem 1rem 1rem;
}

.v2-history-log h3 {
  margin: 0 0 0.65rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--v2-text-muted);
}

.v2-history-log h3 i {
  margin-right: 0.35rem;
}

.v2-history-log-body {
  max-height: min(55vh, 28rem);
  overflow-y: auto;
  padding: 0.5rem;
  background: #f8fafc;
  border: 1px solid var(--v2-border);
  border-radius: 12px;
}

.v2-history-log-body .v2-msg-row:last-child {
  margin-bottom: 0;
}

[x-cloak] { display: none !important; }
