:root {
  --ink: #142721;
  --forest: #153a32;
  --moss: #426d60;
  --sage: #dce8df;
  --paper: #f4f6f1;
  --white: #fbfcf9;
  --line: #cbd5ce;
  --muted: #66756f;
  --amber: #dc9e3d;
  --amber-soft: #f4e3c4;
  --coral: #bd5b4e;
  --coral-soft: #f1d8d3;
  --shadow: 0 18px 55px rgba(20, 39, 33, 0.12);
  --display: Georgia, "Times New Roman", serif;
  --body: "Trebuchet MS", "Segoe UI", sans-serif;
  --utility: "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); }
button, select, textarea, input { font: inherit; }
button, a, select, input, textarea { outline-color: var(--amber); outline-offset: 3px; }
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 20; background: var(--ink); color: white; padding: .8rem 1rem; }
.skip-link:focus { top: 1rem; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.rail { position: sticky; top: 0; height: 100vh; padding: 30px 22px; background: var(--forest); color: var(--white); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding-bottom: 30px; border-bottom: 1px solid rgba(255,255,255,.18); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.42); font: 700 21px/1 var(--display); transform: rotate(-4deg); }
.brand strong, .brand span { display: block; }
.brand strong { font: 600 18px/1.1 var(--display); }
.brand div span { color: #b7c8c1; font-size: 11px; margin-top: 4px; }
nav { display: grid; gap: 3px; margin-top: 32px; }
.nav-item { color: #c9d6d1; text-decoration: none; padding: 12px 10px; border-left: 2px solid transparent; font-size: 14px; }
.nav-item span { margin-right: 14px; color: #7fa095; font-family: var(--utility); font-size: 10px; }
.nav-item:hover, .nav-item.is-active { color: white; border-color: var(--amber); background: rgba(255,255,255,.06); }
.ai-config-trigger { width: 100%; margin-top: auto; padding: 13px 10px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.04); color: white; display: grid; grid-template-columns: 31px 1fr; gap: 10px; align-items: center; text-align: left; cursor: pointer; }
.ai-config-trigger:hover { border-color: var(--amber); background: rgba(255,255,255,.08); }
.ai-config-trigger > span:last-child, .ai-config-trigger strong, .ai-config-trigger small { display: block; }
.ai-config-trigger strong { font-size: 11px; }
.ai-config-trigger small { margin-top: 4px; color: #b7c8c1; font-size: 9px; }
.ai-mark { display: grid; place-items: center; width: 29px; height: 29px; border: 1px solid var(--amber); color: #f0c97f; font: 700 9px/1 var(--utility); }
.ai-config-trigger.is-configured .ai-mark { border-color: #8fc3a7; color: #a8d7bd; }
.connection-card { margin-top: 12px; display: grid; grid-template-columns: 10px 1fr; gap: 10px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.18); }
.connection-card strong, .connection-card span { display: block; }
.connection-card strong { font-size: 12px; }
.connection-card div span { margin-top: 5px; color: #b7c8c1; font-size: 11px; line-height: 1.4; }
.status-dot { width: 8px; height: 8px; margin-top: 3px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(220,158,61,.14); }
.connection-card.is-online .status-dot { background: #8fc3a7; box-shadow: 0 0 0 4px rgba(143,195,167,.14); }
main { padding: 42px clamp(28px, 5vw, 76px) 70px; min-width: 0; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 28px; padding-bottom: 30px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 9px; color: var(--moss); font: 700 10px/1 var(--utility); letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 500; }
h1 { max-width: 780px; font-size: clamp(34px, 4.2vw, 62px); line-height: .98; letter-spacing: -.035em; }
h2 { font-size: 24px; line-height: 1.08; }
.top-actions { display: flex; gap: 12px; align-items: end; }
.profile-filter span { display: block; margin-bottom: 7px; color: var(--muted); font: 700 9px/1 var(--utility); letter-spacing: .08em; text-transform: uppercase; }
select { min-width: 185px; height: 42px; padding: 0 34px 0 12px; border: 1px solid var(--line); border-radius: 0; background: var(--white); color: var(--ink); }
.button, .file-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 0 18px; border: 1px solid var(--forest); background: transparent; color: var(--forest); text-decoration: none; cursor: pointer; font-size: 13px; font-weight: 700; }
.button:hover, .file-button:hover { transform: translateY(-1px); box-shadow: 4px 4px 0 var(--sage); }
.button-primary { background: var(--forest); color: white; }
.button:disabled { opacity: .55; cursor: wait; }
.file-button input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.setup-panel { margin-top: 24px; padding: 25px; border: 1px solid var(--amber); background: var(--amber-soft); display: grid; grid-template-columns: 1fr auto; gap: 24px; }
.setup-panel p:not(.eyebrow) { max-width: 720px; color: #674c20; line-height: 1.55; }
.setup-actions { display: flex; gap: 9px; align-items: center; }
.callback-note { grid-column: 1 / -1; margin: 0 !important; font-size: 12px; }
code { font-family: var(--utility); word-break: break-all; }
.publication-board { margin-top: 34px; padding: 28px; border: 1px solid var(--line); background: var(--white); }
.publication-board-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.publication-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.publication-summary span { padding: 7px 10px; background: var(--paper); color: var(--muted); font: 700 10px/1 var(--utility); }
.publication-summary strong { color: var(--forest); }
.publication-history { display: grid; gap: 8px; margin-top: 16px; }
.publication-card { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 16px; padding: 14px; border-top: 1px solid var(--line); align-items: start; }
.publication-card:first-child { border-top-color: var(--forest); }
.publication-thumb { width: 72px; height: 72px; background: var(--sage); object-fit: cover; }
.publication-thumb-placeholder { display: grid; place-items: center; color: var(--moss); font: 700 10px/1 var(--utility); }
.publication-card-copy p { max-width: 740px; margin: 4px 0 9px; color: #33453f; font-size: 12px; line-height: 1.45; }
.publication-meta { color: var(--muted); font: 10px/1.4 var(--utility); }
.target-results { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.target-result { padding: 5px 7px; background: var(--paper); color: var(--muted); font-size: 9px; }
.target-result.published { background: var(--sage); color: var(--forest); }
.target-result.failed, .target-result.retryable, .target-result.unsupported { background: var(--coral-soft); color: #77352d; }
.target-result.queued, .target-result.scheduled { background: var(--amber-soft); color: #76531e; }
.publication-card-actions { min-width: 108px; text-align: right; }
.publication-dialog { width: min(1050px, calc(100vw - 30px)); }
.publication-form { max-height: calc(100vh - 28px); padding: 28px; overflow-y: auto; }
.publication-sheet { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(270px, .7fr); gap: 28px; margin-top: 22px; }
.publication-editor { min-width: 0; }
.publication-editor > label, .publication-specific > label { display: block; margin-top: 15px; }
.publication-editor label > span, .publication-editor legend { display: block; margin-bottom: 7px; color: var(--muted); font: 700 9px/1 var(--utility); letter-spacing: .08em; text-transform: uppercase; }
.publication-editor label small { display: flex; justify-content: space-between; margin-top: 5px; color: var(--muted); font-size: 9px; }
.publication-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 15px; }
.publication-grid label { min-width: 0; }
.publication-grid select { width: 100%; min-width: 0; }
.profile-picker, .delivery-picker { margin: 0; padding: 13px 14px; border: 1px solid var(--line); }
.profile-picker legend, .delivery-picker legend { padding: 0 5px; }
.picker-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 8px; }
.picker-toolbar span { color: var(--muted); font-size: 10px; }
.profile-checklist { max-height: 150px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.profile-checklist label { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 8px; padding: 9px; background: white; font-size: 11px; }
.profile-checklist input, .delivery-picker input { width: auto; }
.profile-checklist label.is-disabled { color: var(--muted); background: #eef0ec; }
.profile-checklist small { grid-column: 2; color: var(--coral); font-size: 9px; }
.delivery-picker { display: flex; gap: 20px; margin-top: 16px; }
.delivery-picker label { display: flex; gap: 7px; align-items: center; font-size: 12px; }
.publication-specific { margin-top: 15px; padding: 1px 14px 14px; border-left: 3px solid var(--amber); background: var(--amber-soft); }
.publication-preview { position: sticky; top: 0; align-self: start; padding: 17px; border: 1px solid var(--forest); background: #eef2ec; box-shadow: 8px 8px 0 var(--sage); }
.preview-label { display: block; margin-bottom: 12px; color: var(--moss); font: 700 9px/1 var(--utility); letter-spacing: .1em; text-transform: uppercase; }
.preview-image { aspect-ratio: 16 / 9; display: grid; place-items: center; margin-bottom: 14px; overflow: hidden; background: #d9e2dc; color: var(--muted); font-size: 10px; text-align: center; }
.preview-image img { width: 100%; height: 100%; object-fit: cover; }
.publication-preview strong { font: 600 16px/1.2 var(--display); }
.publication-preview p { min-height: 72px; margin: 10px 0; white-space: pre-wrap; color: #33453f; font-size: 12px; line-height: 1.5; }
.preview-button { display: inline-block; padding: 8px 10px; border: 1px solid var(--forest); color: var(--forest); font-size: 10px; font-weight: 700; }
.publication-consent { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 34px; border: 1px solid var(--line); background: var(--white); }
.metrics article { min-height: 128px; padding: 22px; border-right: 1px solid var(--line); display: grid; align-content: space-between; }
.metrics article:last-child { border-right: 0; }
.metric-label { color: var(--muted); font-size: 12px; }
.metrics strong { font: 500 40px/1 var(--display); }
.metrics small { color: var(--muted); font-size: 10px; }
.metrics .metric-new { background: var(--forest); color: white; }
.metrics .metric-new .metric-label, .metrics .metric-new small { color: #c8d8d2; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(290px, .8fr); gap: 42px; margin-top: 50px; align-items: start; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.text-button { border: 0; padding: 4px 0; background: transparent; color: var(--moss); cursor: pointer; border-bottom: 1px solid currentColor; font-size: 12px; }
.workbench { display: grid; grid-template-columns: repeat(4, minmax(118px, 1fr)) minmax(125px, auto); gap: 1px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--line); }
.workbench label, .filter-result { min-width: 0; padding: 11px 12px; background: #eef2ec; }
.workbench label > span, .voice-form label > span { display: block; margin-bottom: 6px; color: var(--muted); font: 700 9px/1 var(--utility); letter-spacing: .08em; text-transform: uppercase; }
.workbench select { width: 100%; min-width: 0; height: 34px; padding-left: 8px; border: 0; background-color: transparent; font-size: 12px; }
.filter-result { display: grid; grid-template-columns: auto 1fr; align-content: center; column-gap: 7px; }
.filter-result strong { color: var(--forest); font: 600 25px/1 var(--display); }
.filter-result span { align-self: center; color: var(--muted); font-size: 10px; }
.filter-result .text-button { grid-column: 1 / -1; justify-self: start; margin-top: 5px; font-size: 10px; }
.profile-context { display: grid; grid-template-columns: minmax(180px, 1fr) repeat(3, auto) auto; gap: 1px; margin-bottom: 16px; border: 1px solid var(--forest); background: var(--forest); color: var(--white); }
.profile-context > * { padding: 13px 16px; background: #24483f; }
.profile-context .profile-identity strong { display: block; font: 500 17px/1.2 var(--display); }
.profile-context .profile-identity span { display: block; margin-top: 4px; color: #bcd0c8; font-size: 10px; }
.profile-stat { min-width: 78px; text-align: center; }
.profile-stat strong, .profile-stat span { display: block; }
.profile-stat strong { font: 600 22px/1 var(--display); }
.profile-stat span { margin-top: 4px; color: #bcd0c8; font-size: 9px; }
.voice-button { border: 0; background: var(--amber) !important; color: #2f2718; cursor: pointer; font-weight: 700; font-size: 11px; }
.review-list { display: grid; gap: 12px; }
.review { position: relative; background: var(--white); border: 1px solid var(--line); padding: 20px 22px 18px 26px; transition: transform .18s ease, box-shadow .18s ease; }
.review::before { content: ""; position: absolute; inset: -1px auto -1px -1px; width: 5px; background: var(--line); }
.review[data-priority="urgent"]::before { background: var(--coral); }
.review[data-priority="new"]::before { background: var(--amber); }
.review:hover { transform: translateX(3px); box-shadow: var(--shadow); }
.review-top { display: flex; justify-content: space-between; gap: 18px; }
.review-meta { display: flex; flex-wrap: wrap; gap: 7px 11px; align-items: center; }
.reviewer { font-weight: 700; }
.business { color: var(--moss); font-size: 12px; }
.date { color: var(--muted); font: 10px/1 var(--utility); }
.stars { color: var(--amber); letter-spacing: .08em; white-space: nowrap; }
.review p { margin: 16px 0; line-height: 1.55; color: #33453f; }
.internal-note { margin: 12px 0 !important; padding: 9px 11px; border-left: 2px solid var(--moss); background: var(--sage); color: #344d45 !important; font-size: 11px; }
.internal-note strong { display: block; margin-bottom: 3px; font: 700 9px/1 var(--utility); letter-spacing: .06em; text-transform: uppercase; }
.review-actions { display: flex; gap: 16px; align-items: center; }
.review-actions button { border: 0; background: transparent; padding: 0; color: var(--forest); font-weight: 700; font-size: 12px; cursor: pointer; }
.review-actions .reply-action { border-bottom: 1px solid var(--forest); }
.reply-status { margin-left: auto; color: var(--muted); font-size: 11px; }
.badge { padding: 4px 7px; background: var(--sage); color: var(--forest); font: 700 9px/1 var(--utility); letter-spacing: .05em; text-transform: uppercase; }
.badge.urgent { background: var(--coral-soft); color: #77352d; }
.badge.new { background: var(--amber-soft); color: #76531e; }
.ledger { position: sticky; top: 24px; padding: 26px; background: #e7ece6; border-top: 5px solid var(--forest); }
.pulse-figure { height: 88px; display: flex; align-items: end; gap: 8px; padding: 16px 0 11px; border-bottom: 1px solid #bcc9c1; }
.pulse-bar { flex: 1; min-height: 5px; background: var(--moss); opacity: .34; transform-origin: bottom; animation: rise .55s ease both; }
.pulse-bar.is-current { background: var(--amber); opacity: 1; }
.profile-list { margin-top: 8px; }
.profile-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 13px 0; border-bottom: 1px solid #c5d0c9; }
.profile-row { cursor: pointer; }
.profile-row:hover strong { text-decoration: underline; }
.profile-row > div { min-width: 0; }
.profile-row strong { display: block; font-size: 12px; line-height: 1.35; }
.profile-row > div span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.profile-score { font: 600 18px/1 var(--display) !important; color: var(--forest) !important; }
.sync-note { color: var(--muted); font-size: 11px; margin: 18px 0 0; }
.empty { padding: 48px 24px; border: 1px dashed var(--line); color: var(--muted); text-align: center; line-height: 1.6; }
dialog { width: min(620px, calc(100vw - 30px)); border: 0; padding: 0; color: var(--ink); box-shadow: 0 24px 100px rgba(10,30,24,.3); }
dialog::backdrop { background: rgba(15,35,29,.62); backdrop-filter: blur(3px); }
.reply-form { padding: 28px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 20px; }
.icon-button { min-width: 44px; min-height: 44px; align-self: start; border: 0; background: transparent; font-size: 28px; cursor: pointer; }
blockquote { margin: 22px 0; padding: 14px 17px; border-left: 3px solid var(--amber); background: var(--paper); color: #3c4d47; line-height: 1.5; }
.reply-form label span { display: block; margin-bottom: 8px; font-weight: 700; font-size: 12px; }
textarea, input { width: 100%; border: 1px solid var(--line); border-radius: 0; padding: 11px 13px; line-height: 1.5; color: var(--ink); background: white; }
textarea { resize: vertical; }
.draft-tools { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: 0 0 14px; }
.style-picker { display: inline-flex; border: 1px solid var(--line); }
.style-picker button { border: 0; border-right: 1px solid var(--line); padding: 8px 11px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.style-picker button:last-child { border-right: 0; }
.style-picker button.is-active { background: var(--forest); color: white; }
.ai-button { border: 1px solid var(--amber); padding: 8px 12px; background: var(--amber-soft); color: #624516; cursor: pointer; font-size: 11px; font-weight: 700; }
.ai-button:disabled { opacity: .55; cursor: not-allowed; }
.ai-note { min-height: 16px; margin: -6px 0 10px; color: var(--muted); font-size: 10px; }
.review-signals { display: flex; flex-wrap: wrap; gap: 6px; margin: -10px 0 15px; }
.signal { padding: 5px 8px; background: var(--coral-soft); color: #77352d; font: 700 9px/1 var(--utility); text-transform: uppercase; }
.draft-comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 12px; border: 1px solid var(--line); background: var(--line); }
.draft-comparison > div { padding: 12px; background: var(--paper); }
.draft-comparison span { color: var(--muted); font: 700 9px/1 var(--utility); letter-spacing: .06em; text-transform: uppercase; }
.draft-comparison p { margin: 8px 0 0; white-space: pre-wrap; color: #33453f; font-size: 11px; line-height: 1.5; }
.comparison-toggle { margin-top: 10px; }
.voice-form { max-height: min(820px, calc(100vh - 40px)); overflow-y: auto; }
.voice-form > label { display: block; margin-top: 14px; }
.template-library { margin-top: 18px; padding: 13px 15px; border: 1px solid var(--line); background: var(--paper); }
.template-library summary { cursor: pointer; color: var(--forest); font-weight: 700; font-size: 12px; }
.template-library label { display: block; margin-top: 12px; }
.voice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 22px; }
.voice-grid label:nth-child(3), .voice-grid label:nth-child(4) { margin-top: 2px; }
.voice-grid select { width: 100%; min-width: 0; }
.ai-settings-form > label { display: block; margin-top: 16px; }
.provider-seal { display: grid; grid-template-columns: 1fr auto; gap: 5px 14px; margin-top: 22px; padding: 14px 16px; border-left: 4px solid var(--amber); background: var(--paper); }
.provider-seal span { color: var(--muted); font: 700 9px/1 var(--utility); letter-spacing: .08em; text-transform: uppercase; }
.provider-seal strong { grid-row: 1 / 3; grid-column: 2; align-self: center; font: 500 20px/1 var(--display); }
.provider-seal small { color: var(--moss); font-size: 11px; }
.ai-settings-actions { align-items: center; }
.ai-settings-actions .danger-action { margin-right: auto; color: var(--coral); }
.form-note { color: var(--muted); font-size: 11px; }
.dialog-actions { display: flex; justify-content: end; gap: 9px; margin-top: 20px; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 380px; padding: 13px 17px; background: var(--ink); color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; font-size: 13px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--coral); }
@keyframes rise { from { transform: scaleY(.1); } }
@media (max-width: 980px) {
  .shell { grid-template-columns: 78px minmax(0,1fr); }
  .rail { padding-inline: 14px; }
  .brand div, .nav-item:not(.is-active), .nav-item span, .connection-card div { display: none; }
  .brand { justify-content: center; }
  .nav-item { text-align: center; }
  .ai-config-trigger { grid-template-columns: 1fr; justify-items: center; padding-inline: 4px; }
  .ai-config-trigger > span:last-child { display: none; }
  .connection-card { grid-template-columns: 1fr; justify-items: center; }
  .workspace { grid-template-columns: 1fr; }
  .ledger { position: static; }
  .topbar { align-items: stretch; flex-direction: column; }
  .top-actions { justify-content: end; }
  h1 { max-width: 620px; }
  .workbench { grid-template-columns: 1fr 1fr; }
  .filter-result { grid-column: 1 / -1; }
  .profile-context { grid-template-columns: 1fr repeat(3, auto); }
  .profile-context .voice-button { grid-column: 1 / -1; }
  .publication-sheet { grid-template-columns: 1fr; }
  .publication-preview { position: static; }
}
@media (max-width: 700px) {
  .shell { display: block; }
  .rail { position: static; width: 100%; height: auto; padding: 14px 18px; flex-direction: row; align-items: center; justify-content: space-between; }
  .brand { border: 0; padding: 0; }
  .brand div { display: block; }
  .rail nav { display: none; }
  .connection-card { margin: 0; padding: 0; border: 0; }
  .ai-config-trigger { width: auto; margin: 0 10px 0 auto; padding: 5px; border: 0; }
  main { padding: 28px 18px 54px; }
  .topbar, .top-actions { align-items: stretch; flex-direction: column; }
  h1 { font-size: 40px; }
  .profile-filter select { width: 100%; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics article:nth-child(2) { border-right: 0; }
  .metrics article { border-bottom: 1px solid var(--line); }
  .setup-panel { grid-template-columns: 1fr; }
  .setup-actions { flex-direction: column; align-items: stretch; }
  .section-heading { align-items: start; flex-direction: column; }
  .review-top { flex-direction: column; }
  .workbench { grid-template-columns: 1fr; }
  .filter-result { grid-column: auto; }
  .profile-context { grid-template-columns: 1fr 1fr 1fr; }
  .profile-context .profile-identity, .profile-context .voice-button { grid-column: 1 / -1; }
  .draft-tools { align-items: stretch; flex-direction: column; }
  .style-picker { display: grid; grid-template-columns: repeat(3, 1fr); }
  .draft-comparison, .voice-grid { grid-template-columns: 1fr; }
  .publication-board { padding: 20px 16px; }
  .publication-board-heading, .publication-card { display: flex; flex-direction: column; align-items: stretch; }
  .publication-card-actions { text-align: left; }
  .profile-checklist, .publication-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }

/* Interfaz serena: selección de perfil primero, una sola tarea después. */
:root {
  --ink: #17231f;
  --forest: #173f35;
  --moss: #4e756a;
  --brand-turquoise: #1daeb3;
  --brand-turquoise-deep: #0d7377;
  --brand-lime: #b7d957;
  --brand-lime-soft: #f0f7dc;
  --sage: #e7f0ec;
  --paper: #f3f6f7;
  --white: #ffffff;
  --line: #dfe6e3;
  --muted: #596a63;
  --amber: #b7791f;
  --amber-soft: #f8ecd7;
  --coral: #bd6559;
  --coral-soft: #faece9;
  --shadow: 0 7px 24px rgba(23, 63, 53, .055);
  --display: "Avenir Next", "Segoe UI", sans-serif;
  --body: "Avenir Next", "Segoe UI", sans-serif;
}

html { scroll-padding-top: 16px; }
body { min-width: 320px; background: var(--paper); font-size: 16px; line-height: 1.5; }
button, a, select, input, textarea { touch-action: manipulation; -webkit-tap-highlight-color: rgba(183, 121, 31, .18); }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--brand-turquoise);
  outline-offset: 3px;
}
.skip-link { border-radius: 8px; }
body.is-profile-home .shell { display: block; }
body.is-profile-home .rail { display: none; }
body.is-profile-home main { max-width: 1220px; margin: 0 auto; padding-top: 0; }
.profile-home { padding-bottom: 60px; }
.home-header { min-height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid rgba(23, 63, 53, .09); }
.home-brand { display: flex; align-items: center; gap: 11px; color: var(--forest); }
.brand-logo { width: 48px; height: 40px; padding: 3px; border-radius: 10px; background: var(--white); object-fit: contain; }
.home-brand .brand-logo { box-shadow: 0 2px 10px rgba(13, 115, 119, .1); }
.home-brand strong { font-size: 15px; letter-spacing: -.01em; }
.home-intro { max-width: 670px; padding: 64px 0 34px; }
.home-intro h1 { max-width: 620px; font-size: clamp(34px, 5vw, 54px); line-height: 1.04; letter-spacing: -.045em; font-weight: 650; }
.home-intro > p:last-child { max-width: 590px; margin: 17px 0 0; color: var(--muted); font-size: 15px; line-height: 1.65; }
.profile-search { display: grid; grid-template-columns: minmax(240px, 420px) auto; align-items: end; gap: 7px 16px; margin-bottom: 18px; }
.profile-search label { grid-column: 1; color: var(--ink); font-size: 13px; font-weight: 700; }
.profile-search input { grid-column: 1; min-height: 46px; padding-inline: 14px; background: var(--white); }
.profile-search span { grid-column: 2; grid-row: 2; color: var(--muted); font-size: 12px; }
.home-profile-list { display: grid; gap: 12px; }
.profile-row { width: 100%; display: grid; grid-template-columns: 46px minmax(220px, 1fr) minmax(110px, auto) minmax(145px, auto) 26px; align-items: center; gap: 18px; padding: 17px 20px; border: 1px solid rgba(23, 63, 53, .08); border-radius: 11px; background: var(--white); color: var(--ink); text-align: left; box-shadow: 0 2px 10px rgba(23, 63, 53, .025); cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.profile-row:hover { transform: translateY(-2px); border-color: rgba(23, 63, 53, .18); box-shadow: var(--shadow); }
.profile-row:focus-visible { outline: 3px solid rgba(216, 160, 71, .45); outline-offset: 2px; }
.profile-avatar { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; background: #e3f3f2; color: var(--brand-turquoise-deep); font-size: 16px; font-weight: 750; }
.profile-copy, .profile-rating { min-width: 0; }
.profile-copy strong, .profile-copy span, .profile-rating strong, .profile-rating small { display: block; }
.profile-copy strong { overflow: hidden; color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.profile-rating { text-align: right; }
.profile-rating strong { color: var(--forest); font-size: 17px; }
.profile-rating small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.profile-state { display: inline-flex; align-items: center; gap: 7px; justify-self: end; padding: 7px 10px; border-radius: 99px; background: var(--brand-lime-soft); color: #496316; font-size: 10px; font-weight: 700; white-space: nowrap; }
.profile-state i { width: 6px; height: 6px; border-radius: 50%; background: #719c21; }
.profile-state.needs-attention { background: var(--amber-soft); color: #80591e; }
.profile-state.needs-attention i { background: var(--amber); }
.profile-arrow { color: #9baba5; font-size: 18px; transition: transform .16s ease; }
.profile-row:hover .profile-arrow { transform: translateX(3px); color: var(--forest); }
.profile-home > .sync-note { margin: 20px 4px 0; }

.shell { grid-template-columns: 224px minmax(0, 1fr); }
.rail { padding: 24px 18px; background: #173b33; }
.brand { padding: 0 4px 24px; border: 0; }
.brand .brand-logo { width: 42px; height: 35px; padding: 2px; border-radius: 9px; box-shadow: 0 0 0 1px rgba(255,255,255,.12); }
.brand strong { font-family: var(--body); font-size: 15px; font-weight: 700; }
.rail-profile { display: flex; align-items: center; gap: 10px; min-height: 66px; padding: 12px 10px; border-radius: 10px; background: rgba(255,255,255,.06); }
.rail-profile .profile-avatar { width: 35px; height: 35px; border-radius: 10px; background: rgba(255,255,255,.12); color: white; font-size: 13px; }
.rail-profile > span:last-child { min-width: 0; }
.rail-profile strong, .rail-profile small { display: block; }
.rail-profile strong { overflow: hidden; font-size: 11px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.rail-profile small { margin-top: 3px; color: #aac0b8; font-size: 9px; }
.rail nav { gap: 6px; margin-top: 22px; }
.nav-item { padding: 11px 12px; border: 0; border-radius: 8px; font-size: 12px; }
.nav-item { min-height: 44px; display: flex; align-items: center; }
.nav-item:hover, .nav-item.is-active { border: 0; background: rgba(255,255,255,.09); }
.nav-item.is-active { box-shadow: inset 3px 0 0 var(--brand-lime); }
.nav-item.is-active > span { color: var(--brand-lime); }
.ai-config-trigger { border: 0; border-radius: 9px; background: rgba(255,255,255,.055); }
.connection-card { border: 0; padding: 12px 8px 0; }

main { padding: 36px clamp(24px, 4vw, 62px) 70px; }
.profile-workspace { max-width: 1180px; margin: 0 auto; }
.topbar { align-items: center; padding-bottom: 26px; border: 0; }
.topbar h1 { font-size: clamp(28px, 3.6vw, 44px); line-height: 1.06; font-weight: 650; }
.eyebrow { color: var(--brand-turquoise-deep); letter-spacing: .11em; }
h2 { font-family: var(--body); font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.button, .file-button { min-height: 44px; border-color: transparent; border-radius: 8px; background: white; box-shadow: 0 2px 9px rgba(23, 63, 53, .05); }
.button:hover, .file-button:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.button-primary { border-color: var(--forest); background: var(--forest); }
.button-quiet { color: var(--forest); }
select, textarea, input { border-color: var(--line); border-radius: 8px; }
select, input { min-height: 44px; }
select { background-color: var(--white); color: var(--ink); }
.activity-status { margin: 0 0 18px; padding: 11px 14px; border-left: 4px solid var(--moss); border-radius: 0 8px 8px 0; background: var(--sage); color: var(--forest); font-size: 13px; }
.activity-status.is-error { border-left-color: var(--coral); background: var(--coral-soft); color: #6f3028; }

.publication-board, .setup-panel, .rating-distribution { margin-top: 24px; padding: 26px; border: 1px solid rgba(23,63,53,.07); border-radius: 12px; background: var(--white); box-shadow: var(--shadow); }
.publication-history { gap: 12px; }
.publication-card { border: 0; border-radius: 10px; background: #f7f9f8; }
.publication-card:first-child { border: 0; }
.publication-thumb { border-radius: 8px; }
.publication-summary span, .target-result { border-radius: 99px; }
.pulse-view { margin-top: 24px; }
.metrics { gap: 14px; margin-top: 0; border: 0; background: transparent; }
.metrics article { min-height: 132px; padding: 21px; border: 1px solid rgba(23,63,53,.07); border-radius: 11px; background: var(--white); box-shadow: var(--shadow); }
.metrics .metric-new { background: var(--forest); border-color: var(--forest); }
.metrics strong { font-family: var(--body); font-size: 34px; font-weight: 650; }
.rating-distribution { display: grid; grid-template-columns: minmax(190px, .7fr) minmax(280px, 1.3fr); align-items: end; gap: 32px; }
.pulse-figure { height: 150px; gap: 12px; padding: 10px 0 0; border: 0; }
.pulse-column { min-width: 0; flex: 1; height: 100%; display: grid; grid-template-rows: 22px 1fr 20px; justify-items: center; align-items: end; }
.pulse-column strong { color: var(--forest); font-size: 12px; font-variant-numeric: tabular-nums; }
.pulse-column small { color: var(--muted); font-size: 10px; }
.pulse-bar { width: 100%; max-width: 72px; border-radius: 7px 7px 3px 3px; background: #8da99f; }

.workspace { display: block; margin-top: 24px; }
.section-heading { margin-bottom: 18px; }
.workbench { grid-template-columns: repeat(4, minmax(118px, 1fr)) minmax(125px, auto); gap: 10px; padding: 12px; border: 0; border-radius: 11px; background: var(--white); box-shadow: var(--shadow); }
.workbench label, .filter-result { border-radius: 8px; background: #f4f7f6; }
.profile-context { gap: 10px; padding: 10px; border: 0; border-radius: 11px; background: var(--forest); box-shadow: var(--shadow); }
.profile-context > * { border-radius: 7px; background: rgba(255,255,255,.055); }
.voice-button { border-radius: 7px; }
.review-list { gap: 14px; }
.load-more { width: 100%; margin-top: 16px; }
.load-more[aria-disabled="true"] { cursor: default; color: var(--muted); box-shadow: none; }
.review { overflow: hidden; padding: 20px 22px 18px 27px; border: 1px solid rgba(23,63,53,.07); border-radius: 11px; box-shadow: 0 2px 10px rgba(23,63,53,.025); }
.review::before { inset: 0 auto 0 0; width: 4px; }
.review:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.empty { border: 0; border-radius: 11px; background: var(--white); box-shadow: var(--shadow); }
.badge, .signal { border-radius: 99px; }
.text-button { border-bottom: 0; text-decoration: underline; text-decoration-color: rgba(78,117,106,.35); text-underline-offset: 3px; }
.text-button { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 4px; }
.review-actions { flex-wrap: wrap; gap: 4px 12px; }
.review-actions button { min-height: 44px; padding: 8px 2px; }
.reply-status { font-size: 12px; }
.date, .badge, .profile-stat span, .rail-profile small { font-size: 10px; }

dialog { max-height: calc(100dvh - 24px); border-radius: 14px; overscroll-behavior: contain; }
.reply-form { background: white; }
.style-picker { overflow: hidden; border-radius: 8px; }
.profile-picker, .delivery-picker, .template-library { border-color: var(--line); border-radius: 9px; }
.profile-checklist { gap: 6px; padding: 6px; border: 0; border-radius: 8px; background: #f2f5f4; }
.profile-checklist label { border-radius: 6px; }
.publication-specific, .provider-seal, blockquote { border-radius: 0 8px 8px 0; }
.publication-preview { border: 0; border-radius: 11px; box-shadow: var(--shadow); }
.preview-image, .preview-button { border-radius: 7px; }
.toast { border-radius: 9px; }
.toast { bottom: max(22px, env(safe-area-inset-bottom)); }
.publication-form > .dialog-actions { position: sticky; z-index: 2; bottom: -28px; margin-inline: -28px; padding: 14px 28px; border-top: 1px solid var(--line); background: rgba(255,255,255,.97); }
.publication-form-status { margin: 16px 0 0; padding: 12px 14px; border-radius: 9px; background: #edf5f0; color: var(--ink); font-size: 14px; line-height: 1.45; }
.publication-form-status.is-error { background: #fff0ed; color: #8f271c; }

.auth-page { min-height: 100vh; background: #173f35; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr); padding: 0; }
.auth-intro { display: grid; align-content: center; padding: clamp(40px, 8vw, 110px); color: var(--white); }
.auth-intro .home-brand { position: absolute; top: 34px; }
.auth-intro .eyebrow { margin-top: 80px; color: var(--brand-lime); }
.auth-intro h1 { max-width: 720px; font-size: clamp(42px, 6vw, 76px); line-height: .96; }
.auth-intro > p:last-child { max-width: 610px; margin: 28px 0 0; color: #c8d8d2; font-size: 16px; line-height: 1.7; }
.auth-card { width: min(520px, calc(100% - 40px)); align-self: center; justify-self: center; padding: clamp(28px, 5vw, 54px); border-radius: 14px; background: var(--white); box-shadow: 0 30px 90px rgba(7, 27, 21, .28); }
.auth-card h2 { font-size: clamp(28px, 4vw, 40px); }
.auth-description { margin: 12px 0 26px; color: var(--muted); line-height: 1.55; }
.auth-card form { display: grid; gap: 18px; }
.auth-card label span { display: block; margin-bottom: 7px; color: var(--ink); font-size: 13px; font-weight: 700; }
.auth-card input { min-height: 48px; }
.auth-card .button { width: 100%; margin-top: 4px; }
.auth-help { margin: -6px 0 0; color: var(--muted); font-size: 12px; }
.auth-status { margin: 0; padding: 11px 13px; border-radius: 8px; background: var(--coral-soft); color: #7c3027; font-size: 13px; }
.account-controls { display: flex; align-items: center; gap: 8px; }
.account-identity { display: grid; text-align: right; }
.account-identity strong { color: var(--forest); font-size: 12px; }
.account-identity span { color: var(--muted); font-size: 10px; }
.account-button { min-height: 38px; padding-inline: 12px; }
.rail-account { margin-top: 14px; padding: 12px 10px; border-radius: 9px; background: rgba(255,255,255,.055); }
.rail-account .account-identity { text-align: left; }
.rail-account .account-identity strong { color: white; }
.rail-account .account-identity span { color: #aac0b8; }
.rail-account-actions { display: flex; gap: 5px; margin-top: 9px; }
.rail-account button { min-height: 32px; padding: 5px 7px; border: 1px solid rgba(255,255,255,.16); border-radius: 6px; background: transparent; color: white; cursor: pointer; font-size: 10px; }
.user-admin-dialog { width: min(760px, calc(100vw - 30px)); }
.user-admin-list { display: grid; gap: 8px; margin: 20px 0; }
.user-admin-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 8px; background: var(--paper); }
.user-admin-row strong, .user-admin-row span { display: block; }
.user-admin-row span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.user-admin-row button { min-height: 36px; }
.admin-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; padding-top: 18px; border-top: 1px solid var(--line); }
.admin-form h3, .admin-form .form-note, .admin-form .dialog-actions { grid-column: 1 / -1; }
.admin-form label span { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 700; }
.admin-form select { width: 100%; }

@media (max-width: 980px) {
  body.is-profile-home main { padding-inline: 28px; }
  .shell { grid-template-columns: 190px minmax(0, 1fr); }
  .rail { padding-inline: 14px; }
  .rail .brand div, .rail .nav-item:not(.is-active), .rail .connection-card div { display: block; }
  .rail .nav-item { display: flex; text-align: left; }
  .rail .nav-item span { display: inline; margin-right: 10px; }
  .rail .ai-config-trigger { grid-template-columns: 31px 1fr; justify-items: stretch; padding-inline: 10px; }
  .rail .ai-config-trigger > span:last-child { display: block; }
  .rail .connection-card { grid-template-columns: 10px 1fr; justify-items: stretch; }
  .profile-row { grid-template-columns: 46px minmax(180px,1fr) 90px 26px; }
  .profile-state { display: none; }
  .workbench { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-intro { min-height: 42vh; padding: 90px 24px 44px; }
  .auth-intro .home-brand { top: 22px; }
  .auth-intro .eyebrow { margin-top: 0; }
  .auth-intro h1 { font-size: 42px; }
  .auth-card { margin: -18px auto 28px; }
  .account-identity { display: none; }
  .admin-form { grid-template-columns: 1fr; }
  .admin-form h3, .admin-form .form-note, .admin-form .dialog-actions { grid-column: 1; }
  .user-admin-row { grid-template-columns: 1fr auto; }
  .user-admin-row .user-role { display: none; }
  body.is-profile-home main { padding: 0 18px 48px; }
  .home-header { min-height: 72px; }
  .home-intro { padding: 42px 0 28px; }
  .home-intro h1 { font-size: 36px; }
  .profile-search { grid-template-columns: 1fr; }
  .profile-search span { grid-column: 1; grid-row: auto; }
  .profile-row { grid-template-columns: 40px minmax(0,1fr) 22px; gap: 12px; padding: 15px; }
  .profile-avatar { width: 38px; height: 38px; }
  .profile-rating { display: none; }
  .profile-copy strong { white-space: normal; }
  .rail { position: sticky; top: 0; z-index: 10; border-radius: 0 0 12px 12px; }
  .rail-profile { display: none; }
  .brand div span { display: none; }
  .rail nav { position: fixed; z-index: 20; inset: auto 10px max(10px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0; padding: 6px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: rgba(23,59,51,.96); box-shadow: 0 12px 36px rgba(10,30,24,.28); backdrop-filter: blur(12px); }
  .rail .nav-item, .rail .nav-item:not(.is-active) { min-height: 48px; display: flex; justify-content: center; padding: 9px 4px; text-align: center; font-size: 11px; }
  .rail .nav-item span { display: none; }
  .rail .nav-item.is-active { box-shadow: inset 0 -2px 0 var(--brand-lime); }
  .rail .ai-config-trigger, .rail .connection-card { display: none; }
  .profile-workspace { padding-top: 4px; }
  .profile-workspace { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .topbar { align-items: flex-start; }
  .metrics { gap: 10px; }
  .metrics article { min-height: 115px; border: 0; }
  .rating-distribution { grid-template-columns: 1fr; }
  .workbench { grid-template-columns: 1fr; }
  .publication-board, .rating-distribution { padding: 20px 16px; }
  .review-actions .reply-status { width: 100%; margin-left: 0; }
  .dialog-actions { position: sticky; bottom: 0; margin-inline: -10px; padding: 12px 10px max(4px, env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); }
}
