:root {
  --bg: #0b0c0f;
  --panel: #14161c;
  --panel-2: #1c1f28;
  --border: #2a2e3a;
  --text: #e8eaef;
  --muted: #9aa3b2;
  --accent: #c4a35a;
  --accent-2: #7c5cff;
  --danger: #e85d5d;
  --ok: #3ecf8e;
  --warn: #e6b84d;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
}
html {
  height: 100%;
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 22, 28, 0.92);
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
}
.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: uppercase;
  font-size: 0.95rem;
  text-decoration: none;
  user-select: none;
}
.nav-right a[href="/"],
.nav-right a[href="/?tab=chat"],
.nav-right a[href="/media"],
.nav-right a[href="/new"],
.nav-right a[href="/users"] {
  font-weight: 600;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}
.muted { color: var(--muted); font-size: 0.9rem; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card h1, .card h2 { margin-top: 0; }
label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}
input[type="email"],
input[type="password"],
input[type="text"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font: inherit;
}
textarea { min-height: 140px; resize: vertical; }
.checks {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 0.25rem;
}
.checks label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
}
button, .btn {
  display: inline-block;
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.secondary, .btn.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
button.danger { background: var(--danger); color: #fff; }
button.linkish {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
  cursor: pointer;
}
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.85rem; }
.inline { display: inline; margin: 0; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.flash.error { background: rgba(232, 93, 93, 0.15); color: #ffb4b4; }
.flash.ok, .flash.info { background: rgba(62, 207, 142, 0.12); color: #b6f5d4; }
.flash.warn { background: rgba(230, 184, 77, 0.12); color: #ffe2a0; }

.auth-wrap {
  max-width: 420px;
  margin: 2rem auto;
}
.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  text-align: left;
  padding: 0.7rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; }
.post-body {
  white-space: pre-wrap;
  max-width: 420px;
  font-size: 0.95rem;
}
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  text-transform: lowercase;
}
.badge-draft { color: var(--muted); }
.badge-pending_approval { color: var(--warn); }
.badge-approved { color: var(--ok); }
.badge-scheduled { color: #8ec8ff; }
.badge-published { color: var(--accent-2); }
.badge-rejected { color: var(--danger); }
.badge-template { color: var(--accent); }

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filters a {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
.filters a.active {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--accent);
}
.platforms { color: var(--muted); font-size: 0.85rem; }
.error-box {
  color: #ffb4b4;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  display: none;
}

/* --- Band chat --- */
/* Soft default width; in-shell Band chat uses workshell (has-workshell). */
.container:has(.chat-shell) {
  max-width: none;
}
.chat-shell {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 8rem);
  padding: 0;
  overflow: hidden;
}
.chat-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 0;
}
.chat-header[hidden],
.chat-header:empty {
  display: none !important;
  padding: 0;
  border: none;
  min-height: 0;
}
.chat-header h1 { margin: 0; font-size: 0.95rem; }
.chat-header .chat-subtitle { display: none; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background:
    radial-gradient(ellipse at top, rgba(124, 92, 255, 0.06), transparent 55%),
    var(--panel);
  min-height: 0;
  max-height: none;
}
.chat-msg {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
}
.chat-msg header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}
.chat-msg-body {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.45;
}
.chat-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.55rem;
}
.chat-att-thumb {
  display: inline-flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 160px;
  font-size: 0.75rem;
  color: var(--muted);
}
.chat-att-thumb img {
  width: 160px;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0a0a0c;
}
.chat-att-file {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 0.85rem;
}
/* Legacy visible drop-zone removed — drag onto chat root instead */
.chat-dropzone {
  display: none !important;
}
.chat-shell.chat-dragover {
  outline: 1px dashed var(--accent);
  outline-offset: -3px;
  box-shadow: inset 0 0 0 1px rgba(196, 163, 90, 0.25),
    inset 0 0 40px rgba(196, 163, 90, 0.06);
}
.chat-file-input {
  display: none !important;
}
.chat-pending {
  display: none;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem 0;
}
.chat-pending-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 0.8rem;
}
.chat-pending-chip button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.chat-composer {
  padding: 0.65rem 1rem 0.55rem;
  border-top: 1px solid var(--border);
}
.chat-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.chat-composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 140px;
  margin: 0;
  resize: none;
  field-sizing: content;
}
.chat-composer-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  padding-bottom: 1px;
}
.chat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.chat-icon-btn:hover {
  color: var(--accent);
  border-color: #3a3f4e;
}
.chat-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.chat-icon-btn svg {
  display: block;
  pointer-events: none;
}
.chat-send-btn {
  background: linear-gradient(180deg, #d4b56a 0%, var(--accent) 55%, #9a7a35 100%);
  color: #111;
  border-color: #8a6e2e;
}
.chat-send-btn:hover {
  color: #000;
  filter: brightness(1.06);
}

.chat-capture {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin: 0 0 0.45rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(28, 30, 38, 0.95), rgba(16, 17, 22, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.chat-capture-modes {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid #2c303c;
  border-radius: 8px;
  overflow: hidden;
  background: #0e1014;
}
.chat-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin: 0;
  padding: 0.35rem 0.55rem;
  border: none;
  border-right: 1px solid #2c303c;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  line-height: 1;
}
.chat-mode-btn:last-child { border-right: none; }
.chat-mode-btn svg { display: block; pointer-events: none; opacity: 0.85; }
.chat-mode-btn:hover { color: #e8e4d8; background: rgba(212, 181, 106, 0.06); }
.chat-mode-btn.is-active {
  color: #111;
  background: linear-gradient(180deg, #d4b56a 0%, var(--accent) 60%, #9a7a35 100%);
}
.chat-mode-btn.is-active svg { opacity: 1; color: #111; }
.chat-record-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.55rem;
  height: 2.55rem;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #4a3a1e;
  background: radial-gradient(circle at 35% 30%, #3a3224 0%, #1a1610 70%);
  color: var(--accent);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
}
.chat-record-btn svg { display: block; pointer-events: none; }
.chat-record-btn:hover { filter: brightness(1.08); color: #f0d78a; }
.chat-record-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.chat-record-btn.is-recording {
  color: #111;
  border-color: #a33;
  background: radial-gradient(circle at 35% 30%, #e85a5a 0%, #a22222 72%);
  animation: chat-rec-glow 1.1s ease-in-out infinite;
}
.chat-record-pulse {
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  border: 2px solid rgba(220, 70, 70, 0.55);
  opacity: 0;
  pointer-events: none;
}
.chat-record-btn.is-recording .chat-record-pulse {
  animation: chat-rec-pulse 1.1s ease-out infinite;
  opacity: 1;
}
@keyframes chat-rec-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 60, 60, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(220, 60, 60, 0); }
}
@keyframes chat-rec-pulse {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.35); opacity: 0; }
}
.chat-record-meta {
  flex: 1 1 auto;
  min-width: 4.5rem;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.chat-chrome-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  flex-shrink: 0;
}
.chat-shell-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.chat-chrome-actions .badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
}
.chat-capture.is-recording .chat-record-meta { color: #e8a0a0; }
.chat-capture-review {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0 0 0.5rem;
  padding: 0.65rem 0.7rem 0.75rem;
  border: 1px solid #3a3428;
  border-radius: 10px;
  background: linear-gradient(180deg, #17151a, #101014);
  box-shadow: inset 0 0 0 1px rgba(212, 181, 106, 0.06);
}
.chat-capture-review[hidden] { display: none !important; }
.chat-review-media {
  display: flex;
  justify-content: center;
  background: #0a0b0e;
  border: 1px solid #2a2d36;
  border-radius: 8px;
  overflow: hidden;
  min-height: 2.5rem;
}
.chat-review-player {
  width: 100%;
  max-height: 220px;
  display: block;
  background: #000;
}
audio.chat-review-player {
  min-height: 2.5rem;
  padding: 0.35rem;
}
.chat-review-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0;
}
.chat-capture-review textarea {
  min-height: 4rem;
  max-height: 9rem;
  margin: 0;
  resize: vertical;
  font-size: 0.95rem;
}
.chat-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}
.chat-review-actions .secondary {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}
.chat-review-send {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid #8a6e2e;
  background: linear-gradient(180deg, #d4b56a 0%, var(--accent) 55%, #9a7a35 100%);
  color: #111;
  cursor: pointer;
}
.chat-review-send:hover { filter: brightness(1.06); }
.chat-review-send:disabled { opacity: 0.55; cursor: wait; }
.chat-composer.is-reviewing .chat-composer-row { opacity: 0.55; pointer-events: none; }

@media (max-width: 720px) {
  .chat-capture {
    gap: 0.4rem;
    padding: 0.3rem 0.35rem;
  }
  .chat-mode-btn span { display: none; }
  .chat-mode-btn { padding: 0.42rem 0.55rem; }
  .chat-record-meta { font-size: 0.68rem; min-width: 3.2rem; }
  .chat-chrome-actions { gap: 0.18rem; }
  .chat-chrome-actions .chat-sound-btn.chat-icon-btn,
  .chat-shell-tools .shell-icon-btn {
    width: 1.7rem;
    height: 1.7rem;
  }
  .chat-review-actions { justify-content: stretch; }
  .chat-review-actions > * { flex: 1; text-align: center; }
}



/* Blank login — no branding */
body.bare { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
body.bare .nav { display: none; }
.bare-auth { max-width: 22rem; width: 100%; margin: 0 auto; padding: 1.5rem; }
.auth-blank { background: transparent; border: none; box-shadow: none; padding: 0; }
.auth-blank input[type="email"],
.auth-blank input[type="password"] {
  width: 100%;
  margin: 0 0 0.75rem;
  padding: 0.7rem 0.85rem;
  background: #111;
  border: 1px solid #2a2a2a;
  color: #ddd;
  border-radius: 4px;
}
.auth-blank .actions { margin-top: 0.5rem; }
.auth-blank button[type="submit"] {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #aaa;
}
.auth-blank button[type="submit"]:hover { color: #eee; border-color: #555; }
.auth-blank .error-box:empty { display: none; }


/* @mention autocomplete */
.chat-mention-menu {
  position: absolute;
  left: 0.55rem;
  right: 0.55rem;
  bottom: calc(100% + 0.25rem);
  max-height: 11rem;
  overflow-y: auto;
  z-index: 40;
  margin: 0;
  padding: 0.25rem 0;
  border: 1px solid #3a3428;
  border-radius: 8px;
  background: #14161c;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}
.chat-composer {
  position: relative;
}
.chat-mention-menu[hidden] {
  display: none !important;
}
.chat-mention-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.85rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chat-mention-item:hover,
.chat-mention-item.is-active {
  background: rgba(196, 163, 90, 0.12);
  color: var(--accent);
}
.chat-mention-name {
  font-size: 0.9rem;
  font-weight: 700;
}
.chat-mention-email {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Media Pool */
.media-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.media-header h1 { margin: 0 0 0.25rem; }
.media-quota {
  min-width: 12rem;
  max-width: 18rem;
  flex: 1;
}
.media-quota-bar {
  height: 8px;
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.media-quota-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent, #c4a35a);
  transition: width 0.2s ease;
}
.media-quota.near-full .media-quota-bar span { background: #b84a3a; }
.media-quota-text {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}
.media-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.media-toolbar input[type="search"] {
  flex: 1;
  min-width: 10rem;
  max-width: 22rem;
  margin: 0;
}
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}
.media-card {
  border: 1px solid var(--border);
  background: var(--panel-2, #121214);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.media-thumb {
  display: block;
  aspect-ratio: 16 / 10;
  background: #0a0a0c;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-badge-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.media-type-badge {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--accent, #c4a35a);
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  background: #0e0e10;
}
.media-meta {
  padding: 0.65rem 0.75rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}
.media-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-sub {
  font-size: 0.75rem;
  color: var(--muted);
}
.media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.media-actions .btn,
.media-actions button {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}
.media-empty { margin-top: 1rem; }

/* --- Workshell (Phase 2) --- */
/* Flex column so real nav height (wrapped links on phones) is never
   subtracted with a magic rem — that was clipping the chat composer. */
/* --app-height tracks visualViewport on mobile (see app.js) so the Android
   keyboard cannot leave a black --bg void under the shell / over the composer. */
body.has-workshell {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: var(--app-height, 100vh);
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100vh);
  max-height: var(--app-height, 100dvh);
  overscroll-behavior: none;
}
body.has-workshell .nav,
body.has-workshell > .shell-top-tabs {
  flex-shrink: 0;
}
body.has-workshell > .container.shell-container {
  max-width: none;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workshell {
  --shell-chat-pct: 38%;
  flex: 1;
  min-height: 0;
  display: grid;
  /* Default / float / hidden: dashboard owns 100% width — no chat track. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  position: relative;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(124, 92, 255, 0.07), transparent 42%),
    radial-gradient(ellipse at 90% 80%, rgba(196, 163, 90, 0.05), transparent 40%),
    var(--bg);
}

/* Only docked mode reserves a chat column. */
.workshell.shell-mode-docked {
  grid-template-columns: minmax(0, 1fr) var(--shell-chat-pct);
}

.workshell.shell-mode-float,
.workshell.shell-mode-hidden {
  grid-template-columns: minmax(0, 1fr) !important;
}

/* Dock must not occupy a track unless docked (hidden attr alone is not enough
   if a two-column template is still active). */
.workshell:not(.shell-mode-docked) .shell-chat-dock,
.shell-chat-dock[hidden] {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

.shell-main {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 1.1rem 1.25rem 2rem;
  width: 100%;
}

/* When chat is not docked, main spans the only track at full width and the
   dashboard card is allowed to grow (980px max left a fake empty right column). */
.workshell:not(.shell-mode-docked) .shell-main {
  grid-column: 1 / -1;
  max-width: none;
}

.shell-main .card {
  max-width: 980px;
  width: 100%;
}

.workshell:not(.shell-mode-docked) .shell-main .card {
  max-width: none;
}

.shell-chat-dock {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: rgba(14, 15, 18, 0.96);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
}

.shell-chat-toolbar {
  position: absolute;
  top: 0.28rem;
  right: 0.4rem;
  z-index: 6;
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0;
  border: none;
  background: transparent;
  flex-shrink: 0;
  pointer-events: none;
}
.shell-chat-toolbar[hidden],
.shell-chat-toolbar[aria-hidden="true"] {
  display: none !important;
}

.shell-chat-toolbar .shell-label {
  display: none;
}

.shell-chat-toolbar .shell-tools {
  display: flex;
  gap: 0.25rem;
  pointer-events: auto;
}

.shell-icon-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.shell-icon-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

#shell-chat,
#shell-chat-float {
  flex: 1;
  min-height: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#shell-chat .chat-header,
#shell-chat-float .chat-header {
  padding: 0.28rem 0.45rem;
  border-bottom: 1px solid var(--border);
}
#shell-chat .chat-header[hidden],
#shell-chat-float .chat-header[hidden],
#shell-chat .chat-header:empty,
#shell-chat-float .chat-header:empty {
  display: none !important;
  padding: 0;
  border: none;
}
#shell-chat .chat-header h1,
#shell-chat-float .chat-header h1,
#shell-chat .chat-title,
#shell-chat-float .chat-title,
#shell-chat .chat-subtitle,
#shell-chat-float .chat-subtitle {
  display: none;
}
#shell-chat .chat-messages,
#shell-chat-float .chat-messages {
  max-height: none;
  flex: 1;
  min-height: 0;
}
#shell-chat.chat-dragover,
#shell-chat-float.chat-dragover {
  outline-offset: -2px;
}
#shell-chat .chat-composer,
#shell-chat-float .chat-composer {
  padding: 0.55rem 0.7rem 0.7rem;
}
#shell-chat .chat-composer textarea,
#shell-chat-float .chat-composer textarea {
  min-height: 40px;
  font-size: 0.9rem;
}
#shell-chat .chat-icon-btn,
#shell-chat-float .chat-icon-btn {
  width: 2.15rem;
  height: 2.15rem;
}

.shell-splitter {
  position: absolute;
  left: -4px;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 3;
}
.shell-splitter::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 30%;
  bottom: 30%;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.15s;
}
.shell-splitter:hover::after,
.workshell.shell-resizing .shell-splitter::after {
  background: var(--accent);
}
.workshell.shell-resizing {
  cursor: col-resize;
  user-select: none;
}

/* FAB */
.shell-fab {
  position: fixed;
  right: 1.15rem;
  bottom: 1.15rem;
  z-index: 40;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 999px;
  border: 1px solid #5a4a28;
  background:
    radial-gradient(circle at 30% 25%, #e0c27a, var(--accent) 55%, #8a6e2e);
  color: #111;
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 10px 28px rgba(0, 0, 0, 0.55),
    0 0 24px rgba(196, 163, 90, 0.25);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.shell-fab:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}
.shell-fab[hidden] {
  display: none !important;
}

/* Floating chat panel */
.shell-float {
  position: fixed;
  right: 1.15rem;
  bottom: 5rem;
  width: min(380px, calc(100vw - 1.5rem));
  height: min(520px, calc(100vh - 6.5rem));
  z-index: 45;
  display: flex;
  flex-direction: column;
  background: rgba(16, 17, 22, 0.98);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(196, 163, 90, 0.12);
  overflow: hidden;
}
.shell-float[hidden] {
  display: none !important;
}
.shell-float.dragging {
  opacity: 0.95;
}
.shell-float-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0.28rem 0.4rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #1c1e26, #12141a);
  cursor: grab;
  flex-shrink: 0;
  touch-action: none;
}
.shell-float-head:active {
  cursor: grabbing;
}
.shell-float-head .shell-label {
  display: none;
}
.shell-float-head .shell-tools {
  display: flex;
  gap: 0.25rem;
}
.shell-float-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Legacy bottom tab bar — permanently retired (top tabs reclaim that strip) */
.shell-mobile-tabs {
  display: none !important;
}

/* Mobile top tab strip — Chat | Drafts | Media + ⋯ overflow */
.shell-top-tabs {
  display: none;
  flex-shrink: 0;
  align-items: stretch;
  justify-content: space-between;
  gap: 0;
  border-bottom: 1px solid #3a3428;
  background: linear-gradient(180deg, #181a22, #0e0f14);
  box-shadow: 0 1px 0 rgba(196, 163, 90, 0.1), 0 8px 20px rgba(0, 0, 0, 0.28);
  z-index: 120;
  padding: 0;
  padding-top: env(safe-area-inset-top, 0);
  position: relative;
  pointer-events: auto;
  isolation: isolate;
}
.shell-top-tabs[hidden] {
  display: none !important;
}
.shell-top-tabs-main {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  min-width: 0;
}
.shell-top-tab {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 2.85rem;
  min-width: 0;
  padding: 0.65rem 0.45rem;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
  touch-action: manipulation;
  pointer-events: auto;
  box-sizing: border-box;
}
a.shell-top-tab[data-mobile-tab-link] {
  /* Guarantee Media (and other link-tabs) receive taps — no overlay steal */
  position: relative;
  z-index: 2;
  -webkit-user-select: none;
  user-select: none;
}
.shell-top-tab + .shell-top-tab {
  border-left: 1px solid rgba(42, 46, 58, 0.85);
}
.shell-top-tab:hover,
.shell-top-tab:focus-visible {
  color: var(--text);
  outline: none;
  background: rgba(196, 163, 90, 0.07);
}
.shell-top-tab.is-active {
  color: var(--accent);
  background: rgba(196, 163, 90, 0.12);
}
.shell-top-tab.is-active::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  box-shadow: 0 0 10px rgba(196, 163, 90, 0.45);
}
.shell-top-overflow {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  border-left: 1px solid rgba(42, 46, 58, 0.85);
}
.shell-top-more {
  min-width: 2.75rem;
  min-height: 2.55rem;
  margin: 0;
  padding: 0 0.65rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.08em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.shell-top-more:hover,
.shell-top-more:focus-visible,
.shell-top-more[aria-expanded="true"] {
  background: rgba(196, 163, 90, 0.1);
  outline: none;
  color: var(--text);
}
.shell-top-menu {
  position: absolute;
  top: calc(100% + 2px);
  right: 0.35rem;
  min-width: 10.5rem;
  padding: 0.35rem 0;
  border: 1px solid #3a3428;
  border-radius: 8px;
  background: #14161c;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 80;
}
.shell-top-menu[hidden] {
  display: none !important;
}
.shell-top-menu a,
.shell-top-menu .linkish,
.shell-top-menu button.linkish {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.9rem;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.shell-top-menu a:hover,
.shell-top-menu .linkish:hover,
.shell-top-menu button.linkish:hover {
  background: rgba(196, 163, 90, 0.1);
  color: var(--accent);
  text-decoration: none;
}
.shell-top-logout {
  display: block;
  width: 100%;
  margin: 0;
  border-top: 1px solid var(--border);
  padding-top: 0.15rem;
  margin-top: 0.15rem;
}

/* Mobile: top tabs + exclusive panes; classic .nav hidden on workshell */
@media (max-width: 860px) {
  /* Pin shell to the layout viewport edges. Explicit height alone leaves a
     black --bg void under the composer on Firefox Android when JS height is
     short of the real visible area (keyboard closed). bottom:0 fills it. */
  html.vv-locked {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--panel, var(--bg));
  }
  html.vv-locked body.has-workshell,
  html.vv-locked body.has-chat {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--app-offset-top, 0px);
    bottom: 0;
    width: 100%;
    /* Stretch between top and bottom — do not trust a short --app-height */
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--panel, var(--bg));
  }
  /* Keyboard open: hug visualViewport so composer sits on the keys */
  html.vv-locked body.has-workshell.keyboard-open,
  html.vv-locked body.has-chat.keyboard-open {
    bottom: auto;
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    min-height: var(--app-height, 100dvh);
    background: var(--bg);
  }

  /* Top tabs replace the fat NIHILUS SOCIAL + link row on all chrome pages */
  body.has-shell-chrome > .nav {
    display: none !important;
  }

  body.has-shell-chrome > .shell-top-tabs:not([hidden]),
  .shell-top-tabs:not([hidden]) {
    display: flex;
  }

  .workshell.shell-mode-docked,
  .workshell.shell-mode-float,
  .workshell.shell-mode-hidden {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr);
    /* flex fallback so only one pane owns the track */
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  /* Default (no tab attr yet): show drafts so list is never blank-covered */
  .workshell .shell-main {
    display: block;
    flex: 1 1 0;
    min-height: 0;
  }
  .workshell .shell-chat-dock {
    border-left: none;
    box-shadow: none;
    background: var(--bg);
  }

  /* Chat tab: exclusive full pane — no absolute overlay over dashboard */
  .workshell[data-mobile-tab="chat"] .shell-main {
    display: none !important;
  }
  .workshell[data-mobile-tab="chat"] .shell-chat-dock {
    display: flex !important;
    flex-direction: column !important;
    position: relative;
    inset: auto;
    z-index: auto;
    flex: 1 1 0;
    align-self: stretch;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100%;
    border: none;
    pointer-events: auto !important;
    overflow: hidden;
    background: var(--panel);
  }

  /* Drafts tab: dashboard list only; chat dock fully out of flow */
  .workshell[data-mobile-tab="drafts"] .shell-main {
    display: block !important;
    flex: 1 1 0;
    min-height: 0;
    grid-column: 1 / -1;
  }
  .workshell[data-mobile-tab="drafts"] .shell-chat-dock,
  .workshell[data-mobile-tab="drafts"] .shell-chat-dock[hidden] {
    display: none !important;
    flex: 0 0 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }

  /* Keep docked chat shell filling the pane; kill standalone min-heights */
  body.has-workshell #shell-chat.chat-shell,
  body.has-workshell #shell-chat {
    flex: 1 1 0;
    align-self: stretch;
    min-height: 0 !important;
    max-height: none !important;
    height: 100% !important;
    margin: 0;
    border-radius: 0;
    display: flex !important;
    flex-direction: column !important;
    background: var(--panel);
  }
  body.has-workshell #shell-chat .chat-messages {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    max-height: none !important;
  }
  /* Composer glued to the bottom of the pane.
     Firefox Android already keeps system nav outside the layout viewport, so
     stacking env(safe-area-inset-bottom) here opens a dead strip under the
     composer. Zero bottom pad when keys are closed — 0.55rem was still a
     visible unused strip above the system nav (matching panel bg). */
  body.has-workshell #shell-chat .chat-composer {
    flex: 0 0 auto;
    margin-top: auto;
    margin-bottom: 0;
    padding-bottom: 0;
    background: var(--panel-2, var(--panel));
    border-top: 1px solid var(--border);
    /* Extend paint past bottom to kill subpixel / flex shortfall hairlines */
    box-shadow: 0 8px 0 0 var(--panel-2, var(--panel));
  }
  html.vv-locked body.has-workshell:not(.keyboard-open) .shell-chat-dock,
  html.vv-locked body.has-workshell:not(.keyboard-open) #shell-chat {
    background: var(--panel) !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
  }
  /* Keyboard closed: keep composer flush on the nav edge (no empty strip). */
  html.vv-locked body.has-workshell:not(.keyboard-open) #shell-chat .chat-composer,
  html.vv-locked body.has-chat:not(.keyboard-open) .chat-composer {
    padding-bottom: 0.12rem;
    margin-bottom: 0;
    box-shadow: 0 10px 0 0 var(--panel-2, var(--panel));
  }
  body.has-workshell #shell-chat .chat-capture {
    flex-shrink: 0;
  }
  /* Entire workshell + container stretch so chat can own the bottom edge */
  body.has-workshell > .container.shell-container,
  body.has-workshell .workshell {
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
  }
  body.has-workshell .workshell[data-mobile-tab="chat"] {
    height: 100%;
  }
  body.has-workshell.keyboard-open .shell-top-tabs,
  body.has-workshell.keyboard-open .shell-mobile-tabs,
  body.has-chat.keyboard-open .shell-top-tabs {
    display: none !important;
  }
  /* Kill safe-area / black strip under composer while keyboard is up */
  body.has-workshell.keyboard-open #shell-chat .chat-composer,
  body.has-chat.keyboard-open .chat-composer {
    padding-bottom: 0.4rem;
    margin-bottom: 0;
    background: var(--bg, #0b0c10);
    position: relative;
    z-index: 5;
  }
  body.has-workshell.keyboard-open #shell-chat,
  body.has-chat.keyboard-open .chat-shell {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
  }
  /* Messages fill remaining space; composer stays glued above keyboard */
  body.has-workshell.keyboard-open #shell-chat .chat-messages,
  body.has-chat.keyboard-open .chat-messages {
    padding-bottom: 0.25rem;
  }

  /* Top tabs replace FAB / float on narrow viewports */
  body.has-workshell .shell-fab,
  body.has-workshell .shell-float {
    display: none !important;
  }

  .shell-splitter {
    display: none;
  }

  .shell-chat-toolbar .shell-tools [data-shell-action="float"],
  .chat-shell-tools [data-shell-action="float"] {
    display: none;
  }
}

@media (min-width: 861px) {
  .shell-top-tabs,
  .shell-mobile-tabs {
    display: none !important;
  }
}

/* grit accent line under nav when shell chrome active (desktop) */
body.has-shell-chrome .nav {
  border-bottom-color: #3a3428;
  box-shadow: 0 1px 0 rgba(196, 163, 90, 0.08);
}

/* --- Phase 3 Modulon OS popouts --- */
.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.page-header-row h1 { margin-top: 0; }
.shell-popout-btn {
  flex-shrink: 0;
  white-space: nowrap;
}
.media-header-actions,
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.chat-sound-btn.chat-icon-btn {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
}
.chat-sound-btn.chat-icon-btn svg {
  width: 16px;
  height: 16px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.modulon-toast {
  position: fixed;
  z-index: 9999;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  max-width: min(480px, calc(100vw - 2rem));
  padding: 0.75rem 1.1rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 0.9rem;
}
.modulon-toast.is-error {
  border-left-color: var(--danger);
}
.modulon-toast[hidden] { display: none !important; }

body.is-popout {
  min-height: 100vh;
}
body.is-popout > .container.popout-container {
  max-width: none;
  width: 100%;
  padding: 0;
  margin: 0;
  min-height: 100vh;
}
.popout-frame {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}
.popout-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 22, 28, 0.95);
}
.popout-bar .brand {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.popout-bar h1 {
  margin: 0;
  font-size: 1rem;
  flex: 1;
  font-weight: 600;
}
.popout-bar h1.sr-only {
  flex: 0;
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.popout-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
}
.popout-root > .chat-shell,
.popout-root > .card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
}
.popout-root .chat-messages {
  flex: 1;
  min-height: 200px;
}
.workshell.shell-chat-popped .shell-fab {
  display: none !important;
}
#popout-status.is-error {
  background: rgba(232, 93, 93, 0.2);
  color: #ffb4b4;
}


/* --- Draft maker + full-width chat --- */
body.has-chat > .container.chat-container,
body.has-chat > .container {
  max-width: none;
  width: 100%;
  padding: 0.75rem 1rem 1.5rem;
}
body.has-chat .chat-shell {
  max-width: none;
  width: 100%;
  min-height: 0;
  height: calc(100vh - 5.5rem);
  height: calc(100dvh - 5.5rem);
}
@media (max-width: 860px) {
  body.has-chat {
    display: flex;
    flex-direction: column;
    height: var(--app-height, 100vh);
    height: var(--app-height, 100dvh);
    overflow: hidden;
    overscroll-behavior: none;
  }
  body.has-chat .nav {
    flex-shrink: 0;
    padding: 0.45rem 0.75rem;
  }
  body.has-chat .nav-right .muted { display: none; }
  body.has-chat > .container.chat-container,
  body.has-chat > .container {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.has-chat .chat-shell {
    flex: 1 1 0;
    min-height: 0 !important;
    height: 100% !important;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    display: flex !important;
    flex-direction: column !important;
    background: var(--panel);
  }
  body.has-chat .chat-messages {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    max-height: none !important;
  }
  body.has-chat .chat-composer {
    flex: 0 0 auto;
    margin-top: auto;
    margin-bottom: 0;
    padding-bottom: 0.12rem;
    background: var(--panel-2, var(--panel));
    box-shadow: 0 10px 0 0 var(--panel-2, var(--panel));
  }
}
.container:has(.chat-shell) {
  max-width: none;
}
body:not(.has-chat):not(.has-workshell) .container:has(.chat-shell) {
  /* keep standalone chat wide only when has-chat is set; workshell unchanged */
}

.draft-stage {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.draft-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse at 0% 0%, rgba(196, 163, 90, 0.12), transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(124, 92, 255, 0.08), transparent 45%),
    var(--panel);
}
.draft-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0 0 0.35rem;
}
.draft-hero h1 { margin: 0 0 0.4rem; font-size: 1.6rem; }
.draft-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-width: min(100%, 280px);
}
.draft-preview-pill {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 0.8rem;
}
.draft-preview-pill.ok { border-color: rgba(62, 207, 142, 0.45); color: #b6f5d4; }
.draft-preview-pill.bad { border-color: rgba(232, 93, 93, 0.5); color: #ffb4b4; }

.draft-form {
  display: grid;
  gap: 1rem;
}
.draft-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}
.draft-panel h2 {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.draft-hint { margin: 0 0 0.85rem; }

.platform-toggles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
}
.platform-toggle {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  color: var(--text);
}
.platform-toggle input { width: auto; accent-color: var(--accent); }
.platform-toggle.is-on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(196, 163, 90, 0.35);
}
.platform-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: #0b0c0f;
  border: 1px solid var(--border);
}
.platform-icon-fb { color: #8ab4ff; }
.platform-icon-ig { color: #ff9ad5; }
.platform-icon-th { color: #c4a35a; }
.platform-icon-x { color: var(--text); }
.platform-copy { display: flex; flex-direction: column; gap: 0.15rem; }
.platform-copy strong { font-size: 0.95rem; }
.platform-copy small { color: var(--muted); font-size: 0.78rem; }

.platform-rules-live {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  margin-top: 0.9rem;
}
.draft-rule-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  background: rgba(11, 12, 15, 0.55);
}
.draft-rule-card.has-error { border-color: rgba(232, 93, 93, 0.55); }
.draft-rule-card header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
}
.draft-rule-card ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.draft-rule-stats { font-size: 0.82rem; color: var(--muted); margin: 0.25rem 0; }

.draft-chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  margin: 0.15rem 0.25rem 0.15rem 0;
  background: var(--panel-2);
}
.draft-chip.ok { color: #b6f5d4; border-color: rgba(62, 207, 142, 0.4); }
.draft-chip.soft { color: #ffe2a0; border-color: rgba(230, 184, 77, 0.45); }
.draft-chip.bad { color: #ffb4b4; border-color: rgba(232, 93, 93, 0.5); }
.draft-chip em { font-style: normal; color: var(--muted); }

.draft-char-row { min-height: 1.5rem; margin-top: 0.35rem; }
.draft-overrides { margin-top: 0.85rem; }
.draft-overrides summary {
  cursor: pointer;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.draft-media-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.draft-media.is-drag {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
}
.draft-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.65rem;
}
.draft-thumb {
  position: relative;
  display: flex;
  gap: 0.55rem;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
}
.draft-thumb-media {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  background: #0b0c0f;
  flex-shrink: 0;
}
.draft-thumb-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.draft-thumb-badge, .draft-thumb-badge {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.draft-thumb-name {
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}
.draft-thumb-remove {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  line-height: 1;
}
.draft-accept-row { display: flex; gap: 0.25rem; margin-top: 0.25rem; }
.draft-accept {
  font-size: 0.65rem;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.draft-accept.ok { color: #b6f5d4; }
.draft-accept.no { color: #ffb4b4; opacity: 0.7; text-decoration: line-through; }

.draft-warnings {
  border: 1px solid rgba(230, 184, 77, 0.35);
  background: rgba(230, 184, 77, 0.08);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}
.draft-warnings .draft-flag { color: #ffe2a0; margin: 0 0 0.4rem; font-weight: 600; }
.draft-warnings ul { margin: 0; padding-left: 1.1rem; }
.draft-warnings li.error { color: #ffb4b4; }
.draft-warnings li.warn { color: #ffe2a0; }

.draft-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.draft-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
  color: var(--text);
}

.draft-modal[hidden] { display: none !important; }
.draft-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.draft-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}
.draft-modal-panel {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(85vh, 820px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  padding: 1rem;
}
.draft-modal-head, .draft-modal-foot, .draft-modal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.draft-modal-head { margin-bottom: 0.75rem; }
.draft-modal-toolbar { margin-bottom: 0.75rem; }
.draft-modal-toolbar input[type="search"] { max-width: 280px; }
.draft-modal-foot { margin-top: 0.85rem; }
.draft-pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem;
}
.draft-pool-card {
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
  color: var(--text);
  cursor: pointer;
}
.draft-pool-card.is-on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(196, 163, 90, 0.35);
}
.draft-pool-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #0b0c0f;
  border: 1px solid var(--border);
  margin-bottom: 0.4rem;
}
.draft-pool-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 720px) {
  .draft-hero { flex-direction: column; }
  .platform-toggles { grid-template-columns: 1fr; }
}

/* --- Overnight pass: dash empty, countdown, media bulk, chat unread, draft polish --- */
.dash-empty {
  text-align: center;
  padding: 2.25rem 1rem 1.75rem;
}
.dash-empty-kicker {
  margin: 0 0 0.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.85rem;
}
.dash-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}
.dash-invite-hint { margin-bottom: 1rem; }
.flash.info {
  border: 1px solid rgba(196, 163, 90, 0.35);
  background: rgba(196, 163, 90, 0.08);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
}

.countdown {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.countdown.is-due { color: var(--danger); }
.countdown-block { margin: 0.75rem 0; }

.media-sort-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}
.media-sort-label select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
}
.media-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.65rem 0 0.85rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(196, 163, 90, 0.35);
  background: rgba(196, 163, 90, 0.07);
  border-radius: var(--radius);
}
.media-bulk[hidden] { display: none !important; }
.media-card {
  position: relative;
}
.media-card.is-selected {
  outline: 1px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(196, 163, 90, 0.25);
}
.media-check {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  z-index: 2;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  padding: 0.15rem 0.2rem;
  border: 1px solid var(--border);
}

.chat-jump {
  display: flex;
  justify-content: center;
  padding: 0.25rem 0;
  position: relative;
  z-index: 2;
}
.chat-jump[hidden] { display: none !important; }
.chat-jump button {
  background: var(--panel-2);
  color: var(--accent);
  border: 1px solid rgba(196, 163, 90, 0.45);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.chat-new-marker {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.65rem 0;
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chat-new-marker::before,
.chat-new-marker::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(196, 163, 90, 0.45);
}
.chat-sound-btn.is-on {
  border-color: var(--accent);
  color: var(--accent);
}

.draft-override-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.55rem 0 0.25rem;
}
.draft-override-strip[hidden] { display: none !important; }
.draft-override-pill {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.draft-override-pill.has {
  color: var(--accent);
  border-color: rgba(196, 163, 90, 0.5);
}
.draft-overrides {
  position: sticky;
  top: 3.5rem;
  z-index: 3;
  background: rgba(20, 22, 28, 0.96);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem 0.75rem;
  backdrop-filter: blur(6px);
}
.draft-override-fields[hidden] { display: none !important; }
.draft-kbd-hint { font-size: 0.78rem; margin-top: 0.65rem; }
.draft-countdown-live { margin: 0.4rem 0 0; color: var(--accent); }

/* Mobile composer / safe area */
@supports (padding: max(0px)) {
  /* Do NOT push chat-composer with safe-area-inset-bottom on mobile Firefox —
     that inset stacks with the vv-lock and opens the black void under the
     composer above system nav. Workshell/has-chat rules own composer padding. */
  .shell-fab {
    bottom: max(0.85rem, env(safe-area-inset-bottom));
    right: max(0.85rem, env(safe-area-inset-right));
  }
}
@media (max-width: 720px) {
  .chat-composer-row {
    align-items: flex-end;
  }
  .chat-composer textarea {
    min-height: 2.6rem;
    font-size: 16px; /* avoid iOS zoom */
  }
  .draft-stage {
    padding-bottom: 1.5rem;
  }
  .media-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}


/* Chat older-history load indicator */
.chat-loading-older {
  text-align: center;
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
