/* High-contrast, big-touch-target styling for field use (sunlight, gloves).
   Selection state is never shown by color alone: selected buttons get a
   thick outline, inverted fill, and a "SELECTED" label. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #111418;
  --muted: #555d66;
  --line: #c9ced4;
  --brand: #1f3347;
  --brand-text: #ffffff;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161b; --surface: #1c2229; --text: #f2f4f6; --muted: #a9b1ba; --line: #3a434d;
    --brand: #dbe6f0; --brand-text: #0d1720;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 900px; margin: 0 auto; padding: 16px; }
h1 { font-size: 20px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h2 { font-size: 20px; margin: 0 0 8px; }
h3 { font-size: 18px; margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 10px; }

header.top {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-text);
}
header.top .btn.ghost { color: var(--brand-text); border-color: currentColor; }
header.top .muted { color: inherit; opacity: .85; }
.top-right { justify-self: end; }

.tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--line); }
.tabs a {
  flex: 1; text-align: center; padding: 14px 8px; text-decoration: none; font-weight: 600;
  border-bottom: 4px solid transparent;
}
.tabs a.on { border-bottom-color: var(--text); text-decoration: underline; text-underline-offset: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 16px; border-radius: var(--radius);
  border: 2px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; padding: 6px 10px; font-size: 14px; }
.btn.big { min-height: 56px; font-size: 18px; padding: 12px 22px; }
.btn.danger { border-color: #8a1c1c; color: #8a1c1c; }
@media (prefers-color-scheme: dark) { .btn.danger { border-color: #ff9a9a; color: #ff9a9a; } }

.cards { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.card {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none;
}
.card-main { display: flex; flex-direction: column; min-width: 0; }
.card-main b { overflow-wrap: anywhere; }
.card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 14px; white-space: nowrap; }
.def { font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.card-side span { display: inline-flex; align-items: center; gap: 4px; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 0 0 16px; padding: 12px 16px 16px; }
legend { font-weight: 700; padding: 0 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 10px; margin: 10px 0; color: var(--text); }
label.check input { width: 24px; height: 24px; }
input, textarea, select {
  font: inherit; font-size: 17px; color: var(--text); background: var(--bg);
  border: 2px solid var(--line); border-radius: 8px; padding: 10px; min-height: 48px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 3px solid var(--text); outline-offset: 1px; }
textarea { resize: vertical; }

.cover img, .logo-prev { max-width: 100%; max-height: 320px; border-radius: 8px; display: block; margin-bottom: 10px; }
.logo-prev { max-height: 100px; }
.danger-zone { margin-top: 24px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.warn { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.sym { flex: none; }

.section-tools { justify-content: flex-end; margin-bottom: 8px; }
.item { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.item.rated { border-left-color: var(--text); }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }

.ratings { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 600px) { .ratings { grid-template-columns: repeat(3, 1fr); } }
.rate {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 76px; padding: 8px 4px; border-radius: var(--radius);
  border: 2px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1.15; text-align: center; cursor: pointer;
}
.rate.on { background: var(--text); color: var(--surface); border: 4px solid var(--text); outline: 3px solid var(--surface); outline-offset: -7px; }
.rate .sel { font-size: 11px; letter-spacing: .06em; font-weight: 800; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  display: inline-flex; align-items: center; gap: 6px; min-height: 52px; padding: 8px 14px;
  border-radius: var(--radius); border: 2px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.choice.on { background: var(--text); color: var(--surface); border: 4px solid var(--text); }
.choice.other { border-style: dashed; }
fieldset > .grid + label, fieldset > label + label { margin-top: 12px; }

.comments { margin-top: 10px; display: grid; gap: 8px; }
.comment-row { display: flex; gap: 8px; align-items: flex-start; }
.comment-row textarea { flex: 1; }
.actions { margin-top: 10px; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 12px; }
.photos figure { margin: 0; display: grid; gap: 6px; }
.thumb { padding: 0; border: 0; background: none; cursor: zoom-in; }
.thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; }
.caption { font-size: 15px; min-height: 42px; padding: 8px; }
.photo-tools { gap: 4px; }
.photo-tools .btn { flex: 1; padding: 4px; }

.pager { display: flex; justify-content: space-between; gap: 10px; margin: 24px 0 40px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; }
.modal { background: var(--surface); color: var(--text); border-radius: 14px; padding: 18px; width: 100%; max-width: 720px; }
.modal h3 { margin: 16px 0 8px; }
.pick { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.pick-btn { width: 100%; justify-content: flex-start; text-align: left; font-weight: 400; }
.modal img.full { width: 100%; height: auto; border-radius: 8px; margin-bottom: 12px; }
