/* Editorial Desk — domain content OS
   Palette: ink, slate, signal cobalt, paper, ember status
   Type: Newsreader (display) + Source Sans 3 (UI) + IBM Plex Mono (meta)
*/

:root {
  --ink: #0e141b;
  --ink-soft: #1a2330;
  --slate: #2c3a4a;
  --muted: #6b7c8f;
  --line: #d5dce6;
  --paper: #f3f0e8;
  --paper-bright: #faf8f3;
  --panel: #ffffff;
  --cobalt: #1f4e8c;
  --cobalt-deep: #163a6b;
  --cobalt-soft: #e8eef7;
  --ember: #c45c26;
  --sage: #2f6b4f;
  --sage-soft: #e6f1eb;
  --rose: #9b2c3a;
  --rose-soft: #f8e8ea;
  --amber: #a67c1a;
  --amber-soft: #f7f0dc;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(14, 20, 27, 0.04), 0 12px 32px rgba(14, 20, 27, 0.06);
  --font-display: "Newsreader", "Iowan Old Style", "Palatino Linotype", serif;
  --font-ui: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1f4e8c18, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #c45c2612, transparent 50%),
    var(--paper);
  font-family: var(--font-ui);
  line-height: 1.5;
}

a {
  color: var(--cobalt);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Shell */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    border-right: none !important;
    border-bottom: 1px solid var(--line);
  }
}

.sidebar {
  background: var(--ink);
  color: #e8edf4;
  padding: 1.5rem 1.15rem;
  border-right: 1px solid #243041;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.brand-kicker {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8fa3bb;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: #f4f7fb;
}

.brand-title em {
  font-style: italic;
  color: #9ec0ef;
  font-weight: 400;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav a {
  color: #c5d0de;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.95rem;
}

.nav a:hover,
.nav a.active {
  background: #243041;
  color: #fff;
  text-decoration: none;
}

.side-meta {
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #8fa3bb;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: fit-content;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #243041;
  color: #d7e2f0;
}

.pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.pill.ok .dot {
  background: #3dbe7a;
}
.pill.bad .dot {
  background: #e35d6a;
}

.main {
  padding: 1.25rem 1.5rem 2rem;
  max-width: 1200px;
  min-width: 0; /* prevent grid blowout from long mono paths */
  width: 100%;
}

@media (max-width: 640px) {
  .main {
    padding: 1rem 1rem 2rem;
  }
}

/* Header */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.page-head .lede {
  margin: 0.35rem 0 0;
  color: var(--slate);
  max-width: 42rem;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem;
  box-shadow: var(--shadow);
}

.week-nav a,
.week-nav span {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  min-width: 2.2rem;
  text-align: center;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  color: var(--slate);
  text-decoration: none;
}

.week-nav a:hover {
  background: var(--cobalt-soft);
  color: var(--cobalt-deep);
  text-decoration: none;
}

.week-nav .current {
  background: var(--ink);
  color: #fff;
  font-weight: 500;
}

/* Alerts */
.toast {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-size: 0.95rem;
}

.toast.ok {
  background: var(--sage-soft);
  border-color: #b7d4c4;
  color: #1d4a35;
}

.toast.err {
  background: var(--rose-soft);
  border-color: #e5bcc2;
  color: #6e1f2a;
}

/* Schedule strip — signature */
.schedule {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 1200px) {
  .schedule {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1000px) {
  .schedule {
    grid-template-columns: 1fr;
  }
}

.slot {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.slot:hover {
  transform: translateY(-2px);
  border-color: #b8c6d8;
}

.slot-day {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.slot-project {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}

.slot-topic {
  font-size: 0.88rem;
  color: var(--slate);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.slot-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.status {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--slate);
}

.status.empty {
  background: #eef2f6;
  color: var(--muted);
}
.status.draft {
  background: var(--amber-soft);
  color: #6d5010;
}
.status.review {
  background: var(--cobalt-soft);
  color: var(--cobalt-deep);
}
.status.approved {
  background: var(--sage-soft);
  color: #1d4a35;
}
.status.published {
  background: var(--ink);
  color: #f3f6fa;
}
.status.skipped {
  background: #ececec;
  color: #666;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1.2;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--cobalt);
  color: #fff;
}
.btn-primary:hover {
  background: var(--cobalt-deep);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--slate);
}
.btn-ghost:hover {
  background: var(--paper-bright);
  color: var(--ink);
}

.btn-ember {
  background: var(--ember);
  color: #fff;
}
.btn-ember:hover {
  filter: brightness(0.95);
  color: #fff;
}

.btn-sage {
  background: var(--sage);
  color: #fff;
}
.btn-sage:hover {
  filter: brightness(0.95);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/*
 * Post desk layout:
 * Page height must follow the LEFT editor only.
 * The right rail is sticky and scrolls inside itself — otherwise a long
 * curriculum/pipeline column forces a huge empty cream area under the editor.
 */
.desk-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
  gap: 1.25rem;
  align-items: start;
  align-content: start;
}

.desk-main {
  align-self: start;
  min-width: 0;
  min-height: 0;
  height: auto;
}

.desk-main .panel,
.desk-main form.panel,
.desk-main > form {
  height: auto;
  min-height: 0;
}

.desk-rail {
  align-self: start;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

@media (max-width: 980px) {
  .desk-grid {
    grid-template-columns: 1fr;
  }
  /* Stacked: no sticky trap on small screens */
  .desk-rail {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-pad {
  padding: 1.15rem 1.25rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.meta-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.field label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: var(--paper-bright);
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid #1f4e8c44;
  border-color: var(--cobalt);
  background: #fff;
}

.field textarea {
  min-height: 140px;
  max-height: min(70vh, 640px);
  resize: vertical;
  font-family: var(--font-ui);
  line-height: 1.55;
}

/* Long-form only: taller editor when that tab is open */
.tab-panel[data-panel="blog"] .field textarea,
.tab-panel[data-panel="devto"] .field textarea {
  min-height: 280px;
}

.tab-panel[data-panel="linkedin"] .field textarea {
  min-height: 160px;
}

.tab-panel[data-panel="x"] .field textarea {
  min-height: 180px;
}

.tab-panel[data-panel="image"] .field textarea {
  min-height: 100px;
}

.field textarea.mono {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* Guidance / regenerate one-shots stay compact */
.field textarea#one-shot-empty,
.field textarea#one-shot-regen,
.field textarea#guide-text,
textarea[name="one_shot"],
textarea[name="text"] {
  min-height: 64px !important;
  max-height: 160px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.65rem;
}

.tabs a,
.tabs button {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--muted);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.tabs a.active,
.tabs button.active {
  background: var(--cobalt-soft);
  color: var(--cobalt-deep);
  font-weight: 600;
}

.tabs a:hover,
.tabs button:hover {
  color: var(--ink);
  text-decoration: none;
}

/* Only the active channel tab is in layout */
.tab-panel {
  display: none;
  margin: 0;
  padding: 0;
  border: 0;
  min-height: 0;
}
.tab-panel.active {
  display: block;
}

/* Inactive channel fields: in DOM for Save, zero contribution to page height */
.field-stash {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.field-stash textarea {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  max-height: 1px !important;
  overflow: hidden !important;
  resize: none !important;
  opacity: 0 !important;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.actions form {
  margin: 0;
}

.rail-section + .rail-section {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.rail-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.65rem;
}

.curriculum {
  font-size: 0.9rem;
  color: var(--slate);
}

.curriculum strong {
  display: block;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.flag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: var(--amber-soft);
  color: #6d5010;
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
}

.cover-preview {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0e141b;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.tweet-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tweet {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  background: var(--paper-bright);
}

.tweet-n {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--slate);
}

.empty-state {
  text-align: left;
  padding: 2rem 1.25rem;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-weight: 500;
  margin: 0 0 0.5rem;
}

.empty-state p {
  color: var(--slate);
  margin: 0 0 1.25rem;
  max-width: 36rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.preview-md {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink);
  max-height: min(55vh, 420px);
  overflow: auto;
  padding: 0.5rem;
  background: var(--paper-bright);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.cover-preview {
  display: block;
  max-width: 100%;
  max-height: 280px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.slot-cover-link {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper-bright);
  line-height: 0;
}

.slot-cover {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
}

/* Files path chip: don't stretch layout with long absolute paths */
.rail-section .meta-chip {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Editorial guidance */
.guide-item {
  font-size: 0.86rem;
  color: var(--ink);
  background: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.45rem;
  line-height: 1.4;
}

.guide-item.standing {
  border-left: 3px solid var(--cobalt);
}

.guide-item.oneshot {
  border-left: 3px solid var(--ember);
  background: #fdf6f0;
}

.guide-item.dim {
  opacity: 0.45;
}

.guide-tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 0.2rem;
}

.guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.4rem;
}

.guide-actions form {
  margin: 0;
}

.guide-form textarea {
  min-height: 72px;
  font-size: 0.88rem;
}

.guide-form select {
  font: inherit;
}

@media (prefers-reduced-motion: reduce) {
  .slot {
    transition: none;
  }
}

/* Auto cover compression feedback */
.cover-compress-status {
  color: var(--sage);
}
.cover-compress-status.cover-ok {
  color: var(--muted);
}
.cover-compress-status.cover-compressed {
  color: var(--sage);
  font-weight: 600;
}
