:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
  background: #070b13;
  color: #f7f8fa;
  --surface: rgba(19, 28, 45, 0.9);
  --surface-soft: rgba(26, 38, 60, 0.72);
  --border: rgba(255, 255, 255, 0.1);
  --muted: #9ba8bc;
  --accent: #69a7ff;
  --accent-strong: #2f80ed;
  --success: #40d49a;
  --warning: #ffcc66;
  --danger: #ff7b86;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: #070b13;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% 0%, rgba(47, 128, 237, 0.2), transparent 34%),
    radial-gradient(circle at 100% 100%, rgba(64, 212, 154, 0.08), transparent 30%),
    #070b13;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(100%, 1200px);
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 10px;
}

.status-bar,
.brand,
.status,
.card-header {
  display: flex;
  align-items: center;
}

.status-bar {
  justify-content: space-between;
  min-height: 44px;
}

.brand {
  gap: 9px;
  font-size: 17px;
  font-weight: 700;
}

.brand-mark,
.dialog-mark {
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, #3c8cff, #2769d2);
  box-shadow: 0 8px 28px rgba(47, 128, 237, 0.28);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.status {
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.status-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 4px rgba(100, 116, 139, 0.12);
}

.status-indicator.listening {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(64, 212, 154, 0.13), 0 0 18px rgba(64, 212, 154, 0.52);
  animation: pulse 1.8s ease-in-out infinite;
}

.status-indicator.starting {
  background: var(--warning);
}

.status-indicator.paused {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(255, 204, 102, 0.12);
}

.status-indicator.error,
.status-indicator.unsupported {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 123, 134, 0.12);
}

.error-banner {
  padding: 10px 12px;
  border: 1px solid rgba(255, 123, 134, 0.28);
  border-radius: 12px;
  color: #ffd9dc;
  background: rgba(125, 38, 50, 0.3);
  font-size: 14px;
  line-height: 1.4;
}

.translation-area {
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.subtitle-card {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(160deg, var(--surface), rgba(10, 16, 27, 0.88));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}

.subtitle-card.translated {
  border-color: rgba(105, 167, 255, 0.17);
}

.card-header {
  min-height: 45px;
  gap: 9px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}

.card-header h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  color: #cbd5e1;
}

.language-badge {
  min-width: 30px;
  padding: 4px 7px;
  border-radius: 7px;
  text-align: center;
  color: #dceaff;
  background: rgba(47, 128, 237, 0.16);
  font-size: 12px;
  font-weight: 750;
}

.card-content {
  min-height: 0;
  overflow-y: auto;
  padding: 12px 13px 26px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.empty-state {
  margin: 12px 0;
  color: #738198;
  font-size: 15px;
  line-height: 1.55;
}

.subtitle-line {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  color: #f6f8fc;
  font-size: clamp(17px, 4.4vw, 22px);
  line-height: 1.52;
  overflow-wrap: anywhere;
}

.subtitle-line.interim,
.subtitle-line.pending {
  color: #9aa8bd;
}

.subtitle-line.pending::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.subtitle-line.failed {
  color: #d7a4aa;
}

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

.control {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  color: #eef2f8;
  background: var(--surface-soft);
  font-size: 15px;
  font-weight: 650;
}

.control.primary {
  border-color: rgba(105, 167, 255, 0.45);
  background: linear-gradient(145deg, #347fdc, #2567c8);
  box-shadow: 0 9px 26px rgba(47, 128, 237, 0.22);
}

.control.quiet {
  min-height: 44px;
  color: #b7c2d2;
  background: rgba(255, 255, 255, 0.04);
}

.control.danger {
  color: #f2aeb5;
}

.control:disabled {
  opacity: 0.38;
  box-shadow: none;
}

.control:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(105, 167, 255, 0.42);
  outline-offset: 2px;
}

.foreground-note {
  margin: 0;
  text-align: center;
  color: #748198;
  font-size: 12px;
  line-height: 1.35;
}

.access-dialog {
  width: min(calc(100% - 30px), 390px);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 22px;
  color: #f7f8fa;
  background: #111a2a;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.52);
}

.access-dialog::backdrop {
  background: rgba(2, 5, 10, 0.78);
  backdrop-filter: blur(8px);
}

.access-form {
  display: grid;
  gap: 13px;
  padding: 25px;
}

.dialog-mark {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  font-size: 20px;
}

.access-form h2,
.access-form p {
  margin: 0;
}

.access-form h2 {
  font-size: 21px;
}

.access-form p,
.access-form label {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.access-form input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  color: white;
  background: rgba(0, 0, 0, 0.25);
  font-size: 17px;
}

@keyframes pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.08); }
}

@media (min-width: 780px) {
  .app-shell {
    padding-inline: 22px;
    gap: 14px;
  }

  .translation-area {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
  }

  .controls {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
  }

  .card-content {
    padding: 18px 20px 35px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
