:root {
  --bg: #11161c;
  --panel: #1b222b;
  --line: #2a333e;
  --accent: #ff7a1a;
  --blue: #2b7de9;
  --red: #d9443a;
  --gray: #3a4552;
  --text: #eef1f4;
  --muted: #8b96a3;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
header h1 { margin: 0; font-size: 17px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#who { color: var(--muted); font-size: 13px; white-space: nowrap; }

h2 { font-size: 16px; margin: 0 0 10px; }
a { color: #7fb2ff; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.msg { color: #ffb37a; font-size: 13px; min-height: 18px; }

.panel {
  max-width: 420px;
  margin: 32px auto;
  padding: 24px;
  background: var(--panel);
  border-radius: 12px;
}
.wide { max-width: 960px; margin: 16px auto; padding: 0 16px 40px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=search], select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f1419;
  color: var(--text);
  font-size: 16px;
}

button, .btn {
  padding: 11px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-family: inherit;
}
button:active, .btn:active { opacity: 0.8; }
button:disabled { opacity: 0.5; cursor: default; }
.blue { background: var(--blue); }
.red { background: var(--red); }
.gray { background: var(--gray); }
.dark { background: #232b35; border: 1px solid var(--line); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.small-btn { padding: 6px 10px; font-size: 13px; }

.row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.row input { flex: 1; }
.row.between { justify-content: space-between; flex-wrap: wrap; margin-top: 24px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 8px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.list li .name { font-size: 16px; }
.list li .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.list li.done { opacity: 0.6; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--gray); white-space: nowrap; }

.join-box { background: var(--panel); border-radius: 12px; padding: 16px; }
.join-box p { margin-top: 0; }
.join-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.join-buttons button { flex: 1; min-width: 200px; padding: 16px; font-size: 16px; }
.join-buttons small { display: block; font-size: 12px; opacity: 0.85; margin-top: 4px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.grid figure { margin: 0; background: #000; border-radius: 8px; overflow: hidden; cursor: pointer; position: relative; }
.grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.grid figcaption { font-size: 11px; padding: 4px 6px; color: var(--muted); background: var(--panel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- 通話 ---- */
#call-view { max-width: 1100px; margin: 0 auto; padding: 10px 12px 30px; position: relative; }
#videos { display: flex; flex-wrap: wrap; gap: 8px; }
.tile {
  position: relative;
  width: 150px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
}
.tile.main {
  order: -1;
  width: 100%;
  height: min(70vh, 62vw);
  aspect-ratio: auto;
  cursor: crosshair;
  border-color: transparent;
}
.tile:not(.main):hover { border-color: var(--accent); }
.tile .video { position: absolute; inset: 0; }
.tile canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.tile:not(.main) canvas { pointer-events: none; }
.tile .label {
  position: absolute; left: 6px; bottom: 6px;
  font-size: 12px; padding: 2px 8px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.6); pointer-events: none;
}
.tile .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; text-align: center; padding: 10px; }

#toolbar { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
#toolbar button { flex: 1 1 auto; }
#people { margin-top: 6px; }
#rec-badge {
  position: fixed; top: 64px; right: 14px; z-index: 10;
  background: var(--red); color: #fff; font-size: 13px; padding: 5px 12px; border-radius: 14px;
  animation: blink 1.4s infinite;
}
@keyframes blink { 50% { opacity: 0.55; } }

/* ---- 写真を大きく見る ---- */
#viewer {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.92);
  display: flex; flex-direction: column;
}
#viewer img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
#viewer-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: var(--panel); align-items: center; }
#viewer-bar input { flex: 1 1 220px; width: auto; }
#viewer-info { font-size: 12px; color: var(--muted); flex: 1 1 100%; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: #000; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: calc(100% - 32px);
}

@media (max-width: 600px) {
  .tile { width: 110px; }
  .tile.main { height: 58vh; }
  #toolbar button { font-size: 13px; padding: 10px 8px; }
}
