:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --surface-blue: #edf4ff;
  --text: #111827;
  --muted: #667085;
  --line: #d9e2ec;
  --blue: #2563eb;
  --teal: #0f766e;
  --amber: #a16207;
  --red: #b42318;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.95);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 6px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0f766e);
  font-size: 20px;
  font-weight: 900;
}

.brand-copy strong,
.publish-state strong { display: block; }
.brand-copy span,
.publish-state span,
.kicker,
.status-strip span,
.section-head p,
.site-card p,
.site-domain,
.result-meta,
.form-notice { color: var(--muted); }

.category-nav {
  display: grid;
  align-content: start;
  gap: 7px;
  overflow: auto;
}

.category-btn {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-weight: 750;
  text-align: left;
}

.category-btn:hover,
.category-btn.active {
  border-color: #cfe0ff;
  background: var(--surface-blue);
  color: var(--blue);
}

.category-btn small { color: var(--muted); font-weight: 850; }

.sidebar-footer { display: grid; gap: 10px; }
.publish-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.state-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.14);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(280px, 520px) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.kicker {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 850;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; }
h2 { margin-bottom: 4px; font-size: 18px; }

.search-bar input,
select,
.form-grid input,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.search-bar input {
  height: 44px;
  padding: 0 14px;
  box-shadow: var(--shadow);
}

.search-bar input:focus,
.form-grid input:focus,
.form-grid textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.toolbar { display: flex; gap: 8px; }
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
}
.icon-btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status-strip div,
.quick-link,
.site-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-strip div { padding: 12px; }
.status-strip strong { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view-row,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  min-width: 72px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}
.segmented button.active { background: var(--surface-blue); color: var(--blue); }

.quick-links {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.quick-link {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  font-weight: 850;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.site-card {
  min-height: 156px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 15px;
}

.site-card:hover { border-color: #b9cef7; transform: translateY(-1px); transition: transform 120ms ease, border-color 120ms ease; }
.card-head { display: flex; align-items: start; gap: 11px; min-width: 0; }
.site-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--blue);
  font-weight: 900;
}
.site-icon img { width: 100%; height: 100%; border-radius: 8px; }
.site-title { min-width: 0; flex: 1; }
.site-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.site-domain { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.site-card p { margin-bottom: 0; }
.card-actions { display: flex; gap: 6px; }
.mini-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 900;
}
.mini-btn.active { color: var(--amber); background: #fff7ed; border-color: #fed7aa; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { min-height: 24px; display: inline-flex; align-items: center; padding: 0 8px; border-radius: 6px; background: var(--surface-soft); color: var(--muted); font-size: 12px; font-weight: 800; }

.empty {
  grid-column: 1 / -1;
  padding: 30px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.site-dialog {
  width: min(680px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}
.site-dialog::backdrop { background: rgba(15, 23, 42, 0.35); }
.site-dialog form { padding: 18px; }
.dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.form-grid label { display: grid; gap: 5px; color: var(--muted); font-weight: 800; }
.form-grid input, .form-grid select, .form-grid textarea { padding: 10px; color: var(--text); }
.form-grid .wide { grid-column: 1 / -1; }
.text-btn, .solid-btn, .danger-btn {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 850;
}
.text-btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.solid-btn { border: 1px solid var(--blue); background: var(--blue); color: #fff; }
.danger-btn { margin-right: auto; border: 1px solid #fecaca; background: #fff1f2; color: var(--red); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 320px;
  padding: 11px 13px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .category-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .topbar { grid-template-columns: 1fr; }
  .toolbar { justify-content: flex-start; }
  .status-strip, .quick-links, .site-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .workspace, .sidebar { padding: 14px; }
  .category-nav, .status-strip, .quick-links, .site-grid, .form-grid { grid-template-columns: 1fr; }
  .view-row, .section-head { align-items: flex-start; flex-direction: column; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; min-width: 0; }
}
