:root {
  color-scheme: light;
  --ink: #142321;
  --muted: #637672;
  --soft: #eef5f2;
  --line: #d9e5e1;
  --paper: #f7fbf9;
  --panel: #ffffff;
  --green: #0b6b58;
  --green-strong: #074f42;
  --red: #bf3737;
  --gold: #c58a26;
  --blue: #245aa6;
  --shadow: 0 18px 46px rgba(18, 45, 39, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, #eaf5f1 0%, rgba(247, 251, 249, 0) 42%),
    var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body.locked {
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.pin-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(234, 245, 241, 0.96), rgba(247, 251, 249, 0.98)),
    var(--paper);
}

body.locked .pin-screen {
  display: grid;
}

body.locked .app-shell {
  filter: blur(12px);
  pointer-events: none;
  user-select: none;
}

.pin-card {
  width: min(100%, 360px);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.pin-card h2 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.05;
}

.pin-card input {
  width: 100%;
  min-height: 64px;
  border: 1px solid rgba(11, 107, 88, 0.25);
  border-radius: 16px;
  background: var(--soft);
  color: var(--ink);
  padding: 0 18px;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-align: center;
}

.pin-card input:focus {
  outline: 3px solid rgba(11, 107, 88, 0.2);
}

.pin-card button {
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

.pin-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
  text-align: center;
}

.pin-message.error {
  color: var(--red);
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: grid;
  align-content: start;
  gap: 14px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: -14px -14px 0;
  padding: max(14px, env(safe-area-inset-top)) 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(247, 251, 249, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(217, 229, 225, 0.8);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.status {
  min-width: 96px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 8px 12px;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.translator-card,
.result-panel,
.type-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.translator-card {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.language-picker {
  display: grid;
  grid-template-columns: 1fr 52px 1fr;
  gap: 10px;
  align-items: stretch;
}

.language-picker label {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.language-picker label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.language-picker select {
  width: 100%;
  min-height: 58px;
  border: 1px solid rgba(11, 107, 88, 0.2);
  border-radius: 14px;
  background: var(--soft);
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
  font-weight: 850;
}

.swap-button,
.record-button,
.translate-button,
.type-card button {
  cursor: pointer;
  border: 0;
}

.swap-button {
  min-width: 52px;
  min-height: 58px;
  align-self: end;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
}

.direction-line {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.direction-line span:first-child,
.direction-line span:last-child {
  color: var(--green-strong);
}

.record-button {
  width: 100%;
  min-height: 132px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.28), transparent 42%),
    linear-gradient(145deg, var(--green), var(--green-strong));
  color: #fff;
  display: grid;
  place-items: center;
  gap: 10px;
  font-size: 1.12rem;
  font-weight: 900;
  box-shadow: 0 16px 32px rgba(11, 107, 88, 0.25);
}

.record-button.recording {
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.22), transparent 42%),
    linear-gradient(145deg, var(--red), #8d2727);
}

.record-ring {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.65);
}

.record-dot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: currentColor;
}

.record-button.recording .record-dot {
  border-radius: 6px;
}

.meter {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.meter span {
  width: 9px;
  height: 16px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 48%, white);
  transform-origin: center;
}

.meter.active span {
  animation: pulse 700ms ease-in-out infinite alternate;
}

.meter span:nth-child(2) { animation-delay: 80ms; }
.meter span:nth-child(3) { animation-delay: 160ms; }
.meter span:nth-child(4) { animation-delay: 240ms; }
.meter span:nth-child(5) { animation-delay: 320ms; }

@keyframes pulse {
  to {
    height: 40px;
    background: var(--gold);
  }
}

.result-stack {
  display: grid;
  gap: 12px;
}

.result-panel {
  display: grid;
  overflow: hidden;
  min-height: 202px;
}

.translated-panel {
  min-height: 248px;
}

.panel-head {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.panel-head p {
  margin: 0;
  font-weight: 900;
}

.panel-head span {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 850;
}

textarea {
  width: 100%;
  min-height: 138px;
  border: 0;
  resize: vertical;
  padding: 14px;
  color: var(--ink);
  background: transparent;
  font-size: 1.02rem;
  line-height: 1.55;
}

.translated-panel textarea {
  min-height: 156px;
}

textarea:focus {
  outline: 2px solid rgba(11, 107, 88, 0.22);
  outline-offset: -2px;
}

.translate-button {
  min-height: 56px;
  margin: 0 14px 14px;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

.translate-button:disabled,
.record-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

audio {
  width: calc(100% - 28px);
  height: 42px;
  margin: 0 14px 14px;
}

.type-card {
  display: grid;
  overflow: hidden;
}

.type-card textarea {
  min-height: 104px;
  border-bottom: 1px solid var(--line);
}

.type-card button {
  min-height: 54px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

@media (min-width: 820px) {
  .app-shell {
    padding-top: 24px;
    gap: 18px;
  }

  .app-header {
    position: static;
    margin: 0;
    padding: 0 2px 6px;
    background: transparent;
    border-bottom: 0;
    backdrop-filter: none;
  }

  h1 {
    font-size: 2.2rem;
  }

  .translator-card {
    padding: 18px;
  }

  .record-button {
    min-height: 154px;
  }

  .result-stack {
    grid-template-columns: 1fr 1fr;
  }

  .result-panel,
  .translated-panel {
    min-height: 320px;
  }

  textarea,
  .translated-panel textarea {
    min-height: 220px;
  }

  .type-card {
    grid-template-columns: 1fr 190px;
  }

  .type-card textarea {
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .app-header {
    margin-left: -10px;
    margin-right: -10px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .language-picker {
    grid-template-columns: 1fr 44px 1fr;
    gap: 8px;
  }

  .swap-button {
    min-width: 44px;
  }

}
