:root {
  color-scheme: light;
  --bg: #fff8f6;
  --surface: #ffffff;
  --surface-soft: #fff1ed;
  --ink: #2d2320;
  --muted: #776761;
  --line: #ecdcd6;
  --brand: #b84a39;
  --brand-dark: #933627;
  --brand-soft: #fde8e2;
  --green: #247a52;
  --green-soft: #e5f4ec;
  --amber: #9a6700;
  --amber-soft: #fff2cf;
  --red: #b3261e;
  --red-soft: #fdecea;
  --blue: #35618e;
  --blue-soft: #e8f1fa;
  --shadow: 0 10px 30px rgba(85, 48, 38, 0.1);
  --radius: 20px;
}

* { box-sizing: border-box; }
/* The hidden attribute must always win: component rules like .topbar
   (display: flex) and .bottom-nav (display: grid) otherwise override the
   UA stylesheet's [hidden] { display: none } and the bars never hide. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #ffe9e2 0, transparent 34rem), var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
img { display: block; max-width: 100%; }
figure { margin: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.7rem + env(safe-area-inset-top)) 1rem 0.7rem;
  background: rgba(255, 248, 246, 0.9);
  border-bottom: 1px solid rgba(236, 220, 214, 0.8);
  backdrop-filter: blur(16px);
}
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 52px;
  padding: 0;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
}
.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 16px;
  background: var(--brand-soft);
  font-size: 1.55rem;
}
.brand strong { display: block; font-size: 1.1rem; }
.brand small { display: block; margin-top: 0.1rem; color: var(--muted); }

.view-root {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 1rem 1rem 6.5rem;
}
.page-head { margin: 0.4rem 0 1rem; }
.page-head h1, .section-title { margin: 0; line-height: 1.2; }
.page-head h1 { font-size: clamp(1.75rem, 7vw, 2.6rem); }
.page-head p, .muted { color: var(--muted); }
.page-head p { margin: 0.45rem 0 0; line-height: 1.55; }

.card, .loading-card, .auth-card, .notice-card, .entry-card, .item-card, .photo-card, .inbox-card, .list-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 16px rgba(85, 48, 38, 0.05);
}
.loading-card, .auth-card, .notice-card { padding: 1.4rem; }
.loading-card { text-align: center; }
.spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 0.8rem;
  border: 4px solid var(--brand-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-wrap { max-width: 520px; margin: 4vh auto 0; }
.auth-card h1 { margin: 0 0 0.5rem; font-size: 2rem; }
.auth-card p { color: var(--muted); line-height: 1.6; }
.notice-card { margin-bottom: 1rem; border-color: #f0cf7d; background: #fffaf0; }
.notice-card strong { color: var(--amber); }
.error-card { border-color: #f2b8b5; background: var(--red-soft); }

.field { display: grid; gap: 0.42rem; margin: 0.85rem 0; }
.field > span, .field-label { font-weight: 700; }
.field small { color: var(--muted); font-weight: 400; line-height: 1.45; }
.input, .select, .textarea {
  width: 100%;
  min-height: 52px;
  padding: 0.78rem 0.9rem;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  outline: none;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.primary-button, .secondary-button, .danger-button, .ghost-button, .choice-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 52px;
  padding: 0.72rem 1.05rem;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font-weight: 800;
  text-decoration: none;
}
.primary-button { color: #fff; background: var(--brand); }
.primary-button:active { background: var(--brand-dark); }
.secondary-button { color: var(--brand-dark); background: var(--brand-soft); border-color: #f3c6bb; }
.ghost-button { color: var(--ink); background: #fff; border-color: var(--line); }
.danger-button { color: var(--red); background: var(--red-soft); border-color: #f2b8b5; }
.choice-button.yes { color: var(--green); background: var(--green-soft); border-color: #a9d8bf; }
.choice-button.no { color: var(--red); background: var(--red-soft); border-color: #f2b8b5; }
.choice-button.new-item { width: 100%; margin-top: 0.6rem; min-height: 62px; font-size: 1.05rem; color: #274b9f; background: #e9f0fe; border-color: #b3c8f5; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1rem; }
.button-row > * { flex: 1 1 150px; }
.full-button { width: 100%; }

.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
.entry-card {
  position: relative;
  min-height: 168px;
  padding: 1.15rem;
  color: var(--ink);
  text-align: left;
}
.entry-card .entry-icon { font-size: 2.2rem; }
.entry-card strong { display: block; margin-top: 0.75rem; font-size: 1.28rem; }
.entry-card small { display: block; margin-top: 0.35rem; color: var(--muted); line-height: 1.45; }
.count-pill, .badge, .nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.65rem;
  min-height: 1.65rem;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  color: #fff;
  background: var(--brand);
  font-size: 0.82rem;
  font-style: normal;
  font-weight: 900;
}
.entry-card .count-pill { position: absolute; top: 1rem; right: 1rem; }
.secondary-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-top: 0.9rem; }
.secondary-links button { min-height: 58px; border: 1px solid var(--line); border-radius: 16px; background: #fff; font-weight: 800; }

.toolbar {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1rem;
  padding: 0.9rem;
  background: rgba(255,255,255,0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.toolbar .input, .toolbar .select { min-height: 50px; }
.filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.toolbar-row { display: flex; gap: 0.65rem; }
.toolbar-row .input { flex: 1; min-width: 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.filter-chip { border: 1px solid var(--line); background: var(--surface-soft); color: var(--ink); border-radius: 999px; padding: 0.35rem 0.7rem; font-size: 0.83rem; font-weight: 700; min-height: 36px; }
.result-line { display: flex; justify-content: space-between; gap: 1rem; margin: 0.4rem 0 0.8rem; color: var(--muted); }

.gallery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.item-card, .photo-card { overflow: hidden; padding: 0; text-align: left; color: var(--ink); }
.image-frame { position: relative; aspect-ratio: 4 / 5; overflow: hidden; background: #f4e9e5; }
.image-frame.square { aspect-ratio: 1; }
.image-frame img { width: 100%; height: 100%; object-fit: cover; }
.image-frame.fit img { object-fit: contain; }
.image-placeholder { display: grid; width: 100%; height: 100%; place-items: center; padding: 1rem; color: var(--muted); text-align: center; font-size: 2.2rem; }
.ai-label {
  position: absolute;
  left: 0.45rem;
  bottom: 0.45rem;
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: rgba(45, 35, 32, 0.66);
}
.card-body { padding: 0.85rem; }
.card-body h3 { margin: 0; font-size: 1.02rem; line-height: 1.35; }
.card-meta { margin-top: 0.35rem; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.badge-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.badge { color: var(--brand-dark); background: var(--brand-soft); }
.badge.green { color: var(--green); background: var(--green-soft); }
.badge.amber { color: var(--amber); background: var(--amber-soft); }
.badge.blue { color: var(--blue); background: var(--blue-soft); }
.badge.red { color: var(--red); background: var(--red-soft); }
.badge.gray { color: #5f5551; background: #f0ebe9; }

.detail-hero { overflow: hidden; margin-bottom: 1rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.detail-hero .image-frame { aspect-ratio: 4 / 3.4; }
.detail-content { padding: 1rem; }
.detail-content h1 { margin: 0; font-size: 1.65rem; line-height: 1.25; }
.detail-content p { line-height: 1.6; }
.form-grid { display: grid; gap: 0 0.85rem; }
.season-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.55rem; }
.season-picker label, .check-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 52px;
  padding: 0.65rem;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-weight: 800;
}
.season-picker input, .check-card input { width: 20px; height: 20px; accent-color: var(--brand); }

.photo-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.photo-tile { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.photo-tile .image-frame { aspect-ratio: 1; }
.photo-tile-body { padding: 0.7rem; }
.photo-tile-body .button-row > * { flex-basis: 110px; min-height: 46px; padding: 0.55rem 0.7rem; }
.section-block { margin-top: 1.2rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.75rem; }
.section-head h2 { margin: 0; font-size: 1.25rem; }

.picker-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem; }
.picker-card { position: relative; overflow: hidden; min-height: 118px; padding: 0; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.picker-card img { width: 100%; height: 100%; min-height: 118px; object-fit: cover; }
.picker-card span { position: absolute; left: 0.45rem; right: 0.45rem; bottom: 0.45rem; padding: 0.32rem 0.42rem; border-radius: 999px; color: #fff; background: rgba(45,35,32,0.8); font-size: 0.78rem; font-weight: 800; }
.picker-card.selected { outline: 4px solid var(--brand); outline-offset: -4px; }

.upload-panel { padding: 1rem; }
.switch-card { padding: 1rem; margin-bottom: 1rem; }
.spec-list { display: grid; gap: 0.45rem; margin: 0.8rem 0 0; }
.spec-list div { display: flex; gap: 0.9rem; }
.spec-list dt { flex: none; width: 4.6rem; color: var(--muted); }
.spec-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
  padding: 0.85rem;
  border: 1.5px solid #f0cf7d;
  border-radius: 16px;
  background: #fffaf0;
}
.switch-row strong { display: block; }
.switch-row small { display: block; margin-top: 0.25rem; color: var(--muted); line-height: 1.45; }
.switch { position: relative; flex: 0 0 auto; width: 64px; height: 38px; }
.switch input { position: absolute; opacity: 0; inset: 0; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: #d9d0cc; transition: 0.2s; }
.switch i::after { content: ""; position: absolute; top: 4px; left: 4px; width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.2); transition: 0.2s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(26px); }
.file-drop {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 150px;
  margin-top: 0.9rem;
  padding: 1rem;
  border: 2px dashed #ddb7ac;
  border-radius: 18px;
  background: var(--surface-soft);
  text-align: center;
  font-weight: 900;
}
.file-drop small { margin-top: 0.35rem; color: var(--muted); font-weight: 500; }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-list { display: grid; gap: 0.7rem; margin-top: 0.9rem; }
.upload-job { display: grid; grid-template-columns: 64px 1fr; gap: 0.75rem; align-items: center; padding: 0.65rem; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.upload-job img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }
.progress { height: 9px; margin-top: 0.45rem; overflow: hidden; border-radius: 999px; background: #f0e3de; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width 0.25s; }

.inbox-progress { margin-bottom: 0.8rem; color: var(--muted); font-weight: 800; }
.inbox-card { padding: 1rem; }
.inbox-card h2 { margin: 0.2rem 0 0.5rem; line-height: 1.35; }
.queue-row { display: flex; gap: 0.75rem; align-items: center; }
.queue-thumb { width: 56px; height: 56px; flex: 0 0 56px; }
.queue-thumb .image-frame { aspect-ratio: 1; border-radius: 10px; }
.queue-main { flex: 1 1 auto; min-width: 0; }
.queue-main h3 { margin: 0; font-size: 1rem; line-height: 1.35; }
.mini-gallery { position: relative; }
.mini-gallery .gallery-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 2rem; height: 2rem; border-radius: 999px; border: none; background: rgba(20, 20, 25, 0.55); color: #fff; font-size: 1.3rem; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2; padding: 0; }
.mini-gallery .gallery-arrow.left { left: 0.4rem; }
.mini-gallery .gallery-arrow.right { right: 0.4rem; }
.mini-gallery .gallery-count { position: absolute; left: 50%; bottom: 0.45rem; transform: translateX(-50%); background: rgba(20, 20, 25, 0.62); color: #fff; font-size: 0.75rem; padding: 0.15rem 0.55rem; border-radius: 999px; white-space: nowrap; z-index: 2; }
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin: 0.9rem 0; }
.compare-box { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.compare-box .image-frame { aspect-ratio: 1; }
.compare-box figcaption { padding: 0.65rem; font-weight: 800; line-height: 1.4; }
.single-confirm-image { overflow: hidden; margin: 0.9rem 0; border-radius: 18px; border: 1px solid var(--line); }
.candidate-block { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px dashed var(--line); }
.candidate-title { margin: 0 0 0.2rem; }
.single-confirm-image .image-frame { aspect-ratio: 4 / 3; }
.decision-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 1rem; }
.decision-buttons .choice-button { min-height: 62px; font-size: 1.05rem; }

.list-stack { display: grid; gap: 0.85rem; }
.list-card { padding: 1rem; }
.list-card h3 { margin: 0; }
.item-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.7rem; }
.item-chip { min-height: 42px; padding: 0.45rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-weight: 700; }
.warning-box { padding: 0.8rem; border: 1px solid #f0cf7d; border-radius: 14px; background: #fffaf0; color: #6c4b00; line-height: 1.5; }
.danger-zone { padding: 1rem; border: 1px solid #f2b8b5; border-radius: var(--radius); background: #fff; }
.empty-state { padding: 2rem 1rem; text-align: center; color: var(--muted); background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); line-height: 1.6; }
.empty-state strong { display: block; color: var(--ink); font-size: 1.15rem; }

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.2rem;
  padding: 0.45rem 0.45rem calc(0.45rem + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.bottom-nav button { position: relative; min-height: 58px; border: 0; border-radius: 15px; background: transparent; color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.bottom-nav button span { display: block; margin-bottom: 0.12rem; font-size: 1.25rem; }
.bottom-nav button.active { color: var(--brand-dark); background: var(--brand-soft); }
.nav-badge { position: absolute; top: 0.25rem; right: calc(50% - 1.35rem); }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 6.8rem;
  left: 1rem;
  z-index: 50;
  max-width: 560px;
  margin: 0 auto;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  color: #fff;
  background: rgba(45,35,32,0.94);
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 800;
}
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; align-items: end; padding: 1rem; background: rgba(45,35,32,0.45); }
.modal-card { max-height: 88vh; overflow: auto; padding: 1rem; border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.modal-card h2 { margin-top: 0; }

@media (min-width: 760px) {
  .view-root { padding: 1.4rem 1.4rem 6.5rem; }
  .toolbar { grid-template-columns: 1.3fr 1fr; align-items: start; }
  .filter-grid { grid-template-columns: repeat(3, 1fr); }
  .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .photo-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-hero { display: grid; grid-template-columns: 0.95fr 1.05fr; }
  .detail-hero .image-frame { height: 100%; aspect-ratio: auto; min-height: 430px; }
  .modal-backdrop { align-items: center; }
  .modal-card { width: min(760px, 100%); margin: 0 auto; }
}
@media (min-width: 1080px) {
  .gallery-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .photo-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
  .home-grid, .secondary-links { grid-template-columns: 1fr; }
  .entry-card { min-height: 132px; }
  .decision-buttons { grid-template-columns: 1fr; }
}
