@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300;0,6..72,400;0,6..72,500;1,6..72,300;1,6..72,400&family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,500;1,8..60,300;1,8..60,400&family=Bodoni+Moda:ital,opsz,wght@0,6..96,400;0,6..96,500;0,6..96,600;1,6..96,400&family=Manrope:wght@300;400;500;600&family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400&family=IBM+Plex+Sans:wght@300;400;500&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=Instrument+Sans:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,400;0,500;1,400&family=Inter:wght@400;500;600&display=swap');

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  overscroll-behavior: none;
}
#lattice-root { position: fixed; inset: 0; overflow: hidden; background:#EFEDE8; }
img { max-width: none; }
button { font: inherit; }

/* ── Canvas (full-bleed) ─────────────────────────────────────────────── */
#canvas-layer {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  transition: background-color .4s ease;
}
#canvas-inner { min-height: 100%; }

/* ── Collapsed pill toggle ───────────────────────────────────────────── */
.lattice-pill {
  position: fixed;
  top: 50%; right: 22px;
  transform: translateY(-50%);
  z-index: 40;
  width: 128px;
  background: rgba(17,17,17,0.92);
  backdrop-filter: blur(6px);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.28);
  overflow: hidden;
  display: flex; flex-direction: column;
  font-family: 'Inter', system-ui, sans-serif;
  animation: latticeFadeIn .25s ease;
}
.lattice-pill button {
  background: none; border: none; color: #F4F1EC;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em;
  padding: 16px 14px; text-align: left; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  transition: background-color .15s ease;
}
.lattice-pill button:hover { background: rgba(255,255,255,0.07); }
.lattice-pill button .chevron { opacity: .45; font-size: 11px; }
.lattice-pill .pill-divider { height: 1px; background: rgba(255,255,255,0.12); margin: 0 14px; }

/* ── Expanded drawer ─────────────────────────────────────────────────── */
.lattice-drawer {
  position: fixed;
  top: 20px; bottom: 20px; right: 20px;
  width: min(420px, calc(100vw - 40px));
  background: #F8F7F4;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.32);
  z-index: 50;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: latticeSlideIn .28s cubic-bezier(.22,1,.36,1);
}
@keyframes latticeSlideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes latticeFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

.lattice-drawer-header {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.07);
}
.lattice-tabs {
  flex: 1; display: flex; background: rgba(0,0,0,0.05);
  border-radius: 10px; padding: 3px; gap: 2px;
}
.lattice-tabs button {
  flex: 1; border: none; background: transparent; border-radius: 8px;
  padding: 8px 10px; font-size: 12px; font-weight: 600; color: #8A8780;
  cursor: pointer; transition: background-color .15s ease, color .15s ease;
  font-family: 'Inter', system-ui, sans-serif;
}
.lattice-tabs button.active { background: #fff; color: #1A1A1A; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.lattice-close {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px;
  border: none; background: transparent; color: #999; cursor: pointer;
  font-size: 15px; display: flex; align-items: center; justify-content: center;
  transition: background-color .15s ease;
}
.lattice-close:hover { background: rgba(0,0,0,0.06); color: #333; }

.lattice-drawer-body { flex: 1; overflow-y: auto; padding: 18px 18px 28px; }

/* ── Current Mix chips ───────────────────────────────────────────────── */
.mix-label {
  font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase;
  color: #B8B5B0; font-weight: 600; margin-bottom: 10px;
}
.mix-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  margin-bottom: 24px;
}
.mix-chip {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid rgba(0,0,0,0.08); border-radius: 10px;
  padding: 9px 10px; background: #fff; cursor: pointer;
  font-family: 'Inter', system-ui, sans-serif; text-align: left;
  transition: border-color .15s ease, transform .1s ease;
}
.mix-chip:hover { border-color: rgba(0,0,0,0.22); }
.mix-chip .mix-swatch { flex-shrink: 0; width: 20px; height: 20px; border-radius: 6px; display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:700; }
.mix-chip .mix-text { min-width: 0; }
.mix-chip .mix-key { font-size: 9px; color: #AAA; text-transform: uppercase; letter-spacing: .06em; line-height:1.3; }
.mix-chip .mix-val { font-size: 11.5px; color: #1A1A1A; font-weight: 600; line-height:1.3; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ── Control sections (typography/atmosphere/spacing lists) ─────────── */
.control-section { margin-bottom: 26px; }
.control-section .section-label {
  font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase;
  color: #C0BEBB; font-weight: 600; margin-bottom: 10px;
}
.control-section .section-desc { font-size: 11px; color: #9A9790; margin: -6px 0 10px; line-height: 1.4; }

.row-list { display: flex; flex-direction: column; gap: 2px; }
.row-card {
  display: flex; align-items: stretch; width: 100%; border: none; border-radius: 8px;
  cursor: pointer; text-align: left; overflow: hidden; background: transparent;
  transition: background-color .18s ease; position: relative; padding: 0;
}
.row-card.active { background: #ECEAE5; }
.row-card .accent-bar { width: 2px; flex-shrink: 0; background: #1A1A1A; border-radius: 0 1px 1px 0; opacity: 0; transform: scaleY(0); transition: opacity .15s, transform .15s; }
.row-card.active .accent-bar { opacity: 1; transform: scaleY(1); }
.row-card .row-content { flex: 1; }

.typo-row { padding: 10px 14px 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.typo-preview { font-size: 16px; color: #BBB; line-height: 1.2; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s ease; }
.row-card.active .typo-preview { color: #1A1A1A; }
.typo-meta { text-align: right; flex-shrink: 0; }
.typo-meta .lbl { font-size: 10px; font-weight: 600; color: #C4C2BE; font-family: 'Inter', system-ui, sans-serif; }
.row-card.active .typo-meta .lbl { color: #1A1A1A; }
.typo-meta .sub { font-size: 9px; color: #D4D2CE; margin-top: 1px; }
.row-card.active .typo-meta .sub { color: #999; }

.atm-row { padding: 9px 12px 9px 10px; display: flex; align-items: center; gap: 11px; }
.atm-swatch { width: 52px; height: 38px; border-radius: 5px; flex-shrink: 0; position: relative; overflow: hidden; border: 1px solid rgba(0,0,0,0.08); }
.atm-text { flex: 1; min-width: 0; }
.atm-text .name { font-size: 11px; font-weight: 600; color: #AAA; margin-bottom: 3px; line-height: 1.2; }
.row-card.active .atm-text .name { color: #1A1A1A; }
.atm-text .kw { font-size: 9px; color: #C8C8C8; letter-spacing: 0.02em; line-height: 1.2; }
.row-card.active .atm-text .kw { color: #888; }
.atm-dots { display: flex; gap: 2px; flex-shrink: 0; }
.atm-dots span { width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.07); opacity: .5; }
.row-card.active .atm-dots span { opacity: 1; }

.spacing-row { padding: 11px 14px 11px 12px; display: flex; align-items: center; gap: 14px; }
.spacing-viz { display: flex; flex-direction: column; flex-shrink: 0; }
.spacing-viz div { width: 28px; height: 3px; border-radius: 2px; background: #CCC; }
.row-card.active .spacing-viz div { background: #1A1A1A; }
.spacing-row .lbl { font-size: 10px; font-weight: 600; color: #C4C2BE; }
.row-card.active .spacing-row .lbl { color: #1A1A1A; }
.spacing-row .sub { font-size: 9px; color: #D4D2CE; margin-top: 1px; }
.row-card.active .spacing-row .sub { color: #999; }

.layout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.layout-card {
  border: 1.5px solid rgba(0,0,0,0.08); border-radius: 10px; padding: 10px 10px 8px;
  cursor: pointer; background: transparent; text-align: left; transition: background-color .15s, border-color .15s;
}
.layout-card.active { border-color: #1A1A1A; background: rgba(0,0,0,0.03); }
.layout-card .thumb { width: 100%; aspect-ratio: 4/3; margin-bottom: 8px; border-radius: 5px; overflow: hidden; }
.layout-card .lbl { font-size: 11px; font-weight: 600; color: #AAA; }
.layout-card.active .lbl { color: #1A1A1A; }
.layout-card .sub { font-size: 9px; color: #CCC; margin-top: 2px; }
.layout-card.active .sub { color: #888; }

.content-list { display: flex; flex-direction: column; gap: 3px; }
.content-card {
  display: flex; align-items: flex-start; gap: 11px; padding: 11px;
  border: 1px solid rgba(0,0,0,0.08); border-radius: 10px; background: transparent;
  cursor: pointer; text-align: left; width: 100%; transition: border-color .15s, background-color .15s;
}
.content-card.active { border-color: rgba(0,0,0,0.18); background: rgba(0,0,0,0.04); }
.content-icon { width: 34px; height: 34px; flex-shrink: 0; border-radius: 8px; background: rgba(0,0,0,0.06); color: #AAA; display: flex; align-items: center; justify-content: center; transition: background-color .15s, color .15s; }
.content-card.active .content-icon { background: #1A1A1A; color: #fff; }
.content-body { flex: 1; min-width: 0; }
.content-body .title { font-size: 12px; font-weight: 600; color: #555; margin-bottom: 2px; }
.content-card.active .content-body .title { color: #1A1A1A; }
.content-body .tagline { font-size: 11px; color: #AAA; }
.content-card.active .content-body .tagline { color: #666; }
.content-body .desc { font-size: 10.5px; color: #888; line-height: 1.5; margin-top: 7px; }
.content-body .tones { font-size: 8px; letter-spacing: .1em; text-transform: uppercase; color: #BBB; margin-top: 6px; }
.content-radio { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; border-radius: 50%; border: 1.5px solid rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; }
.content-card.active .content-radio { border-color: #1A1A1A; background: #1A1A1A; }

/* ── Creative Guide notes ─────────────────────────────────────────────── */
.cg-context-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 9px;
  letter-spacing: 0.14em; text-transform: uppercase; color: #888; font-weight: 600;
  background: #ECEAE5; padding: 3px 10px; border-radius: 20px; margin-bottom: 16px;
}
.cg-note { margin-bottom: 8px; border-radius: 10px; }
.cg-note .cg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cg-note .cg-head-left { display: flex; align-items: center; gap: 5px; }
.cg-note .cg-icon { font-size: 10px; }
.cg-note .cg-label { font-size: 9px; letter-spacing: .13em; text-transform: uppercase; font-weight: 600; }
.cg-note .cg-tag { font-size: 9px; opacity: .85; }
.cg-note p { font-size: 12.5px; line-height: 1.65; margin: 0; color: #3A3A3A; }
.cg-note.primary { background: #fff; border: 1px solid rgba(0,0,0,0.07); padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.cg-note.primary .cg-head { margin-bottom: 8px; }
.cg-note.primary p { font-size: 13px; line-height: 1.7; color: #1A1A1A; }
.cg-note.secondary, .cg-note.tag, .cg-note.pair, .cg-note.diagram, .cg-note.quote { background: #F4F2EF; padding: 11px 14px; }
.cg-note.action { background: rgba(107,92,231,0.05); border: 1px solid rgba(107,92,231,0.1); padding: 11px 14px; }
.cg-note .cg-label { color: #AAAAAA; }
.cg-note.action .cg-label, .cg-note.action .cg-icon { color: #6B5CE7; }
.cg-note.primary .cg-icon { color: #C4956A; }
.cg-note.quote-body { display: flex; gap: 10px; }
.cg-note.quote-body .quote-bar { width: 2px; flex-shrink: 0; background: #D4D0C8; border-radius: 1px; }
.cg-note.quote-body p { font-style: italic; }
.cg-note.action-body { display: flex; gap: 8px; }
.cg-note.action-body .arrow { color: #6B5CE7; font-size: 11px; flex-shrink: 0; margin-top: 1px; }

/* ── The Move ─────────────────────────────────────────────────────────── */
.the-move { margin: 22px 0 26px; }
.the-move .kicker { font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: #B8B5B0; font-weight: 600; margin-bottom: 8px; }
.the-move h2 { font-family: 'Newsreader', Georgia, serif; font-weight: 400; font-size: 24px; line-height: 1.2; margin: 0 0 10px; color: #1A1A1A; }
.the-move p { font-size: 13px; line-height: 1.65; color: #55524C; margin: 0; }

/* ── Go Deeper ────────────────────────────────────────────────────────── */
.go-deeper-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 26px; }
.go-deeper-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 1px solid rgba(0,0,0,0.08); border-radius: 10px; padding: 12px;
  background: #fff; cursor: pointer; transition: border-color .15s ease;
}
.go-deeper-card:hover { border-color: rgba(0,0,0,0.2); }
.go-deeper-thumb { width: 42px; height: 42px; border-radius: 7px; flex-shrink: 0; background: #1A1A1A; }
.go-deeper-body { flex: 1; min-width: 0; }
.go-deeper-body .title { font-size: 12px; font-weight: 600; color: #1A1A1A; margin-bottom: 2px; }
.go-deeper-body .sub { font-size: 11px; color: #999; line-height: 1.35; }
.go-deeper-arrow { flex-shrink: 0; color: #BBB; font-size: 13px; }

/* ── Inspiration grid ─────────────────────────────────────────────────── */
.insp-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.insp-tile {
  aspect-ratio: 1/1; border-radius: 8px; overflow: hidden; cursor: pointer;
  border: none; padding: 0; position: relative; display: block;
  transition: transform .15s ease;
}
.insp-tile:hover { transform: scale(1.03); }
.insp-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.insp-tile.type-tile, .insp-tile.quote-tile, .insp-tile.wordmark-tile {
  background: #111; display: flex; align-items: center; justify-content: center; padding: 8px;
}
.insp-tile.type-tile span { font-family: 'Newsreader', Georgia, serif; color: #F4F1EC; font-size: 34px; }
.insp-tile.quote-tile span { font-family: 'Newsreader', Georgia, serif; color: #F4F1EC; font-size: 13px; line-height: 1.3; text-align: center; }
.insp-tile.wordmark-tile span { font-family: 'Inter', system-ui, sans-serif; color: #F4F1EC; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; }

/* ── Inspiration modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 30px;
  animation: latticeFadeIn .18s ease;
}
.modal-card {
  background: #fff; border-radius: 16px; max-width: 440px; width: 100%;
  overflow: hidden; position: relative; box-shadow: 0 30px 80px rgba(0,0,0,0.4);
}
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 8px;
  border: none; background: rgba(255,255,255,0.85); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; z-index: 2;
}
.modal-visual { width: 100%; aspect-ratio: 4/3; background: #111; display: flex; align-items: center; justify-content: center; }
.modal-visual img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal-visual span { color: #F4F1EC; font-family: 'Newsreader', Georgia, serif; }
.modal-body { padding: 20px 22px 24px; }
.modal-body .kicker { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: #AAA; font-weight: 600; margin-bottom: 8px; }
.modal-body h3 { font-family: 'Newsreader', Georgia, serif; font-weight: 500; font-size: 22px; margin: 0 0 10px; color: #1A1A1A; }
.modal-body p { font-size: 13px; line-height: 1.6; color: #55524C; margin: 0; }

/* ── Scrollbars (subtle) ──────────────────────────────────────────────── */
.lattice-drawer-body::-webkit-scrollbar, #canvas-layer::-webkit-scrollbar { width: 8px; }
.lattice-drawer-body::-webkit-scrollbar-thumb, #canvas-layer::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .lattice-drawer { top: 0; bottom: 0; right: 0; left: 0; width: 100%; border-radius: 0; }
  .lattice-pill { right: 12px; width: 112px; }
  .mix-grid { grid-template-columns: 1fr; }
  .insp-grid { grid-template-columns: 1fr 1fr; }
}
