:root {
  color-scheme: light;
  --page: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #172033;
  --muted: #697386;
  --line: #dce4ef;
  --primary: #2376d9;
  --primary-soft: #e8f2ff;
  --accent: #18a67f;
  --shadow: 0 18px 48px rgba(28, 42, 72, 0.12);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --page: #121722;
  --surface: #1b2230;
  --surface-2: #222b3c;
  --text: #eef3f8;
  --muted: #a9b2c3;
  --line: #334055;
  --primary: #6aa8ff;
  --primary-soft: #1b3355;
  --accent: #42d6ab;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  gap: 6px;
  flex: 1;
}

.topnav a,
.icon-text-btn,
.soft-btn,
.ghost-btn,
.link-btn {
  border: 0;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.topnav a {
  padding: 9px 14px;
  color: var(--muted);
  font-size: 14px;
}

.topnav a:hover,
.icon-text-btn:hover,
.ghost-btn:hover,
.soft-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.icon-text-btn,
.soft-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.circle-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.layout {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  gap: 0;
  flex: 1;
}

.sidebar {
  padding: 24px 14px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.sidebar-title {
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  margin-bottom: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.menu-item span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--primary);
  font-size: 13px;
}

.menu-item strong {
  font-size: 14px;
  font-weight: 650;
}

.menu-item:hover,
.menu-item.is-active {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(28, 42, 72, 0.06);
}

.workspace {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.status-strip p {
  margin: 0 0 3px;
  font-weight: 720;
}

.status-strip span,
.panel-footer,
.result-meta,
.empty-text,
.muted-row {
  color: var(--muted);
  font-size: 13px;
}

.translator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-toolbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

select {
  min-width: 132px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 28px 0 10px;
  background: var(--surface);
  color: var(--text);
}

textarea {
  width: 100%;
  min-height: 220px;
  max-height: 420px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 20px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
}

textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.panel-footer,
.result-meta {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
}

.swap-column {
  display: grid;
  place-items: center;
}

.swap-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 22px;
  box-shadow: 0 12px 28px rgba(28, 42, 72, 0.12);
}

.swap-btn:hover {
  background: var(--primary);
  color: white;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  margin-top: 16px;
}

.compact-panel {
  padding: 16px;
  box-shadow: none;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
}

.link-btn {
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
}

.phonetic {
  min-height: 34px;
  margin: 0 0 12px;
  color: var(--muted);
}

.alternatives,
.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.alt-row,
.muted-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.alt-row span {
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.history-card {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
}

.history-card:hover {
  border-color: var(--primary);
}

.history-card span,
.history-card small {
  color: var(--muted);
}

.history-pair {
  color: var(--primary) !important;
  font-size: 12px;
}

.footer-info {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 22px;
  padding: 16px 24px 22px;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-title {
    display: none;
  }

  .menu-item {
    margin: 0;
    justify-content: center;
  }

  .menu-item strong {
    display: none;
  }

  .translator-grid,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .swap-column {
    min-height: 44px;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: auto;
    min-height: 68px;
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .brand {
    flex: 1 1 100%;
  }

  .topnav {
    overflow-x: auto;
  }

  .workspace {
    padding: 14px;
  }

  .status-strip,
  .panel-footer,
  .result-meta {
    align-items: flex-start;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 12px;
    padding-bottom: 12px;
  }
}
