/* Translator editor (U5) — phone-first, system fonts, zero external assets. */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --ink: #1f2a24;
  --muted: #5f6d64;
  --line: #ddDad2;
  --accent: #1d5c46;
  --accent-ink: #ffffff;
  --error: #a3271d;
  --human-bg: #e2f2e6;
  --human-ink: #1d5c34;
  --machine-bg: #ebebe7;
  --machine-ink: #55605a;
  --review-bg: #fdecc8;
  --review-ink: #8a5a00;
  --dirty: #b98a1f;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
}

.topbar-brand {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.btn-ghost {
  background: transparent;
  color: var(--accent-ink);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  font-size: 1.4rem;
  margin: 0.5rem 0;
}

.note {
  color: var(--muted);
  font-size: 0.95rem;
}

/* --- login ----------------------------------------------------------- */

#login-view {
  max-width: 26rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

#login-form label {
  font-weight: 600;
  font-size: 0.9rem;
}

#key-input {
  font: inherit;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  width: 100%;
}

#login-btn,
.row-save {
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
}

#login-btn:disabled,
.row-save:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.error {
  color: var(--error);
  font-size: 0.9rem;
}

/* --- editor header ---------------------------------------------------- */

.editor-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.lang-label {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#lang-picker {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.progress {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* --- sections + rows -------------------------------------------------- */

.section-title {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--line);
}

.row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.row.dirty {
  border-color: var(--dirty);
  box-shadow: 0 0 0 1px var(--dirty);
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.row-key {
  font-size: 0.75rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}

.badge-human {
  background: var(--human-bg);
  color: var(--human-ink);
}

.badge-machine {
  background: var(--machine-bg);
  color: var(--machine-ink);
}

.badge-review {
  background: var(--review-bg);
  color: var(--review-ink);
  outline: 2px solid var(--review-ink);
  outline-offset: 1px;
}

/* Phone-first: EN above the textarea, single column. */
.row-pair {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.row-lang-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.row-en {
  margin: 0;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.row-target {
  width: 100%;
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  resize: vertical;
  min-height: 3.2rem;
}

.row-target:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.row-error {
  margin: 0.5rem 0 0;
  color: var(--error);
  font-size: 0.85rem;
}

.row-controls {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.row-save {
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
}

/* Side-by-side EN / target on wider screens. */
@media (min-width: 768px) {
  .editor-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .row-pair {
    flex-direction: row;
  }

  .row-en-box,
  .row-target-box {
    flex: 1 1 50%;
    min-width: 0;
  }
}
