/* FoundMark palette (as the artwork renders):
   Bark #2A2521 · Blaze White #F9F6EF · Weathered Red #9B4321 · Weathered Red, light #C25C37
   Trail Blue #2C5D8A · Trail Blue, light #4B7CAB · Spur Yellow #D9A527 */
:root {
  --bg: #F9F6EF;            /* Blaze White */
  --surface: #FFFDF9;
  --surface-2: #F1ECE2;
  --text: #2A2521;          /* Bark */
  --muted: #6F665D;
  --line: #E3DBCE;
  --accent: #9B4321;        /* Weathered Red: the core blaze */
  --accent-ink: #F9F6EF;
  --accent-soft: #F4E4DA;
  --danger: #9B2C21;
  --ok: #2C5D8A;            /* Trail Blue */
  --signal: #D9A527;        /* Spur Yellow */
  --warn-text: #7A5A0E;
  --shadow: 0 1px 2px rgba(42, 37, 33, .06), 0 4px 16px rgba(42, 37, 33, .06);
  --radius: 14px;
  --check-a: #FFFDF9;
  --check-b: #EEE7DA;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #2A2521;          /* Bark */
    --surface: #332D28;
    --surface-2: #3D3630;
    --text: #F9F6EF;        /* Blaze White */
    --muted: #B8AEA0;
    --line: #4A423A;
    --accent: #C25C37;      /* Weathered Red, light: red for use on Bark */
    --accent-ink: #F9F6EF;
    --accent-soft: #4A3328;
    --danger: #E58A72;
    --ok: #4B7CAB;          /* Trail Blue, light */
    --warn-text: #D9A527;
    --shadow: none;
    --check-a: #3D3630;
    --check-b: #342E29;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #2A2521; --surface: #332D28; --surface-2: #3D3630; --text: #F9F6EF; --muted: #B8AEA0;
  --line: #4A423A; --accent: #C25C37; --accent-ink: #F9F6EF; --accent-soft: #4A3328;
  --danger: #E58A72; --ok: #4B7CAB; --warn-text: #D9A527; --shadow: none; --check-a: #3D3630; --check-b: #342E29;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: 96px;
}
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin-bottom: 12px; }
h2 label { cursor: pointer; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; gap: 14px; padding-top: 14px; padding-bottom: 14px; }
.fm-mark { width: 26px; height: 42px; flex: none; display: block; }
.fm-mark svg { width: 100%; height: 100%; display: block; }
.fm-mark .mk-on-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fm-mark .mk-on-light { display: none; } :root:not([data-theme="light"]) .fm-mark .mk-on-dark { display: block; } }
:root[data-theme="dark"] .fm-mark .mk-on-light { display: none; }
:root[data-theme="dark"] .fm-mark .mk-on-dark { display: block; }
h1 { font-family: "Iowan Old Style", "Charter", "Palatino Linotype", Georgia, "Times New Roman", serif; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
.tag .by { color: var(--accent); font-weight: 600; white-space: nowrap; }
.dropzone strong { font-family: "Iowan Old Style", "Charter", "Palatino Linotype", Georgia, serif; font-size: 24px; }
.foot a { color: inherit; }
.tag { margin: 0; color: var(--muted); font-size: 14px; }
.pill { margin-left: auto; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); }
.pill.err { color: var(--danger); }

/* Intro / dropzone */
.drop-hero { padding: 40px 0 24px; max-width: 760px; margin: 0 auto; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 48px 20px; border: 2px dashed var(--line); border-radius: 20px; background: var(--surface);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dropzone strong { font-size: 19px; }
.dropzone span { color: var(--muted); }
.drop-icon { width: 44px; height: 44px; color: var(--accent); }
.dropzone .btn { margin-top: 10px; color: var(--text); }
.how { list-style: none; padding: 0; margin: 28px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.how li { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; font-size: 14px; }
.how b { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 13px; }
.privacy { text-align: center; color: var(--muted); font-size: 13px; margin-top: 20px; }

/* Workspace */
.workspace { display: grid; grid-template-columns: 360px 1fr; gap: 20px; padding: 20px 0; align-items: start; }
.settings { display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.card > .hint:first-of-type { margin-top: -4px; margin-bottom: 12px; }

input[type="text"], input[type="number"] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
input[type="number"] { width: 96px; }
input:focus-visible, button:focus-visible, .chip:focus-within, .segmented label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="color"] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); cursor: pointer; }

.btn { font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid transparent; padding: 10px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { opacity: .55; cursor: progress; }
.btn-secondary { background: var(--surface); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--accent); padding: 6px 8px; }
.btn-sm { padding: 6px 10px; font-size: 14px; }

.logo-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 10px; }
.logo-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; }
.logo-thumb { width: 56px; height: 40px; border-radius: 8px; background: var(--check-a); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.logo-thumb img { max-width: 48px; max-height: 32px; }
.logo-meta { min-width: 0; }
.logo-meta input { padding: 5px 8px; font-size: 14px; }
.logo-meta small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo-meta label { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; padding: 6px; border-radius: 8px; }
.icon-btn:hover { color: var(--danger); background: var(--surface-2); }
.logo-item.loading .logo-thumb { animation: pulse 1.2s infinite; }
.logo-item.error small { color: var(--danger); white-space: normal; }
@keyframes pulse { 50% { opacity: .4; } }

.checks { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.check .sw { width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--line); flex: none; }
.check small { color: var(--muted); margin-left: auto; font-size: 12px; text-align: right; }

.inline-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.inline-row label { font-size: 14px; }

.palette { display: grid; gap: 10px; }
.color-row { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: start; padding-top: 10px; border-top: 1px solid var(--line); }
.color-row:first-child { border-top: 0; padding-top: 0; }
.color-sw { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); cursor: pointer; padding: 0; }
.color-info { font-size: 13px; min-width: 0; }
.color-info code { font: 600 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.color-info .sub { color: var(--muted); font-size: 12px; }
.color-opts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.color-opts label { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.color-opts input { accent-color: var(--accent); margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; background: var(--surface-2); }
.chip input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; border: 1px solid var(--line); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span { display: block; padding: 5px 12px; border-radius: 8px; font-size: 13px; }
.segmented input:checked + span { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.field { display: grid; gap: 8px; }
.field-label { font-size: 14px; }

/* Previews */
.previews { min-width: 0; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.preview-head h2 { margin: 0; }
.notes { background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }
.notes ul { margin: 0; padding-left: 18px; }
.logo-block { margin-bottom: 22px; }
.logo-block h3 { font-size: 15px; margin: 0 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.stage { aspect-ratio: 16 / 10; display: grid; place-items: center; padding: 18px; }
.stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.stage.light { background: #ffffff; }
.stage.dark { background: var(--dark-bg, #111827); }
.stage.checker {
  background-color: var(--check-a);
  background-image: linear-gradient(45deg, var(--check-b) 25%, transparent 25%), linear-gradient(-45deg, var(--check-b) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--check-b) 75%), linear-gradient(-45deg, transparent 75%, var(--check-b) 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.stage .spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(128,128,128,.3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tile-cap { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 14px; }
.tile-cap small { color: var(--muted); }

/* Bottom bar */
.bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(0,0,0,.06); z-index: 10; }
.bar-inner { display: flex; align-items: center; gap: 16px; padding-top: 12px; padding-bottom: 12px; }
.bar-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.bar-text span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.foot { color: var(--muted); font-size: 12px; padding-top: 12px; padding-bottom: 24px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .previews { order: -1; }
}
@media (max-width: 600px) {
  .how { grid-template-columns: 1fr; }
  .top-inner { flex-wrap: wrap; }
  .pill { margin-left: 0; }
  .tag { font-size: 13px; }
  .bar-inner { gap: 10px; }
  .btn-primary { padding: 10px 12px; }
}

/* ---- v2: brand package UI ---- */
.workspace { grid-template-columns: 400px 1fr; }
.colors { display: grid; gap: 12px; }
.color-row { grid-template-columns: 44px 1fr; }
label.color-sw { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; position: relative; overflow: hidden; display: block; }
label.color-sw input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.color-fields { display: flex; gap: 6px; }
.color-fields input, .in-pms { padding: 5px 8px; font-size: 14px; }
.in-name { flex: 1; min-width: 0; font-weight: 600; }
.in-hex { width: 92px; flex: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.in-pms { margin-top: 6px; }
.color-info .sub { margin-top: 5px; }
.exact { color: var(--ok); font-weight: 600; }
.families { display: grid; gap: 10px; }
.family-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.family-row input[type="text"] { padding: 7px 10px; font-size: 14px; }
.swatches { display: inline-flex; gap: 3px; }
.swatches i { width: 18px; height: 28px; border-radius: 5px; border: 1px solid var(--line); display: block; }
.radio { font-size: 13px; color: var(--muted); display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.radio input { accent-color: var(--accent); margin: 0; }
.naming { font-size: 13px; line-height: 2; margin: 0 0 4px; word-break: break-word; }
.naming code { background: var(--surface-2); border-radius: 6px; padding: 2px 6px; font-size: 12px; }
.count { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; letter-spacing: 0; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.asset { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.asset .stage { aspect-ratio: 16 / 9; padding: 20px 26px; }
.asset figcaption { padding: 10px 12px 12px; display: grid; gap: 8px; border-top: 1px solid var(--line); }
.asset .fname { font: 600 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; color: var(--text); }
.asset small { color: var(--muted); font-size: 12px; }
.selects { display: flex; flex-wrap: wrap; gap: 6px; }
.selects select { font: inherit; font-size: 13px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; max-width: 100%; }
.asset.loading .stage { aspect-ratio: 16 / 9; }
.err-note { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.guide-section { margin-top: 28px; }
.guide-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.guide-pages img { width: 100%; display: block; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.bar-inner .btn-secondary { white-space: nowrap; }
@media (max-width: 900px) { .workspace { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
  .bar-inner { flex-wrap: wrap; }
  .bar-text { flex-basis: 100%; }
  .bar-inner .btn { flex: 1; justify-content: center; }
}
.color-fields input.in-name { width: auto; flex: 1 1 0; min-width: 0; }
.color-fields input.in-hex { width: 92px; flex: 0 0 92px; }
.asset .stage { aspect-ratio: auto; height: 150px; padding: 18px 24px; }
.asset .stage img { max-height: 114px; max-width: 100%; width: auto; height: auto; }
.color-row { grid-template-columns: 44px 1fr 28px; }
.color-row .in-note, .color-row .in-pms { margin-top: 6px; font-weight: 400; }
.move-up { font-size: 16px; padding: 4px; }
.move-up:hover { color: var(--accent); }
.art-warn { font-size: 12px; color: var(--warn-text); margin-top: 4px; }
.art-warn code { font-size: 12px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.bg-role { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.bg-role select { font: inherit; font-size: 13px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; }
#suggest-pantone { margin-top: 10px; }
.jpg-white { margin-top: 10px; font-size: 14px; }

/* ---- Phone layout ---- */
.tabs, .for-touch, .guide-empty, .edit-btn, .asset .summary { display: none; }
@media (hover: none) and (pointer: coarse) {
  .for-desktop { display: none !important; }
  .for-touch { display: inline-flex; }
  strong.for-touch { display: block; }
}
@media (max-width: 700px) {
  body { padding-bottom: 150px; }
  .top-inner { flex-wrap: nowrap; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .top-inner > div { min-width: 0; }
  .tag { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pill { margin-left: auto; font-size: 11px; padding: 3px 8px; }
  .fm-mark { width: 22px; height: 36px; }
  h1 { font-size: 21px; }
  .drop-hero { padding-top: 20px; }
  .dropzone { padding: 32px 16px; }
  .how { margin-top: 18px; }

  .workspace { display: block; padding-top: 0; }
  .tabs {
    display: flex; gap: 4px; position: sticky; top: 0; z-index: 6;
    margin: 0 -16px 14px; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .tabs button {
    flex: 1; font: inherit; font-weight: 600; font-size: 15px; min-height: 44px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--surface); color: var(--muted); position: relative;
  }
  .tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .dot { position: absolute; top: 8px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--signal); }
  .workspace[data-tab="logos"] .settings,
  .workspace[data-tab="logos"] #guide-section,
  .workspace[data-tab="logos"] #guide-empty,
  .workspace[data-tab="brand"] .previews,
  .workspace[data-tab="guide"] .settings,
  .workspace[data-tab="guide"] .previews > .preview-head:first-child,
  .workspace[data-tab="guide"] #assets { display: none !important; }
  .workspace[data-tab="guide"] #guide-empty { display: block; }
  .workspace[data-tab="guide"] #guide-section:not([hidden]) ~ #guide-empty,
  .workspace[data-tab="guide"].has-guide #guide-empty { display: none; }
  .guide-section { margin-top: 0; }
  .guide-pages { grid-template-columns: 1fr; gap: 12px; }

  /* Logo cards: two per row, edit controls behind a button */
  .asset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .asset .stage { height: 104px; padding: 12px; }
  .asset .stage img { max-height: 80px; }
  .asset figcaption { padding: 8px 10px 10px; gap: 6px; }
  .asset .fname { font-size: 11px; line-height: 1.35; }
  .asset small { display: none; }
  .asset .summary { display: block; font-size: 12px; color: var(--muted); }
  .asset .selects { display: none; flex-direction: column; }
  .asset.open { grid-column: 1 / -1; }
  .asset.open .stage { height: 150px; }
  .asset.open .stage img { max-height: 120px; }
  .asset.open .selects { display: flex; }
  .asset.open small { display: block; }
  .edit-btn { display: block; font: inherit; font-size: 14px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 8px; min-height: 40px; }

  /* Finger-sized controls; 16px text stops iOS from zooming in on focus */
  input[type="text"], input[type="number"], select, .selects select, .bg-role select, .color-fields input, .family-row input[type="text"] { font-size: 16px !important; min-height: 44px; }
  .selects select { width: 100%; }
  .color-row { grid-template-columns: 44px 1fr 40px; }
  .color-fields { flex-wrap: wrap; }
  .color-fields input.in-hex { flex: 1 1 110px; }
  .move-up { min-width: 40px; min-height: 40px; font-size: 18px; }
  .bg-role { margin-top: 8px; }
  .bg-role select { flex: 1; }
  .btn-sm, .btn-ghost { min-height: 44px; }
  .radio { min-height: 44px; }

  /* Compact bottom bar */
  .bar-inner { flex-wrap: wrap; gap: 8px; padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .bar-text { flex-basis: 100%; gap: 0; }
  .bar-text strong { font-size: 14px; }
  .bar-inner .btn { flex: 1; justify-content: center; min-height: 48px; font-size: 15px; }
  .foot { padding-bottom: 160px; }
}
@media (max-width: 700px) {
  .color-fields input.in-name { flex: 1 1 100%; }
  .color-fields input.in-hex { flex: 1 1 100%; }
}
@media (max-width: 700px) { .tag .slogan { display: none; } }
