/* PostBridge — a light "studio control desk" aesthetic.
   Warm paper canvas, deep navy ink, one vermilion signature. */

:root {
  --paper: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --ink: #16181f;
  --ink-2: #414653;
  --muted: #757b88;
  --faint: #9aa0ab;
  --line: #e6e3d9;
  --line-2: #efece3;
  --accent: #ee4323;      /* vermilion signature */
  --accent-press: #cf3418;
  --accent-soft: #fdece7;
  --indigo: #2f3ac7;      /* scheduled */
  --indigo-soft: #eaebfb;
  --green: #1c8a52;       /* published / online */
  --green-soft: #e5f4ec;
  --amber: #b5720a;
  --amber-soft: #fbf0da;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgba(22, 24, 31, .04), 0 6px 20px rgba(22, 24, 31, .06);
  --shadow-lg: 0 4px 12px rgba(22, 24, 31, .07), 0 24px 60px rgba(22, 24, 31, .12);

  --sans: "Hanken Grotesk", system-ui, sans-serif;
  --display: "Bricolage Grotesque", var(--sans);
  --mono: "DM Mono", ui-monospace, monospace;

  --sidebar-w: 244px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
::selection { background: var(--accent-soft); }

/* ---------- App frame ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px 16px;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { color: var(--accent); display: inline-flex; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.18rem; letter-spacing: -.02em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2);
  font-size: .95rem; font-weight: 600; text-align: left;
  width: 100%;
  transition: background .16s, color .16s;
}
.nav-ic { width: 18px; text-align: center; opacity: .8; font-size: 1.02rem; }
.nav-item:hover { background: var(--line-2); color: var(--ink); }
.nav-item.active { background: var(--ink); color: #fff; }
.nav-item.active .nav-ic { opacity: 1; }
.nav-count {
  margin-left: auto; font-family: var(--mono); font-size: .72rem;
  background: var(--line); color: var(--ink-2);
  border-radius: 20px; padding: 1px 8px; min-width: 20px; text-align: center;
}
.nav-item.active .nav-count { background: rgba(255,255,255,.2); color: #fff; }
.nav-count:empty { display: none; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 8px; }
.sidebar-tag { margin: 0; font-size: .74rem; color: var(--faint); line-height: 1.45; }

.storage-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: .68rem; letter-spacing: .01em;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 4px 10px; width: max-content;
}
.storage-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.storage-pill.local::before { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }

/* Mobile chrome hidden on desktop */
.topbar, .tabbar { display: none; }

.main { padding: 34px 40px 72px; max-width: 1180px; outline: none; }

/* ---------- Shared bits ---------- */
.eyebrow {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent); font-weight: 500;
}
.view-head { margin-bottom: 26px; }
.view-head h1 {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.8rem, 3.4vw, 2.5rem); letter-spacing: -.025em;
  line-height: 1.05; margin: 8px 0 6px;
}
.view-head p { margin: 0; color: var(--muted); max-width: 60ch; font-size: 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: .93rem;
  transition: transform .12s, background .16s, border-color .16s, box-shadow .16s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-press); border-color: var(--accent-press); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); padding: 9px 12px; }
.btn.ghost:hover { background: var(--line-2); color: var(--ink); }
.btn.danger { color: var(--accent); border-color: transparent; background: transparent; }
.btn.danger:hover { background: var(--accent-soft); }
.btn.sm { padding: 7px 13px; font-size: .84rem; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
}

/* ---------- Compose view ---------- */
.compose-grid { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 28px; align-items: start; }

.composer { padding: 6px; }
.composer-inner { padding: 18px 20px 20px; }
.editor {
  width: 100%; border: 0; resize: vertical; min-height: 172px;
  font-size: 1.16rem; line-height: 1.55; color: var(--ink);
  background: transparent; outline: none; padding: 6px 2px;
}
.editor::placeholder { color: var(--faint); }
.compose-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 2px 0; border-top: 1px solid var(--line-2); margin-top: 8px; }
.field { display: flex; align-items: center; gap: 8px; flex: 1 1 240px; min-width: 0; }
.field label { font-size: .78rem; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.field input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 11px; font-size: .9rem; background: var(--surface-2); color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--indigo); background: #fff; }

.section-label { font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 22px 2px 12px; }

.account-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 7px 13px 7px 8px; font-size: .87rem; font-weight: 600;
  color: var(--ink-2); transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.chip:hover { border-color: var(--faint); }
.chip.on { border-color: var(--ink); background: var(--ink); color: #fff; box-shadow: var(--shadow); }
.chip .dot { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: .62rem; font-weight: 700; font-family: var(--mono); flex-shrink: 0; }
.chip .over { font-family: var(--mono); font-size: .72rem; color: var(--accent); }
.chip.on .over { color: #ffb4a5; }
.chip-add {
  border-style: dashed; color: var(--muted); background: transparent;
}
.chip-add:hover { color: var(--ink); border-color: var(--ink-2); }

.compose-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-2); }
.sched-field { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.sched-field label { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sched-field input {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px;
  font-size: .86rem; background: var(--surface-2); color: var(--ink);
}
.sched-field input:focus { outline: none; border-color: var(--indigo); }

/* Preview rail */
.preview-rail { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 14px; }
.preview-rail h3 { font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 4px 2px; font-weight: 500; }
.preview {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 15px; box-shadow: var(--shadow);
}
.preview-top { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.pv-av { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-family: var(--mono); font-weight: 700; font-size: .72rem; flex-shrink: 0; }
.pv-meta { line-height: 1.1; min-width: 0; }
.pv-name { font-weight: 700; font-size: .86rem; }
.pv-handle { color: var(--faint); font-size: .76rem; }
.pv-count { margin-left: auto; font-family: var(--mono); font-size: .74rem; color: var(--muted); flex-shrink: 0; }
.pv-count.over { color: var(--accent); font-weight: 500; }
.pv-body { font-size: .9rem; line-height: 1.5; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }
.pv-body .cut { background: var(--accent-soft); color: var(--accent-press); border-radius: 3px; }
.pv-link { display: inline-block; margin-top: 8px; color: var(--indigo); font-size: .82rem; text-decoration: none; word-break: break-all; }
.pv-note { margin-top: 9px; font-size: .74rem; color: var(--faint); border-top: 1px dashed var(--line); padding-top: 8px; }
.preview-empty { color: var(--faint); font-size: .9rem; padding: 22px 4px; text-align: center; border: 1px dashed var(--line); border-radius: var(--r); }

/* ---------- Queue / Drafts ---------- */
.list { display: flex; flex-direction: column; gap: 14px; }
.post-row { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; padding: 18px 20px; align-items: start; }
.post-when { display: flex; flex-direction: column; gap: 3px; min-width: 96px; }
.when-badge { font-family: var(--mono); font-size: .74rem; font-weight: 500; padding: 3px 9px; border-radius: 6px; width: max-content; }
.when-badge.scheduled { background: var(--indigo-soft); color: var(--indigo); }
.when-badge.draft { background: var(--line-2); color: var(--muted); }
.when-badge.published { background: var(--green-soft); color: var(--green); }
.when-badge.due { background: var(--accent-soft); color: var(--accent-press); }
.when-sub { font-size: .78rem; color: var(--faint); }
.post-body { min-width: 0; }
.post-text { font-size: .98rem; line-height: 1.5; color: var(--ink); margin: 0 0 10px; white-space: pre-wrap; word-break: break-word; }
.post-accounts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mini-av { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-family: var(--mono); font-weight: 700; font-size: .58rem; }
.post-link-tag { font-size: .78rem; color: var(--indigo); margin-left: 4px; font-family: var(--mono); }
.post-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

.empty-state { text-align: center; padding: 72px 20px; }
.empty-state .em-ic { font-size: 2.4rem; }
.empty-state h3 { font-family: var(--display); font-size: 1.4rem; margin: 12px 0 6px; letter-spacing: -.01em; }
.empty-state p { color: var(--muted); margin: 0 auto 20px; max-width: 42ch; }

/* ---------- Connections ---------- */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 15px; }
.conn-card { padding: 18px; display: flex; align-items: center; gap: 13px; position: relative; }
.conn-av { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-family: var(--mono); font-weight: 700; font-size: .9rem; flex-shrink: 0; }
.conn-meta { min-width: 0; }
.conn-plat { font-weight: 700; font-size: .98rem; }
.conn-handle { color: var(--muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-x { position: absolute; top: 10px; right: 10px; border: 0; background: transparent; color: var(--faint); font-size: 1.1rem; line-height: 1; padding: 4px; border-radius: 6px; }
.conn-x:hover { background: var(--accent-soft); color: var(--accent); }
.conn-add-card {
  border: 1.5px dashed var(--line); border-radius: var(--r-lg); background: transparent;
  display: grid; place-items: center; gap: 6px; min-height: 80px; color: var(--muted);
  font-weight: 600; transition: border-color .15s, color .15s, background .15s;
}
.conn-add-card:hover { border-color: var(--ink-2); color: var(--ink); background: var(--surface-2); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.cal-title { font-family: var(--display); font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; min-width: 200px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-dow { font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); text-align: center; padding-bottom: 4px; }
.cal-cell { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); min-height: 96px; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.cal-cell.out { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-daynum { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.cal-cell.today .cal-daynum { color: var(--accent); }
.cal-ev { font-size: .72rem; line-height: 1.25; padding: 3px 6px; border-radius: 5px; background: var(--indigo-soft); color: var(--indigo); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; text-align: left; width: 100%; }
.cal-ev:hover { filter: brightness(.96); }
.cal-ev.draft { background: var(--line-2); color: var(--muted); }
.cal-ev.due { background: var(--accent-soft); color: var(--accent-press); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(22,24,31,.42); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px; z-index: 50;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: 88vh; overflow: auto; animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 8px; }
.modal-head h2 { font-family: var(--display); font-size: 1.35rem; margin: 0; letter-spacing: -.01em; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.modal-x { border: 0; background: transparent; font-size: 1.4rem; color: var(--muted); line-height: 1; padding: 4px 6px; border-radius: 6px; }
.modal-x:hover { background: var(--line-2); color: var(--ink); }
.modal-body { padding: 14px 24px 24px; }

.pub-item { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-top: 1px solid var(--line-2); }
.pub-item:first-child { border-top: 0; }
.pub-meta { min-width: 0; flex: 1; }
.pub-name { font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: 8px; }
.pub-note { color: var(--faint); font-size: .78rem; margin-top: 2px; }
.pub-note.warn { color: var(--accent); }
.pub-item.done .pub-name::after { content: "✓ opened"; font-family: var(--mono); font-size: .68rem; color: var(--green); background: var(--green-soft); padding: 1px 7px; border-radius: 20px; }

.plat-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 9px; }
.plat-opt { display: flex; align-items: center; gap: 9px; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: var(--r); background: var(--surface); font-weight: 600; font-size: .88rem; text-align: left; transition: border-color .15s, background .15s; }
.plat-opt:hover { border-color: var(--ink-2); }
.plat-opt.sel { border-color: var(--ink); background: var(--surface-2); }
.form-field { margin-top: 16px; }
.form-field label { display: block; font-size: .8rem; color: var(--muted); font-family: var(--mono); margin-bottom: 6px; }
.form-field input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: .95rem; background: var(--surface-2); color: var(--ink);
}
.form-field input:focus { outline: none; border-color: var(--indigo); background: #fff; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: .88rem; font-weight: 600; box-shadow: var(--shadow-lg); animation: toast .25s ease;
}
@keyframes toast { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Footer ---------- */
.site-foot { margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--faint); font-size: .82rem; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.site-foot strong { color: var(--ink-2); font-weight: 600; }
.site-foot a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--line); }
.site-foot a:hover { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 30;
    padding: 12px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: sticky; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab {
    border: 0; background: transparent; color: var(--muted);
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: .68rem; font-weight: 600; padding: 6px 2px; border-radius: 8px;
  }
  .tab span { font-size: 1.15rem; }
  .tab.active { color: var(--accent); }
  .main { padding: 22px 18px 40px; }
  .compose-grid { grid-template-columns: 1fr; }
  .preview-rail { position: static; order: 2; }
  .post-row { grid-template-columns: 1fr; gap: 12px; }
  .post-actions { flex-direction: row; align-items: center; justify-content: flex-start; flex-wrap: wrap; }
  .post-when { flex-direction: row; align-items: center; min-width: 0; }
  .cal-cell { min-height: 64px; padding: 5px; }
  .cal-title { min-width: 0; font-size: 1.1rem; }
}
@media (max-width: 480px) {
  .cal-ev { font-size: 0; padding: 4px; }
  .cal-ev::before { content: "•"; font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
