:root {
  --ink: #1a2218;
  --muted: #5c6b58;
  --paper: #f3efe4;
  --paper-2: #e7e1d2;
  --accent: #0f6b5c;
  --accent-2: #c45c26;
  --line: #cfc7b4;
  --ok: #1f7a45;
  --bad: #9b3a2f;
  --shadow: 0 12px 40px rgba(26, 34, 24, 0.08);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #dfe9df 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #efe0d0 0%, transparent 50%),
    var(--paper);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-2); }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 239, 228, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.nav a.active,
.nav a:hover { color: var(--ink); }

.nav .inline { display: inline; margin: 0; }

.linkish {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.linkish:hover { color: var(--ink); }

.main {
  width: min(880px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.hero {
  padding: 3rem 0 2rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 0.75rem;
}

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-weight: 700;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  margin: 0 0 1rem;
}

.lede { font-size: 1.15rem; color: var(--muted); max-width: 36rem; }

.cta-row { display: flex; gap: 0.75rem; margin-top: 1.75rem; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: #f7faf7; }
.btn.primary:hover { background: #0c574b; color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.small { padding: 0.4rem 0.85rem; font-size: 0.9rem; }
.btn.yes { background: var(--ok); color: #fff; }
.btn.no { background: var(--bad); color: #fff; }

.page-head { margin-bottom: 1.5rem; }
.page-head h1 { margin: 0 0 0.35rem; font-size: 2rem; }
.muted { color: var(--muted); }
.break { word-break: break-all; }

.flash {
  list-style: none;
  margin: 0;
  padding: 0.75rem 1.5rem 0;
  width: min(880px, calc(100% - 2rem));
  margin-inline: auto;
}

.flash li {
  background: #dff0e4;
  border: 1px solid #b7d8c2;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 0.4rem;
}

.flash li.error { background: #f7e2de; border-color: #e3b5ad; }

.narrow { width: min(420px, 100%); }
.narrow-form { max-width: 480px; }

.stack { display: grid; gap: 0.75rem; }
.stack p { margin: 0; display: grid; gap: 0.35rem; }
.stack label { font-weight: 600; font-size: 0.92rem; }
.stack input, .stack textarea, .stack select {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
}

.block { margin: 2rem 0; }
.block h2 { font-size: 1.35rem; margin: 0 0 1rem; }

.feed-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.feed-card {
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.feed-card h3 { margin: 0 0 0.35rem; font-size: 1.15rem; }
.feed-card p { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.95rem; }
.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.5rem !important;
}

.item-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }

.brief-toast-host {
  width: min(880px, calc(100% - 2rem));
  margin: 0 auto 0.75rem;
  min-height: 0;
}

.brief-toast {
  background: #dff0e4;
  border: 1px solid #b7d8c2;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  animation: brief-toast-in 0.2s ease;
}

.brief-toast.error {
  background: #f7e2de;
  border-color: #e3b5ad;
}

@keyframes brief-toast-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.item {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.item.is-leaving {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.item h2 { margin: 0.35rem 0 0.5rem; font-size: 1.35rem; }
.item h2 a { color: inherit; text-decoration: none; }
.item h2 a:hover { color: var(--accent); }

.item-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.score {
  font-weight: 700;
  color: var(--accent);
  background: #dcebe6;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.reason { color: var(--ink); margin: 0 0 0.5rem; }
.summary { color: var(--muted); margin: 0 0 0.85rem; }

.feedback-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.callout {
  border: 1px dashed var(--accent);
  background: #e7f2ee;
  border-radius: 14px;
  padding: 1rem 1.15rem;
  margin-bottom: 1.5rem;
}

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

.answered { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.answered li {
  border-left: 3px solid var(--accent);
  padding-left: 0.9rem;
}
.answered .q { font-weight: 600; margin: 0 0 0.25rem; }
.answered .a { margin: 0; color: var(--muted); }

.main:has(.story-grid) {
  width: min(1120px, calc(100% - 2rem));
}

.stories-head { margin-bottom: 1.75rem; }

.story-grid {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.35rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  list-style: none;
}

.story-card {
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.story-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 48px rgba(26, 34, 24, 0.12);
}

.story-media {
  display: block;
  aspect-ratio: 16 / 10;
  background:
    linear-gradient(145deg, #d5e4dc 0%, #e8dfd0 55%, #cfd8c8 100%);
  overflow: hidden;
  text-decoration: none;
}

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

.story-media-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  color: rgba(26, 34, 24, 0.28);
  letter-spacing: -0.04em;
}

.story-media-fallback::after {
  content: attr(data-feed);
  text-transform: uppercase;
}

.story-media-logo {
  padding: 1.4rem 1.6rem;
  background: #f4f1ea;
}

.story-media-logo::after {
  content: none;
}

.story-media-logo img {
  width: min(72%, 220px);
  height: auto;
  max-height: 58%;
  object-fit: contain;
  display: block;
}

.story-media-logo[data-source="bbc"] { background: #bb1919; }
.story-media-logo[data-source="bbc"] img { filter: brightness(0) invert(1); }
.story-media-logo[data-source="npr"] { background: #f7f7f7; }
.story-media-logo[data-source="theverge"] { background: #e8ff47; }
.story-media-logo[data-source="arstechnica"] { background: #111111; }
.story-media-logo[data-source="arstechnica"] img { filter: brightness(0) invert(1); }
.story-media-logo[data-source="nature"] { background: #000000; }
.story-media-logo[data-source="nature"] img { filter: brightness(0) invert(1); }
.story-media-logo[data-source="guardian"] { background: #052962; }
.story-media-logo[data-source="guardian"] img { filter: brightness(0) invert(1); }
.story-media-logo[data-source="ap"] { background: #ffffff; }

.story-body {
  padding: 1rem 1.15rem 1.2rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.35rem;
}

.story-card .tag {
  margin: 0 0 0.15rem !important;
}

.story-card h2 {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.25;
}

.story-card h2 a {
  color: inherit;
  text-decoration: none;
}

.story-card h2 a:hover { color: var(--accent); }

.story-card .summary {
  flex: 1;
  margin: 0.25rem 0 0.55rem;
  font-size: 0.95rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-time {
  margin: auto 0 0;
  font-size: 0.82rem;
}

.location-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}

.location-row {
  display: block;
  padding: 0.35rem 0;
  line-height: 1.4;
}

.location-label {
  font-weight: 600;
}

/* Let the remove control sit on the same line as the place name. */
.location-remove {
  display: contents;
}

.location-remove .linkish {
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.55;
  margin-left: 0.55rem;
  vertical-align: baseline;
}

.location-remove .linkish:hover {
  opacity: 1;
  color: var(--bad);
}

.settings-subhead {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.05rem;
}

.location-picker {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.85rem;
  max-width: 640px;
}

.location-entry-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: end;
}

.location-search {
  position: relative;
  z-index: 5;
  min-width: 0;
}

/* Keep this section above following siblings so the suggestions overlay wins. */
#locations {
  position: relative;
  z-index: 5;
}

.location-current {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.location-current-label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1;
  height: 0.92rem;
}

.location-current .btn {
  width: 100%;
  justify-content: center;
  min-height: 2.55rem;
}

.location-suggestions {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0.25rem;
  position: absolute;
  z-index: 1100;
  left: 0;
  right: 0;
  top: 100%;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow: auto;
}

.location-suggestions button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
}

.location-suggestions button:hover {
  background: #e7f2ee;
}

.location-picker .btn.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.geo-status[hidden] {
  display: none;
}

.geo-status:not([hidden]) {
  margin: 0;
}

@media (max-width: 600px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  .main { padding-top: 1.25rem; }
  .location-entry-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .location-current-label {
    display: none;
  }
}
