:root {
  color-scheme: light;
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef2f6;
  --line: #d8e0ea;
  --text: #17202b;
  --muted: #607083;
  --accent: #1769e0;
  --accent-soft: #e7f0ff;
  --ready: #147a52;
  --warning: #aa5d00;
  --shadow: 0 18px 50px rgba(24, 34, 48, 0.12);
  --radius: 8px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(23, 32, 43, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 32, 43, 0.035) 1px, transparent 1px),
    var(--page);
  background-size: 28px 28px;
  color: var(--text);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  padding: 22px;
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid #111827;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #111827 0 48%, transparent 48%),
    var(--accent-soft);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.search {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
}

.project-list {
  display: grid;
  gap: 8px;
}

.project-button {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.project-button:hover,
.project-button.is-active {
  border-color: var(--line);
  background: var(--surface);
}

.project-button strong {
  font-size: 14px;
}

.project-button span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.badge.ready-for-dev,
.badge.implemented {
  background: #e4f7ed;
  color: var(--ready);
}

.badge.wireframe,
.badge.high-fidelity {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.missing {
  background: #fff1d7;
  color: var(--warning);
}

.stage {
  min-width: 0;
  padding: 26px;
}

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 30px;
  line-height: 1.18;
}

#previewDescription {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid #0f4fb5;
  border-radius: var(--radius);
  padding: 0 13px;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.button.is-disabled {
  pointer-events: none;
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.meta-card {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}

.meta-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.meta-card strong {
  font-size: 14px;
}

.kind-controls {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  max-width: 100%;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 4px;
}

.kind-button {
  min-width: 96px;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.kind-button.is-active {
  background: #111827;
  color: #ffffff;
}

.variant-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.variant-button {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.variant-button span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.variant-button strong {
  font-size: 13px;
}

.variant-button.is-active {
  border-color: #9cc3ff;
  background: var(--accent-soft);
  color: #0e428f;
}

.preview-shell {
  position: relative;
  overflow: hidden;
  height: min(76vh, 920px);
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-shell[data-device="mobile"] {
  width: min(430px, 100%);
  height: min(78vh, 860px);
  min-height: 680px;
  margin-right: auto;
  margin-left: auto;
  border-width: 10px;
  border-color: #111827;
  border-radius: 28px;
  background: #111827;
}

iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.empty-state.is-visible {
  display: grid;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .toolbar {
    display: grid;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preview-shell[data-device="mobile"] {
    min-height: 620px;
  }
}

@media (max-width: 560px) {
  .stage,
  .sidebar {
    padding: 16px;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .kind-controls {
    display: grid;
    grid-auto-flow: row;
    width: 100%;
  }

  .kind-button {
    width: 100%;
  }

  .variant-button {
    width: 100%;
    justify-content: start;
  }

  .preview-shell {
    min-height: 520px;
  }

  .preview-shell[data-device="mobile"] {
    width: 100%;
    min-height: 560px;
    border-width: 6px;
    border-radius: 22px;
  }
}
