:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --text: #171717;
  --muted: #6f6f6b;
  --line: #deddd7;
  --soft: #efeee9;
  --accent: #171717;
  --danger: #9f2f2f;
  --max: 1420px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.shell {
  width: min(var(--max), calc(100% - 36px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  font-size: 11px;
  letter-spacing: .17em;
  color: var(--muted);
  font-weight: 800;
}
h1 {
  margin: 3px 0 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: .95;
  letter-spacing: -.045em;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.updated { color: var(--muted); font-size: 13px; }

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 7px;
  padding: 9px 13px;
  font-weight: 750;
}
button:hover { opacity: .84; }
button:disabled { opacity: .45; cursor: wait; }
button.secondary, button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.login-card {
  max-width: 520px;
  margin: 70px auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 28px;
}
.login-card h2 { margin: 0 0 8px; }
.login-card p { color: var(--muted); margin: 0 0 20px; }
.login-card label { display: block; font-size: 13px; font-weight: 800; margin-bottom: 7px; }
.login-row { display: flex; gap: 8px; }
.login-row input { flex: 1; min-width: 0; }
input {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
  outline: none;
}
input:focus { border-color: #878781; box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.error { color: var(--danger) !important; margin: 12px 0 0 !important; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 12px;
}
.source-filter { display: flex; align-items: center; gap: 10px; }
.source-pill {
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.source-icon {
  width: 16px;
  height: 16px;
  display: block;
  border-radius: 3px;
  object-fit: contain;
}
.count, .hint { font-size: 13px; color: var(--muted); }

.status {
  margin: 15px 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
  color: var(--muted);
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}
.news-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  table-layout: fixed;
}
.news-table th {
  text-align: left;
  padding: 11px 12px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.news-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--soft);
  vertical-align: top;
  font-size: 14px;
  line-height: 1.35;
}
.select-col { width: 42px; }
.time-col { width: 72px; }
.title-col { width: 38%; }
.day-row td {
  padding: 16px 12px 8px;
  background: #faf9f6;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .11em;
  font-weight: 850;
  text-transform: uppercase;
}
.news-row { cursor: pointer; transition: background .12s ease, color .12s ease; }
.news-row:hover { background: #fafaf8; }
.news-row.checked { background: #ecebe6; }
.news-row.checked .story-title { color: #666660; font-weight: 700; }
.news-row.checked .story-desc,
.news-row.checked .story-time { color: #85857f; }
.news-row.selected { background: #f0efe9; }
.news-row.checked.selected { background: #e4e2da; }
.radio-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid #9b9b95;
  margin-top: 2px;
  display: block;
  position: relative;
}
.news-row.selected .radio-dot::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--text);
}
.story-time { color: var(--muted); white-space: nowrap; }
.story-title {
  color: var(--text);
  text-decoration: none;
  font-weight: 820;
  font-size: 15px;
}
.story-title:hover { text-decoration: underline; }
.story-desc { color: #545450; }
.analysis-row td { padding: 0; background: #faf9f6; }
.analysis-panel { padding: 18px 22px 22px 126px; border-bottom: 1px solid var(--line); }
.analysis-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 11px; }
.analysis-actions button { background: white; color: var(--text); border-color: #cfcfc9; }
.ask-form { display: flex; gap: 8px; max-width: 900px; }
.ask-input { flex: 1; min-width: 0; }
.analysis-result {
  max-width: 960px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 17px;
  color: #262622;
}
.analysis-result .result-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 850;
  color: var(--muted);
  margin-bottom: 9px;
}
.analysis-result .answer {
  white-space: pre-wrap;
  line-height: 1.58;
  font-size: 15px;
}
.sources { margin-top: 18px; }
.sources-title { font-size: 12px; font-weight: 850; margin-bottom: 7px; }
.sources a { color: var(--text); font-size: 13px; margin-right: 12px; word-break: break-word; }
.loading { color: var(--muted); }

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, var(--max));
    padding: 18px 0 42px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
  }

  .top-actions {
    width: 100%;
    max-width: none;
    justify-content: flex-start;
  }

  .updated {
    width: 100%;
    text-align: left;
    order: 3;
  }

  button {
    min-height: 46px;
    padding: 11px 15px;
    font-size: 16px;
  }

  .login-card {
    margin-top: 34px;
    padding: 20px;
  }

  .login-row,
  .ask-form {
    flex-direction: column;
  }

  .login-row button,
  .ask-form button {
    width: 100%;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .hint { display: none; }

  .source-pill,
  .story-count,
  .updated {
    font-size: 14px;
  }

  .day-row td {
    font-size: 14px;
  }

  .ask-input,
  .login-row input {
    font-size: 16px;
  }

  .table-wrap {
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
  }

  .news-table,
  .news-table tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .news-table thead { display: none; }

  .day-row {
    display: block;
    margin: 18px 0 8px;
  }

  .day-row:first-child { margin-top: 0; }

  .day-row td {
    display: block;
    padding: 8px 2px;
    background: transparent;
    border: 0;
  }

  .news-row {
    display: grid;
    grid-template-columns: 22px 52px minmax(0, 1fr);
    grid-template-areas:
      "select time title"
      ". desc desc";
    column-gap: 8px;
    row-gap: 7px;
    margin-bottom: 8px;
    padding: 13px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
  }

  .news-row:hover { background: var(--surface); }
  .news-row.checked { background: #ecebe6; }
  .news-row.selected { background: #f0efe9; }
  .news-row.checked.selected { background: #e4e2da; }

  .news-row td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
  }

  .news-row td:nth-child(1) { grid-area: select; }
  .news-row td:nth-child(2) { grid-area: time; }
  .news-row td:nth-child(3) { grid-area: title; }
  .news-row td:nth-child(4) { grid-area: desc; }

  .story-time {
    font-size: 14px;
    line-height: 1.35;
    padding-top: 2px !important;
  }

  .story-title {
    display: inline-block;
    font-size: 18px;
    line-height: 1.32;
  }

  .story-desc {
    font-size: 16px;
    line-height: 1.48;
    padding-left: 60px !important;
  }

  .analysis-row {
    display: block;
    margin: -2px 0 12px;
  }

  .analysis-row td {
    display: block;
    padding: 0;
    border: 0;
  }

  .analysis-panel {
    padding: 14px 12px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #faf9f6;
  }

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

  .analysis-actions button { width: 100%; }

  .analysis-result .answer {
    font-size: 16px;
    line-height: 1.6;
  }

  .sources a {
    display: block;
    margin: 0 0 8px;
  }
}

@media (max-width: 420px) {
  h1 { font-size: 40px; }
  .story-desc { padding-left: 0 !important; grid-column: 1 / -1; }
}
