:root {
  --paper: #f4f2ed;
  --panel: #fff;
  --ink: #10100f;
  --muted: #74726c;
  --line: #d9d6cf;
  --accent: #ff4b35;
  --accent-soft: #ffe5df;
  --black: #0b0b0a;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body { margin: 0; min-width: 0; background: var(--paper); }
body[data-auth-state="loading"] > :not(.auth-gate),
body[data-auth-state="signed-out"] > :not(.auth-gate) { visibility: hidden; }
body[data-auth-state="signed-in"] .auth-gate { display: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.auth-gate {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #fff;
  background:
    radial-gradient(circle at 12% 18%, #ff4b3540, transparent 34%),
    radial-gradient(circle at 88% 80%, #ffffff1f, transparent 32%),
    #080807;
}
.auth-card { width: min(430px, 100%); padding: 34px; border: 1px solid #ffffff24; border-radius: 28px; background: #ffffff10; box-shadow: 0 24px 90px #0009; backdrop-filter: blur(28px) saturate(140%); }
.auth-card > img { width: 64px; height: 64px; object-fit: contain; margin-bottom: 24px; filter: brightness(0) invert(1); }
.auth-card h1 { margin: 7px 0 10px; font: 900 36px/.95 Arial Black, sans-serif; letter-spacing: -.05em; }
.auth-card > p:not(.eyebrow):not(.auth-message) { margin: 0 0 24px; color: #aaa; font-size: 12px; line-height: 1.65; }
.auth-card form { display: grid; gap: 14px; }
.auth-card label { display: grid; gap: 7px; color: #aaa; font-size: 10px; font-weight: 800; }
.auth-card input { width: 100%; padding: 13px 14px; border: 1px solid #ffffff2b; border-radius: 12px; color: #fff; background: #0007; outline: none; }
.auth-card input:focus { border-color: var(--accent); }
.auth-card .button { margin-top: 4px; padding-block: 13px; }
.reset-link { margin-top: 16px; padding: 0; border: 0; color: #aaa; background: none; font-size: 10px; text-decoration: underline; }
.auth-message { min-height: 18px; margin: 15px 0 0; color: #ff9a8e; font-size: 10px; line-height: 1.5; }
.account-label { align-self: center; max-width: 180px; overflow: hidden; color: #8d8c87; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 68px;
  display: grid;
  grid-template-columns: 280px 1fr auto;
  align-items: center;
  gap: 22px;
  padding: 12px 22px;
  color: #fff;
  background: var(--black);
  border-bottom: 1px solid #30302d;
}

.brand { display: flex; align-items: center; color: inherit; text-decoration: none; }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.brand small { margin-left: 15px; font-size: 9px; font-weight: 800; letter-spacing: .18em; color: #8d8c87; }
.sync-status { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 11px; color: #cfcec9; }
.sync-status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #f3b93f; box-shadow: 0 0 0 4px #f3b93f22; }
.status-dot.ready { background: #67cf7b; box-shadow: 0 0 0 4px #67cf7b22; }
.status-dot.error { background: #ff695f; box-shadow: 0 0 0 4px #ff695f22; }
.header-actions { display: flex; gap: 8px; }

.button, .icon-button {
  border: 1px solid #454540;
  border-radius: 999px;
  transition: transform 150ms ease, background 150ms ease;
}
.button:active, .icon-button:active { transform: translateY(1px); }
.button { padding: 9px 15px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.button.quiet { color: #f7f6f2; background: #22221f; }
.button.primary { color: #170e0c; border-color: var(--accent); background: var(--accent); }
.icon-button { width: 34px; height: 34px; color: var(--ink); background: transparent; border-color: var(--line); }

.editor-nav {
  position: sticky;
  top: 68px;
  z-index: 19;
  display: flex;
  gap: 0;
  padding: 0 22px;
  overflow-x: auto;
  color: #fff;
  background: var(--black);
  border-bottom: 1px solid #30302d;
}
.editor-tab { flex: 0 0 auto; min-width: 118px; padding: 14px 18px; border: 0; border-bottom: 3px solid transparent; color: #777; background: transparent; font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.editor-tab.active { color: #fff; border-bottom-color: var(--accent); }
.editor-panel { min-height: calc(100vh - 116px); }

.manager-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 38px 30px 24px;
}
.manager-heading h1 { margin: 4px 0 5px; font: 900 clamp(36px, 5vw, 66px)/.95 Arial Black, sans-serif; letter-spacing: -.06em; }
.manager-heading p:last-child { max-width: 620px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.eyebrow { margin: 0; font-size: 8px; font-weight: 900; letter-spacing: .2em; color: var(--accent); }

.manager-grid, .catalog-editor-grid {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(340px, 560px) minmax(280px, 1fr);
  gap: 20px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 30px 50px;
  align-items: start;
}
.ranking-manager-grid { grid-template-columns: minmax(300px, 400px) minmax(340px, 500px) minmax(320px, 1fr); }
.catalog-editor-grid { grid-template-columns: minmax(340px, 600px) minmax(360px, 620px); justify-content: center; }
.manager-list { display: grid; gap: 9px; min-width: 0; }
.manager-card {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}
.manager-card.selected { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.manager-card > img { width: 78px; height: 78px; object-fit: cover; background: #ddd; }
.manager-card > div:nth-child(2) { min-width: 0; }
.manager-card small, .manager-card span { display: block; color: var(--muted); font-size: 8px; line-height: 1.35; }
.manager-card strong { display: -webkit-box; margin: 4px 0; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font: 800 13px/1.3 Arial, sans-serif; }
.manager-form {
  display: grid;
  gap: 13px;
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.manager-form label, .edit-form label { display: grid; gap: 6px; color: var(--muted); font-size: 9px; font-weight: 800; }
.manager-form input, .manager-form select, .manager-form textarea,
.edit-form input, .edit-form textarea {
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  background: #fff;
  line-height: 1.45;
  resize: vertical;
  outline: none;
}
.manager-form input:focus, .manager-form textarea:focus, .manager-form select:focus,
.edit-form input:focus, .edit-form textarea:focus { border-color: var(--accent); }
.form-artwork { width: min(100%, 300px); aspect-ratio: 1; object-fit: cover; background: #eee; }
.form-artwork.wide { width: 100%; max-width: none; aspect-ratio: 16 / 9; }
.manager-form fieldset, .edit-form fieldset { display: grid; gap: 11px; margin: 4px 0; padding: 14px; border: 1px solid var(--line); }
.manager-form legend, .edit-form legend { padding: 0 6px; color: var(--accent); font-size: 8px; font-weight: 900; letter-spacing: .14em; }
.danger-button { padding: 10px 12px; border: 1px solid #c9bbb5; color: #8d2b20; background: #fff; font-size: 9px; font-weight: 800; }
.manager-preview { min-width: 0; padding: 20px; color: #fff; background: #111; }
.banner-preview { margin-top: 12px; }
.banner-preview-image { position: relative; display: flex; align-items: end; min-height: 440px; padding: 25px; overflow: hidden; background: #222 center / cover; }
.banner-preview-image::after { position: absolute; content: ""; inset: 0; background: linear-gradient(transparent 20%, #000e); }
.banner-preview-image > div { position: relative; z-index: 1; }
.banner-preview-image small { color: var(--accent); font-size: 8px; font-weight: 900; letter-spacing: .13em; }
.banner-preview-image h2 { margin: 8px 0; font: 900 clamp(28px, 3vw, 48px)/.98 Arial Black, sans-serif; letter-spacing: -.04em; }
.banner-preview-image p { max-width: 480px; color: #ccc; font-size: 11px; line-height: 1.5; }
.banner-preview-image span { font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.banner-preview > p { margin: 9px 0 0; color: #666; font-size: 8px; text-transform: uppercase; }
.dsp-mini { display: flex; gap: 5px; margin-top: 7px; }
.dsp-mini a { display: grid; place-items: center; min-width: 23px; height: 23px; padding: 0 5px; border: 1px solid #bbb; border-radius: 999px; color: #111; text-decoration: none; font-size: 7px; font-weight: 900; }
.ranking-preview-panel { display: grid; gap: 13px; }
.dark-label { display: grid; gap: 6px; color: #888; font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.dark-label input, .dark-label textarea, .weight-grid input { width: 100%; padding: 9px; border: 1px solid #3b3b38; color: #fff; background: #1c1c1a; outline: none; }
.weight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.weight-grid label { color: #777; font-size: 7px; font-weight: 900; }
.formula-note { margin: 0; color: #777; font-size: 9px; line-height: 1.55; }
.ranking-preview { display: grid; border-top: 1px solid #333; }
.ranking-preview-row { display: grid; grid-template-columns: 38px 52px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 10px 0; border-bottom: 1px solid #333; }
.ranking-preview-row > strong { font: 900 23px Arial Black, sans-serif; color: var(--accent); }
.ranking-preview-row img { width: 52px; height: 52px; object-fit: cover; }
.ranking-preview-row div { min-width: 0; }
.ranking-preview-row div strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.ranking-preview-row span { color: #888; font-size: 8px; }
.ranking-preview-row > em { color: #fff; font: normal 900 10px Arial, sans-serif; }

.mobile-pane-nav { display: none; }
.workspace { display: grid; grid-template-columns: minmax(300px, 32%) minmax(390px, 41%) minmax(290px, 27%); height: calc(100vh - 116px); }
.pane { min-width: 0; overflow: auto; padding: 24px 20px 36px; border-right: 1px solid var(--line); }
.pane:last-child { border-right: 0; }
.inbox-pane { background: #eceae4; }
.issue-pane { background: var(--paper); }
.detail-pane { background: var(--panel); }
.pane-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.pane-heading h1, .phone-preview h2 { margin: 2px 0 0; font: 900 24px/1 Arial Black, sans-serif; letter-spacing: -.04em; }
.count { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff; background: var(--black); font-size: 10px; }
.search-field { display: block; position: relative; }
.search-field span { position: absolute; left: 12px; top: 11px; color: var(--muted); font-size: 10px; }
.search-field input { width: 100%; padding: 10px 12px 10px 46px; border: 1px solid var(--line); border-radius: 4px; background: #fff; outline: none; }
.search-field input:focus { border-color: var(--accent); }
.filter-row { display: flex; gap: 6px; padding: 12px 0 16px; overflow: auto; }
.filter-chip { flex: none; padding: 6px 9px; border: 1px solid #cecac1; border-radius: 999px; background: transparent; font-size: 9px; }
.filter-chip.active { color: #fff; border-color: var(--black); background: var(--black); }
.article-list { display: grid; gap: 8px; }
.article-card { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 11px; padding: 9px; border: 1px solid transparent; border-radius: 5px; background: #fff; }
.article-card:hover { border-color: #c8c4bb; }
.article-card img { width: 72px; height: 72px; border-radius: 2px; object-fit: cover; background: #ddd; }
.article-card-copy { min-width: 0; }
.article-card .meta, .source-meta { margin: 1px 0 5px; color: var(--accent); font-size: 8px; font-weight: 900; letter-spacing: .11em; }
.article-card h2 { margin: 0; display: -webkit-box; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; font: 700 12px/1.38 Arial, sans-serif; }
.article-card time { display: block; margin-top: 6px; color: var(--muted); font-size: 8px; }
.add-button { align-self: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; background: #fff; }
.empty-list { padding: 36px 12px; text-align: center; color: var(--muted); font-size: 11px; }
.issue-heading { align-items: end; }
.issue-title-input { width: 100%; margin-top: 3px; padding: 0; border: 0; border-bottom: 1px solid transparent; background: transparent; font: 900 24px/1 Arial Black, sans-serif; outline: none; }
.issue-title-input:focus { border-color: var(--accent); }
.composer-help { margin: -6px 0 17px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.section-list { display: grid; gap: 14px; }
.issue-section { border: 1px solid var(--line); background: var(--panel); }
.section-header { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.section-title { min-width: 0; padding: 4px 0; border: 0; background: transparent; font: 900 10px/1.2 sans-serif; letter-spacing: .13em; outline: none; }
.section-layout { padding: 5px 7px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); background: #fff; font-size: 9px; }
.remove-section { border: 0; color: var(--muted); background: none; }
.section-items { min-height: 60px; }
.section-empty { padding: 20px 12px; color: #9b9891; text-align: center; font-size: 9px; }
.section-article { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 8px 10px; border-bottom: 1px solid #e8e5de; cursor: pointer; }
.section-article:last-child { border-bottom: 0; }
.section-article.selected { background: var(--accent-soft); }
.section-article img { width: 42px; height: 42px; object-fit: cover; }
.section-article strong { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font: 700 10px/1.3 Arial, sans-serif; }
.section-article small { color: var(--muted); font-size: 8px; }
.row-actions { display: flex; gap: 1px; }
.row-actions button { width: 24px; height: 24px; border: 0; color: var(--muted); background: transparent; }
.empty-detail { padding: 28px 8px 42px; text-align: center; }
.empty-mark { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 18px; border-radius: 50%; color: #fff; background: var(--accent); font: italic 900 44px Arial Black, sans-serif; }
.empty-detail h2 { margin: 0 0 8px; font: 900 20px Arial Black, sans-serif; }
.empty-detail p { margin: 0 auto; max-width: 270px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.edit-form { display: grid; gap: 13px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.edit-form img { width: 100%; max-height: 210px; object-fit: cover; background: #eee; }
.source-link { color: var(--ink); font-size: 9px; font-weight: 800; text-decoration-color: var(--accent); }
.phone-preview { padding-top: 24px; }
.phone-preview > header { display: flex; justify-content: space-between; align-items: end; margin-bottom: 12px; }
.phone-preview h2 { font-size: 17px; }
.phone-frame { position: relative; width: 238px; height: 468px; margin: 0 auto; padding: 8px; border: 2px solid #20201e; border-radius: 34px; background: #20201e; box-shadow: 0 16px 40px #0002; }
.phone-island { position: absolute; z-index: 2; top: 14px; left: 50%; width: 70px; height: 19px; transform: translateX(-50%); border-radius: 999px; background: #111; }
.phone-screen { height: 100%; overflow: hidden; border-radius: 25px; background: #0c0c0b; color: #fff; }
.preview-nav { display: flex; justify-content: space-between; padding: 38px 13px 9px; background: #0c0c0b; }
.preview-nav strong { font: italic 900 18px Arial Black, sans-serif; }
.preview-nav span { color: var(--accent); }
.preview-tabs { display: flex; gap: 13px; padding: 7px 13px; overflow: hidden; border-top: 1px solid #333; border-bottom: 1px solid #333; white-space: nowrap; font-size: 7px; font-weight: 900; letter-spacing: .08em; }
.preview-issue-title { padding: 10px 13px 7px; font: 900 9px Arial Black, sans-serif; }
.preview-hero { position: relative; min-height: 170px; display: flex; align-items: end; padding: 12px; background: #333 center/cover; }
.preview-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 20%, #000d); }
.preview-hero-copy { position: relative; z-index: 1; }
.preview-hero small, .preview-row small { color: var(--accent); font-size: 7px; font-weight: 900; }
.preview-hero h3 { margin: 4px 0 0; font: 900 15px/1.14 Arial Black, sans-serif; }
.preview-list { padding: 9px 12px 18px; }
.preview-row { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px; padding: 7px 0; border-bottom: 1px solid #333; }
.preview-row img { width: 56px; height: 56px; object-fit: cover; }
.preview-row h4 { margin: 3px 0 0; display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font: 700 8px/1.3 Arial, sans-serif; }
.preview-placeholder { display: grid; place-items: center; min-height: 290px; padding: 28px; color: var(--muted); text-align: center; font-size: 10px; line-height: 1.5; }
.toast { position: fixed; z-index: 30; right: 20px; bottom: 20px; max-width: calc(100vw - 40px); padding: 11px 16px; border-radius: 4px; color: #fff; background: #171715; font-size: 10px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: 180ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 32% 43% 25%; }
  .pane { padding-inline: 14px; }
  .manager-grid { grid-template-columns: minmax(280px, 38%) minmax(340px, 62%); }
  .manager-preview { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .auth-card { padding: 26px 22px; border-radius: 22px; }
  .auth-card h1 { font-size: 31px; }
  .app-header { position: static; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 14px; }
  .brand small { display: none; }
  .sync-status { justify-self: end; max-width: 180px; }
  .header-actions { grid-column: 1 / -1; overflow-x: auto; }
  .header-actions .button { flex: 1; }
  .account-label { display: none; }
  .editor-nav { top: 0; padding: 0; }
  .editor-tab { min-width: 104px; padding-inline: 14px; }
  .editor-panel { min-height: calc(100vh - 48px); }
  .manager-heading { display: grid; gap: 18px; padding: 26px 16px 18px; }
  .manager-heading .button { justify-self: start; }
  .manager-grid, .catalog-editor-grid { grid-template-columns: 1fr; gap: 14px; padding: 0 16px 36px; }
  .ranking-manager-grid { grid-template-columns: 1fr; }
  .manager-list { max-height: none; }
  .manager-form { padding: 16px; }
  .manager-preview { grid-column: auto; }
  .banner-preview-image { min-height: 420px; }
  .mobile-pane-nav { position: sticky; top: 47px; z-index: 12; display: grid; grid-template-columns: repeat(3, 1fr); background: #fff; border-bottom: 1px solid var(--line); }
  .mobile-pane-nav button { padding: 11px 6px; border: 0; border-bottom: 3px solid transparent; color: #888; background: transparent; font-size: 9px; font-weight: 900; }
  .mobile-pane-nav button.active { color: var(--ink); border-bottom-color: var(--accent); }
  .workspace { display: block; height: auto; }
  .pane { display: none; min-height: calc(100vh - 90px); overflow: visible; padding: 20px 16px 40px; border-right: 0; }
  body[data-mobile-pane="inbox"] .inbox-pane,
  body[data-mobile-pane="compose"] .issue-pane,
  body[data-mobile-pane="detail"] .detail-pane { display: block; }
  .phone-frame { width: min(280px, 100%); height: 540px; }
  .toast { right: 12px; bottom: 12px; }
}

@media (max-width: 430px) {
  .manager-card { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .manager-card > img { width: 64px; height: 64px; }
  .row-actions { flex-direction: column; }
  .article-card { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .article-card img { width: 64px; height: 64px; }
}

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