:root {
  --bg: #f7f6f4;
  --card: #ffffff;
  --ink: #1c1b19;
  --muted: #78746e;
  --line: #e2ded8;
  --accent: #7a5c3e;
  --warn: #b3541e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --card: #201f24;
    --ink: #ece9e4;
    --muted: #8f8a84;
    --line: #33313a;
    --accent: #c9a227;
    --warn: #e08d45;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: var(--card); position: sticky; top: 0; z-index: 5;
}
h1 { font-size: 18px; margin: 0; letter-spacing: .02em; }
nav button {
  border: 0; background: none; color: var(--muted);
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
nav button.on { background: var(--bg); color: var(--ink); font-weight: 600; }
#count { margin-left: auto; color: var(--muted); font-size: 13px; }

section { padding: 16px 20px 60px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
select, input, button, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
button { cursor: pointer; }

#grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; cursor: pointer; position: relative;
}
.card.sel { outline: 2px solid var(--accent); }
#grid .card { content-visibility: auto; contain-intrinsic-size: auto 230px; }
#grid-more { text-align: center; min-height: 40px; padding: 12px; }
a.btn { color: inherit; text-decoration: none; }
.card img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.card .label { font-size: 13px; margin-top: 6px; }
.card .sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--line); display: inline-block; }
.badge {
  position: absolute; top: 8px; right: 8px; font-size: 11px;
  background: var(--warn); color: #fff; border-radius: 4px; padding: 1px 5px;
}

#editor {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100%);
  background: var(--card); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 16px; z-index: 10;
}
#editor img { width: 100%; max-height: 260px; object-fit: contain; }
.axis { margin: 14px 0; }
.axis h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase;
           letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  padding: 4px 10px; font-size: 13px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip small { opacity: .65; margin-left: 4px; }
.axis select, .axis input { width: 100%; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin: 12px 0 6px; }
.editor-actions { display: flex; gap: 8px; margin-top: 18px; }
.editor-actions button { flex: 1; }
.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; }

.bar { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 13px; }
.bar span:first-child { width: 130px; }
.bar i { height: 12px; background: var(--accent); border-radius: 3px; display: block; }
.stat-block { background: var(--card); border: 1px solid var(--line);
              border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.stat-block h3 { margin: 0 0 10px; font-size: 14px; }
.mini { display: flex; gap: 8px; flex-wrap: wrap; }
.mini img { width: 64px; height: 64px; object-fit: contain;
            border: 1px solid var(--line); border-radius: 6px; }
.journal-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
#j-picker { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.outfit { background: var(--card); border: 1px solid var(--line);
          border-radius: 10px; padding: 10px; margin: 8px 0; }

.editor-bar { display: flex; align-items: center; justify-content: space-between;
              gap: 10px; margin-bottom: 10px; position: sticky; top: -16px;
              background: var(--card); padding: 8px 0; z-index: 2; }
.close { border: 1px solid var(--line); background: var(--bg); border-radius: 8px;
         width: 40px; height: 40px; font-size: 18px; line-height: 1; }
.wide { width: 100%; margin-top: 10px; padding: 10px; }
@media (max-width: 600px) {
  #editor { width: 100%; }
  .chip { padding: 8px 12px; font-size: 14px; }
  select, input, button { padding: 9px 10px; }
}

.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
               color: var(--muted); margin: 18px 0 8px; }
.group-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.group-grid .card img { aspect-ratio: 1; }
.group-grid .card .sub { font-size: 11px; }
#j-tray {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
#j-tray img { width: 46px; height: 46px; object-fit: contain;
              border: 1px solid var(--line); border-radius: 6px; }
#j-tray .grow { flex: 1; }
.suggestion { background: var(--card); border: 1px solid var(--line);
              border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.suggestion .row-items { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.suggestion .row-items figure { margin: 0; text-align: center; width: 92px; }
.suggestion .row-items img { width: 92px; height: 92px; object-fit: contain;
                             border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.suggestion figcaption { font-size: 11px; color: var(--muted); margin-top: 3px; }
.why { margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.why li:before { content: "\\2022 "; }
.score { float: right; font-size: 12px; color: var(--muted); }

.uploader { display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
            margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--card);
       border-radius: 6px; padding: 8px 12px; cursor: pointer; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.uploader .hint { margin: 0; }
