:root {
  color-scheme: light;
  --ink: #17221c;
  --muted: #627168;
  --paper: #fbfaf5;
  --surface: #ffffff;
  --line: #dfe5df;
  --green: #176b4d;
  --green-dark: #0f5039;
  --green-soft: #e8f3ed;
  --gold: #d6a642;
  --red: #b33d3d;
  --red-soft: #fff0ef;
  --shadow: 0 22px 70px rgba(28, 58, 43, 0.1);
  font-family: "Noto Sans Khmer", "Khmer OS Battambang", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(214, 166, 66, 0.12), transparent 25rem),
    radial-gradient(circle at 88% 14%, rgba(23, 107, 77, 0.1), transparent 30rem),
    var(--paper);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.58; }

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(23, 34, 28, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-centered { justify-content: center; margin-bottom: 26px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: 14px 14px 14px 5px;
  background: linear-gradient(145deg, var(--green), var(--green-dark));
  box-shadow: 0 10px 22px rgba(23, 107, 77, 0.2);
}

.brand-name { font-weight: 700; font-size: 1.08rem; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.header-actions { display: flex; align-items: center; gap: 14px; }
.language-tabs {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}

.language-tab {
  min-height: 34px;
  padding: 6px 13px;
  color: var(--muted);
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 650;
}

.language-tab.is-active { color: white; background: var(--green); }
.language-tabs.compact .language-tab { min-height: 30px; padding: 4px 10px; }

.quiet-button, .text-button, .icon-button {
  color: var(--green-dark);
  border: 0;
  background: transparent;
  font-weight: 650;
}

.quiet-button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.7);
}

.app-shell { width: min(1120px, calc(100% - 40px)); margin: 60px auto 70px; }
.intro { max-width: 760px; margin-bottom: 30px; }
.intro h1 {
  margin: 8px 0 12px;
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 1.18;
  letter-spacing: -0.035em;
}
.intro > p:last-child { color: var(--muted); font-size: 1rem; line-height: 1.8; }

.translator-card {
  overflow: hidden;
  border: 1px solid rgba(23, 34, 28, 0.1);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mode-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 14px 0;
  background: linear-gradient(180deg, #fff, #fbfcfa);
}

.mode-tab {
  min-height: 42px;
  padding: 9px 18px;
  color: var(--muted);
  border: 0;
  border-radius: 11px 11px 0 0;
  background: transparent;
  font-weight: 750;
}

.mode-tab.is-active {
  color: var(--green-dark);
  background: var(--green-soft);
}

.language-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 18px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fbfcfa);
}

.select-group { display: grid; gap: 7px; }
.select-group span, .panel-heading { font-size: 0.82rem; font-weight: 750; color: #425047; }
select {
  width: 100%;
  min-height: 44px;
  padding: 0 38px 0 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
}

.swap-button {
  width: 44px;
  height: 44px;
  color: var(--green-dark);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--green-soft);
  font-size: 1.3rem;
}

.text-grid { display: grid; grid-template-columns: 1fr 1fr; }
.text-panel { min-width: 0; padding: 24px 26px 18px; }
.text-panel + .text-panel { border-left: 1px solid var(--line); background: #fcfdfa; }
.panel-heading, .panel-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading { min-height: 30px; margin-bottom: 10px; }
.text-button { padding: 5px; font-size: 0.78rem; }
textarea {
  display: block;
  width: 100%;
  min-height: 270px;
  resize: vertical;
  padding: 4px 0;
  color: var(--ink);
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 1.04rem;
  line-height: 1.85;
}
textarea::placeholder { color: #9aa49e; }
.panel-footer { min-height: 28px; color: var(--muted); font-size: 0.72rem; }
.near-limit { color: var(--red); font-weight: 700; }
.output-meta span:empty { display: none; }

.file-workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  min-height: 390px;
}

.upload-column, .file-output-column { min-width: 0; padding: 26px; }
.file-output-column { border-left: 1px solid var(--line); background: #fcfdfa; }

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  border: 2px dashed #bfd0c5;
  border-radius: 18px;
  background: #fbfdfb;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--green); background: var(--green-soft); }
.drop-zone strong { margin: 10px 0 4px; color: var(--ink); font-size: 1.05rem; }
.drop-zone small { margin-top: 13px; }
.upload-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: white;
  border-radius: 50%;
  background: var(--green);
  font-size: 1.45rem;
}

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

.file-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.file-details > div { min-width: 0; display: grid; gap: 3px; }
.file-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-details span, .file-privacy { color: var(--muted); font-size: 0.74rem; }
.file-privacy { margin: 16px 2px 0; line-height: 1.65; }

.progress-wrap { display: flex; align-items: center; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 0.74rem; }
.progress-track { flex: 1; height: 7px; overflow: hidden; border-radius: 999px; background: var(--green-soft); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width 0.15s ease; }

.file-results { display: grid; gap: 14px; max-height: 430px; overflow: auto; padding: 2px; }
.empty-result { margin: 70px 20px; color: #9aa49e; text-align: center; line-height: 1.7; }
.page-result { padding: 15px 17px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.page-result strong { display: block; margin-bottom: 8px; color: var(--green-dark); font-size: 0.82rem; }
.page-result pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 0.92rem; line-height: 1.75; }
.file-output-column .panel-footer { margin-top: 14px; }

.translate-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 26px;
  border-top: 1px solid var(--line);
  background: #f8faf7;
}

.data-note { margin: 0; color: var(--muted); font-size: 0.76rem; }
.primary-button {
  min-height: 48px;
  padding: 11px 24px;
  color: white;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--green), var(--green-dark));
  box-shadow: 0 11px 25px rgba(23, 107, 77, 0.2);
  font-weight: 750;
}
.full-width { width: 100%; }
.loading-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 50%;
  background: white;
  animation: pulse 0.9s ease-in-out infinite alternate;
}
.loading-dot[hidden] { display: none; }
@keyframes pulse { to { opacity: 0.25; transform: scale(0.65); } }

.form-message { margin: 0; padding: 12px 26px; font-size: 0.86rem; }
.error-message { color: var(--red); background: var(--red-soft); }
.pilot-note {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 18px 6px 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}
.pilot-note strong { flex: 0 0 auto; color: var(--ink); }

.login-page { display: grid; place-items: center; padding: 28px; }
.login-shell { width: min(100%, 480px); }
.login-card {
  padding: 38px;
  border: 1px solid rgba(23, 34, 28, 0.1);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0; font-size: 1.55rem; }
.login-card > .language-tabs { display: flex; width: fit-content; margin: 0 auto 24px; }
.lead { margin: 0 0 24px; color: var(--muted); text-align: center; line-height: 1.7; }
.login-card form label { display: block; margin-bottom: 8px; font-size: 0.84rem; font-weight: 750; }
.password-row { position: relative; margin-bottom: 16px; }
.password-row input {
  width: 100%;
  height: 50px;
  padding: 0 50px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
}
.password-row input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.icon-button { position: absolute; top: 0; right: 0; width: 48px; height: 50px; }
.login-card .form-message { margin: -3px 0 14px; padding: 10px 12px; border-radius: 9px; }
.privacy-note {
  margin-top: 24px;
  padding: 16px;
  color: var(--muted);
  border-left: 3px solid var(--gold);
  border-radius: 4px 10px 10px 4px;
  background: #fffbf0;
  font-size: 0.76rem;
  line-height: 1.65;
}
.privacy-note strong { color: var(--ink); }
.privacy-note p { margin: 5px 0 0; }

@media (max-width: 760px) {
  .site-header { width: min(100% - 24px, 1180px); min-height: 74px; }
  .brand .eyebrow { display: none; }
  .brand-name { display: none; }
  .header-actions { gap: 7px; }
  .language-tabs.compact .language-tab { padding: 4px 8px; font-size: 0.74rem; }
  .quiet-button { padding: 8px; font-size: 0.76rem; }
  .app-shell { width: min(100% - 24px, 1120px); margin: 36px auto 48px; }
  .intro h1 { font-size: 2.15rem; }
  .language-controls { grid-template-columns: 1fr auto 1fr; gap: 9px; padding: 18px; }
  .select-group span { font-size: 0.7rem; }
  select { padding-left: 9px; font-size: 0.82rem; }
  .text-grid { grid-template-columns: 1fr; }
  .text-panel { padding: 20px 18px 14px; }
  .text-panel + .text-panel { border-top: 1px solid var(--line); border-left: 0; }
  textarea { min-height: 200px; }
  .translate-actions { align-items: stretch; flex-direction: column; padding: 16px 18px 18px; }
  .primary-button { width: 100%; }
  .pilot-note { align-items: flex-start; flex-direction: column; gap: 2px; }
  .file-workspace { grid-template-columns: 1fr; }
  .upload-column, .file-output-column { padding: 20px 18px; }
  .file-output-column { border-top: 1px solid var(--line); border-left: 0; }
  .drop-zone { min-height: 190px; }
}

@media (max-width: 430px) {
  .login-page { padding: 14px; }
  .login-card { padding: 28px 20px; }
  .brand-centered { justify-content: flex-start; }
  .login-card > .language-tabs { width: 100%; }
  .login-card > .language-tabs .language-tab { flex: 1; }
}

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