:root {
  color-scheme: light;
  --background: #f9f9f7;
  --text: #1a1a1a;
  --muted: #787872;
  --subtle: #ecece7;
  --accent: #1a1a1a;
  --selected: #1f5d38;
  font-family: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input {
  border-radius: 0;
}

button {
  border: 0;
  background: var(--accent);
  color: var(--background);
  cursor: pointer;
  padding: 0.72rem 1rem;
}

button:hover {
  opacity: 0.78;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9c9c2;
  background: transparent;
  color: var(--text);
  padding: 0.65rem 0.72rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

a {
  color: var(--text);
  text-underline-offset: 0.18em;
}

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

h1,
h2,
.brand,
.score {
  font-family: "Inter Tight", "Helvetica Neue", Arial, sans-serif;
}

h1 {
  margin-bottom: 1rem;
  font-size: clamp(2.25rem, 6vw, 4rem);
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 0.98;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(960px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.2rem 0;
}

.brand {
  font-size: 0.92rem;
  font-weight: 600;
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

main {
  width: min(960px, calc(100% - 2rem));
  margin: 10vh auto 5rem;
}

.login {
  width: min(100%, 560px);
}

.login p {
  max-width: 480px;
  color: var(--muted);
}

.login form {
  display: grid;
  gap: 0.7rem;
  margin-top: 2rem;
}

.login button {
  justify-self: start;
  margin-top: 0.35rem;
}

label > span,
.login label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.archive-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13rem;
  gap: 2rem;
  align-items: end;
  margin-bottom: 2.5rem;
}

.archive-heading h1 {
  margin-bottom: 0.7rem;
}

.archive-heading select {
  margin-bottom: 0.6rem;
}

.muted,
.run-details,
.material-meta,
.empty {
  color: var(--muted);
}

.run-details {
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
}

.run-details p {
  margin-bottom: 0.35rem;
}

.digest-caption {
  max-width: 760px;
  margin-top: 1.25rem;
  white-space: pre-wrap;
  color: var(--text);
}

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13rem auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 3.5rem;
}

.tabs {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid #c9c9c2;
}

.tab {
  margin-bottom: -1px;
  padding: 0.8rem 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
}

.tab.is-active {
  border-color: var(--text);
  color: var(--text);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.85rem;
  white-space: nowrap;
}

.checkbox-label input {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.checkbox-label span {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
}

.materials {
  margin: 0;
  padding: 0;
  list-style: none;
}

.material {
  display: grid;
  grid-template-columns: 4.4rem minmax(0, 1fr);
  gap: 1.4rem;
  margin-bottom: 4rem;
}

.score {
  font-size: 2.3rem;
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1;
}

.score-label {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.material-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.8rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}

.selected {
  color: var(--selected);
  font-weight: 600;
}

.material-summary {
  max-width: 760px;
  margin-bottom: 0.8rem;
  font-size: 1.08rem;
}

.material-footer {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.material-footer button {
  flex: 0 0 auto;
  padding: 0.5rem 0.75rem;
  font-size: 0.84rem;
}

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

.secondary-button {
  border: 1px solid #c9c9c2;
  background: transparent;
  color: var(--text);
}

.digest-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
  gap: 4rem;
  align-items: start;
}

.section-heading {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: space-between;
}

.section-heading h2,
.digest-layout aside h2,
.history-section h2 {
  margin-bottom: 0.35rem;
  font-size: 1.35rem;
}

.section-heading p {
  margin-bottom: 0;
}

.section-heading button {
  flex: 0 0 auto;
}

.digest-selection {
  margin: 2rem 0 3rem;
  padding-left: 1.4rem;
}

.digest-selection li {
  margin-bottom: 1.5rem;
  padding-left: 0.45rem;
}

.selection-summary {
  margin-bottom: 0.35rem;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.editor-actions {
  display: grid;
  gap: 2rem;
  padding-top: 2rem;
  border-top: 1px solid #c9c9c2;
}

.editor-actions form {
  display: grid;
  gap: 0.7rem;
}

.editor-actions button {
  justify-self: start;
}

.telegram-preview {
  overflow: hidden;
  border-radius: 12px;
  background: #e8f2f8;
  box-shadow: 0 1px 4px rgb(0 0 0 / 12%);
}

.telegram-preview > .muted {
  margin: 0;
  padding: 2rem;
}

.telegram-preview img {
  display: block;
  width: 100%;
  max-height: 25rem;
  object-fit: cover;
  background: var(--subtle);
}

.telegram-caption {
  padding: 1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  line-height: 1.45;
}

.job-status,
.warning {
  min-height: 1.5em;
  font-size: 0.88rem;
}

.job-status {
  color: var(--muted);
}

.warning {
  margin: 1rem 0;
  color: #8a5d0b;
}

.publish-button {
  width: 100%;
  margin-top: 1rem;
}

.history-section {
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid #c9c9c2;
}

.history {
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.history li {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  gap: 0 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--subtle);
}

.history li p {
  grid-column: 2;
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.history-time {
  color: var(--muted);
  font-size: 0.82rem;
}

.source-link {
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.error {
  min-height: 1.5em;
  color: #9b2929;
}

@media (max-width: 720px) {
  main {
    margin-top: 7vh;
  }

  .archive-heading,
  .filters,
  .digest-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .archive-heading select {
    width: 100%;
  }

  .checkbox-label {
    min-height: auto;
  }

  .material {
    grid-template-columns: 3.5rem minmax(0, 1fr);
    gap: 0.8rem;
    margin-bottom: 3rem;
  }

  .score {
    font-size: 1.8rem;
  }

  .material-summary {
    font-size: 1rem;
  }

  .material-footer,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .material-footer button,
  .section-heading button {
    align-self: flex-start;
  }

  .history li {
    grid-template-columns: 1fr;
  }

  .history li p {
    grid-column: 1;
  }
}
