:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --panel: #ffffff;
  --ink: #202725;
  --muted: #66726f;
  --line: #d8e0dd;
  --accent: #176b62;
  --accent-dark: #0f4f49;
  --info: #315f85;
  --plum: #594667;
  --amber: #9a671d;
  --danger: #a34335;
  --soft: #f8faf9;
  --shadow: 0 16px 38px rgba(26, 40, 36, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:focus-visible,
.button-link:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(31, 122, 90, 0.25);
  outline-offset: 2px;
}

.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary,
.button-link {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.secondary:hover,
.button-link:hover {
  border-color: #b8c8c3;
  background: var(--soft);
}

.full {
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 8px 22px rgba(24, 36, 33, 0.05);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card .brand-mark {
  width: 52px;
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.auth-card p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-kicker {
  margin: 0 0 3px !important;
  color: var(--accent-dark) !important;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

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

.brand-mark {
  width: 44px;
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #23312d;
  color: #fff;
  font-weight: 900;
  box-shadow: inset 0 -8px 18px rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.version-badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #c4ded6;
  border-radius: 999px;
  padding: 2px 8px;
  background: #edf6f3;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.session-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #c4ded6;
  border-radius: 999px;
  padding: 5px 10px;
  background: #edf6f3;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.last-activity-pill {
  width: fit-content;
  max-width: 100%;
  margin-top: 7px;
  padding: 5px 9px;
  border: 1px solid #d9e0dd;
  border-radius: 999px;
  background: #f8faf9;
  color: #4f5d59;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.topbar h1,
.results-toolbar h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 23px;
}

.topbar p,
.results-toolbar p,
.result-meta,
.notice,
.attribution,
.source-status {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4f2;
}

.nav-tab {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.nav-tab.active {
  background: #fff;
  color: var(--accent-dark);
  box-shadow: 0 2px 8px rgba(24, 36, 33, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr) minmax(280px, 340px);
  gap: 20px;
  padding: 20px;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
}

.search-panel,
.results-panel,
.saved-panel {
  min-width: 0;
}

.search-panel,
.saved-panel {
  position: sticky;
  top: 102px;
  align-self: start;
}

.search-panel,
.results-panel,
.saved-panel,
.translation-box,
.source-box,
.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-panel {
  display: grid;
  gap: 14px;
  overflow: clip;
  padding: 16px;
}

.results-panel,
.saved-panel {
  container-type: inline-size;
  padding: 16px;
}

.settings-page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 22px 20px 40px;
}

.settings-shell {
  display: grid;
  gap: 16px;
}

.settings-head,
.settings-card,
.settings-note {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.settings-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 18px;
}

.settings-head h2,
.settings-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.settings-head h2 {
  margin-top: 6px;
  font-size: 22px;
}

.settings-head p,
.settings-card p,
.settings-note {
  color: var(--muted);
  line-height: 1.55;
}

.settings-head p {
  margin: 6px 0 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.settings-card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.settings-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.settings-card h3 {
  font-size: 18px;
}

.settings-card p {
  margin: 5px 0 0;
  font-size: 13px;
}

.settings-badge {
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #edf6f3;
  color: var(--accent-dark);
  border: 1px solid #c4ded6;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.settings-note {
  padding: 14px 16px;
  box-shadow: none;
}

.settings-lock {
  padding: 14px 16px;
  border: 1px solid #ead4bd;
  border-radius: 8px;
  background: #fff7ed;
  color: #744b17;
  font-weight: 750;
  line-height: 1.55;
}

.records-panel {
  display: grid;
  gap: 14px;
}

.record-block {
  display: grid;
  gap: 9px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.record-block:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.record-title {
  color: var(--plum);
  font-size: 13px;
  font-weight: 850;
}

.record-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.field-label,
.control-grid label {
  display: grid;
  gap: 7px;
  color: #3a3632;
  font-weight: 700;
  font-size: 14px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4f2;
}

.mode-switch legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.mode-switch label {
  min-width: 0;
}

.mode-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.mode-switch span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 850;
  cursor: pointer;
}

.mode-switch input:checked + span {
  background: #fff;
  color: var(--accent-dark);
  box-shadow: 0 2px 8px rgba(24, 36, 33, 0.08);
}

textarea,
select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
}

textarea:hover,
select:hover,
input:hover {
  border-color: #bdcbc7;
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.55;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}

.example-row,
.chip-list,
.tag-list,
.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.text-chip,
.tag,
.query-chip,
.license-badge,
.status-pill {
  max-width: 100%;
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: #34413d;
  padding: 5px 10px;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}

.text-chip {
  cursor: pointer;
}

.translation-box,
.source-box,
.notice {
  padding: 14px;
  box-shadow: none;
}

.api-settings {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.api-provider-title {
  margin-top: 12px;
  color: var(--info);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.api-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}

.api-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.compact-field {
  display: grid;
  gap: 6px;
  margin-top: 9px;
  color: #3a3632;
  font-size: 13px;
  font-weight: 700;
}

.api-divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0 12px;
}

.api-status,
.microcopy {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.api-status.ok {
  color: var(--accent-dark);
  font-weight: 700;
}

.api-status.warn {
  color: var(--danger);
  font-weight: 700;
}

.section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  color: #4c4741;
  letter-spacing: 0;
}

.query-output {
  margin-top: 9px;
  padding: 12px;
  min-height: 48px;
  border-radius: 8px;
  background: #eef6f3;
  border: 1px solid #cce1da;
  color: #152d28;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.results-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.results-toolbar h2 {
  font-size: 18px;
}

.warnings {
  border-left: 4px solid var(--amber);
  background: #fff8e9;
  color: #61450c;
  padding: 12px;
  margin-bottom: 14px;
  border-radius: 6px;
  line-height: 1.55;
}

.results-list,
.saved-list {
  display: grid;
  gap: 12px;
}

.result-card {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.result-card:hover {
  border-color: #b7cbc5;
  box-shadow: 0 12px 26px rgba(24, 36, 33, 0.07);
  transform: translateY(-1px);
}

.media-mark {
  width: 78px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #eaf2f4;
  border: 1px solid #c9dce2;
  display: grid;
  place-items: center;
}

.bars {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.bars span {
  display: block;
  width: 6px;
  border-radius: 8px;
  background: var(--accent);
}

.bars span:nth-child(1) { height: 17px; }
.bars span:nth-child(2) { height: 31px; }
.bars span:nth-child(3) { height: 24px; }
.bars span:nth-child(4) { height: 38px; }
.bars span:nth-child(5) { height: 21px; }

.result-main {
  min-width: 0;
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  min-width: 0;
}

.result-head > div {
  min-width: 0;
}

.result-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.license-badge {
  color: var(--accent-dark);
  background: #edf6f3;
  border-color: #c4ded6;
  font-weight: 800;
  flex: 0 1 auto;
}

audio {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 12px;
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  min-width: 0;
}

.result-actions a,
.result-actions button {
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
}

.attribution {
  font-size: 13px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.source-status {
  display: grid;
  gap: 7px;
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
}

.status-pill.ok {
  border-color: #bedbd4;
  background: #edf6f3;
  color: #195449;
}

.status-pill.warn {
  border-color: #ead3a7;
  background: #fff8e9;
  color: #6f4c12;
}

.quick-links a {
  max-width: 100%;
  color: var(--accent-dark);
  text-decoration: none;
  border-bottom: 1px solid #a6ccc5;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed #c4cfca;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
  line-height: 1.6;
}

.compact-empty {
  min-height: 96px;
  padding: 14px;
  font-size: 13px;
}

.download-list,
.activity-list {
  display: grid;
  gap: 9px;
}

.record-item,
.saved-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  min-width: 0;
}

.record-item h3,
.saved-item h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.record-item p,
.saved-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.activity-item {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #384641;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.saved-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

@container (max-width: 520px) {
  .result-card {
    grid-template-columns: 1fr;
  }

  .media-mark {
    width: 100%;
    height: 72px;
    aspect-ratio: auto;
  }

  .result-head {
    flex-direction: column;
  }

  .result-actions a,
  .result-actions button {
    width: 100%;
  }
}

@media (max-width: 1380px) {
  .layout {
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  }

  .saved-panel {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 900px) {
  .topbar {
    position: static;
    padding: 18px;
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    align-items: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .search-panel {
    position: static;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .result-head,
  .results-toolbar {
    flex-direction: column;
  }

  .topbar-actions,
  .result-actions,
  .results-toolbar > .secondary {
    width: 100%;
  }

  .nav-tabs {
    width: 100%;
  }

  .nav-tab {
    flex: 1;
  }

  .settings-page {
    padding: 12px;
  }

  .settings-head {
    flex-direction: column;
  }

  .topbar-actions > .secondary,
  .result-actions a,
  .result-actions button,
  .api-row button,
  .results-toolbar > .secondary,
  .settings-head > .secondary {
    width: 100%;
  }

  .api-row {
    grid-template-columns: 1fr;
  }
}
