/* Picky - structure only. Every colour, font, border, radius and shadow is a
   variable defined per theme in themes.css. */

* { box-sizing: border-box; }

html { background: var(--page); color-scheme: var(--scheme, light); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--page);
  background-image: var(--page-pattern);
  background-size: var(--page-pattern-size);
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-spacing);
  text-transform: var(--display-transform);
  line-height: 1.1;
}
h2 { font-size: 28px; margin: 0 0 14px; }
h3 { font-size: 17px; font-weight: 700; margin: 22px 0 8px; }

.hidden { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.icon { width: 20px; height: 20px; flex: none; vertical-align: -4px; }

:focus-visible { outline: 3px dashed var(--focus); outline-offset: 3px; }

/* ---- Logo ---- */
.logo {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  color: var(--logo-color);
  -webkit-text-stroke: var(--logo-stroke);
  paint-order: stroke fill;
  text-shadow: var(--logo-shadow);
  text-transform: var(--display-transform);
  letter-spacing: var(--display-spacing);
  transform: rotate(var(--logo-rotate));
}
.logo-lg { font-size: 60px; margin: 4px 0 0; }
.logo-sm { font-size: 28px; }
.tagline { margin: 6px 0 8px; color: var(--ink-soft); font-weight: 500; }

/* ---- Login ---- */
#view-login {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  overflow: hidden;
}
.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  padding: 26px 24px 20px;
  background: var(--paper);
  border: var(--line) solid var(--line-color);
  border-radius: calc(var(--r-card) + 6px);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.auth-card form { text-align: left; }

.doodle { position: absolute; stroke: var(--line-color); stroke-width: 1.2px; paint-order: stroke; opacity: var(--doodle-opacity, 1); }
.doodle-a { width: 120px; height: 120px; color: var(--t1); top: 7%; left: -20px; transform: rotate(-14deg); }
.doodle-b { width: 70px; height: 70px; color: var(--t2); bottom: 12%; right: 6%; transform: rotate(18deg); }
.doodle-c { width: 90px; height: 90px; color: var(--t4); bottom: 4%; left: 8%; transform: rotate(-24deg); }
@media (min-width: 700px) {
  .doodle-a { width: 180px; height: 180px; left: 12%; }
  .doodle-b { right: 16%; }
}

/* ---- Form controls ---- */
label, .label { display: block; margin: 16px 0 6px; font-weight: 700; font-size: 14px; }
input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--field-bg);
  border: var(--line) solid var(--line-color);
  border-radius: var(--r-field);
}
input::placeholder { color: var(--placeholder); }
input:focus { outline: none; box-shadow: 0 0 0 4px var(--focus); }
input:disabled { background: var(--muted-bg); color: var(--ink-soft); }

.input-with-icon { position: relative; }
.input-with-icon .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); pointer-events: none; }
.input-with-icon input { padding-left: 44px; }

.checkbox-row { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.checkbox-row input { width: 20px; height: 20px; accent-color: var(--primary); }

/* ---- Buttons ---- */
button { font-family: inherit; cursor: pointer; color: var(--ink); }

.btn-primary, .btn-secondary, .btn-danger, .btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: var(--line) solid var(--line-color);
  border-radius: var(--r-pill);
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.btn-primary:active, .btn-secondary:active, .btn-danger:active, .btn-small:active {
  transform: translate(var(--press), var(--press));
  box-shadow: var(--shadow-press);
}
.btn-primary {
  width: 100%;
  margin-top: 20px;
  padding: 13px 18px;
  font-size: 17px;
  background-color: var(--primary);
  background-image: var(--gloss);
  color: var(--on-primary);
}
.btn-secondary { padding: 11px 16px; font-size: 15px; background: var(--paper); }
.btn-danger { width: 100%; margin-top: 14px; padding: 11px 16px; background: var(--paper); color: var(--danger); }
.btn-small {
  padding: 10px 16px;
  background-color: var(--highlight);
  background-image: var(--gloss);
  color: var(--on-highlight);
  font-size: 15px;
  white-space: nowrap;
}

.btn-link, .btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 6px 2px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
.btn-icon-text { text-decoration: none; }

.button-row { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.button-row .btn-primary { width: auto; flex: 1 1 180px; margin-top: 0; }
.button-row .btn-secondary { flex: 0 1 auto; }

.inline-row { display: flex; gap: 10px; align-items: center; }
.inline-row input { flex: 1; }

.error { color: var(--danger); font-size: 14px; font-weight: 500; margin: 8px 0 0; }
.success { color: var(--success); font-size: 14px; font-weight: 700; margin: 6px 0 0; }
.error:empty, .success:empty { display: none; }
.hint { color: var(--ink-soft); font-size: 13px; margin: 6px 0 0; }
.hint:empty { display: none; }
.info-text { font-size: 14px; color: var(--ink-soft); }

/* ---- App shell ---- */
#view-app { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px max(18px, calc((100% - 640px) / 2 + 16px)) 12px;
  background: var(--paper);
  border-bottom: var(--line) solid var(--line-color);
}

#main-content {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 110px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: var(--line) solid var(--line-color);
}
.nav-btn {
  flex: 1;
  max-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 0 6px;
  background: none;
  border: var(--line) solid transparent;
  border-radius: calc(var(--r-field) + 4px);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}
.nav-btn .icon { width: 24px; height: 24px; }
.nav-btn.active { background: var(--highlight); border-color: var(--line-color); color: var(--on-highlight); font-weight: 700; }

.panel {
  background: var(--paper);
  border: var(--line) solid var(--line-color);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-lg);
  padding: 20px;
}
.panel-gap { margin-top: 22px; }
.section-title {
  margin: 28px 4px 10px;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-spacing);
  text-transform: var(--display-transform);
  font-size: 22px;
}

/* ---- Tag stickers ---- */
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.chip-list:empty { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: var(--line-thin) solid var(--line-color);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 700;
  color: var(--on-accent);
  background-color: var(--t4);
  background-image: var(--gloss);
  box-shadow: var(--chip-ring);
  margin: var(--chip-margin, 5px);
}
.chip.tone-0 { background-color: var(--t0); }
.chip.tone-1 { background-color: var(--t1); }
.chip.tone-2 { background-color: var(--t2); }
.chip.tone-3 { background-color: var(--t3); }
.chip.tone-4 { background-color: var(--t4); }
.chip.small { font-size: 12px; padding: 2px 10px; box-shadow: none; margin: 0; }
.chip .remove {
  display: inline-flex;
  padding: 2px;
  margin-right: -6px;
  background: none;
  border: none;
  border-radius: 50%;
  color: inherit;
}
.chip .remove .icon { width: 14px; height: 14px; }

.autocomplete-list {
  margin-top: 6px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--suggest-bg);
  border: var(--line-thin) solid var(--line-color);
  border-radius: var(--r-field);
  box-shadow: var(--shadow);
}
.autocomplete-list:empty { display: none; }
.autocomplete-item { padding: 10px 14px; font-size: 15px; font-weight: 500; border-bottom: 2px dashed var(--suggest-line); cursor: pointer; }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item:active { background: var(--highlight); color: var(--on-highlight); }

/* ---- Stars (display) ---- */
.stars { position: relative; display: inline-block; line-height: 0; white-space: nowrap; }
.stars svg { width: 20px; height: 20px; margin-right: 1px; stroke: var(--star-stroke); stroke-width: 1.6px; }
.stars-bg svg { color: var(--star-empty); }
.stars-fg { position: absolute; inset: 0 auto 0 0; overflow: hidden; }
.stars-fg svg { color: var(--star); }
.stars.lg svg { width: 26px; height: 26px; }

/* ---- Score sticker (the hero element) ---- */
.score-sticker {
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: var(--line) solid var(--line-color);
  border-radius: var(--sticker-radius);
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 24px;
  color: var(--on-accent);
  background-color: var(--paper);
  background-image: var(--gloss);
  box-shadow: var(--sticker-ring);
  transform: rotate(calc(var(--sticker-rotate) * -1));
}
.score-sticker.new { font-family: var(--font-body); font-weight: 700; font-size: 14px; color: var(--ink); }
.score-sticker.tone-top { background-color: var(--t2); }
.score-sticker.tone-good { background-color: var(--t1); }
.score-sticker.tone-ok { background-color: var(--t3); }
.score-sticker.tone-low { background-color: var(--t0); }
.score-sticker.xl { width: 104px; height: 104px; font-size: 40px; }
.score-sticker.xl.new { font-size: 18px; }

/* ---- Search results ---- */
.result-list { display: flex; flex-direction: column; gap: 18px; margin-top: 22px; }
.result-row {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 16px 18px 16px 16px;
  background: var(--paper);
  border: var(--line) solid var(--line-color);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.result-row:hover { transform: translate(-1px, -1px); }
.result-row:active { transform: translate(var(--press), var(--press)); box-shadow: var(--shadow-press); }
.result-row:nth-child(even) .score-sticker { transform: rotate(var(--sticker-rotate)); }
.result-body { flex: 1; min-width: 0; }
.row-name { display: block; font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }

.meta-row { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; color: var(--ink-soft); font-size: 14px; }
.meta-row > span { display: inline-flex; align-items: center; gap: 5px; }
.meta-row > span:empty { display: none; }
.meta-row .icon { width: 17px; height: 17px; vertical-align: 0; }
.result-row .chip-list { margin-top: 10px; gap: 6px; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 28px 16px 8px; }
.empty-state svg { width: 150px; height: 125px; }
.ill-slot { fill: var(--paper); stroke: var(--line-color); }
.ill-peel { fill: var(--t1); stroke: var(--line-color); }
.ill-star { fill: var(--t0); stroke: var(--line-color); }
.empty-state h3 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-spacing);
  text-transform: var(--display-transform);
  font-size: 22px;
  margin: 10px 0 4px;
}
.empty-state p { margin: 0 auto; max-width: 30ch; color: var(--ink-soft); }
.empty-state .btn-small { margin-top: 16px; }

/* ---- Item detail ---- */
.back-link { margin: -6px 0 10px -2px; }
.detail-hero { display: flex; gap: 24px; align-items: center; margin: 8px 0 4px; }
.detail-heading { min-width: 0; }
.detail-heading h2 { margin: 0 0 6px; overflow-wrap: anywhere; }

.rating-list { display: flex; flex-direction: column; gap: 12px; }
.rating-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--paper);
  border: var(--line) solid var(--line-color);
  border-radius: var(--r-small);
}
.rating-row .meta-row { margin-top: 4px; font-size: 13px; }
.rr-actions { display: flex; gap: 4px; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: none;
  border: var(--line-thin) solid transparent;
  border-radius: var(--r-field);
}
.icon-btn:hover { border-color: var(--line-color); background: var(--muted-bg); }
.icon-btn.danger { color: var(--danger); }

/* ---- Star picker (input) ---- */
.star-picker { display: flex; gap: 6px; }
.star-picker button {
  padding: 2px;
  background: none;
  border: none;
  line-height: 0;
  border-radius: var(--r-field);
}
.star-picker svg { width: 44px; height: 44px; color: var(--star-empty); stroke: var(--star-stroke); stroke-width: 1.5px; }
.star-picker button.selected svg { color: var(--star); }
.star-picker button.pop svg { animation: pop 260ms ease-out; }
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.3) rotate(-8deg); }
  100% { transform: scale(1); }
}

/* ---- Theme picker ---- */
.mode-switch {
  display: flex;
  padding: 4px;
  margin-bottom: 14px;
  gap: 4px;
  background: var(--muted-bg);
  border: var(--line-thin) solid var(--line-color);
  border-radius: var(--r-pill);
}
.mode-switch button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 6px;
  background: none;
  border: var(--line-thin) solid transparent;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}
.mode-switch button[aria-checked="true"] {
  background: var(--paper);
  border-color: var(--line-color);
  color: var(--ink);
  box-shadow: var(--shadow-press);
}
.mode-switch .icon { width: 18px; height: 18px; }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.theme-option {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 8px 10px;
  background: var(--paper);
  border: var(--line) solid var(--muted-bg);
  border-radius: var(--r-small);
  text-align: left;
  font-weight: 700;
  font-size: 14px;
}
.theme-option[aria-checked="true"] { border-color: var(--line-color); background: var(--highlight); color: var(--on-highlight); }
.theme-option .check { display: none; }
.theme-option[aria-checked="true"] .check { display: inline-block; }
.theme-name { display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.theme-name .check { margin-left: auto; }

/* Preview tile: renders in its own theme via data-theme on .theme-preview */
.theme-preview {
  display: block;
  height: 86px;
  padding: 12px;
  border-radius: calc(var(--r-field) - 2px);
  background-color: var(--page);
  background-image: var(--page-pattern);
  background-size: var(--page-pattern-size);
  overflow: hidden;
}
.preview-card {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 10px;
  background: var(--paper);
  border: var(--line) solid var(--line-color);
  border-radius: var(--r-field);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.preview-aa {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 24px;
  line-height: 1;
  color: var(--logo-color);
  text-shadow: var(--logo-shadow);
  -webkit-text-stroke: var(--logo-stroke);
  paint-order: stroke fill;
}
.preview-dots { display: flex; gap: 4px; margin-left: auto; }
.preview-dots i { width: 14px; height: 14px; border-radius: 50%; border: var(--line-thin) solid var(--line-color); }
.preview-dots i:nth-child(1) { background: var(--primary); }
.preview-dots i:nth-child(2) { background: var(--t2); }
.preview-dots i:nth-child(3) { background: var(--star); }

/* ---- Account / admin ---- */
.user-list { display: flex; flex-direction: column; gap: 12px; }
.user-row { padding: 12px 14px; border: var(--line) solid var(--line-color); border-radius: var(--r-small); }
.user-row .row-name { font-size: 16px; }
.user-row .status { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 9px;
  border: var(--line-thin) solid var(--line-color);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  color: var(--on-accent);
  background: var(--t2);
  vertical-align: 2px;
}
.badge.muted { background: var(--muted-bg); color: var(--ink); }
.user-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.user-actions button {
  padding: 4px 0;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.user-actions button.danger { color: var(--danger); }

.code-box {
  margin-top: 14px;
  padding: 16px;
  background: var(--code-bg);
  border: var(--line) dashed var(--line-color);
  border-radius: var(--r-small);
  font-size: 14px;
}
.code-box .code {
  display: block;
  margin: 8px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  user-select: all;
}
.code-box .btn-link { margin-right: 14px; }

@media (min-width: 520px) {
  .panel { padding: 26px; }
  h2 { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Photos ---- */
.photo-field .photo-pick { margin: 0; width: auto; cursor: pointer; font-weight: 700; }
#add-photo-input:focus-visible + .photo-pick { outline: 3px dashed var(--focus); outline-offset: 3px; }
.photo-preview { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.photo-preview img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border: var(--line) solid var(--line-color);
  border-radius: var(--r-field);
  background: var(--muted-bg);
}
.photo-field .checkbox-row { margin-top: 12px; }

.detail-photo-wrap { position: relative; margin: 4px 0 26px; }
.detail-photo-btn {
  display: block;
  width: 100%;
  padding: 0;
  background: var(--muted-bg);
  border: var(--line) solid var(--line-color);
  border-radius: var(--r-card);
  overflow: hidden;
  cursor: zoom-in;
}
.detail-photo-btn img { display: block; width: 100%; height: 260px; object-fit: cover; }
/* With a photo, the score sticker sits on the photo corner */
.detail-photo-wrap .score-sticker { position: absolute; right: 14px; bottom: -22px; }

.thumb {
  flex: none;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: var(--line-thin) solid var(--line-color);
  border-radius: var(--r-field);
  background: var(--muted-bg);
}
.result-row .thumb { align-self: flex-start; }
.thumb-btn { padding: 0; border: none; background: none; line-height: 0; cursor: zoom-in; border-radius: var(--r-field); }
.thumb-btn .thumb { width: 52px; height: 52px; }
.rating-main { display: flex; gap: 12px; align-items: center; min-width: 0; }
.cover-label { font-weight: 700; color: var(--ink); }

.photo-viewer {
  width: min(96vw, 1000px);
  max-height: 92vh;
  padding: 0;
  background: var(--paper);
  border: var(--line) solid var(--line-color);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.photo-viewer::backdrop { background: rgba(10, 8, 25, 0.75); }
.photo-viewer img { display: block; width: 100%; max-height: calc(92vh - 6px); object-fit: contain; background: var(--muted-bg); }
.viewer-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--paper);
  border: var(--line) solid var(--line-color);
  border-radius: 50%;
  box-shadow: var(--shadow);
}
