:root {
  color-scheme: light;
  --bg: #f6f6f1;
  --ink: #181b1a;
  --muted: #68706d;
  --line: #d9ded8;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #0b534e;
  --warm: #b45309;
  --soft: #e7f1ef;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 3;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 246, 241, 0.96);
  backdrop-filter: blur(14px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 5vw, 56px) 10px;
}

.brand {
  font-weight: 750;
  color: var(--ink);
}

.navlinks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 14px;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
}

.text-button:hover {
  text-decoration: underline;
}

.topicbar {
  display: flex;
  gap: 4px;
  padding: 0 clamp(18px, 5vw, 56px);
  overflow-x: auto;
  scrollbar-width: none;
}

.topicbar::-webkit-scrollbar {
  display: none;
}

.topic-link {
  flex: 0 0 auto;
  padding: 10px 12px 11px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}

.topic-link:hover {
  color: var(--ink);
  text-decoration: none;
}

.topic-link.is-active {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

.topic-link.is-disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: center;
  padding: 30px 0;
}

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

h1 {
  max-width: 860px;
  margin-bottom: 0;
  font-size: clamp(40px, 8vw, 86px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

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

.status-panel {
  padding: 18px;
}

.status-panel .label,
#item-count,
#items-label,
#reports-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.status-panel strong {
  display: block;
  margin: 8px 0;
  font-size: 18px;
}

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

.digest-head > div {
  min-width: 0;
}

.section-head .section-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.speech-player {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
}

.speech-play {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.audio-icon-button {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
}

.audio-icon-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.speech-select {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.speech-select select {
  height: 40px;
  padding: 0 28px 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.speech-status {
  min-width: 72px;
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-head a,
.section-head span {
  white-space: nowrap;
  font-size: 14px;
}

#latest-summary {
  margin-bottom: 20px;
  color: #303735;
  line-height: 1.7;
}

.daily-analysis {
  display: grid;
  gap: 0;
  margin: 0 -20px;
  border-top: 1px solid var(--line);
}

.analysis-empty {
  margin: 0;
  padding: 18px 20px;
}

.digest-panel .caveats:not(:empty) {
  margin-top: 16px;
}

.analysis-entry {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.analysis-index {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 750;
}

.analysis-entry h3 {
  margin: 1px 0 8px;
  font-size: 17px;
  line-height: 1.35;
}

.analysis-entry p {
  margin-bottom: 0;
  color: #303735;
  line-height: 1.75;
}

.analysis-entry.is-speaking {
  background: #f3f8f6;
}

.caveats {
  display: grid;
  gap: 8px;
}

.caveat {
  padding: 9px 11px;
  border-radius: 8px;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 14px;
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 4px 0 0;
  line-height: 1.5;
}

.config-values {
  display: grid;
  gap: 6px;
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
}

.config-values li {
  position: relative;
  padding-left: 14px;
  color: #303735;
  line-height: 1.45;
}

.config-values li::before {
  position: absolute;
  top: 0.65em;
  left: 1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.items {
  display: grid;
  gap: 14px;
}

.item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.item h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 650;
}

.item p {
  margin-bottom: 8px;
  color: #38403d;
  line-height: 1.65;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  font-size: 14px;
}

.reports {
  display: grid;
  gap: 10px;
}

.report-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 80px;
  gap: 12px;
  align-items: start;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.report-row:first-child {
  border-top: 0;
}

.report-row time {
  color: var(--muted);
  font-size: 14px;
}

.empty {
  color: var(--muted);
  line-height: 1.6;
}

dialog {
  width: min(680px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(24, 27, 26, 0.22);
}

dialog::backdrop {
  background: rgba(24, 27, 26, 0.44);
  backdrop-filter: blur(3px);
}

#config-form {
  padding: 22px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.dialog-head {
  margin-bottom: 22px;
}

.dialog-head h2 {
  margin-top: 3px;
  font-size: 24px;
}

.dialog-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.icon-button {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

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

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field > span {
  font-size: 14px;
  font-weight: 700;
}

.field small {
  color: var(--muted);
  font-size: 12px;
}

.field textarea,
.field input {
  width: 100%;
  border: 1px solid #c8cfca;
  border-radius: 6px;
  outline: 0;
  background: #fbfcfb;
  color: var(--ink);
}

.field textarea {
  min-height: 96px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.5;
}

.field input {
  height: 42px;
  padding: 0 11px;
}

.field textarea:focus,
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--soft);
}

.advanced-fields {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.advanced-fields summary {
  padding: 14px 2px;
  cursor: pointer;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 700;
}

.advanced-grid {
  padding: 2px 0 18px;
}

.dialog-actions {
  margin-top: 20px;
}

.dialog-actions > span {
  color: var(--muted);
  font-size: 12px;
}

.dialog-actions > div {
  display: flex;
  gap: 8px;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 0 15px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .navlinks {
    gap: 10px 14px;
  }

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

  h1 {
    font-size: 42px;
  }

  .report-row {
    grid-template-columns: 1fr;
  }

  #config-form {
    padding: 18px;
  }

  .speech-player {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .speech-play {
    flex: 1 1 calc(100% - 96px);
    justify-content: center;
  }

  .speech-select {
    flex: 1 1 150px;
  }

  .speech-select select {
    flex: 1;
  }

  .speech-status {
    flex: 1 0 100%;
    margin-left: 0;
    text-align: left;
  }

  .analysis-entry {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 10px;
    padding: 16px 18px;
  }

  dl {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-actions > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
