:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --border: #e3e7ee;
  --border-2: #eef1f6;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --muted: #f1f3f8;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-soft: #eef2ff;
  --emerald: #059669;
  --emerald-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --rose: #e11d48;
  --rose-soft: #fef2f2;
  --radius: 8px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

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

.hidden { display: none !important; }
.mono { font-family: var(--mono); }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: #ffffff; border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1600px; margin: 0 auto;
  padding: 0 16px;
  height: 52px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 11px;
}
.brand-name { font-weight: 800; font-size: 13px; letter-spacing: -0.2px; }

.tabs { display: flex; gap: 2px; background: var(--muted); padding: 3px; border-radius: var(--radius); }
.tab-btn {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 12px; border-radius: 5px;
  font: inherit; font-weight: 700; font-size: 11.5px; color: var(--text-2);
  transition: background .12s, color .12s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.on { background: #ffffff; color: var(--text); box-shadow: 0 1px 2px rgba(15,23,42,.08); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 11px;
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  border-radius: var(--radius-sm); font: inherit; font-weight: 700; font-size: 11.5px;
  cursor: pointer; transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #4338ca; border-color: #4338ca; }
.btn-dark { background: #0f172a; border-color: #0f172a; color: #fff; }
.btn-dark:hover { background: #1e293b; border-color: #1e293b; }
.btn-emerald { background: var(--emerald); border-color: var(--emerald); color: #fff; }
.btn-emerald:hover { background: #047857; border-color: #047857; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--rose); }
.btn-danger:hover { background: var(--rose-soft); }
.btn-ghost { background: transparent; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 11px; }
.btn-icon { width: 30px; padding: 0; justify-content: center; }
.btn-icon.btn-sm { width: 26px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 14px 16px;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.sidebar {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px;
  position: sticky; top: 66px;
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column; gap: 8px;
}
@media (max-width: 860px) {
  .sidebar { position: static; max-height: none; }
}

.search-row { display: flex; gap: 6px; }
.search-row input {
  flex: 1; height: 30px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; font: inherit; font-size: 11.5px; color: var(--text);
  outline: none;
}
.search-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }

.list-count {
  font-size: 10px; font-weight: 800; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em; padding: 0 2px;
}

.domain-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.domain-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 7px 8px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  font-size: 12px; transition: background .12s, border-color .12s;
}
.domain-item:hover { background: var(--muted); }
.domain-item.active { background: var(--accent-soft); border-color: #c7d2fe; }
.domain-item .dom-name { font-weight: 700; color: var(--text); word-break: break-all; }
.domain-item .dom-posts { font-size: 10px; color: var(--text-3); font-weight: 700; white-space: nowrap; }

/* ---------- welcome ---------- */
.welcome {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 60px 24px; text-align: center;
}
.welcome-icon { margin: 0 auto 14px; width: 72px; height: 72px; }
.welcome h1 { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; margin: 0 0 6px; }
.welcome p { font-size: 12px; color: var(--text-3); font-weight: 600; margin: 0; }

/* ---------- editor ---------- */
.editor { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.card-tight { padding: 8px; }

.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.editor-head h2 { font-size: 16px; font-weight: 800; letter-spacing: -0.2px; margin: 0; word-break: break-all; }
.editor-head .actions { display: flex; align-items: center; gap: 6px; }

.section-tabs { display: flex; gap: 2px; background: var(--muted); padding: 3px; border-radius: var(--radius); }
.section-tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 5px 12px; border-radius: 5px;
  font: inherit; font-weight: 700; font-size: 11.5px; color: var(--text-2);
}
.section-tab.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(15,23,42,.08); }

.group-label {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-3);
  margin: 12px 2px 6px;
}
.group-label:first-child { margin-top: 0; }

/* ---------- floating-label fields ---------- */
.fld {
  position: relative;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  display: flex; align-items: stretch;
  transition: border-color .12s, box-shadow .12s;
}
.fld:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.fld > label {
  position: absolute; top: 3px; left: 9px;
  font-size: 8.5px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-3);
  pointer-events: none;
  background: transparent;
}
.fld > input,
.fld > select {
  flex: 1; width: 100%;
  padding: 14px 9px 3px 9px;
  border: 0; background: transparent; outline: none;
  font: inherit; font-size: 11.5px; font-weight: 600; color: var(--text);
  border-radius: var(--radius-sm);
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
}
.fld > select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(-45deg, transparent 50%, var(--text-3) 50%);
  background-position: calc(100% - 13px) 17px, calc(100% - 9px) 17px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  padding-right: 24px;
}
.fld > input::placeholder { color: #cbd5e1; font-weight: 500; }

.fld.readonly { background: #f6f7fb; }
.fld.readonly > input { color: var(--text-2); }

.fld.textarea { height: auto; }
.fld.textarea > textarea {
  flex: 1; width: 100%;
  padding: 15px 9px 6px 9px;
  border: 0; background: transparent; outline: none;
  font: inherit; font-size: 11.5px; font-weight: 600; color: var(--text);
  min-height: 58px; resize: vertical;
  font-family: var(--font);
}
.fld.textarea > textarea.mono { font-family: var(--mono); font-size: 11px; font-weight: 500; }

/* grids */
.g2, .g3, .g4 { display: grid; gap: 6px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
@media (max-width: 900px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3, .span-4 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-4 { grid-column: span 1; }
}

.stack { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mt-6 { margin-top: 6px; }
.mt-10 { margin-top: 10px; }
.muted { color: var(--text-3); font-weight: 600; }

/* ---------- posts ---------- */
.post-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: #fff;
}
.post-row:hover { border-color: #c7d2fe; }
.post-row .grow { flex: 1; min-width: 0; }
.post-row .ptitle { font-weight: 700; color: var(--text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-row .purl { font-family: var(--mono); font-size: 10.5px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-row .pdate { font-size: 10px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #cbd5e1; flex-shrink: 0;
}
.status-dot.live { background: #10b981; }
.status-dot.draft { background: #94a3b8; }

.counter { font-size: 10px; color: var(--text-3); font-weight: 700; margin-top: 2px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 999px;
  font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
.badge-new { background: var(--emerald-soft); color: #047857; }
.badge-updated { background: var(--amber-soft); color: #b45309; }
.badge-unchanged { background: #f1f5f9; color: #64748b; }
.badge-removed { background: var(--rose-soft); color: var(--rose); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 500;
  background: #0f172a; color: #fff;
  font-size: 11.5px; font-weight: 700;
  padding: 8px 14px; border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(15,23,42,.3);
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
  max-width: 90vw;
}
.toast.on { opacity: 1; }
.toast.err { background: var(--rose); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: var(--radius);
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(15,23,42,.3);
}
.modal-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-title { font-size: 14px; font-weight: 800; }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.modal-foot { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; gap: 6px; justify-content: flex-end; background: #fafbfd; }

/* ---------- settings sub-tabs ---------- */
.subtabs { display: flex; gap: 2px; background: var(--muted); padding: 3px; border-radius: var(--radius); flex-wrap: wrap; }
.subtab {
  border: 0; background: transparent; cursor: pointer;
  padding: 5px 12px; border-radius: 5px;
  font: inherit; font-weight: 700; font-size: 11.5px; color: var(--text-2);
}
.subtab.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(15,23,42,.08); }

/* ---------- checkboxes ---------- */
.check-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; background: #fff; }
.check-row { display: flex; align-items: flex-start; gap: 6px; padding: 4px 6px; border-radius: 4px; font-size: 11.5px; cursor: pointer; }
.check-row:hover { background: var(--muted); }
.check-row input { margin-top: 2px; accent-color: var(--accent); }
.check-row .ch-label { font-weight: 700; }
.check-row .ch-hint { font-size: 10px; color: var(--text-3); font-weight: 500; }

/* ---------- progress / publish ---------- */
.steps-bar { display: flex; gap: 6px; margin-bottom: 12px; }
.step-item {
  flex: 1; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; font-size: 11.5px; font-weight: 700; color: var(--text-3);
  display: flex; align-items: center; gap: 6px;
}
.step-item.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.step-item.done { border-color: #bbf7d0; color: var(--emerald); background: var(--emerald-soft); }
.step-num {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800;
}
.step-item.on .step-num { background: var(--accent); color: #fff; }
.step-item.done .step-num { background: var(--emerald); color: #fff; }

.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
@media (max-width: 700px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.tile-label { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.tile-value { font-size: 20px; font-weight: 800; color: var(--text); margin-top: 2px; letter-spacing: -0.3px; }

.progress-bar { height: 8px; border-radius: 999px; background: var(--muted); overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }

.error-box {
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--rose-soft); color: #9f1239;
  border: 1px solid #fecdd3;
  font-family: var(--mono); font-size: 11px;
  white-space: pre-wrap; word-break: break-word;
}

.notice-box {
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--amber-soft); color: #92400e;
  border: 1px solid #fde68a; font-size: 11.5px; font-weight: 600;
}

/* site cards in publish view */
.site-card { padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; margin-bottom: 6px; }
.site-card .sc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.site-card .sc-domain { font-weight: 800; font-size: 12.5px; word-break: break-all; }
.url-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 11px; }
.url-row .url-link { font-family: var(--mono); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- success overlay ---------- */
.success-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: #ffffff;
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.success-icon { width: 84px; height: 84px; margin-bottom: 12px; }
.success-title { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; margin: 0 0 4px; text-align: center; }
.success-sub { font-size: 12px; color: var(--text-3); font-weight: 600; margin: 0 0 20px; text-align: center; }
.success-body { width: 100%; max-width: 720px; }
.success-foot { margin-top: 20px; }

.check-svg circle { stroke-dasharray: 166; stroke-dashoffset: 166; animation: dash 0.6s ease forwards; }
.check-svg path { stroke-dasharray: 48; stroke-dashoffset: 48; animation: dash 0.4s 0.6s ease forwards; }
@keyframes dash { to { stroke-dashoffset: 0; } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 450; overflow: hidden; }
.confetti-piece {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 2px;
  animation: confetti-fall 3s linear forwards;
  opacity: 0;
}
@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* spinner */
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login screen */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #f6f7fb 0%, #eef2ff 100%);
}
.login-card {
  width: 320px; max-width: 100%;
  background: #fff; border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(15,23,42,.1);
}
.login-card .brand { justify-content: center; margin-bottom: 4px; }
.login-card .brand-name { font-size: 14px; }
.login-card .brand-sub { text-align: center; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 14px; }
.login-err { color: var(--rose); font-size: 11px; font-weight: 700; min-height: 14px; text-align: center; margin-top: 8px; }

/* helpers */
.vr { width: 1px; height: 20px; background: var(--border); }
.pill-count { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 800; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }

/* text selection inside code fields */
textarea.mono, .mono { color: #0f172a; }