:root {
  --bg: #0f0f0f;
  --panel: #1c1c1c;
  --line: #2e2e2e;
  --text: #f1f1f1;
  --muted: #9a9a9a;
  --accent: #ff4e45;
  --owner: #ffd600;
  --mod: #5e84f1;
  --member: #2ba640;
  --font: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.screen { height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; }
.jump { max-width: 680px; }

/* ログイン */
#login { align-items: center; justify-content: center; padding: 24px; }
.card { width: min(360px, 100%); display: grid; gap: 12px; }
.card h1 { font-size: 20px; margin: 0 0 8px; }
.card label { color: var(--muted); font-size: 14px; }
input {
  width: 100%; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 16px; /* iOSの自動ズームを防ぐ */
}
button {
  padding: 12px 16px; border: 0; border-radius: 10px;
  background: var(--accent); font-weight: 600; cursor: pointer;
}
.error { color: #ff8a80; min-height: 1.4em; margin: 0; font-size: 14px; }

/* 上部バー */
.bar {
  padding: calc(env(safe-area-inset-top) + 8px) 10px 8px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  display: grid; gap: 8px;
}
.target { display: flex; gap: 8px; }
.target input { flex: 1; min-width: 0; padding: 10px 12px; }
.target button { padding: 10px 14px; }
.sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tools { display: flex; gap: 6px; }
.icon { background: #2a2a2a; padding: 6px 10px; font-size: 14px; font-weight: 500; border-radius: 8px; }

.status { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #666; }
.status[data-state="live"]::before { background: #2ecc71; }
.status[data-state="connecting"]::before,
.status[data-state="reconnecting"]::before { background: #f1c40f; }
.status[data-state="error"]::before { background: #e74c3c; }

.recent { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.recent:empty { display: none; }
.recent button {
  flex: none; background: #2a2a2a; font-size: 12px; font-weight: 400;
  padding: 4px 10px; border-radius: 999px; max-width: 60vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* チャット */
.chat {
  flex: 1; overflow-y: auto; margin: 0; padding: 6px 10px calc(env(safe-area-inset-bottom) + 12px);
  list-style: none; font-size: var(--font); line-height: 1.45;
  overscroll-behavior: contain;
}
.msg { padding: 4px 0; overflow-wrap: anywhere; }
.msg .time { color: var(--muted); font-size: 0.75em; margin-right: 6px; font-variant-numeric: tabular-nums; }
.msg .name { color: var(--muted); margin-right: 6px; font-weight: 600; }
.msg.member .name { color: var(--member); }
.msg.mod .name { color: var(--mod); }
.msg.owner .name { color: var(--bg); background: var(--owner); padding: 0 4px; border-radius: 3px; }
.msg img.emoji { height: 1.3em; width: auto; vertical-align: -0.3em; }
.msg.sc {
  margin: 6px 0; padding: 8px 10px; border-radius: 8px;
  background: var(--sc, #1565c0); color: #000;
}
.msg.sc .name, .msg.sc .time { color: rgba(0,0,0,.75); }
.msg.sc .amount { display: block; font-weight: 700; }
.msg.sys { color: var(--muted); font-size: 0.85em; text-align: center; padding: 8px 0; }

.jump {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  border-radius: 999px; padding: 8px 16px; box-shadow: 0 4px 16px rgba(0,0,0,.5);
}

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 12px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
.menu { display: grid; gap: 8px; min-width: 240px; }
.menu button { background: #2a2a2a; font-weight: 500; }

/* モード切替 */
.modes { display: grid; grid-template-columns: 1fr 1fr; background: #2a2a2a; border-radius: 10px; padding: 3px; }
.modes button { background: transparent; font-size: 14px; font-weight: 500; padding: 6px; border-radius: 8px; color: var(--muted); }
.modes button[aria-selected="true"] { background: #444; color: var(--text); }

/* リプレイの再生操作 */
.player { display: grid; gap: 8px; }
.player .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.player .clock { font-variant-numeric: tabular-nums; font-size: 15px; }
.seek-form { display: flex; gap: 6px; }
.seek-form input { width: 96px; padding: 6px 8px; font-size: 16px; }
.player input[type="range"] { width: 100%; accent-color: var(--accent); }
.controls { gap: 4px; }
.controls .icon { flex: 1; padding: 8px 0; text-align: center; white-space: nowrap; }
.controls .play { flex: 1.4; padding: 6px 0; font-size: 16px; }
.link { text-decoration: none; display: inline-block; }
