:root {
  --bg: #eff4f1;
  --panel: #ffffff;
  --sidebar: #0d1e19;
  --ink: #10241d;
  --muted: #5f746c;
  --line: #d4e2db;
  --accent: #f26a4b;
  --green: #1e8a73;
  --warn: #f6b955;
  --shadow: 0 24px 80px rgba(18, 40, 32, 0.08);
  --font: Inter, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input, textarea, select, button { font: inherit; }
button { cursor: pointer; }

.studio-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.studio-sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #112620 100%);
  color: #ecf5f1;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.studio-brand, .login-brand { display: flex; align-items: center; gap: 14px; }
.studio-brand img, .login-brand img { width: 56px; height: 56px; }
.studio-brand strong, .studio-user strong, .stat-card strong, .panel-card h2, .login-panel h1 { font-weight: 800; }
.studio-brand small, .studio-user small, .login-copy, .login-footnote, .studio-description, .studio-table small, .source-card p, .source-card span, .audit-list span { color: var(--muted); }
.muted-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.6px; }

.studio-nav { display: grid; gap: 8px; }
.studio-nav-item { padding: 12px 14px; border-radius: 8px; color: #d7e7e1; border: 1px solid transparent; transition: 180ms ease; }
.studio-nav-item:hover, .studio-nav-item.is-active { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.08); }
.studio-sidebar-footer { margin-top: auto; padding: 16px; border-radius: 8px; background: rgba(255,255,255,0.06); display: grid; gap: 6px; }

.studio-topbar {
  padding: 28px 34px 20px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(14px);
}
.studio-topbar-main { display: flex; gap: 16px; align-items: flex-start; }
.studio-topbar-side, .studio-actions, .button-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.studio-user { display: grid; gap: 2px; text-align: right; }
.studio-kicker { margin: 0 0 10px; color: var(--accent); font-size: 13px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; }
.studio-topbar h1, .login-panel h1 { margin: 0; font-size: clamp(34px, 3vw, 52px); line-height: 1.05; }
.studio-content { padding: 28px 34px 40px; display: grid; gap: 24px; }
.studio-mobile-toggle { display: none; min-height: 42px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }

.stats-grid, .panel-grid, .settings-grid, .editor-grid { display: grid; gap: 20px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel-grid { grid-template-columns: 1.6fr 1fr; }
.settings-grid { grid-template-columns: 1.5fr 0.9fr; }
.editor-grid { grid-template-columns: 1.4fr 1fr; }

.panel-card, .stat-card, .login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.stat-card, .panel-card, .login-panel { padding: 24px; }
.stat-card { display: grid; gap: 10px; }
.stat-card span { color: var(--muted); font-weight: 600; }
.stat-card strong { font-size: 52px; line-height: 1; }
.panel-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.panel-head h2 { margin: 0; font-size: 28px; line-height: 1.15; }

.timeline-list, .status-list, .source-mini-list, .audit-list { display: grid; gap: 14px; padding: 0; margin: 0; list-style: none; }
.timeline-list strong, .status-list strong, .audit-list strong { display: block; margin-bottom: 6px; }
.timeline-list p, .status-list span { margin: 0; color: var(--muted); }
.status-list li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.status-list li:last-child { border-bottom: 0; padding-bottom: 0; }

.studio-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  transition: 180ms ease;
}
.studio-button.primary { background: linear-gradient(135deg, var(--green), var(--accent)); color: #fff; }
.studio-button.secondary, .studio-button.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.studio-button.block { width: 100%; }

.table-wrap { overflow: auto; }
.studio-table { width: 100%; border-collapse: collapse; }
.studio-table th, .studio-table td { text-align: left; vertical-align: top; padding: 14px 12px; border-bottom: 1px solid var(--line); }
.studio-table th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.4px; }
.studio-table td small { display: block; margin-top: 4px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.form-span-2 { grid-column: 1 / -1; }
label { display: grid; gap: 8px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 120px; }
.preset-note-card, .brief-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf9;
}
.preset-note-card {
  padding: 16px;
  display: grid;
  gap: 8px;
  align-content: start;
}
.preset-note-card strong { font-size: 15px; line-height: 1.35; }
.preset-note-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.brief-preview { margin-top: 18px; padding: 16px; }
.brief-preview .code-block { background: #0d1613; min-height: 168px; white-space: pre-wrap; }

.guide-card {
  border: 1px dashed rgba(30, 138, 115, 0.25);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0 18px;
  background: #f6fbf8;
}
.guide-card summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.guide-card-body { margin-top: 10px; color: var(--muted); display: grid; gap: 8px; }
.panel-divider { height: 1px; background: var(--line); margin: 18px 0; }
.panel-head.tight { margin-bottom: 10px; }
.sync-list li { display: flex; justify-content: space-between; gap: 10px; }

.source-list, .side-stack, .review-main, .review-sidebar { display: grid; gap: 14px; }
.review-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr); gap: 20px; }
.body-editor { min-height: 640px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 14px; line-height: 1.6; }
.compact-list { margin-top: 16px; }
.compact-list li { padding-bottom: 10px; }
.mini-item { display: grid; gap: 4px; }
.muted-copy { margin: 0; color: var(--muted); }
.source-card {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fafdfc;
}
.source-card input { margin-top: 4px; }
.source-card p, .source-card span, .audit-list span { font-weight: 500; }

.code-block {
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  background: #0f1714;
  color: #d9ece5;
  overflow: auto;
  font-size: 13px;
  line-height: 1.55;
}
.cover-preview { border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #08110f; }
.cover-preview svg { width: 100%; height: auto; }

.status-badge {
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.3px;
}
.status-generated, .status-draft { background: rgba(246,185,85,0.16); color: #8b6218; }
.status-published { background: rgba(30,138,115,0.14); color: #1c6a58; }
.status-failed { background: rgba(242,106,75,0.16); color: #a34733; }
.audit-pass strong { color: var(--green); }
.audit-warn strong { color: var(--warn); }

.flash {
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-weight: 600;
}
.flash-success { background: rgba(30,138,115,0.08); border-color: rgba(30,138,115,0.24); }
.flash-error { background: rgba(242,106,75,0.08); border-color: rgba(242,106,75,0.24); }
.error-card { border-color: rgba(242,106,75,0.24); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: radial-gradient(circle at top left, rgba(30,138,115,0.18), transparent 28%), linear-gradient(180deg, #eef5f1 0%, #f8fbfa 100%);
}
.login-shell { width: min(100%, 620px); }
.login-panel { display: grid; gap: 24px; }
.auth-form { display: grid; gap: 16px; }

@media (max-width: 1180px) {
  .stats-grid, .panel-grid, .settings-grid, .editor-grid, .preset-grid, .review-layout { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .studio-shell { grid-template-columns: 1fr; }
  .studio-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    z-index: 20;
  }
  .studio-sidebar.is-open { transform: translateX(0); }
  .studio-mobile-toggle { display: inline-flex; }
  .studio-topbar, .studio-content { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 720px) {
  .form-grid, .stats-grid, .preset-grid { grid-template-columns: 1fr; }
  .studio-topbar { flex-direction: column; }
  .studio-topbar-side { width: 100%; justify-content: flex-start; }
}
