:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f0;
  --text: #1d252c;
  --muted: #60707c;
  --border: #d7dee4;
  --accent: #176b55;
  --accent-strong: #0f4d3e;
  --blue: #245a8d;
  --amber: #a46212;
  --red: #ad3434;
  --shadow: 0 10px 28px rgba(29, 37, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
}

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

button.secondary,
.source-actions button,
.tab {
  border-color: var(--border);
  background: #fff;
  color: var(--text);
}

button.secondary:hover,
.source-actions button:hover,
.tab:hover {
  border-color: var(--accent);
  background: var(--surface-soft);
}

button.danger {
  border-color: #d8b1b1;
  color: var(--red);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 85, 0.12);
}

textarea {
  resize: vertical;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(246, 247, 249, 0.94);
  backdrop-filter: blur(12px);
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.app-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-actions,
.toolbar-actions,
.section-head,
.updates-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 18px;
  min-height: calc(100vh - 72px);
  padding: 18px;
}

.sources-pane,
.updates-pane {
  min-width: 0;
}

.sources-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel,
.sources-section,
.updates-pane {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel,
.sources-section {
  padding: 14px;
}

.panel h2,
.sources-section h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.helper-copy {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stats-row div {
  min-height: 68px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow);
}

.stats-row span {
  display: block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.stats-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 10px;
}

.form-stack label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(116px, auto);
  align-items: end;
  gap: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 8px;
  color: var(--text);
}

.checkbox-label input {
  width: 16px;
  height: 16px;
}

.checkbox-label span {
  margin: 0;
  color: var(--text);
  white-space: nowrap;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
}

.section-head input {
  max-width: 160px;
}

.source-list {
  display: grid;
  gap: 8px;
  max-height: 48vh;
  overflow: auto;
  padding-right: 2px;
}

.source-item,
.candidate-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.source-main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 8px;
}

.source-title {
  min-width: 0;
}

.source-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.source-title small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.source-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.source-actions {
  display: flex;
  gap: 6px;
}

.source-actions button,
.candidate-actions button {
  min-height: 32px;
  padding: 0 9px;
}

.settings-box {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.settings-box summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.settings-box label {
  margin-top: 10px;
}

.candidate-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.candidate-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
}

.candidate-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.candidate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.candidate-url {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-actions {
  display: flex;
  gap: 8px;
}

.notice-list {
  display: grid;
  gap: 6px;
  color: var(--amber);
  font-size: 13px;
  line-height: 1.45;
}

.health-ok {
  color: var(--accent);
}

.health-error {
  color: var(--red);
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.ok {
  background: var(--accent);
}

.status-dot.error {
  background: var(--red);
}

.status-dot.checking {
  background: var(--blue);
}

.badge {
  min-width: 28px;
  height: 24px;
  border-radius: 999px;
  background: #e5effb;
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.updates-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.updates-toolbar {
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: inline-flex;
  gap: 6px;
}

.tab {
  min-width: 72px;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.toolbar-actions {
  min-width: 0;
}

.toolbar-actions input {
  width: min(360px, 38vw);
}

.article-list {
  display: grid;
  align-content: start;
  gap: 0;
  min-height: 0;
  overflow: auto;
}

.article-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.article-item.unread {
  background: #fbfdfc;
}

.article-title {
  display: inline-block;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.4;
  text-decoration: none;
  word-break: break-word;
}

.article-title:hover {
  color: var(--accent);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.article-actions {
  display: flex;
  align-items: center;
}

.article-actions button {
  min-width: 58px;
}

.empty-state {
  padding: 40px 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #1d252c;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

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

  .source-list {
    max-height: 320px;
  }

  .toolbar-actions input {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-header,
  .updates-toolbar,
  .header-actions,
  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header {
    position: static;
  }

  .app-shell {
    padding: 12px;
  }

  .form-grid,
  .stats-row,
  .article-item {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .section-head input {
    max-width: none;
  }

  .tabs,
  .tab,
  .header-actions button,
  .toolbar-actions button {
    width: 100%;
  }
}
