:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #1d2522;
  --muted: #63706b;
  --line: #dce2dc;
  --accent: #1f6f5b;
  --accent-strong: #174e42;
  --warn: #9b2c2c;
  --tag: #edf4f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 40px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: 0;
}

.repo-link {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.logout-form {
  display: block;
}

.logout-form button {
  min-width: 74px;
  padding: 8px 12px;
  background: var(--accent-strong);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 28px;
  padding: 28px 40px 48px;
}

.panel,
.paper,
.empty,
.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-panel {
  align-self: start;
  padding: 22px;
  position: sticky;
  top: 20px;
}

form,
label {
  display: grid;
  gap: 8px;
}

form {
  gap: 16px;
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.combo-box {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 38px;
}

.combo-box input {
  border-radius: 6px 0 0 6px;
}

.combo-toggle {
  min-height: 44px;
  padding: 0;
  border-left: 0;
  border-radius: 0 6px 6px 0;
  border: 1px solid var(--line);
  background: #fbfcfb;
  color: var(--accent-strong);
  font-size: 16px;
}

.combo-options {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 26px rgb(29 37 34 / 14%);
}

.combo-option {
  width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-weight: 750;
}

.combo-option:hover,
.combo-option:focus {
  background: var(--tag);
  color: var(--accent-strong);
  outline: none;
}

input,
textarea,
select,
button {
  width: 100%;
  border-radius: 6px;
  font: inherit;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 14px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.dropdown-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.dropdown-panel summary {
  min-height: 44px;
  padding: 12px 14px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.dropdown-body {
  padding: 0 14px 14px;
}

.option-group + .option-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.group-title {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.group-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.select-all {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.select-all input {
  width: 14px;
  min-width: 14px;
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.check-grid.compact {
  grid-template-columns: 1fr 1fr;
}

.check-card {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-height: 34px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fbfcfb;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
}

.check-card input {
  width: 14px;
  min-width: 14px;
  margin-top: 1px;
}

.check-card:has(input:checked) {
  border-color: #96cabb;
  background: #edf8f3;
}

.inline-check {
  justify-content: flex-start;
  align-self: end;
  min-height: 42px;
}

.query-preview {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  background: #fbfcfb;
}

.query-preview summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.query-preview pre {
  max-height: 190px;
  overflow: auto;
  margin: 12px 0 0;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.inline-field {
  margin-top: 14px;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfcfb;
}

textarea {
  resize: vertical;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

button {
  border: 0;
  padding: 11px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button + button {
  background: var(--accent-strong);
}

.actions button:last-child {
  grid-column: 1 / -1;
  background: #244f7a;
}

.results {
  min-width: 0;
}

.result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.result-header h2 {
  margin-bottom: 0;
}

.result-header span {
  color: var(--muted);
}

.paper {
  padding: 22px;
  margin-bottom: 16px;
}

.paper-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.paper-meta span,
.tags span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--tag);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.paper h3 {
  margin-bottom: 8px;
  font-size: 21px;
  letter-spacing: 0;
}

.paper a {
  color: var(--ink);
  text-decoration-color: var(--accent);
}

.authors {
  color: var(--muted);
  font-size: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.empty,
.notice {
  padding: 28px;
}

.empty p,
.notice {
  color: var(--muted);
}

.error {
  color: var(--warn);
  border-color: #e3b5b5;
  background: #fff7f7;
}

.success {
  color: var(--accent-strong);
  border-color: #a8d7c8;
  background: #f1faf6;
}

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

.form-hint a {
  color: var(--accent-strong);
  font-weight: 800;
}

.auth-layout {
  display: grid;
  place-items: start center;
  padding: 40px 22px;
}

.auth-panel {
  width: min(100%, 460px);
  padding: 24px;
}

.account-layout {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}

.account-summary {
  align-self: start;
  padding: 22px;
}

.account-summary h2 {
  font-size: 20px;
  word-break: break-word;
}

.schedule-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.subscription-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.subscription-actions form {
  display: block;
}

.subscription-actions button {
  min-height: 42px;
}

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

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

  .search-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .field-row,
  .actions,
  .check-grid,
  .check-grid.compact {
    grid-template-columns: 1fr;
  }
}
