:root {
  --paper: #f5f1e8;
  --ink: #151515;
  --muted: #6f675b;
  --line: #d7cdbd;
  --panel: #fffaf0;
  --accent: #a83f2f;
  --accent-2: #1f6d67;
  --coin: #c69a42;
  --shadow: 0 18px 50px rgba(31, 24, 16, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(198, 154, 66, 0.16), transparent 26rem),
    linear-gradient(135deg, #f8f4ea 0%, #efe5d6 100%);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

body.dark {
  --paper: #191816;
  --ink: #f8f1e3;
  --muted: #beb29f;
  --line: #443d34;
  --panel: #24211d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  background: linear-gradient(135deg, #171513 0%, #252019 100%);
}

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

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
}

button:hover,
button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
}

.masthead {
  border-bottom: 4px double var(--ink);
  padding: 12px 0 18px;
}

.edition-row,
.header-actions,
.section-nav,
.story-meta,
.quick-actions,
.tool-band,
.section-heading,
.reader-actions {
  display: flex;
  align-items: center;
}

.edition-row {
  justify-content: space-between;
  gap: 14px;
}

.kicker,
.section-label,
.tagline,
.story-meta,
.section-heading p,
.quiet,
.status-line {
  color: var(--muted);
}

.kicker,
.section-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-family: Arial, sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 8vw, 5.4rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.tagline {
  max-width: 760px;
  margin: 12px 0 0;
  font-size: 1.05rem;
}

.icon-button {
  width: 44px;
  padding: 0;
  border-radius: 50%;
  font-family: Arial, sans-serif;
  font-size: 1.15rem;
}

.header-actions {
  gap: 8px;
  flex-shrink: 0;
}

.admin-button {
  border-radius: 999px;
  min-height: 44px;
  font-family: Arial, sans-serif;
  font-size: 0.84rem;
  font-weight: 800;
}

.edition-controls {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.edition,
.section-chip {
  border-radius: 999px;
  min-height: 36px;
  font-family: Arial, sans-serif;
  font-size: 0.86rem;
  font-weight: 700;
}

.section-nav {
  gap: 8px;
  overflow-x: auto;
  padding: 16px 0;
  scrollbar-width: none;
}

.section-nav::-webkit-scrollbar {
  display: none;
}

.top-grid,
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.lead-story,
.desk-panel,
.market-card,
.print-card,
.editor-card,
.story-card,
.edition-upload {
  background: rgba(255, 250, 240, 0.82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

body.dark .lead-story,
body.dark .desk-panel,
body.dark .market-card,
body.dark .print-card,
body.dark .editor-card,
body.dark .story-card,
body.dark .edition-upload,
body.dark .admin-strip {
  background: rgba(36, 33, 29, 0.9);
}

.admin-strip {
  background: rgba(255, 250, 240, 0.82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: Arial, sans-serif;
}

.admin-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

.lead-story {
  min-height: 430px;
  display: grid;
  grid-template-columns: minmax(230px, 0.42fr) 1fr;
  overflow: hidden;
  cursor: pointer;
}

.coin-plate {
  position: relative;
  min-height: 100%;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.18) 0 1px, transparent 1px 12px),
    linear-gradient(150deg, #2d675f, #10100f 58%, #a83f2f);
}

.coin {
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 7px double rgba(92, 63, 19, 0.72);
  background:
    radial-gradient(circle at 35% 30%, #f8dd86, #c99f45 45%, #7d5a21 100%);
  color: #4f3210;
  font-family: Arial, sans-serif;
  font-weight: 900;
}

.coin-large {
  position: absolute;
  width: 210px;
  height: 210px;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  font-size: 4rem;
}

.coin-small {
  position: absolute;
  width: 86px;
  height: 86px;
  right: 16px;
  bottom: 18px;
  font-size: 2rem;
}

.lead-copy {
  padding: clamp(22px, 4vw, 44px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.lead-copy h2 {
  margin: 12px 0;
  font-size: clamp(2rem, 5vw, 4.25rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.lead-copy p:not(.section-label) {
  font-size: 1.18rem;
  max-width: 620px;
}

.story-meta {
  gap: 12px;
  flex-wrap: wrap;
  font-family: Arial, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
}

.desk-panel,
.market-card,
.print-card,
.editor-card {
  padding: 18px;
}

.desk-panel h2,
.market-card h2,
.editor-card h2 {
  margin: 6px 0 10px;
}

.quick-actions,
.tool-band {
  gap: 10px;
}

.quick-actions button,
.reader-actions button,
.print-card button,
.editor-card button,
#dealerSubmit,
#adminSubmit,
#publishEditionButton {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.tool-band {
  justify-content: space-between;
  margin: 18px 0;
  border-block: 1px solid var(--line);
  padding: 12px 0;
}

.edition-upload {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(280px, 1.1fr);
  gap: 14px;
  align-items: start;
  padding: 18px;
  margin-bottom: 18px;
}

.edition-upload h2 {
  margin: 6px 0 8px;
  font-size: 1.7rem;
}

.edition-upload p {
  margin: 0;
  color: var(--muted);
}

.reader-edition-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.admin-panel {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 12px;
}

.admin-panel h3 {
  margin: 6px 0 6px;
  font-size: 1.24rem;
}

.upload-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 10px;
}

.upload-tools button,
.file-picker {
  min-height: 44px;
}

.file-picker {
  border: 1px dashed var(--accent-2);
  background: rgba(31, 109, 103, 0.08);
  border-radius: 6px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  font-family: Arial, sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--accent-2);
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.edition-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.edition-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.edition-archive {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.archive-item {
  border-top: 1px solid var(--line);
  padding-top: 9px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-family: Arial, sans-serif;
}

.archive-item strong {
  display: block;
}

.archive-item span {
  color: var(--muted);
  font-size: 0.85rem;
}

.search-box,
.select-box {
  display: grid;
  gap: 6px;
  font-family: Arial, sans-serif;
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.search-box {
  flex: 1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  border-radius: 6px;
  font-family: Arial, sans-serif;
  font-size: 0.95rem;
}

textarea {
  resize: vertical;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.65rem;
}

.section-heading p {
  margin: 0;
  font-family: Arial, sans-serif;
  font-weight: 800;
  font-size: 0.82rem;
}

.section-heading.compact {
  align-items: flex-start;
}

.story-list {
  display: grid;
  gap: 12px;
}

.story-card {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 14px;
  padding: 14px;
  align-items: center;
}

.story-thumb {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(31, 109, 103, 0.18), rgba(168, 63, 47, 0.18));
}

.story-thumb span {
  width: 58px;
  height: 58px;
  font-size: 1.2rem;
}

.story-card h3 {
  margin: 4px 0 6px;
  font-size: 1.22rem;
  line-height: 1.08;
}

.story-card p {
  margin: 0 0 8px;
  color: var(--muted);
}

.story-card .save-mini {
  width: 42px;
  padding: 0;
  border-radius: 50%;
}

.right-rail {
  display: grid;
  gap: 14px;
  align-content: start;
}

.ticker-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  font-family: Arial, sans-serif;
}

.ticker-row strong {
  color: var(--accent-2);
}

.mini-front {
  min-height: 180px;
  border: 2px solid var(--ink);
  padding: 12px;
  display: grid;
  gap: 8px;
  background:
    linear-gradient(var(--ink), var(--ink)) 12px 76px / calc(100% - 24px) 4px no-repeat,
    repeating-linear-gradient(0deg, transparent 0 16px, rgba(21,21,21,0.12) 16px 17px);
  margin-bottom: 12px;
}

.mini-front span {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
}

.mini-front strong {
  align-self: end;
  color: var(--accent);
}

.mini-front i {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f8dd86, #c99f45 45%, #7d5a21 100%);
  border: 6px double #6d4b1a;
}

.editor-card {
  display: grid;
  gap: 10px;
}

.pitch-list {
  display: grid;
  gap: 8px;
  font-family: Arial, sans-serif;
  font-size: 0.9rem;
}

.pitch-item {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.reader-dialog {
  width: min(760px, calc(100% - 24px));
  border: 0;
  padding: 0;
  background: transparent;
}

.reader-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.reader-dialog article {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: clamp(22px, 5vw, 42px);
  box-shadow: var(--shadow);
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
}

.reader-dialog h2 {
  font-size: clamp(2rem, 6vw, 3.8rem);
  line-height: 0.98;
  margin: 10px 48px 10px 0;
}

.reader-art {
  position: relative;
  height: 180px;
  margin: 22px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(120deg, rgba(31, 109, 103, 0.28), rgba(168, 63, 47, 0.22)),
    repeating-linear-gradient(90deg, rgba(21,21,21,0.08) 0 1px, transparent 1px 14px);
}

.reader-art .coin {
  position: absolute;
  width: 138px;
  height: 138px;
  left: 34px;
  top: 22px;
  font-size: 2.2rem;
}

.reader-art .rays {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 24% 50%, transparent 0 70px, rgba(255,255,255,0.24) 72px, transparent 74px);
}

#readerBody {
  font-size: 1.15rem;
  line-height: 1.65;
}

.reader-actions {
  gap: 10px;
}

.status-line {
  min-height: 22px;
  margin-bottom: 0;
  font-family: Arial, sans-serif;
}

@media (max-width: 900px) {
  .top-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .lead-story {
    grid-template-columns: 1fr;
  }

  .coin-plate {
    min-height: 230px;
  }

  .right-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .edition-upload {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .edition-row {
    align-items: flex-start;
  }

  .edition-controls,
  .tool-band,
  .quick-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .lead-copy h2 {
    font-size: 2rem;
  }

  .story-card {
    grid-template-columns: 72px 1fr;
  }

  .story-card .save-mini {
    grid-column: 2;
    border-radius: 999px;
    width: auto;
  }

  .right-rail {
    grid-template-columns: 1fr;
  }

  .upload-tools {
    grid-template-columns: 1fr;
  }

  .edition-actions,
  .archive-item {
    flex-direction: column;
    align-items: stretch;
  }
}

@media print {
  body {
    background: white;
  }

  .section-nav,
  .tool-band,
  .right-rail,
  .edition-upload,
  .icon-button,
  .edition-controls,
  .quick-actions,
  .save-mini {
    display: none !important;
  }

  .top-grid,
  .content-grid,
  .lead-story {
    display: block;
  }

  .lead-story,
  .story-card {
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 14px;
  }
}
