:root {
  color-scheme: light;
  --ink: #151713;
  --muted: #6d7168;
  --paper: #f2f0e9;
  --card: #fbfaf6;
  --line: #d8d5ca;
  --red: #a43a2b;
  --green: #246b4d;
  --amber: #9a6715;
  --blue: #335f78;
  --shadow: 0 22px 70px rgba(31, 29, 22, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  min-height: 100vh; margin: 0; color: var(--ink);
  background: radial-gradient(circle at 15% 0%, rgba(164, 58, 43, .07), transparent 27rem), linear-gradient(180deg, #f7f5ee 0, var(--paper) 32rem);
  font: 15px/1.55 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.grain { position: fixed; inset: 0; pointer-events: none; opacity: .25; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='2' stitchTiles='stitchTiles'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E"); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--red); }

.masthead { width: min(1220px, calc(100% - 40px)); margin: 0 auto; padding: 25px 0; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(21, 23, 19, .14); }
.brand { display: flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; object-fit: contain; background: white; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 13px; letter-spacing: .03em; }
.brand small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .13em; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.system-status { color: var(--muted); font-size: 12px; }
.system-status i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(36, 107, 77, .12); }

main { width: min(1220px, calc(100% - 40px)); margin: 0 auto; padding: 60px 0 110px; }
h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 400; letter-spacing: -.035em; }
h1 { font-size: clamp(48px, 7vw, 88px); line-height: .98; }
h1 em { color: var(--red); font-weight: inherit; }
h2 { font-size: clamp(28px, 3vw, 39px); line-height: 1.08; }
h3, p { margin: 0; }
.eyebrow { margin-bottom: 12px; color: var(--red); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.lede { max-width: 650px; margin: 25px 0 32px; color: var(--muted); font: 19px/1.55 Georgia, serif; }
.muted, .section-note { color: var(--muted); }
.section-note { max-width: 390px; font-size: 12px; text-align: right; }
.card { background: rgba(251, 250, 246, .93); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.narrow { max-width: 720px; margin: 5vh auto 0; padding: clamp(28px, 5vw, 58px); }
.gate h1, #bootstrap-view h1 { font-size: clamp(48px, 7vw, 75px); }
.stack { display: grid; gap: 17px; }
label { display: grid; gap: 7px; color: #484b44; font-size: 12px; font-weight: 700; letter-spacing: .03em; }
input, textarea, select { width: 100%; border: 1px solid #c9c6ba; border-radius: 9px; background: #fffefb; padding: 12px 13px; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(164, 58, 43, .1); }
textarea { resize: vertical; }

.primary, .secondary, .mode-pill, .provider-button { border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 750; transition: transform .15s, background .15s, color .15s; }
.primary { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; background: var(--ink); color: white; }
.primary:hover, .secondary:hover, .provider-button:hover { transform: translateY(-1px); }
.secondary { border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.link-button { display: inline-flex; text-decoration: none; }
.text-button { padding: 0; border: 0; background: none; color: var(--muted); font-weight: 700; }
.text-button:hover { color: var(--ink); }
.destructive { color: var(--red); }
.form-error { min-height: 22px; margin-top: 12px; color: var(--red); }

.hero-row { display: grid; grid-template-columns: 1fr 390px; gap: 55px; align-items: end; margin: 24px 0 46px; }
.hero-controls { padding: 10px 22px; box-shadow: none; }
.control-line { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 15px 0; }
.control-line + .control-line { border-top: 1px solid var(--line); }
.control-line strong, .control-line small { display: block; }
.control-line strong { font-size: 13px; }
.control-line small { color: var(--muted); font-size: 11px; }
.info { position: relative; width: 17px; height: 17px; padding: 0; border: 1px solid #aaa; border-radius: 50%; background: transparent; color: var(--muted); font-size: 10px; }
.info:hover::after, .info:focus::after { content: attr(data-tip); position: absolute; z-index: 20; right: -12px; bottom: calc(100% + 10px); width: 250px; padding: 10px 12px; border-radius: 8px; background: var(--ink); color: white; text-align: left; font: 11px/1.4 Inter, sans-serif; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.mode-pill { padding: 8px 13px; background: #eadfca; color: #6f5018; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.mode-pill.live { background: #d8eadf; color: var(--green); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { display: block; width: 43px; height: 24px; padding: 3px; border-radius: 999px; background: #c9c7bf; transition: .2s; }
.switch span::after { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: white; transition: .2s; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(19px); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 15px; overflow: hidden; background: rgba(255,255,255,.42); }
.stat { min-height: 115px; padding: 22px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat strong { display: block; font: 39px/1 Georgia, serif; }
.stat span { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }

.section-block { margin-top: 72px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 25px; margin-bottom: 25px; }
.ghost-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; padding: 25px; box-shadow: none; }
.source-icon { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 17px; background: #ece9df; }
.source-icon img { width: 31px; height: 31px; }
.source-title { display: flex; align-items: center; gap: 15px; margin-bottom: 4px; }
.source-title h3 { font: 24px/1.2 Georgia, serif; }
.ghost-copy p { max-width: 760px; color: var(--muted); font-size: 13px; }
.ghost-copy small { display: block; margin-top: 7px; color: #93958e; }

.article-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.article-card { min-width: 0; overflow: hidden; box-shadow: none; }
.article-image { width: 100%; height: 145px; object-fit: cover; background: #e7e4da; }
.article-body { padding: 20px; }
.article-body > small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; }
.article-body h3 { margin: 9px 0; font: 22px/1.15 Georgia, serif; }
.article-body h3 a { color: inherit; text-decoration: none; }
.article-body p { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: 12px; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.article-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.article-actions span { color: var(--green); font-size: 11px; font-weight: 750; }
.article-actions .secondary { padding: 8px 11px; font-size: 10px; }
.article-actions button:disabled { opacity: .5; cursor: default; transform: none; }

.account-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.account { min-height: 235px; padding: 22px; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.account-top { display: flex; justify-content: space-between; align-items: start; }
.account-avatar-wrap { position: relative; width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%; background: #ece9df; }
.platform-logo { width: 28px; height: 28px; object-fit: contain; }
.profile-avatar { width: 50px; height: 50px; object-fit: cover; border-radius: 50%; }
.profile-avatar + .platform-logo { position: absolute; right: -4px; bottom: -3px; width: 22px; height: 22px; padding: 4px; border: 2px solid var(--card); border-radius: 7px; background: white; }
.connection-dot { color: var(--muted); font-size: 11px; }
.connection-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #a4a69f; }
.connection-dot.connected { color: var(--green); }
.connection-dot.connected::before { background: var(--green); }
.connection-dot.reading { color: var(--amber); }
.connection-dot.reading::before { background: var(--amber); }
.account h3 { margin: 25px 0 2px; font: 24px/1.15 Georgia, serif; }
.account > p { color: var(--muted); font-size: 12px; word-break: break-word; }
.account-actions { display: flex; gap: 16px; margin-top: auto; }
.account-actions button { padding: 0; border: 0; background: none; color: var(--red); font-weight: 800; font-size: 11px; }
.account-actions button + button { color: var(--muted); }

.ledger-heading { align-items: center; }
.button-help { display: grid; justify-items: end; gap: 6px; max-width: 340px; }
.button-help small { color: var(--muted); font-size: 10px; text-align: right; }
.table-shell { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th, td { padding: 14px 17px; border-bottom: 1px solid #e2dfd5; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 10px; letter-spacing: .11em; text-transform: uppercase; }
td { font-size: 12px; }
td:first-child { max-width: 360px; font: 15px/1.3 Georgia, serif; }
td:first-child a { color: inherit; text-decoration: none; }
tr:last-child td { border-bottom: 0; }
.table-platform { display: flex; align-items: center; gap: 8px; }
.table-platform img { width: 17px; height: 17px; }
.status { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; background: #e7e4da; color: #696a64; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.status.published { background: #dcebe2; color: var(--green); }
.status.simulated { background: #e5e7ef; color: #4c5877; }
.status.failed { background: #f2ddd9; color: var(--red); }
.status.retrying, .status.queued, .status.pending_enqueue, .status.publishing { background: #e4eaf0; color: var(--blue); }
.status.held { background: #eee4ce; color: var(--amber); }
.row-action { border: 0; background: none; color: var(--red); font-weight: 700; }
.empty { padding: 32px; color: var(--muted); text-align: center; }

dialog { width: min(700px, calc(100% - 30px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 18px; background: transparent; }
dialog::backdrop { background: rgba(22, 23, 20, .55); backdrop-filter: blur(4px); }
.dialog-card { position: relative; padding: 35px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 100px rgba(0,0,0,.25); }
.wide-dialog { width: min(1000px, calc(100vw - 34px)); }
#settings-dialog { width: min(1000px, calc(100% - 30px)); }
.dialog-close { position: absolute; top: 17px; right: 20px; border: 0; background: none; font-size: 27px; color: var(--muted); }
.dialog-platform { display: flex; align-items: center; gap: 15px; padding-right: 30px; }
.dialog-platform > img { width: 42px; height: 42px; }
.dialog-platform .eyebrow { margin-bottom: 3px; }
.dialog-platform h2 { font-size: 33px; }
.dialog-intro { margin: 18px 0 24px; }
.provider-button { width: 100%; display: flex; justify-content: space-between; margin-top: 10px; background: var(--ink); color: white; }
.security-note { margin: 18px 0; padding: 11px 13px; border-left: 3px solid var(--green); background: #e8efe9; color: #4f6257; font-size: 11px; }
.setup-needed { padding: 20px; border: 1px solid #e0cda8; border-radius: 12px; background: #f6efe1; }
.setup-needed p { margin: 8px 0 12px; color: #735e39; font-size: 12px; }
.setup-needed ol, .guided-steps { margin: 13px 0 20px; padding-left: 22px; color: #4f514b; font-size: 12px; }
.setup-needed li + li, .guided-steps li + li { margin-top: 7px; }
.dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 22px; }
.dialog-actions .primary { min-width: 210px; }
.dialog-actions a { font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.one-column { grid-template-columns: 1fr; }

.settings-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 18px; margin-top: 25px; }
fieldset { min-width: 0; margin: 0; padding: 20px; border: 1px solid var(--line); border-radius: 13px; }
legend { padding: 0 8px; font: 20px Georgia, serif; }
fieldset > label + label, fieldset > label + .toggle-list, .toggle-list + label { margin-top: 14px; }
.toggle-list { margin: 14px 0; border-top: 1px solid #e2dfd5; }
.toggle-list label { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #e2dfd5; }
.toggle-list input, .inline-check input { width: auto; accent-color: var(--red); }
.field-help { margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.field-help code { color: var(--ink); }
.comment-editor { padding: 14px 0; border-top: 1px solid var(--line); }
.comment-editor:first-of-type { border-top: 0; }
.comment-editor label + label { margin-top: 10px; }
.inline-check { display: flex; align-items: center; gap: 8px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.comments-disabled .comment-editor { opacity: .35; pointer-events: none; }
.notice { padding: 12px; border-radius: 9px; background: #eee4ce; color: #70531a; font-size: 11px; }

.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: 440px; padding: 13px 17px; border-radius: 10px; background: var(--ink); color: white; box-shadow: 0 15px 45px rgba(0,0,0,.25); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
[hidden] { display: none !important; }

@media (max-width: 960px) {
  .hero-row { grid-template-columns: 1fr; }
  .account-grid, .article-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .stat:nth-child(4) { border-top: 1px solid var(--line); }
  .ghost-card { grid-template-columns: auto 1fr; }
  .ghost-card > button { grid-column: 1 / -1; }
}
@media (max-width: 590px) {
  .masthead, main { width: min(100% - 26px, 1220px); }
  .system-status { display: none; }
  main { padding-top: 35px; }
  .hero-row { gap: 32px; }
  .account-grid, .article-grid, .form-grid, .split { grid-template-columns: 1fr; }
  .section-heading { align-items: start; }
  .section-note { display: none; }
  .section-heading h2 { font-size: 28px; }
  .ledger-heading { display: grid; }
  .button-help { justify-items: start; }
  .button-help small { text-align: left; }
  .source-title { align-items: flex-start; flex-direction: column; gap: 4px; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
  .dialog-actions .primary { width: 100%; }
}
