:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: #17231f;
  background: #edf2ef;
  font-synthesis: none;
  letter-spacing: 0;
  --green: #0a806d;
  --green-dark: #065c50;
  --green-deep: #173b34;
  --green-soft: #dff1eb;
  --ink: #17231f;
  --muted: #687872;
  --line: #d8e2de;
  --surface: #ffffff;
  --surface-muted: #f5f8f6;
  --warm: #c47b21;
  --warm-soft: #fff3dc;
  --danger: #b63b3b;
  --shadow: 0 18px 42px rgba(22, 55, 46, 0.1);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background: #edf2ef;
}

button, textarea, select {
  font: inherit;
  letter-spacing: 0;
}

button, select { min-height: 40px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.app-header {
  border-bottom: 1px solid #244e45;
  background: var(--green-deep);
  color: #ffffff;
}

.header-inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 82px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #e6b458;
  color: var(--green-deep);
  font-size: 23px;
  font-weight: 800;
}

.brand-copy h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.brand-copy p {
  margin: 3px 0 0;
  color: #b9ccc5;
  font-size: 13px;
}

.brand-copy p span { color: #efc875; font-weight: 700; }

.service-status {
  margin-left: auto;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c6d5d0;
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #899a94;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.service-status.is-online .status-dot { background: #a8df72; }
.service-status.is-offline .status-dot { background: #ed8580; }

.main-content {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 24px;
}

.translator {
  position: relative;
  overflow: hidden;
  border: 1px solid #cbd8d3;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.translator::before {
  content: "";
  display: block;
  height: 4px;
  background: #e1a641;
}

.tool-row {
  min-height: 72px;
  padding: 13px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, 86px);
  padding: 3px;
  border: 1px solid #cbd8d3;
  border-radius: 8px;
  background: #e6eeeb;
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  transition: background 120ms ease, color 120ms ease;
}

.segment:hover:not(.is-active) { color: var(--green-dark); }

.segment.is-active {
  background: var(--surface);
  color: var(--green-dark);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(25, 64, 53, 0.12);
}

.example-select {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.example-select select {
  width: 124px;
  padding: 0 30px 0 11px;
  border: 1px solid #cbd8d3;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px minmax(0, 1fr);
  min-height: 350px;
}

.editor-pane {
  min-width: 0;
  display: grid;
  grid-template-rows: 54px minmax(248px, 1fr) 44px;
}

.source-pane { border-right: 1px solid var(--line); }
.target-pane { border-left: 1px solid var(--line); background: #f8fbf9; }

.pane-header,
.pane-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}

.pane-header { border-bottom: 1px solid #e5ece8; }

.pane-header h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
  letter-spacing: 0.03em;
}

.text-button {
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--green-dark);
  font-size: 13px;
}

.text-button:hover:not(:disabled) { color: var(--green); text-decoration: underline; }

#source-input,
.translation-output {
  width: 100%;
  min-width: 0;
  padding: 22px;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.7;
}

#source-input { resize: none; background: var(--surface); }
#source-input::placeholder,
.translation-output.is-empty { color: #9aa7a1; }
#source-input:focus { box-shadow: inset 0 0 0 2px rgba(10, 128, 109, 0.22); }

.translation-output {
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pane-footer {
  border-top: 1px solid #e5ece8;
  color: var(--muted);
  font-size: 12px;
}

.flow-arrow {
  display: grid;
  place-items: center;
  color: var(--warm);
  background: var(--surface-muted);
}

.flow-arrow::before {
  content: "→";
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid #edcf91;
  border-radius: 50%;
  background: var(--warm-soft);
  font-size: 18px;
  font-weight: 800;
}

.action-row {
  min-height: 80px;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-muted);
}

.feedback {
  min-height: 22px;
  margin: 0 auto 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.feedback.is-success { color: var(--green-dark); }

.primary-button {
  width: 138px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex: 0 0 138px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: var(--green);
  color: #ffffff;
  font-weight: 700;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.primary-button:hover:not(:disabled) {
  border-color: var(--green-dark);
  background: var(--green-dark);
  transform: translateY(-1px);
}

.spinner {
  width: 16px;
  height: 16px;
  display: none;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.primary-button.is-loading .spinner { display: block; }
.primary-button.is-loading .button-label { opacity: 0.85; }

.app-footer {
  width: min(1180px, calc(100% - 40px));
  min-height: 52px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.app-footer a { color: var(--green-dark); font-weight: 700; text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

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

@media (max-width: 780px) {
  .header-inner,
  .main-content,
  .app-footer { width: min(100% - 24px, 620px); }

  .header-inner { min-height: 70px; }
  .brand-mark { width: 40px; height: 40px; flex-basis: 40px; font-size: 21px; }
  .brand-copy h1 { font-size: 18px; }
  .service-status { font-size: 12px; }
  .main-content { padding-top: 18px; }

  .tool-row {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }

  .segmented-control { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .example-select { justify-content: space-between; }
  .example-select select { flex: 1; max-width: 220px; }
  .editor-grid { grid-template-columns: 1fr; min-height: 0; }
  .editor-pane { grid-template-rows: 52px minmax(200px, auto) 42px; }
  .source-pane, .target-pane { border-right: 0; border-left: 0; }

  .flow-arrow {
    min-height: 38px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .flow-arrow::before { content: "↓"; }

  #source-input,
  .translation-output { min-height: 200px; padding: 16px; font-size: 16px; }
  .pane-header, .pane-footer { padding-left: 16px; padding-right: 16px; }

  .action-row {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
  }

  .primary-button { width: 100%; flex-basis: 46px; }
  .feedback { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner, .primary-button, .segment { animation: none; transition: none; }
}
