:root {
  --ink: #101114;
  --muted: #6e7078;
  --line: #e7e7ea;
  --soft: #f6f6f7;
  --white: #fff;
  --green: #18a875;
  --green-soft: #eaf8f2;
  --blue: #1b6fff;
  --blue-soft: #edf4ff;
  --amber: #a66b00;
  --amber-soft: #fff5db;
  --red: #c43636;
  --shadow: 0 20px 60px rgba(17, 18, 22, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--white); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--white);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 19px; font-weight: 800; text-decoration: none; letter-spacing: -.03em; }
.brand-mark, .wizard-agent, .autopilot-icon, .site-avatar {
  display: inline-grid;
  place-items: center;
  color: var(--white);
  background: var(--ink);
  border-radius: 10px;
  font-weight: 800;
}
.brand-mark { width: 28px; height: 28px; font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.system-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.text-button, .back-button, .text-link { padding: 0; border: 0; color: var(--ink); background: transparent; font-size: 13px; font-weight: 650; }
.text-button:hover, .back-button:hover, .text-link:hover { color: var(--blue); }

.auth-shell {
  min-height: calc(100vh - 66px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr);
  align-items: center;
  gap: clamp(40px, 8vw, 120px);
  max-width: 1180px;
  margin: 0 auto;
  padding: 64px 32px 96px;
}
.auth-copy { max-width: 610px; }
.eyebrow { display: block; margin-bottom: 10px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.auth-copy h1 { max-width: 580px; margin: 0; font-size: clamp(48px, 6vw, 78px); line-height: .98; letter-spacing: -.065em; }
.auth-copy > p { max-width: 580px; margin: 26px 0 0; color: var(--muted); font-size: 18px; line-height: 1.7; }
.proof-line { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.proof-line span { padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; color: #4b4d54; background: var(--white); font-size: 12px; font-weight: 650; }

.auth-card { width: 100%; max-width: 470px; padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: var(--white); box-shadow: var(--shadow); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; margin-bottom: 28px; border-radius: 12px; background: var(--soft); }
.auth-tab { padding: 11px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 700; }
.auth-tab.active { color: var(--ink); background: var(--white); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { font-size: 12px; font-weight: 750; }
.field small, .form-help, .form-help-text { color: var(--muted); font-size: 11px; line-height: 1.5; }
input, textarea, select {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid #d9dade;
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: var(--white);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(16, 17, 20, .08); }
.primary-button, .secondary-button {
  min-height: 44px;
  padding: 11px 17px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 750;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}
.primary-button { border: 1px solid var(--ink); color: var(--white); background: var(--ink); }
.primary-button:hover { transform: translateY(-1px); background: #292b31; }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: var(--white); }
.secondary-button:hover { border-color: #c9cacf; background: var(--soft); }
.primary-button:disabled, .secondary-button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.full { width: 100%; }
.form-error { min-height: 18px; margin: 12px 0 0; color: var(--red); font-size: 12px; line-height: 1.5; }
.auth-note { margin: 18px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; }

.wizard-shell { min-height: calc(100vh - 66px); padding: 52px 20px 100px; background: #fbfbfc; }
.wizard-wrap { width: min(100%, 620px); margin: 0 auto; }
.wizard-progress { width: 100%; height: 5px; overflow: hidden; margin-bottom: 26px; border-radius: 999px; background: #e4e4e7; }
.wizard-progress span { display: block; width: 10%; height: 100%; border-radius: inherit; background: var(--ink); transition: width .25s ease; }
.back-button { margin-bottom: 28px; }
.back-button::before { content: "‹"; margin-right: 6px; font-size: 18px; vertical-align: -1px; }
.wizard-agent { width: 34px; height: 34px; margin-bottom: 12px; border-radius: 50%; font-size: 13px; }
.wizard-card { min-height: 240px; padding: 26px; border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: 0 12px 40px rgba(17, 18, 22, .055); }
.wizard-card h1 { margin: 0; font-size: clamp(25px, 4vw, 34px); line-height: 1.2; letter-spacing: -.04em; }
.wizard-card > p { margin: 12px 0 22px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.wizard-actions { margin-top: 18px; }
.choice-grid { display: grid; gap: 10px; }
.choice-button { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--white); text-align: left; font-size: 13px; font-weight: 650; }
.choice-button::after { content: ""; width: 14px; height: 14px; border: 1px solid #bbbcc2; border-radius: 50%; }
.choice-button.selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.choice-button.selected::after { border: 4px solid var(--white); background: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.wizard-fields { display: grid; gap: 14px; }
.wizard-fields .field { margin: 0; }
.wizard-summary { display: grid; gap: 10px; }
.summary-row { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.summary-row span { color: var(--muted); }
.summary-row strong { max-width: 60%; text-align: right; }
.personal-plan { padding: 16px; border-radius: 12px; background: var(--soft); color: #34363b; font-size: 13px; line-height: 1.65; }

.app-shell { min-height: calc(100vh - 66px); display: grid; grid-template-columns: 236px minmax(0, 1fr); background: #fafafb; }
.sidebar { position: sticky; top: 66px; height: calc(100vh - 66px); display: flex; flex-direction: column; padding: 24px 16px; border-right: 1px solid var(--line); background: var(--white); }
.sidebar-site { display: flex; align-items: center; gap: 11px; padding: 8px 8px 20px; border-bottom: 1px solid var(--line); }
.site-avatar { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 10px; }
.sidebar-site span:last-child { min-width: 0; display: grid; gap: 3px; }
.sidebar-site strong, .sidebar-site small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-site strong { font-size: 12px; }
.sidebar-site small { color: var(--muted); font-size: 10px; }
.side-nav { display: grid; gap: 5px; margin-top: 22px; }
.side-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 9px; color: #5b5d65; background: transparent; text-align: left; font-size: 12px; font-weight: 650; }
.side-link span { width: 18px; text-align: center; }
.side-link:hover, .side-link.active { color: var(--ink); background: var(--soft); }
.side-help { margin-top: auto; padding: 15px; border-radius: 12px; background: var(--soft); }
.side-help strong { font-size: 11px; }
.side-help p { margin: 5px 0 9px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.side-help a { color: var(--ink); font-size: 10px; font-weight: 750; }

.app-main { min-width: 0; padding: clamp(24px, 4vw, 48px); }
.app-panel { max-width: 1240px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 26px; }
.page-head h2 { margin: 0; font-size: clamp(30px, 4vw, 44px); letter-spacing: -.045em; }
.page-head p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric-card { display: grid; gap: 6px; min-height: 122px; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--white); }
.metric-card > span { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.metric-card strong { align-self: end; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.metric-card .metric-plan { font-size: 20px; }
.metric-card small { color: var(--muted); font-size: 10px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; }
.panel-card { border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel-head h3 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.calendar-card { min-height: 620px; padding: 22px; }
.legend { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; font-weight: 650; }
.legend i { width: 7px; height: 7px; margin-left: 5px; border-radius: 50%; }
.legend i.published { background: var(--green); }
.legend i.queued { background: var(--blue); }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { margin-top: 22px; border-bottom: 1px solid var(--line); }
.calendar-weekdays span { padding: 8px 5px; color: var(--muted); font-size: 8px; font-weight: 750; text-align: center; text-transform: uppercase; }
.calendar-grid { border-left: 1px solid var(--line); }
.calendar-day { position: relative; min-height: 94px; padding: 8px; overflow: hidden; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--white); }
.calendar-day .day-number { color: var(--muted); font-size: 9px; }
.calendar-day .day-topic { display: -webkit-box; margin-top: 9px; overflow: hidden; color: #3a3c43; font-size: 9px; font-weight: 650; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.calendar-day::after { content: ""; position: absolute; top: 9px; right: 9px; width: 6px; height: 6px; border-radius: 50%; }
.calendar-day.published { background: var(--green-soft); }
.calendar-day.published::after { background: var(--green); }
.calendar-day.queued { background: var(--blue-soft); }
.calendar-day.queued::after { background: var(--blue); }
.calendar-day.draft { background: var(--amber-soft); }
.calendar-day.draft::after { background: var(--amber); }
.dashboard-side { display: grid; align-content: start; gap: 14px; }
.autopilot-card, .connection-card { padding: 20px; }
.autopilot-head { display: flex; align-items: center; gap: 11px; }
.autopilot-icon { width: 40px; height: 40px; border-radius: 50%; }
.autopilot-head span:last-child { display: grid; gap: 3px; }
.autopilot-head small { color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.autopilot-head strong { font-size: 13px; }
.autopilot-card > p, .connection-card > p { margin: 16px 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.next-run { display: flex; justify-content: space-between; gap: 12px; padding: 13px 0; margin-bottom: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 9px; }
.next-run span { color: var(--muted); }
.next-run strong { font-size: 9px; }
.autopilot-card .secondary-button { margin-top: 8px; }
.connection-card h3 { margin: 0; font-size: 16px; }
.text-link { text-decoration: underline; text-underline-offset: 3px; }

.article-list-card { overflow: hidden; }
.article-list { display: grid; }
.article-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 120px 28px; align-items: center; gap: 16px; min-height: 78px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.article-row:last-child { border-bottom: 0; }
.article-status { width: fit-content; padding: 5px 8px; border-radius: 999px; font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.article-status.published { color: #087a54; background: var(--green-soft); }
.article-status.draft { color: var(--amber); background: var(--amber-soft); }
.article-title { min-width: 0; }
.article-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.article-title small, .article-date { color: var(--muted); font-size: 9px; }
.article-link { color: var(--ink); font-size: 16px; text-decoration: none; }
.empty-state { padding: 48px 20px; color: var(--muted); text-align: center; font-size: 12px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-card { padding: 22px; }
.settings-card .panel-head { margin-bottom: 22px; }
.two-col { grid-template-columns: 120px minmax(0, 1fr); }
.two-col > span { display: grid; gap: 8px; }
.full-row { grid-column: 1 / -1; }
.connection-badge { padding: 6px 9px; border-radius: 999px; color: var(--muted); background: var(--soft); font-size: 9px; font-weight: 750; }
.connection-tabs { display: flex; gap: 6px; margin-bottom: 22px; }
.connection-tab { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--white); font-size: 10px; font-weight: 700; }
.connection-tab.active { border-color: var(--ink); color: var(--white); background: var(--ink); }
.connection-form { max-width: 680px; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(390px, calc(100vw - 44px)); padding: 13px 16px; border-radius: 10px; color: var(--white); background: var(--ink); box-shadow: var(--shadow); font-size: 11px; font-weight: 650; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.loading-cover { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; justify-items: center; gap: 14px; background: rgba(255,255,255,.92); backdrop-filter: blur(4px); font-size: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 720px; }
  .auth-card { max-width: none; }
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 18px 10px; }
  .sidebar-site span:last-child, .side-link:not(.active)::after, .side-link { font-size: 0; }
  .sidebar-site { justify-content: center; padding-inline: 0; }
  .side-link { justify-content: center; padding: 12px; }
  .side-link span { font-size: 16px; }
  .side-help { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .topbar { height: 58px; padding: 0 16px; }
  .system-status { display: none; }
  .auth-shell { min-height: calc(100vh - 58px); padding: 46px 18px 70px; }
  .auth-copy h1 { font-size: 48px; }
  .auth-copy > p { font-size: 15px; }
  .auth-card { padding: 24px 18px; border-radius: 16px; }
  .wizard-shell { min-height: calc(100vh - 58px); padding: 32px 15px 70px; }
  .wizard-card { padding: 20px 17px; }
  .app-shell { display: block; min-height: calc(100vh - 58px); }
  .sidebar { position: fixed; top: auto; right: 0; bottom: 0; left: 0; z-index: 40; width: auto; height: 64px; display: block; padding: 7px 10px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); border-right: 0; }
  .sidebar-site, .side-help { display: none; }
  .side-nav { grid-template-columns: repeat(3, 1fr); margin: 0; }
  .side-link { display: grid; justify-items: center; gap: 2px; padding: 5px; font-size: 8px; }
  .side-link span { font-size: 15px; }
  .app-main { padding: 24px 14px 94px; }
  .page-head { align-items: flex-start; }
  .page-head h2 { font-size: 34px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { min-height: 105px; }
  .dashboard-side, .settings-grid { grid-template-columns: 1fr; }
  .calendar-card { min-height: 0; padding: 15px; overflow-x: auto; }
  .calendar-weekdays, .calendar-grid { min-width: 620px; }
  .full-row { grid-column: auto; }
  .article-row { grid-template-columns: 78px minmax(0, 1fr) 24px; }
  .article-date { display: none; }
  .two-col { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
