/* =========================================================
   Agentic Apples — v7
   Light theme. Dot grid. Splash + legal + embed picker.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:           #ffffff;
  --bg-soft:      #fafafa;
  --bg-page:      #ffffff;
  --bg-page-deep: #d4d4cc;
  --panel:        rgba(255, 255, 255, 0.85);
  --rule:         #e8e8e0;
  --rule-soft:    #d8d8d4;
  --ink:          #1a1a1a;
  --ink-soft:     #3a3a3a;
  --ink-mute:     #666666;
  --ink-faint:    #888888;
  --ink-ghost:    #b0b0b0;
  --apple:        #d63031;
  --apple-dk:     #a82420;
  --leaf:         #3f6b2a;
  --signal:       #2a8c3a;

  --body: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--body);
  background: var(--bg-page);
  background-image: radial-gradient(circle, var(--rule-soft) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: 0 0;
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
}

body.embed-page {
  background: var(--bg-page-deep);
  background-image: radial-gradient(circle, #a8a8a0 1px, transparent 1px);
  background-size: 22px 22px;
}

a { color: var(--ink-soft); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--apple); }

.splash { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.splash-main {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4rem 1.5rem; text-align: center;
}

.hero-logo {
  margin-bottom: 1.5rem;
  max-width: 320px; width: 70vw; height: auto;
  transition: transform 0.4s ease;
}
.hero-logo:hover { transform: translateY(-2px); }

.splash-tag {
  font-size: 0.95rem; color: var(--ink-mute);
  font-weight: 400; letter-spacing: -0.005em;
}

.splash-foot {
  position: relative; z-index: 1;
  border-top: 1px solid var(--rule);
  background: var(--panel);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 0.9rem 1.5rem;
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
}
.splash-foot .links { display: flex; gap: 1.25rem; }
.splash-foot a { color: var(--ink-faint); letter-spacing: 0.05em; }
.splash-foot a:hover { color: var(--apple); }
.splash-foot .meta { display: flex; gap: 1rem; align-items: center; }
.splash-foot .meta .ver { color: var(--ink-ghost); }

.legal-shell { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.legal-head {
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 1rem 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
}
.legal-head .brand-link {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--ink); font-weight: 500; font-size: 0.95rem; letter-spacing: -0.01em;
}
.legal-head .brand-link:hover { color: var(--apple); }
.legal-head .brand-link .accent { color: var(--apple); }
.legal-head .brand-link img { height: 26px; width: auto; }
.legal-head nav {
  display: flex; gap: 1.5rem;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
}
.legal-head nav a { color: var(--ink-faint); }
.legal-head nav a:hover { color: var(--apple); }

.legal { flex: 1; padding: 3rem 1.5rem 5rem; }
.legal-wrap {
  max-width: 720px; margin: 0 auto;
  background: var(--bg); border-radius: 8px;
  padding: 2rem; border: 1px solid var(--rule);
}

.legal h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 500; letter-spacing: -0.025em;
  margin-bottom: 0.5rem; color: var(--ink);
}
.legal .meta-line {
  font-family: var(--mono); font-size: 12px; color: var(--ink-faint);
  margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--rule);
}
.legal h2 {
  font-size: 1.25rem; font-weight: 500; margin: 2.5rem 0 0.85rem;
  color: var(--ink); letter-spacing: -0.01em;
}
.legal h3 { font-size: 1rem; font-weight: 500; margin: 1.5rem 0 0.5rem; color: var(--ink); }
.legal p, .legal ul, .legal ol {
  margin-bottom: 1rem; color: var(--ink-soft); line-height: 1.7; font-size: 0.95rem;
}
.legal ul, .legal ol { padding-left: 1.5rem; }
.legal li { margin-bottom: 0.4rem; }
.legal a {
  color: var(--apple); text-decoration: underline;
  text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.legal a:hover { color: var(--ink); }
.legal strong { color: var(--ink); font-weight: 500; }

.legal .toc {
  background: var(--bg-soft); border: 1px solid var(--rule);
  border-radius: 6px; padding: 1.5rem; margin-bottom: 2.5rem;
}
.legal .toc h4 {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.15em;
  margin-bottom: 0.75rem; color: var(--ink-faint);
}
.legal .toc ol { padding-left: 1.25rem; margin: 0; font-size: 0.9rem; }
.legal .toc li { margin-bottom: 0.25rem; }
.legal .toc a { color: var(--ink-soft); text-decoration: none; }
.legal .toc a:hover { color: var(--apple); }

.legal-note {
  background: rgba(214, 48, 49, 0.05); border-left: 2px solid var(--apple);
  padding: 1rem 1.25rem; margin: 1.5rem 0;
  font-size: 0.9rem; border-radius: 0 4px 4px 0; color: var(--ink-soft);
}
.legal-note strong { color: var(--apple); }

.legal-eyebrow {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.15em;
  color: var(--apple); margin-bottom: 1rem; display: inline-block;
}

.legal-foot {
  position: relative; z-index: 1;
  border-top: 1px solid var(--rule); background: var(--panel);
  padding: 0.9rem 1.5rem;
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
}
.legal-foot .links { display: flex; gap: 1.25rem; }
.legal-foot a { color: var(--ink-faint); letter-spacing: 0.05em; }
.legal-foot a:hover { color: var(--apple); }
.legal-foot .ver { color: var(--ink-ghost); }

.embed-shell { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.embed-head {
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 1rem 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
}
.embed-head .brand-link {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--ink); font-weight: 500; font-size: 0.95rem;
}
.embed-head .brand-link:hover { color: var(--apple); }
.embed-head .brand-link .accent { color: var(--apple); }
.embed-head .brand-link img { height: 26px; width: auto; }
.embed-head .pill {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.15em;
  background: var(--ink); color: var(--bg);
  padding: 4px 10px; border-radius: 99px;
}

.embed { flex: 1; padding: 2.5rem 1.5rem 5rem; }
.embed-wrap { max-width: 1100px; margin: 0 auto; }

.embed-intro {
  background: var(--bg); border: 1px solid var(--rule);
  border-radius: 8px; padding: 1.75rem 2rem; margin-bottom: 2.5rem;
}
.embed-intro h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem); font-weight: 500;
  letter-spacing: -0.025em; color: var(--ink); margin-bottom: 0.5rem;
}
.embed-intro p {
  color: var(--ink-soft); margin-bottom: 0.5rem;
  font-size: 0.95rem; line-height: 1.7;
}
.embed-intro p:last-child { margin-bottom: 0; }
.embed-intro code {
  background: var(--bg-soft); border: 1px solid var(--rule);
  padding: 1px 6px; border-radius: 3px; font-size: 0.85em;
  font-family: var(--mono); color: var(--apple);
}


@media (max-width: 600px) {
  .splash-foot, .legal-foot { flex-direction: column; gap: 0.5rem; text-align: center; }
  .splash-foot .meta { justify-content: center; }
  .legal-head, .embed-head { flex-direction: column; gap: 0.5rem; }
  .legal-wrap, .embed-intro { padding: 1.25rem; }
}

/* =========================================================
   v9 additions — splash brand line, secondary tagline,
   The Orchard portfolio section, centered footer override
   ========================================================= */

/* Brand line below the hero logo */
.brand-line {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-bottom: 0.65rem;
}
.brand-line .dot { color: var(--apple); }
.brand-line .farm { color: var(--ink-faint); font-weight: 400; }

/* Splash main — tightened spacing so hero sits naturally above orchard */
.splash-main {
  flex: 0 0 auto;
  padding: 3rem 1.5rem 1rem;
}

/* The Orchard portfolio section */
.orchard {
  position: relative; z-index: 1;
  padding: 0.5rem 1.5rem 4rem;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
}

.orchard-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  text-align: center;
  margin-bottom: 1.25rem;
}

.orchard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.orchard-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.orchard-card:hover:not(.is-soon) {
  border-color: var(--ink-faint);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.orchard-card.is-soon {
  cursor: default;
  background: #fafafa;
}

/* Abbreviation tiles */
.tile {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #fff;
}
.tile-fo  { background: #d63031; }
.tile-ems { background: #1a4d8c; }
.tile-ss  { background: #2a8c3a; }
.tile-se  { background: #0e8587; }
.tile-ctp { background: #6b4ec7; }
.tile-bp  { background: #c47010; }

/* Card body */
.card-body { flex: 1; min-width: 0; }
.card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  margin-bottom: 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.card-desc {
  font-size: 0.78rem;
  color: var(--ink-mute);
  line-height: 1.4;
  margin-bottom: 0.2rem;
}
.card-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

/* Coming soon badge */
.badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #5a5a5a;
  background: #e0e0d8;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid #d0d0c8;
}

/* Centered footer variant for splash */
.splash-foot.is-centered {
  justify-content: center;
}
.splash-foot.is-centered .meta .sep {
  color: var(--ink-ghost);
}

/* Mobile — single column for the orchard, splash foot stacks */
@media (max-width: 600px) {
  .orchard-grid { grid-template-columns: 1fr; }
  .splash-foot.is-centered { flex-direction: row; flex-wrap: wrap; gap: 0.6rem; }
  .splash-foot.is-centered .meta .sep:first-child { display: none; }
  .splash-main { padding: 3.5rem 1.5rem 2rem; }
}


/* =========================================================
   v12 — Builder UI styles
   ========================================================= */

.builder-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* Left: controls panel (sticky on desktop) */
.builder-controls {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.25rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.builder-controls h2 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-faint);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.ctrl-row { margin-bottom: 0.85rem; }
.ctrl-row .lbl {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  margin-bottom: 4px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.ctrl-row select,
.ctrl-row input[type="text"] {
  width: 100%;
  padding: 5px 9px;
  font-size: 12px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
}
.ctrl-row input[type="text"]:focus,
.ctrl-row select:focus {
  outline: none;
  border-color: var(--ink-faint);
}
.ctrl-row .btn-row {
  display: flex;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}
.ctrl-row .btn-row button {
  flex: 1;
  padding: 5px 0;
  font-size: 11px;
  background: var(--bg);
  border: none;
  cursor: pointer;
  border-left: 1px solid var(--rule);
  font-family: var(--body);
  color: var(--ink-mute);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.ctrl-row .btn-row button:first-child { border-left: none; }
.ctrl-row .btn-row button:hover { background: var(--bg-soft); }
.ctrl-row .btn-row button.active { background: var(--ink); color: var(--bg); }

/* Color picker row — clr-* are Coloris's default classes; we only need a wrapper */
.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.7rem;
}
.color-row .lbl {
  flex: 1;
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 500;
}
.color-row .clr-field {
  width: 90px;
}
.color-row input.clr-field {
  font-size: 11px;
  padding-left: 28px;
  height: 26px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--mono);
  color: var(--ink);
  background: var(--bg);
}

.section-divider {
  margin: 1rem 0 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
}
.section-divider .heading {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.loaded-badge {
  display: none;
  margin-bottom: 0.75rem;
  padding: 6px 10px;
  background: rgba(214, 48, 49, 0.06);
  border: 1px solid rgba(214, 48, 49, 0.2);
  border-radius: 4px;
  font-size: 11px;
  color: var(--apple-dk);
}
.loaded-badge.is-shown { display: block; }
.loaded-badge .name {
  font-weight: 500;
}

/* Action row at bottom of controls */
.actions-row {
  display: flex;
  gap: 6px;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--rule);
}
.actions-row button {
  flex: 1;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--body);
  transition: opacity 0.15s, background 0.15s;
}
.actions-row .btn-primary {
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
}
.actions-row .btn-primary:hover:not(:disabled) { background: var(--apple-dk); border-color: var(--apple-dk); }
.actions-row .btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.actions-row .btn-secondary {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule);
}
.actions-row .btn-secondary:hover { border-color: var(--ink-faint); background: var(--bg-soft); }
.actions-row .btn-update {
  background: var(--bg);
  color: var(--apple-dk);
  border: 1px solid var(--apple-dk);
  display: none;
}
.actions-row .btn-update.is-shown { display: block; }
.actions-row .btn-update:hover { background: rgba(214, 48, 49, 0.06); }

/* Right side: stack of preview, code, saved list */
.builder-output {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.output-card {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
.output-card-head {
  padding: 9px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 500;
}
.output-card-head .meta {
  font-size: 10px;
  color: var(--ink-faint);
}

.preview-stage-wrap {
  background: #f0f0ec;
  padding: 1.5rem;
  background-image:
    linear-gradient(45deg, #e8e8e0 25%, transparent 25%),
    linear-gradient(-45deg, #e8e8e0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8e8e0 75%),
    linear-gradient(-45deg, transparent 75%, #e8e8e0 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.preview-host {
  background: var(--bg);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 1.25rem;
  min-height: 60px;
}
.preview-host.dark { background: #0d1422; }

.code-wrap {
  position: relative;
}
.code-pre {
  background: #f4f4ee;
  margin: 0;
  padding: 1rem 1.25rem;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
  white-space: pre;
  overflow-x: auto;
  max-height: 260px;
  overflow-y: auto;
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 16px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  padding: 5px 12px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  z-index: 2;
}
.copy-btn:hover { background: var(--apple-dk); }
.copy-btn.copied { background: var(--signal); }

/* Saved footers list */
.saved-list {
  padding: 0.4rem;
}
.saved-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--ink-faint);
  font-size: 12px;
  font-style: italic;
}
.saved-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 4px;
  gap: 0.5rem;
  transition: background 0.1s;
}
.saved-item:hover { background: var(--bg-soft); }
.saved-item-info { min-width: 0; flex: 1; }
.saved-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 1px;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-item-meta {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}
.saved-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.saved-item-actions button {
  padding: 3px 8px;
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg);
  color: var(--ink-mute);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
}
.saved-item-actions button:hover { border-color: var(--ink-faint); color: var(--ink); }
.saved-item-actions .del:hover { color: var(--apple-dk); border-color: var(--apple-dk); }

/* Toast for save confirmations / overwrite prompt */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: none;
}
.toast.is-shown { display: block; }
.toast.success { background: var(--signal); }
.toast.error { background: var(--apple-dk); }

.modal-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-backdrop.is-shown { display: flex; }
.modal {
  background: var(--bg);
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 380px;
  width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.modal h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.modal p {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.modal-actions button {
  padding: 7px 14px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--body);
  font-weight: 500;
}
.modal-actions .btn-primary {
  background: var(--apple-dk);
  color: var(--bg);
  border: 1px solid var(--apple-dk);
}
.modal-actions .btn-secondary {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule);
}
.modal-actions .btn-tertiary {
  background: var(--bg);
  color: var(--ink-mute);
  border: 1px solid var(--rule);
}

/* Responsive */
@media (max-width: 900px) {
  .builder-grid { grid-template-columns: 1fr; }
  .builder-controls { position: static; max-height: none; }
}
