:root {
  /* Palette: kmacd "work" panel base, brightened muted tones for readability
     since this is an editor (text-dense), not a portfolio (display-dense). */
  --bg: #0d1b2a;
  --bg-elev: #0f1f30;
  --ink: #fafafa;
  --ink-mid: #d8d8d8;          /* was #c9c9c9 */
  --ink-soft: #a8a8a8;         /* was #888 — major bump for label/desc contrast */
  --ink-faint: #7a7a7a;        /* was #555 — placeholders + empty states */
  --line: #2a3a52;             /* was #1f2c3d — brighter so hairlines stay visible */
  --line-strong: #3d4d6a;      /* was #2a3a52 */
  --accent: #c9c9c9;
  --accent-soft: rgba(255,255,255,.08);
  --topbar-h: 70px;
  --radius-sm: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-mid);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--ink); color: var(--bg); }
::-moz-selection { background: var(--ink); color: var(--bg); }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ====== Topbar ====== */
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.4rem 2rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  border-bottom: 1px solid var(--line);
}
.topbar__brand {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  font-size: 26px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.topbar__progress {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
  text-transform: lowercase;
}
@media (max-width: 600px) {
  .topbar__progress { display: none; }
}

/* ====== Compose layout (single page) ====== */
.compose {
  display: grid;
  grid-template-columns: minmax(360px, 480px) 1fr;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

/* ---- Left: inputs ---- */
.compose__inputs {
  padding: 3rem 3rem 6rem;
  border-right: 1px solid var(--line);
  min-height: calc(100vh - var(--topbar-h));
}

/* ---- Right: live preview, sticky to viewport ---- */
.compose__preview {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  padding: 2rem;
  background: var(--bg);
}
.preview__frame {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
}
.preview__frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: white;
}
.preview__caption {
  margin-top: 0.85rem;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
  text-align: center;
  text-transform: lowercase;
}

/* Narrow: stack. Preview comes after inputs and goes to natural height. */
@media (max-width: 1100px) {
  .compose {
    grid-template-columns: 1fr;
    max-width: 720px;
  }
  .compose__inputs {
    padding: 2rem 1.5rem 3rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    min-height: 0;
  }
  .compose__preview {
    position: static;
    height: auto;
    padding: 2rem 1.5rem 4rem;
  }
  .preview__frame {
    height: 70vh;
    min-height: 500px;
  }
}

/* ====== Blocks (input sections) ====== */
.block {
  margin: 0 0 3rem;
}
.block:last-child { margin-bottom: 0; }
.block__title {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
}
.block__title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.block__sub {
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  color: var(--ink-mid);
  margin: -0.5rem 0 1.5rem;
  max-width: 44ch;
}
.block--cta {
  padding-top: 1rem;
  text-align: center;
  border-top: 1px solid var(--line);
}
.cta__hint {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--ink-mid);
  margin: 1rem auto 0;
  max-width: 40ch;
  line-height: 1.55;
}

/* ====== Fields ====== */
.field { display: block; margin: 0 0 1.5rem; }
.field:last-child { margin-bottom: 0; }
.field__label {
  display: block;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.65rem;
}
.field__optional {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: var(--ink-faint);
  margin-left: 0.5rem;
  text-transform: none;
  letter-spacing: 0.02em;
}
.field__input {
  width: 100%;
  padding: 0.7rem 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  font-family: 'Inter', sans-serif;
  font-size: 16.5px;
  font-weight: 500;
  color: var(--ink);
  transition: border-color 0.15s;
}
.field__input::placeholder { color: var(--ink-faint); font-weight: 400; }
.field__input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}
select.field__input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 14px) 16px, calc(100% - 9px) 16px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.sub-field {
  margin-top: 0.85rem;
}

/* ====== Devices ====== */
.device-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
}
@media (max-width: 600px) { .device-choices { grid-template-columns: 1fr; } }
.device {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.85rem 0.75rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  color: var(--ink-mid);
  transition: color 0.15s, background 0.15s;
}
.device:last-child { border-right: 0; }
@media (max-width: 600px) { .device { border-right: 0; } }
.device:hover { color: var(--ink); }
.device--on {
  color: var(--ink);
  background: rgba(255,255,255,.06);
}
.device__name {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}
.device__desc {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  line-height: 1.5;
}

/* ====== Checklist ====== */
.check-grid {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.check {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink-mid);
  transition: color 0.15s;
}
.check:hover { color: var(--ink); }
.check--on { color: var(--ink); }
.check__mark {
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--line-strong);
  border-radius: 3px;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.check:hover .check__mark { border-color: var(--ink-soft); }
.check--on .check__mark {
  background: var(--ink);
  border-color: var(--ink);
}
.check--on .check__mark::after {
  content: '';
  position: absolute;
  top: 2px; left: 5px;
  width: 4px; height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.check__label {
  font-family: 'Inter', sans-serif;
  font-size: 15.5px;
  font-weight: 500;
}

/* ====== Photos ====== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.photo-tile {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.photo-tile__img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg);
}
.photo-tile__caption {
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  padding: 0.5rem 0.65rem;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: var(--ink-mid);
}
.photo-tile__caption:focus { outline: none; background: rgba(255,255,255,.06); }
.photo-tile__remove {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  padding: 0.4rem;
  cursor: pointer;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.photo-tile__remove:hover { color: #d97862; }

/* ====== Style picker ====== */
.style-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
}
.style-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.95rem 1rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  color: var(--ink-mid);
  transition: color 0.15s, background 0.15s;
}
.style-card:last-child { border-right: 0; }
.style-card:hover { color: var(--ink); }
.style-card--on {
  color: var(--ink);
  background: rgba(255,255,255,.06);
}
.style-card__name {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}
.style-card__desc {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* ====== Swatches ====== */
.swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
}
@media (max-width: 600px) { .swatches { grid-template-columns: repeat(2, 1fr); } }
.swatch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.4rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.swatch:last-child { border-right: 0; }
.swatch:hover { background: rgba(255,255,255,.06); }
.swatch--active { background: rgba(255,255,255,.06); }
.swatch__dot { width: 14px; height: 14px; border-radius: 999px; flex-shrink: 0; }
.swatch__name {
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink-mid);
}
.swatch--active .swatch__name { color: var(--ink); }

/* ====== Editors (inline lists under check groups) ====== */
.editor {
  margin-top: 1.5rem;
}
.editor__head {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.65rem;
}
.editor__list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.editor__list:empty + .editor__add { margin-top: 0; }
.editor__empty {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}
.editor__add {
  margin-top: 0.65rem;
  background: transparent;
  border: 0;
  padding: 0.4rem 0;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.editor__add:hover {
  color: var(--ink);
  border-bottom-color: var(--ink-soft);
}
.editor__remove {
  background: transparent;
  border: 0;
  color: var(--ink-faint);
  font-size: 16px;
  padding: 4px 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
  flex-shrink: 0;
}
.editor__remove:hover { color: #d97862; }

/* Bookmark row: favicon + label + url + × */
.editor-bookmark {
  display: grid;
  grid-template-columns: 22px 1fr 1.4fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}
.editor-bookmark:hover .editor__remove { opacity: 0.8; }
.editor-bookmark__fav {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: var(--bg-elev);
  border-radius: 3px;
  overflow: hidden;
}
.editor-bookmark__fav img { width: 18px; height: 18px; display: block; }
.editor-bookmark__fav-stub {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--line) 0%, var(--line-strong) 100%);
}
.editor-bookmark__label,
.editor-bookmark__url {
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 0.3rem 0;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 0.15s;
  min-width: 0;
}
.editor-bookmark__url {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-mid);
}
.editor-bookmark__label::placeholder,
.editor-bookmark__url::placeholder { color: var(--ink-faint); }
.editor-bookmark__label:focus,
.editor-bookmark__url:focus {
  outline: none;
  border-bottom-color: var(--ink-soft);
}
@media (max-width: 600px) {
  .editor-bookmark { grid-template-columns: 22px 1fr auto; }
  .editor-bookmark__url { grid-column: 2 / -1; padding-left: 0; }
}

/* Tip row: details with title input + body textarea */
.editor-tip {
  border-bottom: 1px solid var(--line);
}
.editor-tip[open] { background: rgba(255,255,255,.02); }
.editor-tip__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.editor-tip__head::-webkit-details-marker { display: none; }
.editor-tip:hover .editor__remove,
.editor-tip[open] .editor__remove { opacity: 0.8; }
.editor-tip__title {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 0.3rem 0;
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: text;
  transition: border-color 0.15s;
  min-width: 0;
}
.editor-tip__title::placeholder { color: var(--ink-faint); font-weight: 400; }
.editor-tip__title:focus { outline: none; border-bottom-color: var(--ink-soft); }
.editor-tip__caret {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 14px;
  color: var(--ink-faint);
  width: 12px;
  text-align: center;
  transition: transform 0.15s;
}
.editor-tip[open] .editor-tip__caret { transform: rotate(45deg); }
.editor-tip__body {
  display: block;
  width: 100%;
  margin: 0 0 0.6rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: var(--ink-mid);
  line-height: 1.5;
  resize: vertical;
}
.editor-tip__body:focus {
  outline: none;
  border-color: var(--ink-soft);
  color: var(--ink);
}
.editor-tip__body::placeholder { color: var(--ink-faint); }

/* Generic single-line row: text + remove (prompts, goals) */
.editor-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.editor-text:hover .editor__remove { opacity: 0.8; }
.editor-text__input {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 0.3rem 0;
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color 0.15s;
  min-width: 0;
}
.editor-text__input::placeholder { color: var(--ink-faint); }
.editor-text__input:focus { outline: none; border-bottom-color: var(--ink-soft); }

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--ink-mid);
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm);
  text-transform: lowercase;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.btn--primary {
  border: 1px solid var(--ink);
  color: var(--ink);
  padding: 0.9rem 2rem;
}
.btn--primary:hover { background: var(--ink); color: var(--bg); }
.btn--outline {
  border: 1px solid var(--line-strong);
  color: var(--ink-mid);
  padding: 0.75rem 1.25rem;
}
.btn--outline:hover { color: var(--ink); border-color: var(--ink-soft); }
.btn--block { width: 100%; display: flex; }
.btn--large { padding: 1.05rem 2.5rem; font-size: 14px; }

/* ====== Empty states ====== */
.empty {
  padding: 1rem 0;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  line-height: 1.5;
}

/* ====== Footbar (just the km '26 mark) ====== */
.footbar {
  padding: 1rem 2rem 1.25rem;
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--line);
}
.footer-mark {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #555;
  letter-spacing: 0.05em;
}
.footer-mark .yr { opacity: 0.6; }
