:root {
  color-scheme: light;
  --ink: #20242a;
  --muted: #626b76;
  --line: #d9d2c3;
  --paper: #fbfaf6;
  --surface: #ffffff;
  --sage: #5f735f;
  --sage-deep: #344c3d;
  --clay: #b45f45;
  --gold: #c99a3f;
  --blue: #486b86;
  --shadow: 0 18px 45px rgba(32, 36, 42, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f4f1e8;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 750;
}

.account-mini {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

.account-mini a {
  color: var(--clay);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 32px;
}

.nav-item,
.icon-button,
.segment,
.text-button {
  border: 0;
  background: transparent;
  color: inherit;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
}

.nav-item svg,
.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item.is-active {
  background: #e8dfcf;
  color: var(--ink);
}

.workspace {
  padding: 24px;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: end;
  min-height: 240px;
  overflow: hidden;
  border-radius: 8px;
  background: #26352f;
  color: #fff;
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 40px;
}

.eyebrow {
  margin: 0 0 12px;
  color: #dbc893;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 54px;
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-line {
  max-width: 520px;
  margin-bottom: 0;
  color: #ece7dc;
  font-size: 17px;
  line-height: 1.6;
}

.hero-visual {
  height: 100%;
  min-height: 240px;
}

.hero-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.toolbar,
.section-head,
.brief-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.toolbar {
  margin: 22px 0;
}

.segmented {
  display: flex;
  min-height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.segment {
  min-width: 72px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--muted);
}

.segment.is-active {
  background: var(--ink);
  color: #fff;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: start;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.brief-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.brief-card,
.panel-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.brief-card {
  padding: 18px;
}

.brief-meta,
.tag-row,
.source-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brief-meta {
  justify-content: space-between;
  margin-bottom: 12px;
}

.source-pill,
.score-pill,
.tag,
.topic-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.source-pill {
  padding: 0 10px;
  background: #edf2e7;
  color: var(--sage-deep);
}

.score-pill {
  padding: 0 9px;
  background: #f6ead2;
  color: #7d561b;
}

.brief-card h3 {
  margin-bottom: 10px;
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: 0;
}

.summary {
  margin-bottom: 14px;
  color: var(--muted);
  line-height: 1.65;
}

.tag-row {
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tag {
  padding: 0 9px;
  background: #eef1f4;
  color: #425261;
}

.read-link {
  color: var(--sage-deep);
  font-weight: 750;
  text-decoration: none;
}

.text-button,
.read-link {
  color: var(--clay);
  font-weight: 700;
}

.read-link {
  padding: 0;
  border: 0;
  background: transparent;
}

.primary-button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.update-stamp {
  display: inline-flex;
  max-width: 100%;
  margin: 18px 0 0;
  padding: 7px 10px;
  border: 1px solid rgba(244, 241, 232, 0.25);
  border-radius: 999px;
  color: #f6eddc;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.side-panel {
  display: grid;
  gap: 16px;
}

.panel-section {
  padding: 16px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.chip-list.compact {
  margin: 8px 0 0;
}

.interest-group {
  width: 100%;
  margin-bottom: 10px;
}

.interest-group p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.topic-chip {
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fffaf0;
}

.topic-chip input {
  width: 16px;
  height: 16px;
  accent-color: var(--sage);
}

.add-form {
  display: grid;
  grid-template-columns: 88px 1fr 42px;
  gap: 8px;
}

.add-form input,
.add-form select {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.source-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.source-card {
  min-height: 92px;
  padding: 12px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
}

.source-card.is-suggestion {
  background: #f4f6f3;
}

.source-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.source-card-head span,
.source-card-head strong {
  min-width: 0;
}

.source-card strong {
  color: var(--ink);
  font-size: 14px;
}

.source-card p {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.source-card small {
  display: block;
  line-height: 1.5;
}

.source-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.source-tags span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef1f4;
  color: #425261;
  font-size: 12px;
  font-weight: 700;
}

.config-summary {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--paper);
}

.config-row strong,
.config-block p {
  color: var(--ink);
  font-size: 13px;
}

.config-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.config-block {
  padding: 10px;
  border-radius: 8px;
  background: var(--paper);
}

.config-block p {
  margin-bottom: 4px;
  font-weight: 800;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage);
}

.reader-dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.reader-dialog::backdrop {
  background: rgba(32, 36, 42, 0.42);
}

.reader-shell {
  padding: 22px;
}

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

.reader-head .eyebrow {
  color: var(--clay);
}

.reader-head h2 {
  margin-bottom: 8px;
  font-size: 24px;
  line-height: 1.3;
}

.reader-head p,
.auth-line {
  color: var(--muted);
  line-height: 1.55;
}

.auth-line {
  margin: 12px 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8efe3;
  font-size: 13px;
  font-weight: 700;
}

.summary-panel,
.translation-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.summary-panel {
  padding: 16px;
}

.summary-panel h3,
.translation-grid h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.summary-panel h4 {
  margin: 14px 0 6px;
  color: var(--ink);
  font-size: 13px;
}

.summary-panel p,
.translation-grid p {
  color: var(--muted);
  line-height: 1.72;
}

.summary-panel ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--ink);
  line-height: 1.7;
}

.translation-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.translation-grid > div {
  padding: 16px;
}

.original-link {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--sage-deep);
  font-weight: 800;
  text-decoration: none;
}

.original-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f5ef;
}

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

.original-head h3 {
  margin: 0;
  font-size: 15px;
}

.fulltext-status {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8efe3;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

#readerOriginalText {
  display: grid;
  gap: 12px;
}

#readerOriginalText p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

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

.auth-shell {
  width: min(420px, 100%);
}

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

.auth-brand {
  margin-bottom: 28px;
}

.auth-panel h1 {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 42px;
  line-height: 1;
}

.auth-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.auth-form,
.user-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.auth-form input,
.user-form input,
.user-form select {
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #9c3322;
  font-size: 13px;
  font-weight: 750;
}

.admin-shell {
  min-height: 100vh;
  padding: 24px;
}

.admin-head,
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-head {
  max-width: 1120px;
  margin: 0 auto 22px;
}

.admin-nav a {
  color: var(--clay);
  font-weight: 800;
  text-decoration: none;
}

.admin-main {
  display: grid;
  max-width: 1120px;
  gap: 16px;
  margin: 0 auto;
}

.admin-main h1 {
  margin: 0;
  font-family: inherit;
  font-size: 22px;
  line-height: 1.2;
}

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

.user-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 120px 96px;
}

.user-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: var(--paper);
}

.user-card h3 {
  margin-bottom: 4px;
  font-size: 16px;
}

.user-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.danger {
  color: #9c3322;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: fixed;
    z-index: 10;
    right: 12px;
    bottom: 12px;
    left: 12px;
    top: auto;
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

  .rail .brand {
    display: none;
  }

  .account-mini {
    display: none;
  }

  .nav-list {
    grid-template-columns: 1fr;
    margin: 0;
  }

  .nav-item {
    justify-content: center;
    padding: 0 8px;
  }

  .workspace {
    padding: 14px 14px 92px;
  }

  .hero-band,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .hero-band {
    position: relative;
    min-height: 360px;
    height: 320px;
  }

  .hero-copy {
    z-index: 1;
    padding: 28px;
  }

  .hero-visual {
    position: absolute;
    inset: 0;
    min-height: 160px;
  }

  .hero-visual::after {
    position: absolute;
    inset: 0;
    content: "";
    background: linear-gradient(90deg, rgba(38, 53, 47, 0.92), rgba(38, 53, 47, 0.2));
  }

  h1 {
    font-size: 42px;
  }

  .toolbar {
    align-items: stretch;
  }

  .segmented {
    flex: 1;
    overflow-x: auto;
  }

  .segment {
    min-width: 66px;
  }

  .add-form,
  .translation-grid,
  .user-form {
    grid-template-columns: 1fr;
  }

  .admin-shell {
    padding: 14px;
  }

  .user-card,
  .admin-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .reader-shell {
    padding: 16px;
  }
}

@media (max-width: 520px) {
  .hero-band {
    min-height: 300px;
    height: 300px;
  }

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

  .nav-item span {
    display: none;
  }
}
