:root {
  --ink: #18211c;
  --muted: #66716a;
  --paper: #f7f7f2;
  --card: #ffffff;
  --line: #dfe5df;
  --green: #2f7155;
  --green-dark: #21573f;
  --green-soft: #e3f0e8;
  --orange: #e1783f;
  --orange-soft: #f8e8dc;
  --shadow: 0 24px 80px rgba(29, 55, 42, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 2%, rgba(227, 240, 232, 0.85), transparent 26rem),
    radial-gradient(circle at 92% 30%, rgba(248, 232, 220, 0.7), transparent 25rem),
    var(--paper);
  font-family: "DM Sans", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(47, 113, 85, 0.25);
  outline-offset: 3px;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  height: 84px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  color: var(--ink);
  text-decoration: none;
  font-family: "Manrope", sans-serif;
  font-size: 19px;
  font-weight: 700;
}

.brand-mark {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border-radius: 11px 11px 11px 4px;
  color: white;
  background: var(--green);
  box-shadow: 0 7px 20px rgba(47, 113, 85, 0.2);
}

.brand-mark span {
  font-size: 18px;
}

.session-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #85a091;
}

.session-status.listening .status-dot {
  background: var(--orange);
  box-shadow: 0 0 0 4px var(--orange-soft);
  animation: blink 1.2s infinite;
}

.icon-button {
  justify-self: end;
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
}

.icon-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

main {
  padding-top: 52px;
}

.hero {
  max-width: 760px;
  margin: 0 auto 44px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 20px;
  font-family: "Manrope", sans-serif;
  font-size: clamp(42px, 6vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

h1 span {
  color: var(--green);
}

.hero-copy {
  max-width: 570px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.translator-card {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 20px 28px;
  border: 1px solid rgba(220, 228, 220, 0.9);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

.language-select {
  display: block;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fff;
}

.field-label {
  display: block;
  margin-bottom: 9px;
  color: #8a938e;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.select-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: center;
}

.language-orb {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.orb-one {
  color: var(--green-dark);
  background: var(--green-soft);
}

.orb-two {
  color: #9f4d24;
  background: var(--orange-soft);
}

.select-row select {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  appearance: none;
  font-size: 16px;
  font-weight: 700;
}

.select-row svg {
  width: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
}

.both-ways {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0 auto 11px;
  color: var(--green);
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.both-ways svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.pair-explanation {
  margin: 14px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
}

.microphone-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  width: min(520px, 100%);
  margin: 14px auto 0;
  padding: 8px 9px 8px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbf9;
}

.microphone-picker label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.microphone-picker select {
  min-width: 0;
  padding: 6px 8px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 11px;
  font-weight: 600;
}

.microphone-picker button {
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 9px;
  font-weight: 700;
}

.mode-switch {
  width: min(430px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin: 24px auto 0;
  padding: 5px;
  border-radius: 15px;
  background: #f0f2ee;
}

.mode-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 12px;
  border: 0;
  border-radius: 11px;
  color: #808983;
  background: transparent;
}

.mode-option.active {
  color: var(--green-dark);
  background: white;
  box-shadow: 0 3px 12px rgba(38, 63, 50, 0.08);
}

.mode-option svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.mode-option span {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.mode-option strong {
  font-size: 12px;
}

.mode-option small {
  margin-top: 1px;
  font-size: 9px;
}

.listening-stage {
  position: relative;
  min-height: 335px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 25px;
  overflow: hidden;
}

.turn-controls {
  position: absolute;
  left: 50%;
  top: 49%;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: min(500px, calc(100% - 30px));
  transform: translate(-50%, -50%);
}

.turn-button {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: white;
  box-shadow: 0 10px 28px rgba(29, 55, 42, 0.1);
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
}

.turn-button:hover {
  transform: translateY(-2px);
}

.turn-one:hover,
.turn-one.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.turn-two:hover,
.turn-two.active {
  border-color: var(--orange);
  background: var(--orange-soft);
}

.turn-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.turn-mic {
  font-size: 24px;
}

.turn-button span:last-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.turn-button small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}

.turn-button strong {
  font-size: 13px;
}

.ambient-ring {
  position: absolute;
  left: 50%;
  top: 49%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.ring-one {
  width: 112px;
  height: 112px;
  background: rgba(47, 113, 85, 0.08);
}

.ring-two {
  width: 175px;
  height: 175px;
  border: 1px solid rgba(47, 113, 85, 0.08);
}

.ring-three {
  width: 245px;
  height: 245px;
  border: 1px solid rgba(47, 113, 85, 0.045);
}

.listen-button {
  position: absolute;
  left: 50%;
  top: 49%;
  z-index: 2;
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--green);
  box-shadow: 0 14px 32px rgba(47, 113, 85, 0.28);
  transform: translate(-50%, -50%);
  transition: transform 0.2s, background 0.2s;
}

.listen-button:hover {
  transform: translate(-50%, -50%) scale(1.05);
  background: var(--green-dark);
}

.listen-button svg {
  width: 31px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.stop-icon {
  display: none;
}

.listening .listen-button {
  background: var(--orange);
}

.listening .mic-icon {
  display: none;
}

.listening .stop-icon {
  display: block;
}

.listening .ambient-ring {
  animation: breathe 2s ease-in-out infinite;
}

.listening .ring-two {
  animation-delay: 0.25s;
}

.listening .ring-three {
  animation-delay: 0.5s;
}

.waveform {
  position: absolute;
  top: calc(49% + 55px);
  display: flex;
  gap: 4px;
  align-items: center;
  height: 24px;
  opacity: 0;
}

.listening .waveform {
  opacity: 1;
}

.waveform i {
  width: 3px;
  height: 6px;
  border-radius: 9px;
  background: var(--orange);
  animation: wave 0.8s ease-in-out infinite alternate;
}

.waveform i:nth-child(2),
.waveform i:nth-child(8) { animation-delay: -0.5s; }
.waveform i:nth-child(3),
.waveform i:nth-child(7) { animation-delay: -0.2s; }
.waveform i:nth-child(4),
.waveform i:nth-child(6) { animation-delay: -0.7s; }
.waveform i:nth-child(5) { animation-delay: -0.35s; }

.listen-title {
  margin-bottom: 5px;
  font-size: 15px;
  font-weight: 700;
}

.listen-hint {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
}

.quick-input {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fafbf9;
}

.quick-input input,
.quick-input select {
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.quick-input input {
  padding: 0 10px;
  font-size: 13px;
}

.quick-input select {
  padding: 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.auto-detect-label {
  align-self: center;
  padding: 5px 9px;
  color: var(--green-dark);
  border-radius: 99px;
  background: var(--green-soft);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.quick-input button,
.dialog-done {
  padding: 10px 17px;
  border: 0;
  border-radius: 10px;
  color: white;
  background: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.conversation-section {
  max-width: 880px;
  margin: 90px auto 120px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 22px;
}

.section-heading .eyebrow {
  margin-bottom: 7px;
}

h2 {
  margin-bottom: 0;
  font-family: "Manrope", sans-serif;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.clear-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 600;
}

.empty-state {
  padding: 54px 20px;
  border: 1px dashed #cdd5ce;
  border-radius: 22px;
  text-align: center;
}

.empty-icon {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  margin: 0 auto 15px;
  border-radius: 14px;
  color: var(--green);
  background: var(--green-soft);
}

.empty-icon svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.empty-state h3 {
  margin-bottom: 6px;
  font-size: 14px;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
}

.transcript-list {
  display: grid;
  gap: 14px;
}

.transcript-entry {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  animation: slideIn 0.35s ease-out;
}

.transcript-entry.to-one {
  border-left: 3px solid var(--green);
}

.transcript-entry.to-two {
  border-left: 3px solid var(--orange);
}

.entry-orb {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 10px;
  font-weight: 700;
}

.to-two .entry-orb {
  color: #9f4d24;
  background: var(--orange-soft);
}

.original-text {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.translated-text {
  margin-bottom: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
}

.entry-meta {
  color: #9aa29d;
  font-size: 9px;
  white-space: nowrap;
}

.entry-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
}

.play-translation {
  padding: 8px 11px;
  border: 0;
  border-radius: 9px;
  color: white;
  background: var(--green);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.play-translation:disabled {
  opacity: 0.65;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 25px 0 35px;
  color: #7c8580;
  border-top: 1px solid var(--line);
  font-size: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 25px;
  z-index: 10;
  max-width: calc(100% - 40px);
  padding: 11px 16px;
  border-radius: 10px;
  color: white;
  background: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  font-size: 11px;
  opacity: 0;
  transform: translate(-50%, 15px);
  pointer-events: none;
  transition: 0.25s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

dialog {
  width: min(440px, calc(100% - 30px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  box-shadow: 0 25px 80px rgba(25, 41, 32, 0.25);
}

dialog::backdrop {
  background: rgba(24, 33, 28, 0.38);
  backdrop-filter: blur(4px);
}

dialog form {
  padding: 25px;
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 25px;
}

.dialog-heading .icon-button {
  border: 0;
  font-size: 21px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 17px 0;
  border-top: 1px solid var(--line);
}

.setting-row span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.setting-row strong {
  font-size: 13px;
}

.setting-row small {
  color: var(--muted);
  font-size: 10px;
}

.setting-row input[type="range"] {
  width: 120px;
  accent-color: var(--green);
}

.setting-row input[type="checkbox"] {
  width: 38px;
  height: 21px;
  accent-color: var(--green);
}

.dialog-done {
  width: 100%;
  margin-top: 18px;
}

@keyframes breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.65; }
  50% { transform: translate(-50%, -50%) scale(1.12); opacity: 1; }
}

@keyframes wave {
  to { height: 20px; }
}

@keyframes blink {
  50% { opacity: 0.45; }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
  }

  .topbar {
    height: 72px;
    grid-template-columns: 1fr auto;
  }

  .session-status {
    display: none;
  }

  main {
    padding-top: 36px;
  }

  h1 {
    font-size: clamp(38px, 12vw, 58px);
  }

  .hero-copy {
    font-size: 14px;
  }

  .translator-card {
    padding: 13px 13px 20px;
    border-radius: 22px;
  }

  .language-picker {
    grid-template-columns: 1fr 38px 1fr;
    gap: 5px;
  }

  .language-select {
    padding: 11px;
  }

  .language-orb,
  .field-label {
    display: none;
  }

  .select-row {
    grid-template-columns: 1fr auto;
    gap: 5px;
  }

  .select-row select {
    font-size: 13px;
  }

  .both-ways {
    margin-bottom: 4px;
  }

  .both-ways span {
    display: none;
  }

  .mode-option {
    padding: 9px 6px;
  }

  .microphone-picker {
    grid-template-columns: 1fr auto;
  }

  .microphone-picker label {
    display: none;
  }

  .mode-option small {
    display: none;
  }

  .listening-stage {
    min-height: 300px;
  }

  .turn-controls {
    gap: 8px;
    width: calc(100% - 12px);
  }

  .turn-button {
    min-height: 72px;
    padding: 10px 8px;
  }

  .turn-mic {
    font-size: 19px;
  }

  .quick-input {
    grid-template-columns: 1fr auto;
  }

  .quick-input button {
    grid-column: 2;
    grid-row: 1;
  }

  .auto-detect-label {
    grid-column: 1 / -1;
    width: fit-content;
    margin-left: 7px;
  }

  .conversation-section {
    margin: 65px auto 85px;
  }

  .transcript-entry {
    grid-template-columns: 34px 1fr;
    gap: 11px;
    padding: 16px;
  }

  .entry-meta {
    display: none;
  }

  .entry-actions {
    grid-column: 2;
    align-items: flex-start;
  }

  footer {
    flex-direction: column;
    gap: 8px;
  }
}

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