:root {
  color-scheme: light;
  --background: #ffffff;
  --surface: #ffffff;
  --text: #253238;
  --subtext: #6b777b;
  --line: #dce3e2;
  --primary: #3f8eaa;
  --primary-pressed: #33758d;
  --soft: #edf4f4;
  --error: #9a3f3f;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  background: #ffffff;
  padding: env(safe-area-inset-top) 4px calc(124px + env(safe-area-inset-bottom));
}

.direction-switch,
.source-block {
  display: none;
}

.language-bar {
  display: grid;
  grid-template-columns: minmax(66px, 0.8fr) 38px minmax(86px, 1.2fr);
  align-items: center;
  gap: 1px;
  min-width: 0;
}

.fixed-language,
select {
  width: 100%;
  min-height: 44px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.fixed-language {
  display: grid;
  place-items: center;
  padding: 3px;
}

.language-select-label {
  min-width: 0;
}

select {
  padding: 3px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
}

.swap-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--primary);
  background: var(--soft);
  font-size: 21px;
  line-height: 1;
}

.language-bar.reverse .fixed-language {
  order: 3;
}

.language-bar.reverse .swap-button {
  order: 2;
}

.language-bar.reverse .language-select-label {
  order: 1;
}

.text-workspace {
  width: 100%;
  background: var(--surface);
}

.input-area {
  border: 0;
  border-bottom: 1px solid var(--line);
}

textarea {
  display: block;
  width: 100%;
  height: 32vh;
  min-height: 180px;
  max-height: 240px;
  padding: 13px 11px;
  border: 0;
  border-radius: 0;
  color: var(--text);
  background: transparent;
  font-size: 21px;
  line-height: 1.42;
  resize: none;
}

textarea::placeholder {
  color: #919b9f;
}

.message {
  min-height: 0;
  margin: 0 7px;
  color: var(--subtext);
  font-size: 12px;
  line-height: 17px;
}

.message:empty {
  display: none;
}

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

.message.listening {
  color: var(--primary-pressed);
}

.result-block {
  height: auto;
  min-height: 96px;
  padding: 11px;
  border: 0;
}

.result-label {
  margin: 0 0 3px;
  color: var(--subtext);
  font-size: 12px;
}

.text-output {
  min-height: 42px;
  margin: 0;
  font-size: 19px;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.muted {
  color: #8c979b;
}

.action-row {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 50px;
  grid-template-rows: 60px 48px;
  align-items: center;
  gap: 5px;
  width: min(100%, 520px);
  min-height: 116px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border-top: 1px solid #242424;
  background: #2b2b2b;
}

.clear-button,
.voice-button,
.translate-button,
.copy-button {
  min-width: 0;
  min-height: 46px;
  padding: 0 5px;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 700;
}

.clear-button,
.copy-button {
  border: 1px solid #555555;
  color: #ffffff;
  background: #171717;
}

.clear-button {
  grid-column: 2;
  grid-row: 2;
  width: 40px;
  min-height: 40px;
  padding: 0;
  justify-self: center;
  border-radius: 10px;
  font-size: 16px;
}

.voice-button {
  grid-column: 1 / -1;
  grid-row: 1;
  width: 56px;
  height: 56px;
  min-height: 56px;
  justify-self: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: var(--primary);
  line-height: 1;
}

.language-bar {
  grid-column: 1;
  grid-row: 2;
}

.action-row .fixed-language,
.action-row select {
  color: #ffffff;
}

.action-row select option {
  color: #111111;
  background: #ffffff;
}

.action-row .swap-button {
  color: #ffffff;
  background: #242424;
}

.voice-button svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.translate-button {
  border: 0;
  color: #ffffff;
  background: var(--primary);
}

.translate-button:active {
  background: var(--primary-pressed);
}

.voice-button:active {
  background: var(--primary-pressed);
}

select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(63, 142, 170, 0.23);
  outline-offset: 1px;
}

button:disabled,
select:disabled {
  opacity: 0.55;
}

button:active {
  transform: translateY(1px);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
