/* Editor / admin / store UI. Reuses the colour variables from site.css,
   so light and dark mode come for free. */
:root { --danger: #c92a2a; --ok: #2b8a3e; --ok-soft: #e6f4ea; --warn-soft: #fff4e6; }
@media (prefers-color-scheme: dark) {
  :root { --danger: #ff8787; --ok: #69db7c; --ok-soft: #12291a; --warn-soft: #2e2214; }
}

.cms-muted { color: var(--muted); }
.cms-error { color: var(--danger); }
.cms-status { color: var(--muted); font-size: 14px; min-height: 1.4em; margin: 8px 0 0; }
.cms-link { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

.cms-btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.cms-btn:hover { border-color: var(--accent); }
.cms-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.cms-btn.block { width: 100%; margin-top: 16px; }
.cms-btn:disabled { opacity: .55; cursor: default; }
.cms-tool {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
  min-width: 32px; padding: 4px 8px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.cms-tool.small { font-size: 12px; padding: 2px 7px; }
.cms-tool.danger { color: var(--danger); }
.cms-tool:hover { border-color: var(--accent); }

.cms-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 11px; background: var(--bg); border: 1px solid var(--border); }
.cms-seg > button, .cms-seg > a {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px; border: 0; background: transparent; color: var(--muted);
}
.cms-seg > [aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.cms-seg > .is-off { opacity: .55; }

.badge { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.is-done { background: var(--ok-soft); color: var(--ok); }
.badge:empty { display: none; }

/* ── markdown editor on doc pages ───────────────────────── */
.cms-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--accent-soft); border-radius: 12px; padding: 8px 8px 8px 14px; margin: 0 0 14px; font-size: 14px;
}
.doc:has(.cms-editor) { max-width: 1200px; }
.cms-editor { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.cms-editor-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cms-tools { display: flex; flex-wrap: wrap; gap: 4px; }
.cms-actions { margin-left: auto; display: flex; gap: 6px; }
.cms-meta { font-size: 13px; color: var(--muted); margin: 10px 0; }
.cms-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cms-pane { min-width: 0; display: flex; flex-direction: column; }
.cms-pane-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 6px; }
.cms-text {
  flex: 1; min-height: 60vh; resize: vertical; width: 100%;
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.cms-text:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.cms-preview { min-height: 60vh; max-height: 75vh; overflow: auto; padding: 0 16px 12px; border-radius: 10px; border: 1px dashed var(--border); }
.cms-preview h2 { font-size: 19px; margin: 22px 0 8px; }
.cms-preview ul, .cms-preview ol { padding-left: 22px; }
.cms-help { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.cms-help code { background: var(--bg); border: 1px solid var(--border); border-radius: 5px; padding: 0 4px; }
.cms-history { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; background: var(--bg); }
.cms-history ul { margin: 0; padding-left: 18px; }
.doc article img { max-width: 100%; height: auto; }
.doc article table { border-collapse: collapse; width: 100%; }
.doc article th, .doc article td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }

/* ── admin / store shell ───────────────────────────────── */
.wide { max-width: 1160px; margin: 0 auto; padding: 28px 16px 64px; }
.login-card {
  max-width: 400px; margin: 40px auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px; display: flex; flex-direction: column;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card label { font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
.login-card .cms-link { margin-top: 12px; align-self: flex-start; font-size: 14px; }
.login-card input, .field input:not([type=checkbox]):not([type=radio]), .field textarea, .field select, .editor-add input {
  font: inherit; font-size: 15px; width: 100%; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.field textarea { resize: vertical; line-height: 1.55; }
.login-card input:focus, .field input:focus, .field textarea:focus, .field select:focus, .editor-add input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field input[readonly] { color: var(--muted); }

.store-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; margin: 0 0 16px; }
.store-head h1 { font-size: 26px; margin: 0 0 4px; }
.store-head p { margin: 0; max-width: 640px; }
.store-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.platform-tabs { margin: 0 0 12px; }
.store-sticky {
  position: sticky; top: 57px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--border); margin: 0 0 16px;
}
.store-filter { font-size: 14px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.store-status { margin-left: auto; font-size: 13px; color: var(--muted); }
.store-status.is-error { color: var(--danger); }
.store-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.store-toc { position: sticky; top: 130px; display: flex; flex-direction: column; gap: 2px; }
.store-toc a { display: flex; justify-content: space-between; gap: 8px; align-items: center; text-decoration: none; color: var(--muted); font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.store-toc a:hover { background: var(--accent-soft); color: var(--text); }
.store-sections { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.store-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 6px 20px 20px; scroll-margin-top: 130px; }
.store-card h2 { font-size: 19px; margin: 16px 0 8px; }
.store-card .note { font-size: 14px; margin: 0 0 8px; }
.store-fields { display: flex; flex-direction: column; }

.field { padding: 14px 0; border-top: 1px solid var(--border); }
.store-fields .field:first-child { border-top: 0; }
.field-head { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.field-head label, .field-label { font-weight: 600; font-size: 15px; margin-right: auto; }
.req { color: var(--danger); }
.loc { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count.is-over { color: var(--danger); font-weight: 700; }
.field-hint { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.field-where { font-size: 12px; color: var(--muted); margin: 6px 0 0; opacity: .85; }
.field-warn { font-size: 13px; color: var(--danger); margin: 6px 0 0; }
.field-warn:empty, .field-off:empty { display: none; }
.field-off { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.field.is-off > :is(input, textarea, select, .choices) { opacity: .6; }
.field.is-required.is-missing { box-shadow: inset 3px 0 0 var(--accent); padding-left: 12px; margin-left: -12px; }
.only-missing .field:not(.is-missing) { display: none; }
.only-missing .store-card:not(:has(.field.is-missing)) { display: none; }
.choices { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.choices label { display: inline-flex; gap: 6px; align-items: center; font-size: 15px; cursor: pointer; white-space: nowrap; }
.choices input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

.dropzone { border: 1px dashed var(--border); border-radius: 12px; padding: 12px; }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 13px; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.shots:not(:empty) { margin: 0 0 12px; }
.shot { margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); display: flex; flex-direction: column; }
.shot.is-bad { border-color: var(--danger); }
.shot img { display: block; width: 100%; height: 180px; object-fit: contain; background: var(--surface); }
.shot figcaption { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 12px; color: var(--muted); }
.shot-name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-bad { color: var(--danger); font-weight: 700; }
.shot-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.admin-h2 { font-size: 18px; margin: 28px 0 10px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.admin-tile { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; color: var(--text); text-decoration: none; }
a.admin-tile:hover { border-color: var(--accent); }
.admin-tile p { margin: 0; font-size: 14px; }
.admin-tile-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.admin-go { color: var(--accent); font-weight: 600; font-size: 14px; margin-top: auto; }
.admin-links { font-size: 14px; margin-top: auto; }
.editor-list { list-style: none; padding: 0; margin: 8px 0 12px; }
.editor-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.editor-add { display: flex; gap: 8px; }
.editor-add input { max-width: 360px; }

@media (max-width: 860px) {
  .cms-panes { grid-template-columns: 1fr; }
  .cms-text, .cms-preview { min-height: 40vh; }
  .store-layout { grid-template-columns: 1fr; }
  .store-toc { display: none; }
  .store-sticky { top: 57px; }
}
@media (max-width: 560px) {
  .cms-actions { margin-left: 0; width: 100%; }
  .cms-actions .cms-btn { flex: 1; }
  .store-status { margin-left: 0; width: 100%; }
  .store-card { padding: 4px 14px 16px; }
}
