* { box-sizing: border-box; }

#dev-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: #1f2630;
  border-bottom: 1px solid #2a2f3a;
  color: #d4dae1;
  font-size: 13px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
#dev-banner.reload { background: #4f7cff; color: white; border-bottom-color: #3f6cef; }
#dev-banner .title { font-weight: 600; }
#dev-banner .progress {
  display: inline-block;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 2px 8px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
#dev-banner .details { color: #9aa3ad; }
#dev-banner .recent { color: #6b7280; font-size: 12px; }
#dev-banner button {
  margin-left: auto;
  background: white;
  color: #1f2630;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
}
#dev-banner button:hover { background: #e7eaee; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  background: #0c0e12;
  color: #e7eaee;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}
main {
  width: 100%;
  max-width: 720px;
  padding: 32px 16px 64px;
}
h1 { font-size: 28px; margin: 0 0 8px; }
.lead { color: #9aa3ad; margin: 0 0 32px; }

form { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #b9c2cb; }
label.row { flex-direction: row; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
input[type="text"], input#name, input#room {
  background: #1a1d24;
  border: 1px solid #2a2f3a;
  color: #e7eaee;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
}
input:focus { outline: 2px solid #4f7cff; outline-offset: 1px; }

fieldset {
  border: 1px solid #2a2f3a;
  border-radius: 8px;
  padding: 12px;
  margin: 0;
}
legend { color: #b9c2cb; font-size: 13px; padding: 0 6px; }

button {
  background: #4f7cff;
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: #3f6cef; }
button.danger { background: #d04545; }
button.danger:hover { background: #c03535; }
button.ghost { background: transparent; border: 1px solid #2a2f3a; color: #b9c2cb; padding: 6px 10px; font-size: 13px; }
button.ghost:hover { background: #1a1d24; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.error { color: #ff7676; font-size: 14px; margin: 0; }
.hint { color: #9aa3ad; font-size: 13px; }

#connecting { text-align: center; padding-top: 64px; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #2a2f3a;
  border-top-color: #4f7cff;
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1a1d24;
  border: 1px solid #2a2f3a;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.call-header > div { flex: 1; text-align: center; }
.call-header .lbl { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; }
.call-header .name { font-size: 18px; font-weight: 600; margin-top: 4px; }
.call-header .lang { font-size: 13px; color: #9aa3ad; margin-top: 2px; }
.call-header .sep { flex: 0 0 24px; font-size: 18px; color: #6b7280; }

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 24px;
  margin-bottom: 8px;
  font-size: 13px;
}
.status { color: #9aa3ad; flex: 1; text-align: center; }
.quality {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
}
.quality::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
}
.quality.good { color: #4ade80; }
.quality.good::before { background: #22c55e; }
.quality.fair { color: #fbbf24; }
.quality.fair::before { background: #f59e0b; }
.quality.poor { color: #f87171; }
.quality.poor::before { background: #ef4444; }

.subtitles-wrap { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.subs-block .subs-label {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  padding-left: 4px;
}
.subtitles {
  background: #14171d;
  border: 1px solid #2a2f3a;
  border-radius: 12px;
  padding: 16px;
  min-height: 140px;
  max-height: 240px;
  overflow-y: auto;
  font-size: 18px;
  line-height: 1.6;
}
.subtitles .line { margin: 0 0 6px; color: #e7eaee; }
.subtitles .line.cur { color: #b9c2cb; }
.subtitles:empty::before { content: "相手が話し始めるとここに表示されます"; color: #4b5563; font-size: 14px; }
.subs-block.self .subtitles {
  background: #11141a;
  font-size: 15px;
  min-height: 80px;
  max-height: 160px;
}
.subs-block.self .subtitles .line { color: #9aa3ad; }
.subs-block.self .subtitles .line.cur { color: #6b7280; font-style: italic; }
.subs-block.self .subtitles:empty::before { content: "発話を始めると相手側で認識された内容がここに出ます"; }

.controls { display: flex; gap: 12px; margin-bottom: 16px; }
.controls button { flex: 1; }

.mic-bar {
  width: 100%;
  height: 4px;
  background: #2a2f3a;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.mic-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #4f7cff, #7aa1ff);
  width: 0;
  transition: width 60ms linear;
}

.volume {
  background: #14171d;
  border: 1px solid #2a2f3a;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.volume label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #b9c2cb;
  margin-bottom: 8px;
}
.volume label span { color: #e7eaee; font-variant-numeric: tabular-nums; }
.volume input[type="range"] {
  width: 100%;
  accent-color: #4f7cff;
}

.share { color: #6b7280; font-size: 12px; }
.share-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.share code {
  background: #1a1d24;
  padding: 4px 8px;
  border-radius: 4px;
  color: #b9c2cb;
  font-size: 12px;
  word-break: break-all;
  flex: 1;
  min-width: 0;
}
#qr-area { margin-top: 12px; text-align: center; }
#qr-img { width: 200px; height: 200px; background: white; border-radius: 8px; padding: 8px; }

#tr-audio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.improvements {
  margin-top: 32px;
  padding: 16px 18px;
  background: #14171d;
  border: 1px solid #2a2f3a;
  border-radius: 12px;
}
.imp-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.imp-header h2 {
  font-size: 14px;
  margin: 0;
  color: #b9c2cb;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.imp-version {
  font-size: 11px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}
.imp-current {
  background: #1a1d24;
  border: 1px solid #2a2f3a;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.imp-current .imp-title { color: #e7eaee; font-weight: 600; }
.imp-current .imp-progress {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  background: #4f7cff;
  color: white;
  padding: 1px 8px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.imp-current .imp-details { color: #9aa3ad; font-size: 12px; margin-top: 4px; }
.imp-recent {
  margin: 0;
  padding-left: 0;
  list-style: none;
  font-size: 13px;
}
.imp-recent li {
  padding: 6px 0 6px 22px;
  position: relative;
  color: #b9c2cb;
  border-top: 1px solid #1a1d24;
}
.imp-recent li:first-child { border-top: 0; }
.imp-recent li::before {
  content: "✓";
  position: absolute;
  left: 4px;
  color: #4ade80;
  font-weight: 700;
}

@media (max-width: 600px) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  main {
    padding: 16px 12px 80px;
  }
  h1 { font-size: 22px; }
  .lead { font-size: 14px; margin-bottom: 20px; }
  button {
    min-height: 48px;
    font-size: 16px;
  }
  button.ghost { min-height: 36px; padding: 8px 12px; }
  input[type="text"], input#name, input#room {
    font-size: 16px;     /* prevents iOS zoom-on-focus */
    min-height: 44px;
  }
  fieldset label.row { padding: 8px 0; }
  .call-header { padding: 12px; }
  .call-header .name { font-size: 16px; }
  .call-header .lang { font-size: 12px; }
  .subtitles {
    font-size: 16px;
    padding: 16px;
    min-height: 200px;
    max-height: 50vh;
  }
  .controls { gap: 8px; position: sticky; bottom: env(safe-area-inset-bottom, 0); }
  .controls button { min-height: 52px; font-size: 16px; }
  #dev-banner { font-size: 12px; padding: 6px 10px; gap: 8px; }
  #dev-banner .recent { display: none; }
  #qr-img { width: 80vw; max-width: 280px; height: auto; aspect-ratio: 1/1; }
  .share-row { gap: 6px; }
  .share code { font-size: 11px; padding: 6px 8px; }
}
