:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  --page-bg: #f5f7fa;
  --sidebar-bg: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f7f9fc;
  --surface-hover: #eef2f6;
  --text: #152238;
  --heading: #0f1728;
  --muted: #65748a;
  --border: #dfe5ec;
  --border-strong: #c5cfdb;
  --accent: #0b9f7c;
  --accent-strong: #087b61;
  --accent-soft: #e5f7f1;
  --focus: rgba(11, 159, 124, 0.3);
  --danger: #bd3744;
  --danger-strong: #9f2935;
  --danger-soft: #fff0f2;
  --success-text: #11613d;
  --success-soft: #e8f7ee;
  --warning-text: #80510e;
  --warning-soft: #fff3d9;
  --shadow: 0 8px 24px rgba(23, 35, 55, 0.07);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #09111f;
  --sidebar-bg: #0e1828;
  --surface: #111d30;
  --surface-subtle: #17253a;
  --surface-hover: #1b2b42;
  --text: #e7edf6;
  --heading: #f7f9fc;
  --muted: #9aacbf;
  --border: #26374e;
  --border-strong: #3a4c65;
  --accent: #23d09d;
  --accent-strong: #16aa80;
  --accent-soft: #123b35;
  --focus: rgba(35, 208, 157, 0.35);
  --danger: #e25c69;
  --danger-strong: #c44754;
  --danger-soft: #3b1c27;
  --success-text: #8be2b3;
  --success-soft: #123529;
  --warning-text: #f2c877;
  --warning-soft: #382d18;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
textarea,
.button {
  font: inherit;
  font-size: 15px;
}

h1,
h2 {
  margin: 0;
  color: var(--heading);
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(25px, 3vw, 32px);
  line-height: 1.12;
}

h2 {
  font-size: clamp(20px, 2.4vw, 24px);
  line-height: 1.2;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
}

.sidebar-brand {
  display: grid;
  gap: 1px;
  margin: 0 10px 32px;
  color: var(--heading);
  text-decoration: none;
}

.sidebar-brand span {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.sidebar-brand strong {
  font-size: 21px;
  letter-spacing: -0.03em;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.sidebar-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.sidebar-link.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 0;
  border-top: 1px solid var(--border);
}

.sidebar-footer p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sidebar-footer strong {
  color: var(--text);
}

.workspace {
  min-width: 0;
}

.workspace-topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
}

.workspace-topbar > div:first-child p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.workspace-main {
  padding: 24px 28px 48px;
}

.publisher-layout {
  width: 100%;
  max-width: 1180px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  margin: 0 auto;
  align-items: start;
}

.publisher-rail {
  position: sticky;
  top: 108px;
  display: grid;
  gap: 16px;
}

.feed-column {
  min-width: 0;
}

.feed-heading {
  min-height: 52px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.feed-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.post-feed {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.feed-post,
.workflow-card,
.auth-card,
.settings-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.feed-post {
  min-width: 0;
  overflow: hidden;
}

.feed-post__header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.feed-post__header > div {
  display: grid;
  gap: 1px;
}

.feed-post__header strong {
  color: var(--heading);
  font-size: 14px;
}

.feed-post__header span:not(.status) {
  color: var(--muted);
  font-size: 12px;
}

.feed-post__content {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-width: 0;
}

.feed-post__media {
  min-width: 0;
  margin: 0;
  border-right: 1px solid var(--border);
  background: #071424;
}

.feed-post__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: contain;
}

.feed-post__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.feed-post__caption {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 15px;
  line-height: 1.58;
}

.feed-post__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
}

.feed-post__actions form {
  margin: 0;
}

.feed-post__actions .button {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 14px;
}

.feed-post__error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.inline-schedule {
  flex-basis: 100%;
  display: grid;
  gap: 7px;
}

.workflow-card {
  min-width: 0;
  padding: 20px;
}

.composer-card h2,
.usage-card h2 {
  margin-bottom: 6px;
}

.lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.brief-form,
.settings-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

label {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

input[type="password"],
input[type="datetime-local"],
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  background: var(--surface);
}

textarea {
  resize: vertical;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button-primary {
  color: #ffffff;
  border-color: var(--accent-strong);
  background: var(--accent);
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button-secondary {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface);
}

.button-secondary:hover {
  background: var(--surface-hover);
}

.button-danger {
  color: #ffffff;
  border-color: var(--danger-strong);
  background: var(--danger);
}

.button-danger:hover {
  background: var(--danger-strong);
}

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

.button-full,
.brief-form .button {
  width: 100%;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.account-email {
  max-width: 210px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.theme-toggle {
  min-width: 100px;
}

.status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.status-configured {
  color: var(--success-text);
  background: var(--success-soft);
}

.status-missing {
  color: var(--warning-text);
  background: var(--warning-soft);
}

.status-neutral {
  color: var(--muted);
  background: var(--surface-subtle);
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 0;
}

.usage-grid div,
.credential-summary div,
.post-summary div,
.post-status div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-subtle);
}

.usage-grid dt,
.credential-summary dt,
.post-summary dt,
.post-status dt,
.metadata-label {
  color: var(--muted);
  font-size: 12px;
}

.usage-grid dd,
.credential-summary dd,
.post-summary dd,
.post-status dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.alert {
  max-width: 1180px;
  margin: 0 auto 16px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 14px;
}

.alert-error {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

.alert-success {
  color: var(--success-text);
  border-color: var(--success-text);
  background: var(--success-soft);
}

.empty-state {
  padding: 20px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-subtle);
}

.muted-copy,
.metadata {
  color: var(--muted);
}

.metadata {
  margin: 14px 0 0;
  font-size: 13px;
}

.text-link {
  color: var(--accent-strong);
  font-weight: 750;
}

.page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  padding: 36px;
  text-align: center;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

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

.product-name {
  color: var(--heading);
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
}

.settings-card {
  width: 100%;
  padding: 30px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.credential-summary,
.post-summary,
.post-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.settings-form {
  gap: 18px;
  margin-top: 26px;
}

.security-note {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 1080px) {
  .publisher-layout {
    grid-template-columns: minmax(0, 1fr) 290px;
  }

  .feed-post__content {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .account-email {
    display: none;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .publisher-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .publisher-rail {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    position: sticky;
    width: 100%;
    height: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-brand {
    margin: 0;
  }

  .sidebar-brand span {
    font-size: 9px;
  }

  .sidebar-brand strong {
    font-size: 17px;
  }

  .sidebar-nav {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
  }

  .sidebar-link {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .sidebar-footer {
    display: none;
  }

  .workspace-topbar {
    position: static;
    align-items: flex-start;
    padding: 16px;
  }

  .workspace-topbar > div:first-child p,
  .topbar-create {
    display: none;
  }

  .workspace-main {
    padding: 16px 16px 36px;
  }

  .account-actions {
    flex-wrap: wrap;
  }

  .theme-toggle {
    min-width: auto;
  }
}

@media (max-width: 560px) {
  body,
  button,
  input,
  textarea,
  .button {
    font-size: 14px;
  }

  .app-sidebar {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .sidebar-nav {
    justify-content: stretch;
  }

  .sidebar-link {
    flex: 1;
    justify-content: center;
  }

  .workspace-topbar {
    display: grid;
    gap: 12px;
  }

  .account-actions {
    justify-content: flex-start;
  }

  .feed-post__content {
    grid-template-columns: minmax(0, 1fr);
  }

  .feed-post__media {
    width: min(100%, 240px);
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .feed-post__body {
    padding: 15px;
  }

  .feed-post__caption {
    font-size: 14px;
  }

  .page {
    padding: 16px 16px 36px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-card,
  .settings-card {
    padding: 24px 20px;
  }

  .credential-summary,
  .post-summary,
  .post-status {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}

/* Publisher queue — selected desktop/mobile direction. */
.workspace-topbar {
  min-height: 108px;
  padding: 24px 40px 20px;
  background: var(--page-bg);
  backdrop-filter: none;
}

.workspace-main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 18px 40px 64px;
}

.feed-column {
  width: 100%;
}

.feed-heading {
  min-height: 50px;
  align-items: center;
  margin-bottom: 14px;
}

.publish-safety {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid #f0d59b;
  border-radius: 9px;
  color: var(--warning-text);
  background: var(--warning-soft);
  font-size: 13px;
  font-weight: 750;
}

.publish-safety::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e7a63f;
  content: "";
}

.publish-safety--enabled {
  border-color: #a9dec2;
  color: var(--success-text);
  background: var(--success-soft);
}

.publish-safety--enabled::before {
  background: var(--accent);
}

.post-feed {
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: none;
}

.feed-post {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 220px;
  gap: 18px;
  min-height: 190px;
  padding: 16px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}

.post-feed > li:last-child .feed-post {
  border-bottom: 0;
}

.feed-post__media {
  width: 140px;
  height: 175px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #071424;
}

.feed-post__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feed-post__body {
  justify-content: flex-start;
  padding: 1px 0;
}

.feed-post__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.feed-post__meta time::before {
  margin-right: 7px;
  color: var(--border-strong);
  content: "·";
}

.feed-post__caption {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  font-size: 15px;
  line-height: 1.58;
}

.feed-post__controls {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 12px;
}

.post-state {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-subtle);
  font-size: 13px;
  font-weight: 750;
}

.post-state--prepared { border-color: #f0d59b; color: var(--warning-text); background: var(--warning-soft); }
.post-state--approved,
.post-state--scheduled { border-color: #bfd6fb; color: #2467c7; background: #edf5ff; }
.post-state--published { border-color: #a9dec2; color: var(--success-text); background: var(--success-soft); }
.post-state--failed { border-color: #f4bac0; color: var(--danger); background: var(--danger-soft); }

.feed-post__actions {
  width: 100%;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
  padding-top: 0;
}

.feed-post__actions form,
.feed-post__actions .button {
  width: 100%;
}

.feed-post__actions .button {
  min-height: 40px;
}

.inline-schedule {
  gap: 6px;
}

.inline-schedule label {
  font-size: 12px;
}

.inline-schedule input[type="datetime-local"] {
  min-height: 40px;
  padding: 7px 8px;
  font-size: 13px;
}

.publisher-composer {
  display: grid;
  grid-template-columns: minmax(180px, 0.45fr) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  margin-top: 28px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.publisher-composer h2 { font-size: 20px; }
.publisher-composer p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.publisher-composer .brief-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.publisher-composer textarea { min-height: 70px; }
.publisher-composer .button { width: auto; min-width: 112px; align-self: stretch; }

.mobile-create,
.mobile-brand,
.sr-only {
  display: none;
}

:root[data-theme="dark"] .post-state--approved,
:root[data-theme="dark"] .post-state--scheduled { border-color: #335f9d; color: #8cb8ff; background: #172a44; }

@media (max-width: 900px) {
  .workspace-topbar { padding: 20px 24px; }
  .workspace-main { padding: 16px 24px 48px; }
  .feed-post { grid-template-columns: 120px minmax(0, 1fr) 184px; gap: 14px; }
  .feed-post__media { width: 120px; height: 150px; }
}

@media (max-width: 700px) {
  .workspace-topbar { min-height: 94px; padding: 17px 16px; }
  .workspace-subtitle, .topbar-create, .account-email, .account-actions form { display: none; }
  .workspace-main { padding: 16px 16px 96px; }
  .workspace-topbar > div:first-child .mobile-brand { display: block; margin: 0 0 5px; color: var(--accent-strong); font-size: 11px; font-weight: 800; letter-spacing: 0.04em; }
  .app-sidebar { display: none; }
  .feed-heading { align-items: flex-start; }
  .feed-heading h2 { font-size: 27px; }
  .feed-heading p { font-size: 13px; }
  .publish-safety { min-height: 32px; padding: 6px 9px; font-size: 12px; }
  .feed-post { grid-template-columns: 108px minmax(0, 1fr); gap: 14px; min-height: 0; padding: 14px 0; }
  .feed-post__media { width: 108px; height: 135px; margin-left: 14px; }
  .feed-post__body { min-height: 135px; padding: 0 14px 0 0; }
  .feed-post__meta { gap: 5px; margin-bottom: 8px; }
  .feed-post__caption { -webkit-line-clamp: 4; font-size: 14px; line-height: 1.45; }
  .feed-post__controls { grid-column: 2; gap: 8px; padding-right: 14px; }
  .post-state { min-height: 28px; padding: 4px 8px; font-size: 12px; }
  .feed-post__actions { flex-direction: row; flex-wrap: wrap; }
  .feed-post__actions form { width: auto; flex: 1 1 120px; }
  .feed-post__actions .button { min-height: 42px; font-size: 14px; }
  .inline-schedule { flex-basis: 100%; }
  .publisher-composer { grid-template-columns: 1fr; gap: 14px; margin-top: 18px; padding: 18px; }
  .publisher-composer .brief-form { grid-template-columns: 1fr; }
  .publisher-composer .button { width: 100%; min-height: 44px; }
  .mobile-create { position: fixed; z-index: 20; right: 16px; bottom: 16px; left: 16px; display: inline-flex; min-height: 54px; border-radius: 12px; box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28); }
}
