:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --blue: #2563eb;
  --blue-bg: #eaf1ff;
  --green: #16a34a;
  --green-bg: #eafaf0;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--blue);
}

h1 { font-size: 38px; line-height: 1.1; margin: 6px 0 8px; }
.subtitle { color: var(--muted); margin: 0; font-size: 15px; }

.badge {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-idle  { background: #e5e7eb; color: #374151; }
.badge-live  { background: #dcfce7; color: #166534; }
.badge-busy  { background: #fef3c7; color: #92400e; }
.badge-error { background: #fee2e2; color: #991b1b; }

.alert {
  background: #fee2e2;
  color: #7f1d1d;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.55;
}
.alert a { color: #7f1d1d; }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.card h2 { margin: 0 0 8px; font-size: 20px; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 18px; line-height: 1.5; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
select:disabled { background: #f9fafb; color: #9ca3af; }

.actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1.2;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary   { background: var(--blue); color: #fff; }
.btn-secondary { background: #f3f4f6; color: var(--text); }
.btn-ghost     { background: transparent; color: var(--muted); }
.btn-danger    { background: #fde4e4; color: #b91c1c; }

.panels {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}
.panels .card { margin-bottom: 0; }

.swap-icon {
  align-self: center;
  font-size: 24px;
  color: #9ca3af;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-blue  { background: var(--blue); }
.dot-green { background: var(--green); }

.panel-label { font-size: 13px; color: var(--muted); }
.panel-lang  { font-size: 20px; font-weight: 700; }

.meter {
  height: 6px;
  background: #f3f4f6;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}
.meter-bar {
  height: 100%;
  width: 0%;
  transition: width 0.08s linear;
}
.bar-blue  { background: var(--blue); }
.bar-green { background: var(--green); }

.state-text {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  min-height: 18px;
}

.box {
  background: #f9fafb;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.box:last-child { margin-bottom: 0; }
.box-blue  { background: var(--blue-bg); }
.box-green { background: var(--green-bg); }

.box-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.box-content {
  font-size: 16px;
  line-height: 1.45;
  min-height: 24px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.box-content.error { color: #b91c1c; font-size: 14px; }

.bottom-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sensitivity {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}
.sensitivity label { font-size: 13px; font-weight: 600; white-space: nowrap; }
.sensitivity input { flex: 1; }
.sensitivity span { font-weight: 700; width: 26px; text-align: right; }

.log-card summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.log {
  margin-top: 14px;
  max-height: 260px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #374151;
  white-space: pre-wrap;
  word-break: break-word;
}
.log .l-err { color: #b91c1c; }
.log .l-ok  { color: #166534; }

.footnote {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .panels { grid-template-columns: 1fr; }
  .swap-icon { display: none; }
}

@media (max-width: 620px) {
  .page { padding: 20px 14px 40px; }
  h1 { font-size: 30px; }
  .grid-4 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .sensitivity { margin-left: 0; width: 100%; }
  .actions .btn, .bottom-bar .btn { flex: 1 1 auto; text-align: center; }
}
