:root {
  color-scheme: dark;
  --bg: #0b0b0a;
  --surface: #171714;
  --surface-2: #22211d;
  --text: #fbfaf2;
  --muted: #aaa799;
  --line: rgba(251, 250, 242, 0.12);
  --accent: #ff5a3d;
  --accent-2: #52d39b;
  --danger: #ff3b30;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23aaa799' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  font-family: -apple-system, "SF Pro Text", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  color: var(--text);
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 620px;
  overflow: hidden;
  background:
    linear-gradient(115deg, rgba(255, 90, 61, 0.18), transparent 34%),
    linear-gradient(250deg, rgba(82, 211, 155, 0.14), transparent 32%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 12px),
    var(--bg);
}

.home-screen {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.result-display {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.status-strip,
.diagnostic-row,
.bottom-controls,
.language-pair,
.sheet-header,
.sheet-actions,
.check-row {
  display: flex;
  align-items: center;
}

.status-strip,
.sheet-header {
  justify-content: space-between;
  gap: 16px;
}

.status-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.brand-mark {
  display: grid;
  gap: 3px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-text {
  color: rgba(251, 250, 242, 0.76);
  font-size: 14px;
}

h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

.output-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 12px 2px 8px;
}

.translation-region {
  min-height: 0;
  display: grid;
  align-items: center;
  overflow: hidden;
  overscroll-behavior: contain;
}

.translation-region.is-empty {
  align-items: stretch;
}

.translation-region.is-scrollable {
  overflow: auto;
}

.translated-text {
  margin: 0;
  max-width: 100%;
  color: var(--text);
  font-size: 40px;
  font-weight: 850;
  line-height: 1.14;
  letter-spacing: 0;
  hyphens: auto;
  overflow-wrap: anywhere;
  text-wrap: balance;
  word-break: normal;
}

.translated-text.is-scrollable {
  padding-right: 4px;
}

.original-region {
  max-height: min(24dvh, 150px);
  overflow: auto;
  border-top: 1px solid rgba(251, 250, 242, 0.12);
  padding-top: 12px;
  overscroll-behavior: contain;
}

.original-region.is-empty {
  display: none;
}

.original-text {
  margin: 0;
  color: rgba(251, 250, 242, 0.58);
  font-size: clamp(13px, 3.8vw, 18px);
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: normal;
}

.meter-block {
  display: grid;
  min-height: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.app-shell[data-state="recording"] .meter-block {
  opacity: 1;
}

.volume-meter {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(251, 250, 242, 0.08);
}

.volume-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2);
  transition: width 90ms linear;
}

.app-shell[data-state="recording"] .volume-meter span {
  background: var(--accent);
}

.bottom-controls {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 72px;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(23, 23, 20, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.icon-button,
.record-button,
.swap-button {
  display: inline-grid;
  place-items: center;
  color: var(--text);
}

.icon-button {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: rgba(251, 250, 242, 0.08);
  border: 1px solid var(--line);
}

.icon-button.dark {
  color: #11110f;
  background: rgba(17, 17, 15, 0.06);
  border-color: rgba(17, 17, 15, 0.12);
}

.language-pair {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
  gap: 8px;
}

.language-select {
  width: 100%;
  height: 48px;
  min-width: 0;
  padding: 0 34px 0 10px;
  border: 1px solid rgba(251, 250, 242, 0.12);
  border-radius: 14px;
  background-color: rgba(251, 250, 242, 0.08);
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 15px 15px;
  color: var(--text);
  font-weight: 800;
  outline: none;
}

.language-select option {
  background: #171714;
  color: #fbfaf2;
}

.swap-button {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(82, 211, 155, 0.14);
  color: var(--accent-2);
  border: 1px solid rgba(82, 211, 155, 0.24);
}

.record-button {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: var(--accent);
  color: #160806;
  box-shadow: 0 18px 48px rgba(255, 90, 61, 0.34);
  transition: transform 180ms ease, background 180ms ease;
}

.record-button::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(22, 8, 6, 0.2);
  transition: width 180ms ease, height 180ms ease, border-radius 180ms ease, background 180ms ease, transform 180ms ease;
}

.record-button[data-mode="recording"]::before {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--accent);
}

.record-button[data-mode="processing"]::before {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(22, 8, 6, 0.25);
  border-top-color: rgba(22, 8, 6, 0.72);
  background: transparent;
  animation: spin 820ms linear infinite;
}

.record-button:active {
  transform: scale(0.96);
}

.app-shell[data-state="recording"] .record-button,
.app-shell[data-state="processing"] .record-button {
  background: #fbfaf2;
}

.icon-button svg,
.record-button svg,
.swap-button svg,
.primary-button svg,
.danger-button svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
  pointer-events: none;
}

.record-button svg {
  width: 28px;
  height: 28px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.timer {
  min-width: 64px;
  padding: 7px 10px;
  text-align: center;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(251, 250, 242, 0.08);
  font-variant-numeric: tabular-nums;
}

.user-chip {
  min-width: 40px;
  max-width: 112px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid rgba(251, 250, 242, 0.12);
  border-radius: 999px;
  background: rgba(251, 250, 242, 0.08);
  color: rgba(251, 250, 242, 0.82);
  font-size: 12px;
  font-weight: 800;
}

.user-chip img {
  width: 24px;
  height: 24px;
  border-radius: 999px;
}

.user-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-screen {
  position: absolute;
  inset: 0;
  z-index: 18;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    linear-gradient(180deg, rgba(11, 11, 10, 0.28), rgba(11, 11, 10, 0.82)),
    rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(14px);
}

.auth-screen.is-hidden {
  display: none;
}

.auth-panel {
  width: min(360px, 100%);
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid rgba(251, 250, 242, 0.13);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 90, 61, 0.12), transparent 42%),
    linear-gradient(235deg, rgba(82, 211, 155, 0.1), transparent 38%),
    rgba(23, 23, 20, 0.94);
  box-shadow:
    inset 0 1px 0 rgba(251, 250, 242, 0.08),
    0 28px 88px rgba(0, 0, 0, 0.58);
}

.auth-panel h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.auth-copy,
.auth-status {
  margin: 0;
  color: rgba(251, 250, 242, 0.62);
  font-size: 14px;
  line-height: 1.55;
}

.google-button {
  min-height: 44px;
}

.settings-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}

.settings-sheet.is-open {
  display: block;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(11, 11, 10, 0.18), rgba(11, 11, 10, 0.82)),
    rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(7px);
}

.sheet-panel {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  left: max(10px, env(safe-area-inset-left));
  display: grid;
  gap: 18px;
  max-height: calc(100dvh - 28px);
  overflow: auto;
  padding: 18px 16px 16px;
  border: 1px solid rgba(251, 250, 242, 0.13);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 90, 61, 0.12), transparent 42%),
    linear-gradient(235deg, rgba(82, 211, 155, 0.1), transparent 38%),
    rgba(23, 23, 20, 0.94);
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(251, 250, 242, 0.08),
    0 28px 88px rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(22px);
  overscroll-behavior: contain;
}

.sheet-panel::before {
  content: "";
  justify-self: center;
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: rgba(251, 250, 242, 0.18);
}

.sheet-panel .icon-button {
  width: 46px;
  height: 46px;
  color: rgba(251, 250, 242, 0.9);
  border-color: rgba(251, 250, 242, 0.12);
  border-radius: 16px;
  background: rgba(251, 250, 242, 0.08);
}

.sheet-header h2 {
  color: var(--text);
  font-size: 24px;
}

.field {
  display: grid;
  gap: 9px;
}

.field span,
.check-row span {
  color: rgba(251, 250, 242, 0.58);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.field input,
.field select {
  width: 100%;
  min-height: 56px;
  border: 1px solid rgba(251, 250, 242, 0.12);
  border-radius: 18px;
  background-color: rgba(251, 250, 242, 0.08);
  color: var(--text);
  font-weight: 750;
  outline: none;
}

.field input {
  padding: 0 16px;
}

.field select {
  padding: 0 44px 0 16px;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px 16px;
}

.field select option {
  background: #171714;
  color: #fbfaf2;
}

.field input:focus,
.field select:focus {
  border-color: rgba(82, 211, 155, 0.58);
  box-shadow: 0 0 0 4px rgba(82, 211, 155, 0.12);
}

.check-row {
  gap: 10px;
}

.check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.security-note {
  margin: -4px 0 0;
  color: rgba(17, 17, 15, 0.58);
  font-size: 12px;
  line-height: 1.5;
}

.sheet-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  padding-top: 4px;
}

.primary-button,
.danger-button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 18px;
  font-weight: 800;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.primary-button:active,
.danger-button:active {
  transform: scale(0.98);
}

.primary-button {
  background: var(--accent-2);
  color: #06140f;
  box-shadow: 0 16px 38px rgba(82, 211, 155, 0.2);
}

.danger-button {
  padding: 0 12px;
  border-color: rgba(255, 90, 61, 0.18);
  background: rgba(255, 90, 61, 0.1);
  color: rgba(255, 178, 164, 0.96);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 30;
  min-height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(17, 17, 15, 0.9);
  color: #fbfaf2;
  font-size: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}

.toast.is-visible {
  display: flex;
}

[hidden] {
  display: none !important;
}

@media (min-width: 720px) {
  body {
    display: grid;
    place-items: center;
    background: #11110f;
  }

  .app-shell {
    width: min(430px, 100vw);
    height: min(920px, 100dvh);
    border: 1px solid rgba(251, 250, 242, 0.12);
    border-radius: 28px;
    box-shadow: var(--shadow);
  }

  .settings-sheet {
    position: absolute;
  }
}
