:root {
  --fb-blue: #1877f2;
  --fb-blue-hover: #166fe5;
  --fb-blue-light: #e7f3ff;
  --fb-green: #42b72a;
  --fb-green-hover: #36a420;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --ink: #050505;
  --muted: #65676b;
  --border: #ced0d4;
  --divider: #dadde1;
  --hover: #f2f3f5;
  --secondary-btn: #e4e6eb;
  --secondary-btn-hover: #d8dadf;
  --ok: #31a24c;
  --err: #e41e3f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.12);
  --radius: 8px;
  --radius-btn: 6px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* legacy aliases */
  --panel: var(--surface);
  --accent: var(--fb-blue);
  --accent-hover: var(--fb-blue-hover);
  --paper: var(--surface);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--fb-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-btn);
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease;
}

.btn-primary {
  background: var(--fb-blue);
  color: #fff;
}

.btn-primary:hover {
  background: var(--fb-blue-hover);
  text-decoration: none;
}

.btn-secondary {
  background: var(--secondary-btn);
  color: var(--ink);
}

.btn-secondary:hover {
  background: var(--secondary-btn-hover);
  text-decoration: none;
}

.btn-danger {
  background: #ffeef0;
  color: var(--err);
}

.btn-danger:hover {
  background: #fdd;
  text-decoration: none;
}

.btn-google {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-google:hover {
  background: var(--hover);
  text-decoration: none;
}

.btn-save {
  background: var(--fb-green);
  color: #fff;
  width: 100%;
  margin-top: 16px;
  min-height: 40px;
}

.btn-save:hover {
  background: var(--fb-green-hover);
}

.btn-success {
  background: var(--fb-green);
  color: #fff;
}

.btn-success:hover {
  background: var(--fb-green-hover);
  text-decoration: none;
}

.btn:disabled { opacity: .55; cursor: wait; }

.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: .8125rem;
}

.btn-block { width: 100%; }

label {
  display: block;
  font-size: .9375rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: .9375rem;
  background: var(--surface);
  color: var(--ink);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--fb-blue);
  box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

.form-field { margin-bottom: 16px; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: .9375rem;
  margin-bottom: 16px;
}

.alert-error {
  background: #ffeef0;
  color: #b32d2e;
  border: 1px solid #f5c2c7;
}

.alert-success {
  background: #e7f3ef;
  color: #1c5e33;
  border: 1px solid #b7dfc9;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  min-height: 56px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fb-blue);
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-actions span,
.topbar-user {
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
  padding: 0 4px;
}

.topbar a:not(.btn) { color: var(--fb-blue); font-weight: 600; }

.page-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.settings-card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.settings-sub,
.field-hint,
.settings-meta {
  color: var(--muted);
  font-size: .9375rem;
  line-height: 1.5;
}

.settings-sub { margin: 0 0 20px; }
.field-hint { margin: 8px 0 0; }

.settings-meta {
  margin: 8px 0 20px;
  padding: 12px 14px;
  background: var(--hover);
  border-radius: var(--radius);
}

.settings-page .page-shell {
  max-width: 900px;
}

.settings-page .settings-card + .settings-card {
  margin-top: 16px;
}

.journal-table-wrap {
  overflow-x: auto;
}

.journal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9375rem;
}

.journal-table th,
.journal-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  text-align: left;
  vertical-align: top;
}

.journal-table th {
  color: var(--muted);
  font-weight: 600;
}

.journal-status-ok { color: #059669; }
.journal-status-error { color: #dc2626; }
.journal-status-running { color: #d97706; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.hidden { display: none !important; }

/* Auth — Facebook login layout */
.auth-page {
  min-height: 100vh;
  background: var(--bg);
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 32px;
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px;
}

.auth-brand {
  padding: 0 16px;
}

.auth-brand .logo {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--fb-blue);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 16px;
}

.auth-brand .tagline {
  font-size: 1.75rem;
  line-height: 1.3;
  color: var(--ink);
  margin: 0;
  max-width: 420px;
}

.auth-shell {
  display: flex;
  justify-content: center;
}

.auth-card {
  width: 100%;
  max-width: 396px;
  padding: 20px 16px 24px;
}

.auth-card h1 {
  display: none;
}

.auth-card .sub {
  display: none;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--hover);
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.tab-btn.active {
  background: var(--fb-blue-light);
  color: var(--fb-blue);
}

.social-auth {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
}

.social-note {
  color: var(--muted);
  font-size: .875rem;
  text-align: center;
  margin: 0;
}

/* Workspace */
.workspace-page {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.workspace-page > .topbar { flex: 0 0 auto; }

.workspace-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  gap: 0;
  padding: 16px;
  gap: 16px;
}

.workspace-sidebar {
  flex: 0 0 33.333%;
  width: 33.333%;
  max-width: 33.333%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.workspace-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--divider);
}

.workspace-sidebar-head h2 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
}

.workspace-count {
  color: var(--muted);
  font-size: .8125rem;
  background: var(--hover);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.workspace-sidebar .alert { margin: 12px 16px 0; }

.workspace-channel-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.workspace-loading,
.workspace-loading-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.workspace-empty-channels {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  display: grid;
  gap: 16px;
}

.workspace-channel-item {
  border: none;
  border-radius: var(--radius);
  background: var(--hover);
  overflow: hidden;
  transition: background .15s ease;
}

.workspace-channel-item:hover { background: #e4e6eb; }

.workspace-channel-item.is-active {
  background: var(--fb-blue-light);
  box-shadow: inset 3px 0 0 var(--fb-blue);
}

.workspace-channel-select {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 12px 14px 8px;
  cursor: pointer;
}

.workspace-channel-select h3 {
  margin: 0 0 6px;
  font-size: .9375rem;
  line-height: 1.35;
  color: var(--ink);
  font-weight: 600;
}

.workspace-channel-actions {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
}

.workspace-content {
  flex: 1 1 66.666%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.workspace-content-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
}

.workspace-content-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.workspace-content-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--ink);
}

.workspace-content-refreshed,
.workspace-content-next-refresh {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--muted);
}

.workspace-content-refreshed.hidden,
.workspace-content-next-refresh.hidden { display: none; }

.workspace-content-meta {
  margin-top: 2px;
  font-size: .8125rem;
  color: var(--muted);
}

.workspace-content-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.workspace-content-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--bg);
}

.workspace-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius);
  background: var(--bg);
  border: none;
}

.workspace-panel.hidden { display: none !important; }

.workspace-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.workspace-preview {
  background: var(--bg);
  font-family: var(--font);
  color: var(--ink);
  padding-bottom: 16px;
}

.workspace-boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(244, 244, 244, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.workspace-boot-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.workspace-boot-card p {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

/* Feed / preview cards (Facebook post style) */
.feed-header {
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.feed-header h2 {
  margin: 0 0 4px;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--ink);
}

.feed-header .meta {
  color: var(--muted);
  font-size: .8125rem;
}

.feed-headline {
  margin: 0 0 12px;
  padding: 0 4px;
  font-size: .9375rem;
  font-weight: 600;
  color: var(--ink);
}

.feed-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.feed-stats span {
  background: var(--hover);
  color: var(--muted);
  padding: 6px 10px;
  font-size: .8125rem;
  border-radius: 999px;
  font-weight: 600;
}

.article-card,
.workspace-preview .article-card {
  margin: 0 0 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.article-card h3,
.workspace-preview .article-card h3 {
  margin: 0 0 8px;
  font-size: .9375rem;
  line-height: 1.4;
  font-weight: 600;
}

.article-card .article-body p,
.workspace-preview .article-card .article-body p {
  margin: 0 0 8px;
  line-height: 1.5;
  font-size: .9375rem;
  color: var(--ink);
}

.article-card .meta-line,
.workspace-preview .article-card .meta-line {
  color: var(--muted);
  font-size: .8125rem;
  margin-bottom: 8px;
}

.article-card .pub-date,
.article-card .score,
.workspace-preview .article-card .pub-date,
.workspace-preview .article-card .score {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}

.article-card .pub-date,
.workspace-preview .article-card .pub-date {
  background: var(--hover);
  color: var(--muted);
}

.article-card .score,
.workspace-preview .article-card .score {
  background: var(--fb-blue-light);
  color: var(--fb-blue);
}

.article-card a,
.workspace-preview .article-card a {
  color: var(--fb-blue);
  font-weight: 600;
  text-decoration: none;
}

.article-card a:hover,
.workspace-preview .article-card a:hover {
  text-decoration: underline;
}

.article-card .ai-note,
.workspace-preview .article-card .ai-note {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 8px;
}

.edition-header,
.workspace-preview .edition-header {
  text-align: left;
  border-bottom: none;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.edition-header h2,
.workspace-preview .edition-header h2 {
  margin: 0 0 4px;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.edition-header .meta,
.workspace-preview .edition-header .meta {
  color: var(--muted);
  font-size: .8125rem;
}

.edition-headline,
.workspace-preview .edition-headline {
  margin: 0 0 12px;
  padding: 0 4px;
  font-size: .9375rem;
  font-style: normal;
  font-weight: 600;
  color: var(--ink);
}

.edition-stats,
.workspace-preview .edition-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px 12px;
}

.edition-stats span,
.workspace-preview .edition-stats span {
  background: var(--hover);
  border: none;
  color: var(--muted);
  padding: 6px 10px;
  font-size: .8125rem;
  border-radius: 999px;
  font-family: var(--font);
  font-weight: 600;
}

.channel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: .8125rem;
}

.channel-meta span {
  background: rgba(255, 255, 255, 0.7);
  padding: 3px 8px;
  border-radius: 999px;
}

.workspace-channel-item.is-active .channel-meta span {
  background: rgba(255, 255, 255, 0.8);
}

/* Channel form */
.channel-form-page {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.channel-form-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  padding: 16px;
}

.channel-form-sidebar {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  overflow-y: auto;
}

.channel-form-sidebar h1 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  font-weight: 700;
}

.channel-form-sidebar .sub {
  color: var(--muted);
  font-size: .9375rem;
  margin-bottom: 16px;
}

.sidebar-nav { margin-bottom: 16px; }

.sidebar-nav a {
  font-size: .9375rem;
  font-weight: 600;
}

.logs { margin-top: 24px; }

#log-list {
  max-height: 320px;
  overflow-y: auto;
}

.logs h2 {
  font-size: .9375rem;
  font-weight: 700;
  margin: 0 0 12px;
}

.log-item {
  border-left: 3px solid var(--border);
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--hover);
  border-radius: 0 var(--radius-btn) var(--radius-btn) 0;
  font-size: .8125rem;
}

.log-item.ok { border-left-color: var(--ok); }
.log-item.error { border-left-color: var(--err); }
.log-item strong { display: block; margin-bottom: 2px; }

.preview-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.preview-toolbar {
  flex: 0 0 auto;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  font-size: .875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 600;
}

.preview-toolbar a {
  color: var(--fb-blue);
  text-decoration: none;
  white-space: nowrap;
}

.preview-stage {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

.stage-panel {
  position: absolute;
  inset: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius);
  background: var(--bg);
  border: none;
}

.stage-panel[hidden] { display: none !important; }

.stage-placeholder,
.stage-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

#preview-content {
  background: var(--bg);
  font-family: var(--font);
  color: var(--ink);
  padding-bottom: 16px;
}

.examples {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--hover);
  color: var(--fb-blue);
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .8125rem;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover { background: var(--fb-blue-light); }

#save-status {
  margin-top: 10px;
  font-size: .875rem;
  color: var(--muted);
  min-height: 1.2em;
}

#save-status.ok { color: var(--ok); }
#save-status.error { color: var(--err); }

/* Mobile workspace tab switcher (shown via media query) */
.workspace-mobile-nav {
  display: none;
}

@media (max-width: 900px) {
  .auth-layout {
    grid-template-columns: 1fr;
    padding: 24px 16px;
  }

  .auth-brand {
    text-align: center;
    padding: 0;
  }

  .auth-brand .logo { font-size: 2.75rem; }
  .auth-brand .tagline {
    font-size: 1.25rem;
    max-width: none;
    margin: 0 auto;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 0 12px;
    min-height: 52px;
    gap: 8px;
  }

  .topbar h1 {
    font-size: 1.125rem;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    gap: 6px;
    flex-shrink: 0;
  }

  .topbar-user {
    display: none;
  }

  .topbar .btn-sm {
    min-height: 40px;
    padding: 0 10px;
  }

  .topbar-back {
    font-size: .8125rem;
    padding: 0 10px;
  }

  /* Workspace — vertical layout with channel/content tabs */
  .workspace-page {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .workspace-mobile-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px 8px 0;
    flex: 0 0 auto;
  }

  .workspace-mobile-nav-btn {
    border: 0;
    border-radius: var(--radius);
    padding: 10px 12px;
    min-height: 44px;
    font-size: .9375rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--muted);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .workspace-mobile-nav-btn.is-active {
    background: var(--fb-blue-light);
    color: var(--fb-blue);
  }

  .workspace-layout {
    flex: 1 1 auto;
    flex-direction: column;
    overflow: visible;
    padding: 8px;
    gap: 8px;
    min-height: 0;
  }

  .workspace-page.workspace-mobile-channels .workspace-content {
    display: none;
  }

  .workspace-page.workspace-mobile-content .workspace-sidebar {
    display: none;
  }

  .workspace-sidebar {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    max-height: none;
    min-height: 0;
    overflow: visible;
  }

  .workspace-page.workspace-mobile-channels .workspace-sidebar {
    min-height: calc(100dvh - 120px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .workspace-page.workspace-mobile-channels .workspace-channel-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .workspace-channel-select {
    padding: 14px 14px 10px;
  }

  .workspace-channel-select h3 {
    font-size: 1rem;
  }

  .workspace-channel-actions {
    flex-wrap: wrap;
    padding: 0 10px 12px;
  }

  .workspace-channel-actions .btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 40px;
  }

  .workspace-channel-list {
    padding: 10px;
  }

  /* Content tab: scroll the page, not a nested panel */
  .workspace-page.workspace-mobile-content {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .workspace-page.workspace-mobile-content .workspace-layout {
    flex: none;
    overflow: visible;
  }

  .workspace-page.workspace-mobile-content .workspace-content {
    flex: none;
    min-height: 0;
    overflow: visible;
  }

  .workspace-page.workspace-mobile-content .workspace-content-stage {
    flex: none;
    min-height: 0;
    overflow: visible;
    padding: 8px;
  }

  .workspace-page.workspace-mobile-content .workspace-panel {
    flex: none;
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  .workspace-content-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
  }

  .workspace-content-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .workspace-content-title {
    font-size: 1rem;
    line-height: 1.35;
  }

  .workspace-content-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .workspace-content-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .workspace-content {
    flex: 1 1 auto;
  }

  .workspace-content-stage {
    padding: 8px;
  }

  .workspace-preview .article-card {
    padding: 14px;
    margin-bottom: 10px;
  }

  .workspace-preview .article-card h3 {
    font-size: 1rem;
    line-height: 1.45;
  }

  .workspace-preview .article-card .meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    line-height: 1.45;
    font-size: .8125rem;
  }

  .workspace-preview .article-card a {
    display: inline-block;
    margin-top: 4px;
    min-height: 44px;
    line-height: 44px;
  }

  .workspace-boot-overlay {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
  }

  /* Channel form — form on top, preview below, page scrolls */
  .channel-form-page {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .channel-form-layout {
    display: flex;
    flex-direction: column;
    flex: none;
    grid-template-columns: none;
    grid-template-rows: none;
    padding: 8px;
    gap: 8px;
    overflow: visible;
    min-height: 0;
  }

  .channel-form-sidebar {
    flex: 0 0 auto;
    max-height: none;
    padding: 16px;
    overflow: visible;
  }

  .channel-form-sidebar h1 {
    font-size: 1.125rem;
  }

  .channel-form-sidebar .sub {
    font-size: .875rem;
    margin-bottom: 14px;
  }

  .channel-form-sidebar input,
  .channel-form-sidebar select {
    min-height: 44px;
    font-size: 16px;
  }

  .channel-form-sidebar .btn-block,
  .channel-form-sidebar .btn-save,
  .channel-form-sidebar #run-btn {
    min-height: 44px;
  }

  .logs {
    margin-top: 20px;
  }

  #log-list {
    max-height: 240px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .preview-pane {
    flex: none;
    min-height: 0;
    overflow: visible;
  }

  .preview-toolbar {
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 12px;
    font-size: .8125rem;
  }

  .preview-toolbar #preview-meta {
    width: 100%;
    color: var(--muted);
    font-weight: 500;
  }

  .preview-stage {
    flex: none;
    min-height: 0;
    padding: 8px;
    overflow: visible;
    position: static;
  }

  .stage-panel {
    position: static;
    inset: auto;
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  .article-card .meta-line,
  #preview-content .article-card .meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    line-height: 1.45;
  }

  #preview-content .article-card {
    padding: 14px;
  }

  #preview-content .article-card h3 {
    font-size: 1rem;
    line-height: 1.45;
  }

  #preview-content .article-card a {
    display: inline-block;
    min-height: 44px;
    line-height: 44px;
  }
}

@media (max-width: 480px) {
  .topbar-actions .btn-primary.btn-sm {
    padding: 0 8px;
    font-size: .75rem;
  }

  .topbar-actions .btn-secondary.btn-sm:not(.topbar-back) {
    min-width: 40px;
    padding: 0 8px;
  }

  .workspace-content-actions {
    grid-template-columns: 1fr;
  }

  .workspace-channel-actions {
    flex-direction: column;
  }

  .workspace-channel-actions .btn {
    flex: 1 1 auto;
    width: 100%;
  }

  .examples {
    gap: 8px;
  }

  .chip {
    min-height: 36px;
    padding: 8px 12px;
  }
}
