:root {
  --ink: #203139;
  --muted: #68777b;
  --paper: #f7f4ed;
  --white: #fffdf8;
  --cream: #ece5d7;
  --line: rgba(32, 49, 57, 0.13);
  --coral: #d36d58;
  --coral-dark: #ae4d3b;
  --sage: #7b9386;
  --gold: #b88746;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
  background: #f2eee6;
  color: #302a25;
}

.login-card {
  width: min(100%, 430px);
  padding: clamp(28px, 7vw, 48px);
  border: 1px solid rgba(76, 61, 47, 0.16);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 24px 70px rgba(70, 52, 36, 0.14);
}

.login-card h1 {
  margin: 6px 0 10px;
  font-family: Georgia, serif;
  font-size: clamp(2.1rem, 9vw, 3.25rem);
  font-weight: 500;
}

.login-card form {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.login-card label {
  margin-top: 8px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid #b9aa98;
  border-radius: 10px;
  background: #fff;
}

.login-card button {
  min-height: 50px;
  margin-top: 14px;
  border: 0;
  border-radius: 999px;
  background: #59483a;
  color: #fff;
  font-weight: 700;
}

.login-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f9dede;
  color: #7d2727;
}

.topbar {
  height: 78px;
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, .95);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-seal {
  width: 41px;
  height: 41px;
  display: grid;
  place-items: center;
  border: 1px solid var(--coral);
  border-radius: 50%;
  color: var(--coral-dark);
  font: 14px var(--serif);
  letter-spacing: .08em;
}
.brand strong, .brand small { display: block; }
.brand strong { font: 19px var(--serif); }
.brand small { margin-top: 3px; color: var(--muted); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }

.progress-summary { width: min(420px, 90%); justify-self: center; }
.progress-summary > div:first-child { display: flex; justify-content: space-between; align-items: baseline; }
.progress-summary span { color: var(--muted); font-size: 11px; }
.progress-summary b { font: 17px var(--serif); }
.progress-track { height: 4px; margin-top: 7px; overflow: hidden; border-radius: 4px; background: #ded9cf; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--coral); transition: width .35s ease; }

.privacy-badge { justify-self: end; padding: 8px 12px; border: 1px solid #b9cec0; border-radius: 20px; color: #526d5e; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.privacy-badge i { width: 7px; height: 7px; display: inline-block; margin-right: 6px; border-radius: 50%; background: #6d9a7e; }

.workspace { height: calc(100vh - 78px); display: grid; grid-template-columns: 320px minmax(480px, 1fr) 320px; }
.library, .inspector { min-height: 0; background: var(--white); }
.library { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.inspector { overflow-y: auto; border-left: 1px solid var(--line); }
.reader { min-width: 0; overflow-y: auto; }

.library-heading { padding: 26px 24px 16px; }
.eyebrow { color: var(--coral-dark); font-size: 9px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.library-heading h1 { margin: 7px 0 4px; font: 31px var(--serif); }
.library-heading p { margin: 0; color: var(--muted); font-size: 11px; }

.search-field { height: 44px; display: flex; align-items: center; gap: 8px; margin: 0 18px 14px; padding: 0 12px; border: 1px solid var(--line); background: var(--paper); }
.search-field span { color: var(--coral); font-size: 21px; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 12px; }

.filters { display: flex; gap: 6px; overflow-x: auto; padding: 0 18px 14px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { flex: 0 0 auto; padding: 7px 9px; border: 1px solid var(--line); border-radius: 16px; background: transparent; color: var(--muted); font-size: 9px; }
.filters button span { margin-left: 3px; }
.filters button.active { border-color: var(--coral); background: #fff3ee; color: var(--coral-dark); }

.entry-list { min-height: 0; flex: 1; overflow-y: auto; border-top: 1px solid var(--line); }
.entry-list-empty { padding: 40px 25px; color: var(--muted); font: 16px/1.5 var(--serif); text-align: center; }
.entry-row { width: 100%; position: relative; display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 16px 20px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.entry-row:hover { background: #faf6ee; }
.entry-row.active { background: var(--cream); }
.entry-row.active::before { content: ""; width: 3px; position: absolute; inset: 0 auto 0 0; background: var(--coral); }
.entry-row.sequence-proposal {
  border-left: 3px solid #b42318;
  background: #fff2f0;
}
.entry-row.sequence-proposal:hover { background: #ffe7e3; }
.entry-row.sequence-proposal.active { background: #fbdad5; }
.entry-row.sequence-proposal .row-top strong,
.entry-row.sequence-proposal .candidate-flag {
  color: #9f1c13 !important;
}
.entry-row.evidence-conflict:not(.sequence-proposal) {
  border-left: 3px solid #b42318;
  background: #fff7f5;
}
.entry-row.evidence-conflict:not(.sequence-proposal):hover { background: #ffece8; }
.entry-row .evidence-flag { color: #9f1c13 !important; font-weight: 800; }
.day-tile { width: 39px; height: 44px; display: grid; place-content: center; border: 1px solid #d7cfc1; color: var(--muted); text-align: center; }
.day-tile b { font: 15px var(--serif); line-height: 1; }
.day-tile span { margin-top: 3px; font-size: 7px; letter-spacing: .08em; text-transform: uppercase; }
.entry-row.active .day-tile { border-color: var(--coral); color: var(--coral-dark); background: var(--white); }
.row-copy { min-width: 0; }
.row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row-top strong { overflow: hidden; font: 16px var(--serif); text-overflow: ellipsis; white-space: nowrap; }
.row-top time { flex: 0 0 auto; color: var(--muted); font-size: 8px; letter-spacing: .05em; text-transform: uppercase; }
.row-copy p { margin: 5px 0 8px; overflow: hidden; color: var(--muted); font: 11px/1.45 var(--serif); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-meta { display: flex; align-items: center; gap: 6px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #baa98e; }
.status-approved { background: #6c9b7e; }
.status-edit-needed { background: #d49145; }
.status-excluded { background: #8a8d8d; }
.row-meta span:not(.status-dot) { color: #8b9697; font-size: 8px; letter-spacing: .07em; text-transform: uppercase; }
.row-flag { color: var(--coral-dark) !important; }
.candidate-flag { font-weight: 800; }

.reader-empty { min-height: 100%; display: grid; place-content: center; justify-items: center; padding: 50px; text-align: center; }
.empty-monogram { width: 92px; height: 92px; display: grid; place-items: center; border: 1px solid var(--coral); border-radius: 50%; color: var(--coral-dark); font: 27px var(--serif); }
.reader-empty h2 { margin: 23px 0 8px; font: 38px var(--serif); }
.reader-empty p { max-width: 450px; margin: 0; color: var(--muted); font: 16px/1.6 var(--serif); }

.entry-view { width: min(820px, calc(100% - 72px)); margin: 0 auto; padding-bottom: 110px; }
.entry-toolbar { height: 65px; position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--line); background: rgba(247,244,237,.94); backdrop-filter: blur(13px); }
.quiet-button { padding: 0; border: 0; background: none; color: var(--muted); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
#next-entry { justify-self: end; }
.view-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 20px; background: var(--white); }
.view-switch button { padding: 6px 14px; border: 0; border-radius: 15px; background: transparent; color: var(--muted); font-size: 9px; letter-spacing: .09em; text-transform: uppercase; }
.view-switch button.active { background: var(--ink); color: white; }

.entry-header { display: flex; justify-content: space-between; align-items: end; gap: 30px; padding: 55px 0 28px; border-bottom: 1px solid var(--line); }
.entry-header h2 { margin: 8px 0 5px; font: 58px/1 var(--serif); letter-spacing: -.035em; }
.entry-header time { color: var(--coral-dark); font: italic 17px var(--serif); }
.media-tally { color: var(--muted); font-size: 9px; letter-spacing: .09em; text-align: right; text-transform: uppercase; }

.flag-row { display: flex; flex-wrap: wrap; gap: 7px; padding: 18px 0 0; }
.flag { padding: 6px 8px; border: 1px solid #e3b49e; background: #fff4ee; color: var(--coral-dark); font-size: 8px; letter-spacing: .09em; text-transform: uppercase; }
.flag.neutral { border-color: #cdd6d0; background: #f0f5f1; color: #597061; }
.flag.sequence-proposal-flag {
  border-color: #b42318;
  background: #ffe5e1;
  color: #8f160f;
  font-weight: 800;
}
.sequence-proposal-label { color: #a61b13 !important; }

.story { padding: 28px 0; }
.story p { margin: 0 0 18px; color: #45575d; font: 18px/1.78 var(--serif); }
.story h1, .story h2, .story h3 { font-family: var(--serif); font-weight: 400; }
.story figure { margin: 34px 0; padding: 10px; background: var(--white); box-shadow: 0 12px 38px rgba(34,46,52,.1); }
.story figure img { width: 100%; max-height: 720px; display: block; object-fit: contain; background: #ebe7de; }
.story figure figcaption { padding: 9px 3px 2px; color: var(--muted); font: italic 11px var(--serif); }
.story audio { width: 100%; margin: 8px 0 25px; }
.story a { color: var(--coral-dark); }

.editor { padding: 28px 0; }
.editor-note { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 12px; padding: 12px 14px; border: 1px solid #d7cdbb; background: #f1ebdf; }
.editor-note strong { font: 14px var(--serif); }
.editor-note span { max-width: 430px; color: var(--muted); font-size: 10px; line-height: 1.4; text-align: right; }
.proofing-panel { margin-bottom: 14px; border: 1px solid #d8cdbd; background: var(--white); }
.proofing-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.proofing-heading strong { display: block; margin-top: 5px; font: 16px var(--serif); }
.proofing-help { display: block; margin-top: 5px; color: var(--muted); font: italic 10px var(--serif); }
.proofing-heading button { padding: 7px 10px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.proofing-heading button:hover { border-color: var(--coral); color: var(--coral-dark); }
.proofing-heading button:disabled { opacity: .5; cursor: wait; }
.proofing-list { max-height: 265px; overflow-y: auto; }
.proofing-empty { padding: 20px 16px; color: #597061; font: italic 14px/1.5 var(--serif); }
.proofing-issue { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); transition: background .15s ease; }
.proofing-issue:last-child { border-bottom: 0; }
.proofing-issue:hover { background: #faf6ee; }
.proofing-issue-copy { min-width: 0; }
.proofing-kind { display: inline-block; margin-right: 6px; padding: 3px 5px; border-radius: 10px; background: #fff0e8; color: var(--coral-dark); font-size: 7px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.proofing-issue.grammar .proofing-kind,
.proofing-issue.punctuation .proofing-kind { background: #f4ead5; color: #875f29; }
.proofing-issue strong { font: 14px var(--serif); }
.proofing-issue p { margin: 5px 0 0; overflow: hidden; color: var(--muted); font: 11px/1.45 var(--serif); text-overflow: ellipsis; white-space: nowrap; }
.proofing-choice { display: inline-block; margin-top: 8px; padding: 6px 8px; border: 1px solid #a9c1b0; background: #eff6f1; color: #4f735c; font-size: 8px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.proofing-actions { display: flex; gap: 7px; align-items: center; }
.proofing-action { min-height: 38px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 3px; background: var(--white); color: var(--ink); font-size: 8px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.proofing-action span { margin-right: 3px; font-size: 14px; line-height: 0; vertical-align: -1px; }
.proofing-action.accept { border-color: #8fb29c; background: #edf6f0; color: #426d53; }
.proofing-action.ignore { border-color: #d2a397; background: #fff2ed; color: #9c4f40; }
.proofing-action:hover:not(:disabled), .proofing-action:focus-visible { box-shadow: 0 0 0 2px rgba(32,49,57,.12); }
.proofing-action:disabled { opacity: .38; cursor: not-allowed; }
#body-editor { width: 100%; min-height: 65vh; padding: 23px; resize: vertical; border: 1px solid var(--line); outline: 0; background: var(--white); color: #394b51; font: 15px/1.65 Consolas, "Courier New", monospace; }
#body-editor:focus { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(211,109,88,.09); }

.inspector-inner { padding: 31px 25px 45px; }
.inspector-title { padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.inspector-title h2 { margin: 7px 0 0; font: 25px var(--serif); }
.date-evidence { margin-top: 23px; padding: 18px; border: 1px solid #d8cdbd; background: #f4eee3; }
.date-evidence-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.date-evidence-heading h3 { margin: 5px 0 0; font: 19px var(--serif); }
.confidence-pill { padding: 5px 7px; border: 1px solid #c9bda9; border-radius: 14px; color: var(--muted); font-size: 7px; letter-spacing: .09em; text-transform: uppercase; }
.confidence-pill.high { border-color: #8bb09a; background: #edf6f0; color: #4c745d; }
.confidence-pill.medium { border-color: #d5aa6a; background: #fff7e7; color: #926128; }
.confidence-pill.low { border-color: #d3a08f; background: #fff1eb; color: #a15240; }
.evidence-list { margin-top: 14px; border-top: 1px solid rgba(32,49,57,.1); }
.evidence-list > div { display: grid; grid-template-columns: 1fr auto 28px; align-items: center; gap: 7px; padding: 9px 0; border-bottom: 1px dotted rgba(32,49,57,.16); }
.evidence-list span { color: var(--muted); font-size: 8px; letter-spacing: .05em; text-transform: uppercase; }
.evidence-list strong { font: 12px var(--serif); }
.evidence-list button { padding: 3px 0; border: 0; border-bottom: 1px solid var(--coral); background: none; color: var(--coral-dark); font-size: 8px; text-transform: uppercase; }
.evidence-list button:disabled { opacity: .35; cursor: default; }
.evidence-list .photo-evidence-row { grid-template-columns: 1fr auto 28px; }
.evidence-list .text-evidence-row { grid-template-columns: 1fr auto 28px; }
.photo-evidence-row small,
.text-evidence-row small { grid-column: 1 / -1; color: var(--muted); font: italic 9px/1.4 var(--serif); }
.date-evidence .field { margin-top: 14px; }
.final-date-field input { width: 100%; height: 42px; padding: 0 10px; border: 1px solid var(--line); outline: 0; background: var(--white); font-size: 12px; }
.final-date-field input:focus { border-color: var(--coral); }
.date-selects { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }
.date-evidence textarea, .date-evidence select { background: var(--white); }
.field { display: block; margin-top: 22px; }
.field > span { display: block; margin-bottom: 7px; color: var(--ink); font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.field select, .field textarea { width: 100%; border: 1px solid var(--line); outline: 0; background: var(--paper); font-size: 12px; }
.field select { height: 43px; padding: 0 10px; }
.field textarea { padding: 11px; resize: vertical; line-height: 1.5; }
.field select:focus, .field textarea:focus { border-color: var(--coral); }
.field small { display: block; margin-top: 6px; color: #8c9798; font: italic 10px var(--serif); }

.source-details { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.source-details dl { margin: 12px 0 0; }
.source-details dl div { display: grid; grid-template-columns: 1fr 1.2fr; gap: 10px; padding: 8px 0; border-bottom: 1px dotted var(--line); font-size: 10px; }
.source-details dt { color: var(--muted); }
.source-details dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

.save-area { margin-top: 27px; padding-top: 19px; border-top: 1px solid var(--line); }
.save-area > span { min-height: 15px; display: block; margin-bottom: 8px; color: var(--muted); font-size: 9px; text-align: center; }
.save-area > span.dirty { color: var(--coral-dark); }
.save-area button { width: 100%; min-height: 43px; padding: 10px; border: 0; background: var(--ink); color: white; font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.save-area button:hover { background: #314850; }
.save-area button:disabled { opacity: .55; cursor: wait; }
.save-area .secondary-save { margin-top: 8px; border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.save-area .secondary-save:hover { background: var(--cream); }

.toast { min-width: 260px; position: fixed; z-index: 50; left: 50%; bottom: 26px; padding: 13px 18px; border-radius: 4px; background: var(--ink); color: white; box-shadow: 0 14px 40px rgba(0,0,0,.2); font-size: 11px; text-align: center; transform: translate(-50%, 100px); opacity: 0; transition: .25s ease; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 1120px) {
  .topbar { grid-template-columns: 270px 1fr auto; }
  .workspace { grid-template-columns: 285px 1fr; }
  .inspector { width: 320px; position: fixed; z-index: 20; top: 78px; right: 0; bottom: 0; box-shadow: -12px 0 40px rgba(32,49,57,.12); transform: translateX(calc(100% - 4px)); transition: transform .25s ease; }
  .inspector:focus-within, .inspector:hover { transform: translateX(0); }
  .entry-view { width: min(760px, calc(100% - 52px)); padding-right: 15px; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { height: auto; min-height: 70px; grid-template-columns: 1fr auto; padding: 12px 16px; }
  .progress-summary { display: none; }
  .brand small { display: none; }
  .workspace { height: auto; display: block; }
  .library { height: 44vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .library-heading { padding: 18px 18px 10px; }
  .library-heading h1 { font-size: 25px; }
  .reader { min-height: 56vh; overflow: visible; }
  .entry-view { width: calc(100% - 32px); }
  .entry-header h2 { font-size: 45px; }
  .inspector { width: 100%; position: static; transform: none; box-shadow: none; }
  .inspector-inner { border-top: 1px solid var(--line); }
  .entry-toolbar { top: 0; }
  .proofing-issue { grid-template-columns: 1fr; }
  .proofing-actions { width: 100%; }
  .proofing-action { flex: 1; min-height: 44px; }
}
