:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f3efe9;
  --line: #e3ddd4;
  --ink: #1e1b18;
  --ink-soft: #6d655c;
  --accent: #a3421c;
  --accent-ink: #ffffff;
  --danger: #9b2c2c;
  --warn-bg: #fdf1dc;
  --warn-ink: #7a4a08;
  --ok-bg: #e6f2e6;
  --ok-ink: #275c2c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 27, 24, .06), 0 4px 14px rgba(30, 27, 24, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #201e1b;
    --surface-2: #2a2724;
    --line: #383430;
    --ink: #f0ece6;
    --ink-soft: #a49b90;
    --accent: #e07a4a;
    --accent-ink: #1a1512;
    --danger: #e08585;
    --warn-bg: #3a2f16;
    --warn-ink: #f0d194;
    --ok-bg: #1e3220;
    --ok-ink: #a8d5ab;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 980px; margin: 0 auto; padding: 28px 20px 64px; }

h1 { font-size: 1.6rem; margin: 0 0 4px; letter-spacing: -.015em; }
h2 { font-size: 1.15rem; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 0 0 2px; }

/* ---------- chrome ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.topbar nav { display: flex; gap: 18px; }
.topbar nav a { color: var(--ink-soft); text-decoration: none; font-size: .9rem; }
.topbar nav a:hover { color: var(--accent); }

.foot {
  max-width: 980px; margin: 0 auto; padding: 0 20px 40px;
  color: var(--ink-soft); font-size: .82rem;
}

.messages { list-style: none; max-width: 980px; margin: 16px auto 0; padding: 0 20px; }
.msg {
  padding: 9px 13px; border-radius: var(--radius); margin-bottom: 8px;
  font-size: .9rem; border: 1px solid transparent;
}
.msg--success { background: var(--ok-bg); color: var(--ok-ink); }
.msg--warning { background: var(--warn-bg); color: var(--warn-ink); }
.msg--error   { background: #fbe6e6; color: var(--danger); }

/* ---------- panels ---------- */

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-bottom: 28px;
  box-shadow: var(--shadow);
}
.panel--tight { padding: 14px 18px; }
.panel--tight summary { cursor: pointer; font-weight: 550; color: var(--ink-soft); }
.panel--tight[open] summary { margin-bottom: 14px; color: var(--ink); }

.lede { color: var(--ink-soft); margin: 0 0 16px; max-width: 62ch; }
.hint { color: var(--ink-soft); font-size: .82rem; margin: 10px 0 0; }
.empty { color: var(--ink-soft); font-style: italic; }
.section-head { margin-bottom: 12px; }

/* ---------- forms ---------- */

.import-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.import-form .field { flex: 1 1 380px; }

input[type="text"], input[type="url"], input[type="number"],
input[type="password"], input[type="email"], textarea, select {
  width: 100%; padding: 8px 10px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px;
  font: inherit;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent;
}

.field { display: block; }
.field > span {
  display: block; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-soft); margin-bottom: 3px;
}
.field--grow { flex: 1 1 auto; }
.field--price { flex: 0 0 110px; }

.row { display: flex; gap: 12px; margin-bottom: 10px; }
.row--split { align-items: flex-end; flex-wrap: wrap; }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; white-space: nowrap; }
.check input { width: auto; }
.toggles { display: flex; gap: 14px; padding-bottom: 8px; }

.grid-form p { margin: 0 0 12px; }
.grid-form label { font-size: .8rem; color: var(--ink-soft); display: block; }

.err { color: var(--danger); font-size: .84rem; margin: 5px 0 0; }

/* ---------- buttons ---------- */

.btn {
  display: inline-block; padding: 8px 15px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--ink-soft); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--primary:hover { filter: brightness(1.08); }
.btn--danger { color: var(--danger); }

.linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: .84rem; color: var(--ink-soft); text-decoration: underline;
}
.linkbtn--danger { color: var(--danger); }

/* ---------- store list ---------- */

.store-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.store-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  /* Anchors the live-site badge, which sits outside the card's own link. */
  position: relative;
}

/* Opens the client's public site. Deliberately small and in the corner - the
   card's main job is still to open the editor. */
.store-card__live {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  text-decoration: none; font-size: .95rem; line-height: 1;
}
.store-card__live:hover { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.store-card__link { text-decoration: none; color: inherit; display: block; }
.store-card__img { width: 100%; height: 116px; object-fit: cover; display: block; }
.store-card__img--empty { background: var(--surface-2); }
.store-card__body { padding: 12px 14px; }
.meta { color: var(--ink-soft); font-size: .84rem; margin: 0; }
.meta--hosts { margin-top: 3px; }
.meta--hosts a { color: var(--ink-soft); }

/* ---------- store detail ---------- */

.store-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.store-head__id { display: flex; align-items: center; gap: 14px; }

.store-logo {
  width: 56px; height: 56px; object-fit: contain;
  border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--line); padding: 4px; flex: 0 0 auto;
}
.store-logo--sm {
  width: 22px; height: 22px; padding: 2px; border-radius: 5px;
  vertical-align: -5px; margin-right: 4px;
}
.store-head__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.store-head__actions form { margin: 0; }

.menu-section { margin-bottom: 30px; }
.menu-section__head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--line);
}
.menu-section__head form { margin: 0 0 0 auto; }
.count {
  background: var(--surface-2); color: var(--ink-soft);
  border-radius: 20px; padding: 1px 9px; font-size: .78rem;
}

.items { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }

.item {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.item--hidden { opacity: .55; }
.item__form { display: flex; gap: 18px; padding: 16px; flex-wrap: wrap; }

.item__photo { flex: 0 0 150px; position: relative; }
.item__photo img {
  width: 150px; height: 150px; object-fit: cover;
  border-radius: 8px; display: block; background: var(--surface-2);
}
.item__photo--empty {
  width: 150px; height: 150px; border-radius: 8px;
  background: var(--surface-2); color: var(--ink-soft);
  display: grid; place-items: center; font-size: .8rem;
}
.badge {
  position: absolute; top: 6px; left: 6px;
  font-size: .7rem; padding: 2px 7px; border-radius: 20px;
}
.badge--warn { background: var(--warn-bg); color: var(--warn-ink); }

.upload { display: block; margin-top: 8px; font-size: .76rem; color: var(--ink-soft); }
.upload input { font-size: .74rem; width: 150px; }
.upload span { display: block; margin-top: 2px; }

.item__fields { flex: 1 1 340px; min-width: 0; }
.item__actions { display: flex; align-items: center; gap: 14px; margin-top: 4px; }

@media (max-width: 620px) {
  .item__form { flex-direction: column; }
  .item__photo, .item__photo img, .item__photo--empty, .upload input { width: 100%; }
  .item__photo img, .item__photo--empty { height: 190px; }
}

/* --- Gallery photos (builder) ------------------------------------------- */
/* Uploaded by hand rather than scraped, so this panel is always in play even
   for a store whose import brought back nothing usable. */
.panel__head { margin-bottom: .9rem; }
.panel__note { margin: .25rem 0 0; color: #666; font-size: .85rem; max-width: 60ch; }

.photo-add {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  padding: .8rem; margin-bottom: 1rem;
  background: #faf8f5; border: 1px dashed #d6cec4; border-radius: 6px;
}
.photo-add input[type="file"] { flex: 1 1 18rem; min-width: 0; font-size: .9rem; }

.photo-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.photo {
  border: 1px solid #e3ddd5; border-radius: 6px; overflow: hidden;
  background: #fff; display: flex; flex-direction: column;
}
/* Hidden photos stay legible - greying them out entirely makes it hard to
   tell what you're about to un-hide. */
.photo--hidden { opacity: .55; }
.photo__img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  background: #f0ece7;
}
.photo__form { padding: .7rem; display: flex; flex-direction: column; gap: .55rem; }
.photo__row { display: flex; gap: .8rem; align-items: flex-end; }
.photo__actions { display: flex; gap: .4rem; }
.field--narrow { width: 5.5rem; }
.f-pos { width: 100%; }
.photo .warn { margin: .4rem .7rem 0; font-size: .78rem; color: #a3421c; }

/* --- Reviews (builder) --------------------------------------------------- */
.review-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 1rem; }
.review {
  border: 1px solid #e3ddd5; border-radius: 6px; background: #fff; padding: .9rem;
}
/* A hidden review is the default for a new one, so this state is common and
   should read as "not finished yet", not as an error. */
.review--hidden { border-style: dashed; background: #fcfbfa; }
.review__form { display: flex; flex-direction: column; gap: .6rem; }
.review__row { display: flex; gap: .8rem; flex-wrap: wrap; }
.review__row .field { flex: 1 1 10rem; min-width: 0; }
.review__foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: .8rem; flex-wrap: wrap; padding-top: .2rem;
}
.review__actions { display: flex; gap: .4rem; }

/* --- Sign in -------------------------------------------------------------
   The login panel is the one page an anonymous visitor can reach, so it gets
   a narrower measure than the builder's full-width panels. */
.panel--login { max-width: 22rem; margin: 3rem auto; }
.panel--login .field { margin-bottom: 1rem; }

/* Sign-out has to be a form (POST), so the button is dressed as a nav link. */
.topbar .logout { display: inline; margin: 0; }
.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--ink-soft); font: inherit; font-size: .9rem;
}
.linkish:hover { color: var(--accent); }
.whoami { color: var(--ink-soft); font-size: .9rem; opacity: .75; }
