:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #61706b;
  --line: #d8dfdc;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --sage: #6d8b74;
  --coral: #c75f4a;
  --gold: #d8a83f;
  --blue: #3e6f8f;
  --shadow: 0 18px 45px rgba(24, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(216, 168, 63, 0.14), transparent 28rem),
    linear-gradient(315deg, rgba(62, 111, 143, 0.11), transparent 24rem),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--blue);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

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

.topbar {
  align-items: center;
  background: rgba(251, 250, 247, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 5vw;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-weight: 800;
  gap: 0.65rem;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: var(--ink);
  color: #fff;
  display: inline-flex;
  height: 42px;
  justify-content: center;
  letter-spacing: 0;
  width: 42px;
}

nav {
  display: flex;
  gap: 0.4rem;
}

nav a {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  gap: 0.42rem;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
}

nav a.active {
  text-decoration: underline;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.32em;
}

.nav-status-dot {
  background: var(--gold);
  border-radius: 50%;
  display: inline-flex;
  flex: 0 0 auto;
  height: 0.62rem;
  width: 0.62rem;
}

.nav-status-dot.open {
  background: var(--sage);
}

.nav-status-dot.closed {
  background: var(--coral);
}

main {
  margin: 0 auto;
  max-width: 1180px;
  padding: 3rem 5vw 5rem;
}

.intro-band {
  align-items: end;
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.38fr);
  min-height: 290px;
}

.library-head {
  display: block;
  min-height: 220px;
}

.intro-copy,
.library-head > div:first-child {
  max-width: 100%;
}

.eyebrow {
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0 0 0.7rem;
  text-transform: uppercase;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 7vw, 5.8rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 0.95;
  margin: 0;
}

.library-head h1 {
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  white-space: nowrap;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0.04em;
  margin: 0 0 0.9rem;
  text-transform: uppercase;
}

.lead {
  color: var(--muted);
  font-size: 1.08rem;
  margin: 1.1rem 0 0;
  max-width: 58rem;
}

.library-summary {
  align-items: start;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
}

.window-panel,
.stats {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  gap: 0.9rem;
  padding: 1.1rem;
}

.stats {
  align-self: start;
  min-width: 0;
  margin-top: 1.1rem;
}

.status-dot {
  background: var(--gold);
  border-radius: 50%;
  flex: 0 0 auto;
  height: 14px;
  margin-top: 0.32rem;
  width: 14px;
}

.status-dot.open {
  background: var(--sage);
}

.status-dot.closed {
  background: var(--coral);
}

.window-panel strong,
.stats strong {
  display: block;
}

.window-panel p,
.stats p {
  color: var(--muted);
  margin: 0.2rem 0 0;
}

.window-panel .story-window {
  color: var(--ink);
  font-weight: 800;
  margin-top: 0.55rem;
}

.window-panel .story-window span {
  display: inline-block;
  margin-top: 0.1rem;
}

.guidelines,
.submission-form,
.toolbar,
.results-meta {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  margin-top: 1.4rem;
  padding: 1.2rem;
}

.guidelines ul {
  margin: 0;
  padding-left: 1.2rem;
}

.guidelines li + li {
  margin-top: 0.45rem;
}

.field-grid,
.toolbar {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toolbar-row {
  display: grid;
  gap: 1rem;
  grid-column: 1 / -1;
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 0.4rem;
}

label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wide,
.search-box {
  grid-column: 1 / -1;
}

.third {
  grid-column: span 1;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 48px;
  outline: none;
  padding: 0.75rem 0.85rem;
  width: 100%;
}

textarea {
  min-height: 116px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(62, 111, 143, 0.16);
}

.form-actions,
.results-meta {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.form-actions {
  border: 0;
  margin-top: 1rem;
  padding: 0;
}

.form-actions p,
.results-meta p {
  color: var(--muted);
  margin: 0;
}

.toolbar-meta {
  align-items: end;
  display: flex;
  gap: 0.8rem;
  justify-content: space-between;
  min-width: 0;
}

.toolbar-meta p {
  color: var(--muted);
  margin: 0 0 0.75rem;
  white-space: nowrap;
}

button {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  min-height: 46px;
  padding: 0.75rem 1rem;
}

button:hover {
  background: #2b3633;
}

.story-button {
  align-items: center;
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #fff;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  justify-content: center;
  letter-spacing: 0.08em;
  min-height: 40px;
  padding: 0.62rem 0.78rem;
  text-decoration: none;
  white-space: nowrap;
}

.story-button:hover {
  background: #2b3633;
}

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

#refreshButton {
  background: transparent;
  color: var(--ink);
}

.submissions-list {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.submission-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(24, 33, 31, 0.05);
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
}

.submission-card header {
  align-items: start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.submission-card h2 {
  font-size: 1.15rem;
  letter-spacing: 0;
  margin: 0;
  text-transform: none;
}

.submission-card p {
  color: var(--muted);
  margin: 0.15rem 0 0;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill {
  background: #eef2ee;
  color: #34423e;
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
}

.issue-side {
  align-items: flex-end;
  display: grid;
  gap: 0.45rem;
  justify-items: end;
}

.issue-number {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.post-date {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.monthly-recap-card {
  border-left: 4px solid var(--gold);
}

.recap-badge {
  background: #fff4cf;
  border: 1px solid #e7c766;
  color: #6d4c00;
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 0.32rem 0.55rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.line {
  border-left: 3px solid var(--gold);
  color: var(--ink);
  padding-left: 0.8rem;
}

.empty-state {
  background: var(--panel);
  border: 1px dashed var(--line);
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

@media (min-width: 860px) {
  .field-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .field-grid label {
    grid-column: span 3;
  }

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

  .field-grid .third {
    grid-column: span 2;
  }

  .toolbar {
    grid-template-columns: minmax(260px, 1fr) 210px 230px 180px;
  }

  .issues-toolbar {
    grid-template-columns: 1fr;
  }

  .issues-toolbar-primary {
    grid-template-columns: minmax(260px, 1fr) 190px 240px;
  }

  .issues-toolbar-secondary {
    grid-template-columns: 150px 150px minmax(205px, 1fr) minmax(225px, 0.75fr);
  }

  .search-box {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    padding-bottom: 0.8rem;
    padding-top: 0.8rem;
    position: static;
  }

  .intro-band,
  .library-head,
  .library-summary,
  .field-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .results-meta,
  .submission-card header {
    align-items: stretch;
    flex-direction: column;
  }

  .issue-side {
    align-items: start;
    justify-items: start;
  }

  .toolbar-meta {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-meta p {
    margin: 0;
  }

  button {
    width: 100%;
  }

  .library-head h1 {
    font-size: clamp(2rem, 10vw, 3.8rem);
  }
}
