:root {
  color-scheme: light;
  --ink: #16202a;
  --muted: #637181;
  --line: #d9e0e7;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --accent: #9d2f36;
  --accent-strong: #742129;
  --gold: #b0832c;
  --green: #2f7a5c;
  --shadow: 0 12px 34px rgba(30, 41, 59, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

.app {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 1440px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  margin: 0;
}

.actions {
  display: flex;
  gap: 8px;
}

button,
.button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 750;
  height: 38px;
  justify-content: center;
  min-width: 78px;
  padding: 0 14px;
  text-decoration: none;
  touch-action: manipulation;
}

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

.secondary {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.secondary:hover {
  background: #eef2f6;
  border-color: #c8d1db;
}

.metrics,
.controls,
.workspace {
  margin-left: auto;
  margin-right: auto;
  max-width: 1440px;
}

.metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
}

.metrics div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metrics span {
  display: block;
  font-size: 22px;
  font-weight: 850;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metrics label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
}

.controls {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(240px, 1fr) 180px 180px 220px;
  margin-bottom: 14px;
}

input,
select,
textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
}

input,
select {
  height: 40px;
  min-width: 0;
  padding: 0 12px;
}

button:focus-visible,
.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(157, 47, 54, 0.24);
  outline-offset: 2px;
}

textarea {
  line-height: 1.45;
  min-height: 104px;
  padding: 12px;
  resize: vertical;
  width: 100%;
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(420px, 0.95fr) minmax(480px, 1.05fr);
}

.list,
.detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 620px;
}

.list {
  max-height: calc(100vh - 206px);
  overflow: auto;
}

.date-group {
  background: #eef2f6;
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  color: #49586a;
  font-size: 12px;
  font-weight: 850;
  padding: 9px 16px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.row {
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid transparent;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 8px;
  height: auto;
  justify-content: stretch;
  min-width: 0;
  padding: 14px 16px;
  text-align: left;
  width: 100%;
}

.row:hover,
.row.active {
  background: #f9f2f3;
}

.row.active {
  border-left: 4px solid var(--accent);
  padding-left: 12px;
}

.row-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
}

.pill {
  background: #edf7f2;
  border: 1px solid #cce7db;
  border-radius: 999px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
}

.preview {
  color: #3e4a57;
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}

.detail {
  max-height: calc(100vh - 206px);
  overflow: auto;
  padding: 24px;
}

.detail h2 {
  font-size: 24px;
  line-height: 1.2;
  margin: 8px 0 14px;
}

.detail .date {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  margin: 0;
}

.detail h3 {
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 850;
  margin: 22px 0 10px;
  padding-top: 16px;
  text-transform: uppercase;
}

.detail-tags {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
  margin-bottom: 4px;
}

.detail ul {
  margin: 0;
  padding-left: 20px;
}

.detail li {
  line-height: 1.55;
  margin-bottom: 12px;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
}

.writer {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 2px;
}

.writer-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.writer-option {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  margin-top: 10px;
}

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

.story-output {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 14px;
  padding: 16px;
}

.story-output:empty {
  display: none;
}

.story-output h2 {
  font-size: 21px;
  margin: 4px 0 14px;
}

.story-label {
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
  margin: 14px 0 4px;
  text-transform: uppercase;
}

.story-label:first-child {
  margin-top: 0;
}

.strap {
  color: #334155;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.5;
  margin: 0;
}

.body-copy p {
  line-height: 1.62;
  margin: 0 0 12px;
}

.empty {
  color: var(--muted);
  margin: 0;
}

.status {
  color: var(--muted);
  font-size: 12px;
  margin: 12px auto 0;
  max-width: 1440px;
}

@media (max-width: 980px) {
  .app {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .actions {
    width: 100%;
  }

  .actions button,
  .actions .button {
    flex: 1 1 0;
  }

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

  .controls,
  .workspace {
    grid-template-columns: 1fr;
  }

  .list,
  .detail {
    max-height: none;
    min-height: 320px;
  }
}

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

  h1 {
    font-size: 24px;
  }

  .eyebrow {
    font-size: 11px;
  }

  button,
  .button,
  input,
  select {
    min-height: 44px;
  }

  .metrics {
    gap: 8px;
  }

  .metrics div {
    padding: 11px;
  }

  .metrics span {
    font-size: 18px;
  }

  .metrics label {
    font-size: 11px;
  }

  .controls {
    gap: 8px;
    margin-bottom: 12px;
  }

  .workspace {
    gap: 12px;
  }

  .list,
  .detail {
    border-radius: 6px;
    box-shadow: none;
    min-height: 0;
  }

  .list {
    max-height: 58vh;
    -webkit-overflow-scrolling: touch;
  }

  .date-group {
    padding: 8px 12px;
  }

  .row {
    gap: 7px;
    padding: 13px 12px;
  }

  .row.active {
    padding-left: 8px;
  }

  .row-title {
    font-size: 14px;
  }

  .meta {
    gap: 6px;
  }

  .preview {
    display: -webkit-box;
    font-size: 12px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .detail {
    padding: 16px;
  }

  .detail h2 {
    font-size: 20px;
  }

  .detail h3 {
    margin-top: 18px;
  }

  .links .button,
  .writer-actions button {
    width: 100%;
  }

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

  .writer-status {
    line-height: 1.4;
  }

  .story-output {
    padding: 13px;
  }

  .story-output h2 {
    font-size: 19px;
  }

  .body-copy p {
    font-size: 15px;
    line-height: 1.58;
  }
}
