:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --panel-soft: #eef3ef;
  --ink: #1f2523;
  --muted: #68716d;
  --line: rgba(31, 37, 35, 0.14);
  --green: #23715d;
  --blue: #315f8f;
  --amber: #a36a28;
  --red: #b44c43;
  --violet: #6a5b96;
  --shadow: 0 18px 44px rgba(31, 37, 35, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 1540px;
}

.topbar h1,
.source-toolbar h2 {
  letter-spacing: 0;
  line-height: 1.08;
  margin: 0;
}

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

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0 0 7px;
  text-transform: uppercase;
}

.topbar-actions,
.source-toolbar,
.button-row,
.reader-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.ghost-link,
.primary-link,
.download-list a,
.reader-actions a {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.primary-link {
  background: var(--ink);
  border-radius: 8px;
  color: #ffffff;
  min-height: 38px;
  padding: 10px 13px;
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  margin: 0 auto;
  max-width: 1540px;
}

.sidebar,
.source-panel,
.inspector {
  min-width: 0;
}

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

.panel {
  margin-bottom: 16px;
  padding: 14px;
}

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

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-heading strong {
  color: var(--green);
  font-size: 12px;
}

.metric-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-grid div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 74px;
  padding: 10px;
}

.metric-grid span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.metric-grid strong {
  font-size: 24px;
}

.search-input {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 0 12px;
  width: 100%;
}

.search-input:focus {
  border-color: rgba(35, 113, 93, 0.55);
  box-shadow: 0 0 0 3px rgba(35, 113, 93, 0.13);
}

.button-stack {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.filter-button {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 10px;
  text-align: left;
}

.filter-button strong,
.filter-button span {
  font-size: 12px;
}

.filter-button strong {
  font-weight: 800;
}

.filter-button span {
  color: var(--muted);
  font-weight: 700;
}

.filter-button.active {
  border-color: rgba(35, 113, 93, 0.48);
  box-shadow: inset 3px 0 0 var(--green);
}

.segmented {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
  padding: 4px;
}

.segmented button {
  background: transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  min-height: 32px;
}

.segmented button.active {
  background: #ffffff;
  color: var(--ink);
}

.download-list {
  display: grid;
  gap: 8px;
}

.download-list a {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.source-panel {
  overflow: hidden;
}

.source-toolbar {
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  padding: 16px;
}

.source-toolbar button {
  background: var(--ink);
  border-radius: 8px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  min-height: 36px;
  padding: 0 13px;
}

.source-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 142px);
  overflow: auto;
  padding: 14px;
}

.source-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 13px;
}

.source-card:hover,
.source-card.active {
  border-color: rgba(35, 113, 93, 0.48);
}

.source-card.active {
  box-shadow: inset 3px 0 0 var(--green);
}

.source-card h3 {
  font-size: 16px;
  line-height: 1.24;
  margin: 0;
}

.source-card p {
  color: #35403c;
  line-height: 1.55;
  margin: 8px 0 0;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.badge {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 7px;
}

.badge.verified {
  background: rgba(35, 113, 93, 0.12);
  border-color: rgba(35, 113, 93, 0.24);
  color: var(--green);
}

.badge.manual {
  background: rgba(163, 106, 40, 0.13);
  border-color: rgba(163, 106, 40, 0.24);
  color: var(--amber);
}

.badge.specialist {
  color: var(--green);
}

.badge.daily {
  color: var(--blue);
}

.badge.broadcast {
  color: var(--red);
}

.badge.official {
  color: var(--violet);
}

.card-actions {
  align-items: end;
  display: grid;
  gap: 8px;
  min-width: 118px;
}

.card-actions a,
.card-actions button,
.button-row button {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  min-height: 34px;
  padding: 0 10px;
  text-align: center;
  text-decoration: none;
}

.card-actions .rss-link {
  background: rgba(35, 113, 93, 0.1);
  color: var(--green);
}

.card-actions .disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.62;
}

.sticky {
  position: sticky;
  top: 16px;
}

.source-detail {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  min-height: 190px;
  padding: 12px;
}

.source-detail h3 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0 0 7px;
}

.source-detail p {
  color: #35403c;
  line-height: 1.55;
  margin: 8px 0;
}

.source-detail dl {
  display: grid;
  gap: 7px;
  grid-template-columns: 84px minmax(0, 1fr);
  margin: 12px 0 0;
}

.source-detail dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.source-detail dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-detail a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

#wikiCard {
  background: #17201c;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  color: #eff8f3;
  display: block;
  line-height: 1.45;
  min-height: 260px;
  outline: none;
  padding: 12px;
  resize: vertical;
  width: 100%;
}

.button-row {
  margin-top: 10px;
}

.button-row button {
  flex: 1;
}

.reader-actions {
  align-items: stretch;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.reader-actions a {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 10px;
  text-align: center;
}

.empty {
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  font-weight: 700;
  justify-content: center;
  min-height: 138px;
  padding: 18px;
  text-align: center;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
  }

  .sticky {
    position: static;
  }

  .source-list {
    max-height: none;
  }
}

@media (max-width: 820px) {
  .app {
    padding: 12px;
  }

  .topbar,
  .source-toolbar {
    align-items: flex-start;
    display: grid;
  }

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

  .source-card {
    grid-template-columns: 1fr;
  }

  .card-actions,
  .reader-actions {
    grid-template-columns: 1fr;
  }
}
