:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #5d6675;
  --line: #dde1e7;
  --accent: #2563eb;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #a16207;
  --warn-bg: #fef9c3;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --key: #eef1f5;
  --on-strong: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --card: #1b2029;
    --text: #e6e9ef;
    --muted: #9aa3b2;
    --line: #2c3340;
    --accent: #6b9bff;
    --ok: #4ade80;
    --ok-bg: #12301f;
    --warn: #facc15;
    --warn-bg: #3a3210;
    --bad: #f87171;
    --bad-bg: #3a1717;
    --key: #252b36;
    /* 明るい緑・赤のボタンの上の文字 */
    --on-strong: #10141a;
  }
}

* { box-sizing: border-box; }
/* display を指定した要素でも hidden を効かせる */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.5;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}
h1 { font-size: 1.15rem; margin: 0; }
h1 small { color: var(--muted); font-weight: normal; font-size: .85rem; margin-left: 4px; }
h2 { font-size: 1rem; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: baseline; }
main { max-width: 480px; margin: 0 auto; padding: 0 16px 32px; }

.pill { font-size: .8rem; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.wait { background: var(--warn-bg); color: var(--warn); }
.pill.off { background: var(--bad-bg); color: var(--bad); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
}
label { display: block; margin-bottom: 12px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; }
input[type=password], input[type=tel], select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  font-size: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--key);
  color: var(--text);
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-strong); width: 100%; font-weight: 600; }
button.answer { background: var(--ok); border-color: var(--ok); color: var(--on-strong); font-weight: 600; }
button.hangup { background: var(--bad); border-color: var(--bad); color: var(--on-strong); font-weight: 600; }
button.on { outline: 2px solid var(--warn); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: .9rem; }

.banner { margin-top: 12px; }
.banner button { width: 100%; background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }

.call { text-align: center; padding: 8px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.call-label { color: var(--muted); font-size: .9rem; }
.call-peer { font-size: 1.6rem; font-weight: 600; min-height: 2.2rem; word-break: break-all; }
.call-time { font-variant-numeric: tabular-nums; color: var(--muted); min-height: 1.5rem; }
.call.incoming .call-label { color: var(--ok); font-weight: 600; animation: blink 1s steps(2) infinite; }
.call.active .call-label { color: var(--ok); }
.call-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.call-actions button { min-width: 112px; padding: 12px 20px; font-size: 1.05rem; }
@keyframes blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .call.incoming .call-label { animation: none; } }

.dial input { text-align: center; letter-spacing: .05em; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.keypad button { font-size: 1.3rem; padding: 12px 0; }
.dial > button { width: 100%; font-size: 1.1rem; padding: 12px; }

.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.history li:first-child { border-top: 0; }
.history .dir {
  grid-row: span 2;
  align-self: center;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .75rem;
  background: var(--key);
}
.history li.missed .dir { background: var(--bad-bg); color: var(--bad); }
.history li.in .dir { background: var(--ok-bg); color: var(--ok); }
.history .peer { justify-self: start; font-size: 1rem; text-decoration: none; color: var(--text); }
.history .meta { color: var(--muted); font-size: .8rem; }

.note { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
.notes ul { margin: 0; padding-left: 1.2em; color: var(--muted); font-size: .85rem; }
.notes li + li { margin-top: 4px; }
.actions { margin: 12px 0 0; }
code { font-size: .85em; }

.presence { display: flex; gap: 0; margin: -4px 0 12px; }
.presence button { flex: 1; border-radius: 0; padding: 8px 0; }
.presence button:first-child { border-radius: 8px 0 0 8px; }
.presence button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.presence button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-strong); font-weight: 600; }
#presence-away[aria-pressed="true"] { background: var(--warn); border-color: var(--warn); }

details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 12px; }
select { font-size: 1rem; padding: 8px 10px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.row select { margin-top: 0; flex: 1; min-width: 0; }
.row button { white-space: nowrap; }
.level-row { display: flex; gap: 12px; align-items: center; margin: -4px 0 12px; font-size: .9rem; color: var(--muted); }
.level-row meter { flex: 1; height: 12px; }

.parked { font-size: .85rem; color: var(--warn); background: var(--warn-bg); border-radius: 6px; padding: 4px 8px; margin-bottom: 8px; display: inline-block; }
.call.held .call-label { color: var(--warn); font-weight: 600; }
.xfer-row { display: flex; gap: 8px; margin-top: 8px; }
.xfer-row button { flex: 1; }
