:root {
  color-scheme: light;
  --paper: #fff8f3;
  --surface: #ffffff;
  --surface-soft: #fff0e8;
  --ink: #392b26;
  --muted: #816b62;
  --line: #ecd9cf;
  --accent: #df6b52;
  --accent-deep: #bd4f3a;
  --shadow: 0 18px 55px rgba(108, 69, 52, .1);
}

:root.dark {
  color-scheme: dark;
  --paper: #1f1917;
  --surface: #2b2320;
  --surface-soft: #382823;
  --ink: #f8eae2;
  --muted: #c9aaa0;
  --line: #4b3932;
  --accent: #f08b72;
  --accent-deep: #ffad98;
  --shadow: 0 18px 55px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 24rem),
    radial-gradient(circle at 90% 70%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 28rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

button, select, textarea { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 32%, transparent);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; letter-spacing: .08em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.top-actions { display: flex; gap: 7px; align-items: center; }

.nav-button, .icon-button, .filter-button, .text-button {
  border: 0;
  color: var(--muted);
  background: transparent;
}

.nav-button {
  padding: 9px 13px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
}

.nav-button:hover, .nav-button.active {
  color: var(--accent-deep);
  background: var(--surface-soft);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  font-size: 19px;
}

.icon-button:hover { color: var(--accent-deep); background: var(--surface-soft); }
.home-link { text-decoration: none; }

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

.intro { max-width: 700px; }
.eyebrow { margin: 0 0 10px; color: var(--accent-deep); font-size: 12px; font-weight: 800; letter-spacing: .16em; }
.intro h1, .history-heading h1 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(36px, 6vw, 64px); line-height: 1.08; letter-spacing: -.04em; }
.intro h1 span { color: var(--accent); }
.intro > p:last-child, .history-heading p { color: var(--muted); line-height: 1.7; }

.language-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  margin: 44px 0 14px;
}

.language-bar label > span {
  display: block;
  margin: 0 0 8px 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  color: var(--ink);
  background: var(--surface);
}

select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }

.swap-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--accent-deep);
  background: var(--surface-soft);
  font-size: 23px;
  transition: transform .2s ease;
}

.swap-button:hover { transform: rotate(180deg); }

.translator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.translation-card { min-width: 0; }
.translation-card + .translation-card { border-left: 1px solid var(--line); }
.result-card { background: color-mix(in srgb, var(--surface) 76%, var(--surface-soft)); }

.card-heading, .card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.card-heading { border-bottom: 1px solid var(--line); }
.card-footer { min-height: 55px; border-top: 1px solid var(--line); }
.card-footer > div { display: flex; gap: 3px; }

textarea, .translated-text {
  width: 100%;
  min-height: 300px;
  padding: 24px;
  border: 0;
  outline: 0;
  resize: vertical;
  color: var(--ink);
  background: transparent;
  font-size: clamp(17px, 2.2vw, 21px);
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

textarea::placeholder, .translated-text.empty { color: color-mix(in srgb, var(--muted) 58%, transparent); }
.translated-text.error { color: #c95243; }

.text-button { padding: 8px 10px; border-radius: 9px; font-size: 13px; font-weight: 700; }
.text-button:hover { color: var(--accent-deep); background: var(--surface-soft); }
.text-button.active { color: var(--accent-deep); }
.text-button.danger { color: #c95243; }

.below-actions {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

kbd { padding: 2px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; color: var(--ink); background: var(--surface); font-family: inherit; }

.primary-button {
  min-width: 142px;
  height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 30%, transparent);
}

.primary-button:disabled { cursor: wait; opacity: .68; }
.privacy-note { margin: 18px 2px 0; color: var(--muted); font-size: 12px; }

.history-view { padding: 72px 0 60px; }
.history-heading { display: flex; justify-content: space-between; gap: 24px; align-items: end; }
.history-heading h1 { font-size: clamp(36px, 5vw, 56px); }
.history-filters { display: flex; gap: 8px; margin: 30px 0 18px; }
.filter-button { padding: 9px 15px; border-radius: 999px; font-weight: 700; }
.filter-button.active { color: #fff; background: var(--accent); }
.history-list { display: grid; gap: 12px; }

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.history-item p, .history-item strong { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.history-item p { color: var(--muted); font-size: 13px; }
.history-item strong { display: block; margin-top: 5px; line-height: 1.55; }
.history-meta { margin-top: 8px !important; font-size: 11px !important; }
.history-actions { display: flex; }
.empty-history { padding: 70px 20px; border: 1px dashed var(--line); border-radius: 20px; color: var(--muted); text-align: center; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  padding: 11px 16px;
  border-radius: 12px;
  color: #fff;
  background: #302622;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .2);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

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

@media (max-width: 760px) {
  .topbar { min-height: 64px; padding: 10px 14px; }
  .brand small { display: none; }
  .brand-mark { width: 39px; height: 39px; border-radius: 12px; }
  .nav-button { padding: 8px 9px; }
  main { width: min(100% - 24px, 1180px); }
  .workspace, .history-view { padding-top: 42px; }
  .intro h1 { font-size: 40px; }
  .language-bar { margin-top: 30px; gap: 7px; }
  .translator-grid { grid-template-columns: 1fr; border-radius: 19px; }
  .translation-card + .translation-card { border-top: 1px solid var(--line); border-left: 0; }
  textarea, .translated-text { min-height: 220px; padding: 18px; font-size: 17px; }
  .below-actions { align-items: stretch; flex-direction: column; }
  .below-actions p { margin-bottom: 0; line-height: 1.7; }
  .primary-button { width: 100%; }
  .history-heading { align-items: start; flex-direction: column; }
  .history-item { grid-template-columns: 1fr; gap: 14px; }
  .history-item > div + div { padding-top: 14px; border-top: 1px solid var(--line); }
  .history-actions { justify-content: flex-end; }
}

@media (max-width: 410px) {
  .home-link { display: none; }
  .top-actions { gap: 2px; }
  .language-bar { grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr); }
  .swap-button { width: 40px; height: 44px; }
  select { padding: 0 8px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
