:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --live: #16a34a;
  --stage: #0b0d12;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px rgb(0 0 0 / 0.06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #1f232a;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #2a2f38;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-soft: #1e293b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --live: #22c55e;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", "Yu Gothic UI", "Hiragino Sans", system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
p { margin: 0; }
.mono { font-variant-numeric: tabular-nums; }
.muted, .sub { color: var(--muted); }
.sub { font-size: 13px; }

/* ---- ボタン ---- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: var(--danger-hover); }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn.ghost:hover { color: var(--text); }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- 接続前 ---- */
.landing {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.brand h1 { font-size: 20px; margin: 0; }
.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}
.logo svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; }

.join { display: grid; gap: 10px; }
.join label { font-size: 13px; color: var(--muted); }
.join input {
  font: inherit;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 14px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
}
.join input::placeholder { color: var(--border); }
.join input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.join .btn { margin-top: 6px; }

.waiting {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px 14px;
  align-items: center;
}
.waiting .btn { grid-column: 1 / -1; }
.waiting-title { font-weight: 600; }
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.message { min-height: 1.4em; margin-top: 16px; font-size: 14px; color: var(--muted); text-align: center; }
.message.error { color: var(--danger); }

/* ---- 接続中 ---- */
.session {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--stage);
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 16px;
  background: #14171d;
  color: #e5e7eb;
  border-bottom: 1px solid #262a33;
  font-size: 14px;
}
.live { display: flex; align-items: center; gap: 10px; }
.live .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgb(34 197 94 / 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgb(34 197 94 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0); }
}
.live .divider { width: 1px; height: 14px; background: #343a46; }
.live .muted { color: #9ca3af; }
.actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  color: #cbd5e1;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}
.icon-btn:hover { background: #222731; color: #fff; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.actions .btn { margin-left: 8px; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px;
}
#screen {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  background: #000;
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.5);
  outline: none;
}
#screen:focus { box-shadow: 0 0 0 2px var(--accent), 0 10px 40px rgb(0 0 0 / 0.5); }
.session:fullscreen .stage { padding: 0; }
.session:fullscreen #screen { border-radius: 0; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgb(20 23 29 / 0.92);
  color: #e5e7eb;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #2a2f38;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.toast.show { opacity: 1; }

/* ---- ログイン ---- */
.login { display: grid; gap: 8px; }
.login label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.login input {
  font: inherit;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
}
.login input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.login .btn { margin-top: 14px; }

/* ---- ログイン中の担当者・記録へのリンク ---- */
.account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.account .links { display: flex; gap: 4px; }
.link-btn {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.link-btn:hover { background: var(--accent-soft); }

/* ---- 記録 ---- */
.logs-page { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.logs-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.logs-head h1 { font-size: 20px; margin: 0 0 4px; }
.logs-actions { display: flex; gap: 8px; }
.logs-actions a.btn { text-decoration: none; }
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
#logs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#logs-table th, #logs-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
#logs-table th { background: var(--surface-2); color: var(--muted); font-weight: 600; position: sticky; top: 0; }
#logs-table td:first-child { font-variant-numeric: tabular-nums; }
#logs-table tr:last-child td { border-bottom: 0; }
#logs-table tr.warn td:nth-child(2) { color: var(--danger); font-weight: 600; }

@media (max-width: 560px) {
  .icon-btn span { display: none; }
  .card { padding: 22px; }
}
