:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-subtle: #faf9f6;
  --border: #e6e3db;
  --border-strong: #d3cec2;
  --ink: #18181b;
  --ink-2: #4b4b52;
  --ink-muted: #7e7c75;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --teal: #0f766e;
  --teal-soft: #f0fdfa;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 2px 12px rgba(24, 24, 27, 0.04);
  --shadow-float: 0 12px 36px rgba(24, 24, 27, 0.12);
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: 14px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(246, 245, 241, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-name small {
  font-weight: 500;
  color: var(--ink-muted);
  font-size: 12px;
  margin-left: 3px;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #eceae3;
  padding: 4px;
  border-radius: 12px;
}

.nav-pill {
  border: none;
  background: transparent;
  color: var(--ink-2);
  padding: 7px 14px;
  border-radius: 9px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.16s ease;
}

.nav-pill:hover {
  color: var(--ink);
}

.nav-pill.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.engine-badge {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.engine-badge:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.engine-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

.engine-badge.llm-active .dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

/* Main container */
.main-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.view {
  display: none;
  animation: fadeIn 0.2s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero Banner */
.hero {
  margin-bottom: 22px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.hero-eyebrow.teal {
  color: var(--teal);
  background: var(--teal-soft);
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.hero p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
  max-width: 740px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.card + .card {
  margin-top: 16px;
}

.card-subtle {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Forms & Inputs */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.field .hint {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 400;
  margin-left: 6px;
}

.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.6;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.wish-textarea {
  min-height: 110px;
  font-size: 15.5px;
  padding: 14px 16px;
}

/* Chips & Model Selector */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.chip.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.model-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--surface-subtle);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.model-card:hover {
  border-color: var(--primary);
}

.model-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.model-card .m-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 3px;
}

.model-card .m-desc {
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.4;
}

/* Buttons */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-teal {
  background: var(--teal);
  color: #fff;
}

.btn-teal:hover:not(:disabled) {
  background: #0d5e58;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--ink);
  background: var(--surface-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  padding: 7px 11px;
}

.btn-ghost:hover:not(:disabled) {
  background: #eceae3;
  color: var(--ink);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

/* Clarification Questions */
.q-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin: 14px 0 18px;
}

.q-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--surface-subtle);
}

.q-title {
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 10px;
}

.q-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.q-opt {
  text-align: left;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.14s;
}

.q-opt:hover {
  border-color: var(--primary);
}

.q-opt.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* Alerts & Callouts */
.callout {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 14px;
}

.callout-info {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.callout-teal {
  background: var(--teal-soft);
  border: 1px solid #99f6e4;
  color: #115e59;
}

.callout-amber {
  background: var(--amber-soft);
  border: 1px solid #fde68a;
  color: #92400e;
}

/* Code / Prompt Display Box */
.prompt-box {
  background: #14151a;
  color: #f3f4f6;
  border-radius: var(--radius-md);
  padding: 15px 16px;
  font-family: var(--font-mono);
  font-size: 12.8px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
}

.prompt-box.light {
  background: var(--surface-subtle);
  color: var(--ink);
  border: 1px solid var(--border);
}

/* Blueprint Steps */
.step-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.step-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface);
}

.step-card.done {
  border-color: #99f6e4;
  background: #fafefd;
}

.step-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.step-goal {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.run-output {
  margin-top: 12px;
  border-top: 1px dashed var(--border-strong);
  padding-top: 12px;
}

/* Segmented Tabs inside Cards */
.subtabs {
  display: inline-flex;
  gap: 4px;
  background: #eceae3;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.subtab {
  border: none;
  background: transparent;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
}

.subtab.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Community Grid */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.recipe-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(24, 24, 27, 0.07);
}

.cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(24, 24, 27, 0.78);
  color: #fff;
  backdrop-filter: blur(8px);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
}

.recipe-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
}

.wish-quote {
  font-size: 12.5px;
  color: var(--ink-muted);
  background: var(--surface-subtle);
  border-left: 3px solid var(--border-strong);
  padding: 6px 10px;
  border-radius: 0 8px 8px 0;
}

.outcome-line {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.session-item {
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 11px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: all 0.14s;
}

.session-item:hover {
  border-color: var(--primary);
}

.session-item.selected {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.session-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-muted);
  flex-wrap: wrap;
}

.paste-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  background: var(--surface-subtle);
  transition: border-color 0.15s, background 0.15s;
}

.paste-zone:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.preview-frame {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.step-edit-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-subtle);
  margin-bottom: 8px;
}

.discover-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.discover-title {
  margin: 0;
  font-size: 23px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.discover-sub {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-muted);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: #eceae3;
  color: var(--ink-2);
}

.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-teal { background: var(--teal-soft); color: var(--teal); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }

.before-after {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 12.5px;
}

.ba-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 11px;
}

.ba-box.after {
  background: #f5fbfa;
  border-color: #cceee8;
}

.ba-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.ba-box.after .ba-label {
  color: var(--teal);
}

.outcome-thumb {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.recipe-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.stats-mini {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-muted);
}

/* Split Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(20, 20, 22, 0.48);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-sheet {
  width: 100%;
  max-width: 780px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-float);
}

/* Toast */
.toast-host {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #18181b;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

/* Mobile Nav */
.mobile-nav {
  display: none;
}

/* Utility */
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.muted { color: var(--ink-muted); font-size: 13px; }
.hidden { display: none !important; }

/* Responsive Breakpoints */
@media (max-width: 980px) {
  .brand-sub { display: none; }
}

@media (max-width: 860px) {
  .model-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recipe-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .desktop-nav, .brand-sub { display: none; }
  .topbar-inner { padding: 10px 14px; }
  .main-container { padding: 16px 14px 92px; }
  .hero h1 { font-size: 21px; }
  .card { padding: 16px; border-radius: 16px; }
  .before-after { grid-template-columns: 1fr; }
  .modal-sheet { padding: 18px; max-height: 92vh; border-radius: 16px; }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }

  .mobile-nav-item {
    border: none;
    background: transparent;
    color: var(--ink-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
  }

  .mobile-nav-item .m-ico {
    font-size: 17px;
    line-height: 1.1;
  }

  .mobile-nav-item.active {
    color: var(--primary);
    font-weight: 700;
  }

  .toast-host {
    bottom: 84px;
  }
}
