:root {
  --bg: #0e1116;
  --panel: #171b22;
  --line: #2a303b;
  --text: #eef1f5;
  --dim: #9aa4b2;
  --accent: #4cc2a4;
  --accent-ink: #06231c;
  --mine: #1d2a3d;
  --theirs: #1a2622;
  --danger: #e5645a;
  --warn-bg: #3a2420;
}

* { box-sizing: border-box; }

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

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 17px; margin: 0; font-weight: 700; flex: 1; white-space: nowrap; }

.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.chip b { color: var(--text); font-weight: 600; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--dim);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
}
.icon-btn:active { background: var(--panel); }

.banner {
  margin: 10px 16px 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  border: 1px solid var(--danger);
  font-size: 14px;
  line-height: 1.5;
}

.log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.empty { margin: auto; color: var(--dim); font-size: 15px; text-align: center; }

.entry {
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--theirs);
  border: 1px solid var(--line);
  max-width: 92%;
  align-self: flex-start;
  overflow-wrap: anywhere;
}
.entry.mine { background: var(--mine); align-self: flex-end; }
.entry .src { font-size: 14px; color: var(--dim); line-height: 1.5; margin: 0 0 6px; }
.entry .dst { font-size: 24px; line-height: 1.45; margin: 0; font-weight: 600; }
.entry .tag { font-size: 11px; color: var(--dim); letter-spacing: 0.04em; margin: 0 0 4px; }
.entry .note { font-size: 12px; color: var(--dim); margin: 8px 0 0; }

.bottom {
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--dim);
  min-height: 24px;
  margin-bottom: 10px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.dot.listening { background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.dot.working { background: #e0b34a; }
.dot.speaking { background: #6aa7ff; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .dot.listening { animation: none; } }

.meter {
  margin-left: auto;
  width: 72px;
  height: 6px;
  border-radius: 3px;
  background: var(--panel);
  overflow: hidden;
  flex: none;
}
.meter span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 80ms linear; }

.actions { display: flex; gap: 10px; }
.main-btn {
  flex: 1;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 20px;
  font-weight: 700;
  padding: 18px;
  min-height: 64px;
}
.main-btn.running { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.main-btn:disabled { opacity: 0.6; }
.main-btn.small { font-size: 16px; padding: 12px; min-height: 48px; width: 100%; margin-top: 8px; }
.sub-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: 0 14px;
  font-size: 13px;
  color: var(--dim);
  max-width: 40%;
}

/* ポケット用ロック：真っ黒で、長押し以外は何も起きない */
.lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.lock-inner { text-align: center; color: #3a3f48; font-size: 14px; }
.lock-ring {
  --p: 0;
  width: 84px;
  height: 84px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: conic-gradient(#4cc2a4 calc(var(--p) * 1turn), #1a1d22 0);
  -webkit-mask: radial-gradient(circle, transparent 34px, #000 35px);
  mask: radial-gradient(circle, transparent 34px, #000 35px);
}

.sheet {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  width: min(92vw, 420px);
  padding: 20px;
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet h2 { margin: 0 0 14px; font-size: 18px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--dim); margin-bottom: 6px; }
.field small { display: block; font-size: 12px; color: var(--dim); margin-top: 6px; }
.field input[type="password"], .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px; /* 16px 未満だと iOS が勝手に拡大する */
}
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; font-size: 14px; line-height: 1.5; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
