:root {
  color-scheme: light;
  --bg: #f7f6ef;
  --card: #fffefa;
  --card-tint: #eef5ed;
  --mint: #abcdb7;
  --mint-deep: #3f6555;
  --lavender: #cdc5df;
  --apricot: #ecd0a4;
  --blue-gray: #adbfca;
  --pink: #e7b9b9;
  --lemon: #e9df91;
  --text: #333832;
  --muted: #6d7169;
  --soft-muted: #8c9188;
  --line: #dcdfd6;
  --shadow: 0 14px 38px rgba(111, 94, 70, 0.09);
  --radius: 18px;
  --radius-small: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #fbfaf5 0%, var(--bg) 55%, #f2f4ee 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px calc(28px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(87, 106, 89, 0.12);
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--text);
  font-size: clamp(22px, 7vw, 30px);
  line-height: 1.18;
  font-weight: 800;
}

h2 {
  margin-bottom: 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(171, 205, 183, 0.6);
  border-radius: 15px;
  background: rgba(171, 205, 183, 0.34);
  color: var(--mint-deep);
  font-size: 26px;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(87, 106, 89, 0.08);
}

.summary-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  padding: 13px;
  border: 1px solid rgba(220, 223, 214, 0.86);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, 0.92);
  box-shadow: var(--shadow);
}

.summary-card div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(238, 245, 237, 0.78);
}

.summary-card div:nth-child(2) {
  background: rgba(236, 208, 164, 0.26);
}

.summary-card div:nth-child(3) {
  background: rgba(205, 197, 223, 0.25);
}

.summary-card span {
  display: block;
  color: var(--text);
  font-size: 23px;
  font-weight: 800;
  line-height: 1.1;
}

.summary-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  margin-bottom: 14px;
  padding: 0 14px;
  border: 1px solid rgba(220, 223, 214, 0.9);
  border-radius: 16px;
  background: rgba(255, 254, 250, 0.9);
  color: var(--muted);
  box-shadow: 0 8px 22px rgba(111, 94, 70, 0.055);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.search-field input::placeholder {
  color: var(--soft-muted);
}

.empty-state {
  display: none;
  margin-top: 32px;
  padding: 32px 24px;
  text-align: center;
  border: 1px solid rgba(220, 223, 214, 0.86);
  border-radius: 24px;
  background: rgba(255, 254, 250, 0.78);
  box-shadow: var(--shadow);
}

.empty-state.visible {
  display: block;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 22px;
  background: rgba(171, 205, 183, 0.27);
  color: var(--mint-deep);
  font-size: 30px;
  font-weight: 800;
}

.empty-state h2 {
  margin-bottom: 8px;
  font-size: 20px;
}

.empty-state p {
  max-width: 28rem;
  margin: 0 auto 18px;
  color: var(--muted);
  line-height: 1.7;
}

.kind-list {
  display: grid;
  gap: 14px;
}

.kind-section {
  display: grid;
  gap: 8px;
}

.kind-header {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 62px;
  padding: 12px;
  border: 1px solid rgba(220, 223, 214, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, 0.92);
  color: var(--text);
  text-align: left;
  box-shadow: 0 10px 24px rgba(111, 94, 70, 0.065);
}

.kind-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-right: 12px;
  border-radius: 13px;
  color: var(--mint-deep);
  font-size: 18px;
  flex: 0 0 auto;
}

.kind-title {
  min-width: 0;
  flex: 1;
  font-weight: 800;
}

.count-pill,
.type-pill,
.expiry-pill,
.severity-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(173, 191, 202, 0.18);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.disclosure-icon {
  width: 18px;
  margin-left: 10px;
  color: var(--soft-muted);
  text-align: center;
  transform: rotate(90deg);
  transition: transform 0.18s ease;
}

.kind-section.collapsed .disclosure-icon {
  transform: rotate(0deg);
}

.item-list {
  display: grid;
  gap: 8px;
}

.kind-section.collapsed .item-list {
  display: none;
}

.item-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 82px;
  padding: 12px;
  border: 1px solid rgba(220, 223, 214, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, 0.94);
  color: var(--text);
  text-align: left;
  box-shadow: 0 8px 22px rgba(111, 94, 70, 0.055);
}

.thumb {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border: 1px solid rgba(220, 223, 214, 0.8);
  border-radius: 16px;
  background: rgba(238, 245, 237, 0.82);
  color: var(--mint-deep);
  font-size: 20px;
  font-weight: 800;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-main {
  min-width: 0;
}

.item-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.item-title {
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.row-chevron {
  color: var(--soft-muted);
  font-weight: 800;
}

.food-tint {
  background: rgba(236, 208, 164, 0.3);
}

.medicine-tint {
  background: rgba(171, 205, 183, 0.3);
}

.manual-tint {
  background: rgba(205, 197, 223, 0.32);
}

.other-tint {
  background: rgba(173, 191, 202, 0.25);
}

.sheet {
  width: min(100% - 18px, 720px);
  max-width: 720px;
  max-height: min(88vh, 920px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: transparent;
  color: var(--text);
}

.sheet::backdrop {
  background: rgba(66, 71, 63, 0.24);
  backdrop-filter: blur(5px);
}

.sheet-panel {
  max-height: min(88vh, 920px);
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(220, 223, 214, 0.9);
  border-radius: 26px;
  background: linear-gradient(180deg, #fffefa 0%, #f8f7ef 100%);
  box-shadow: 0 24px 80px rgba(65, 58, 44, 0.24);
}

.sheet-header,
.sheet-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-header {
  margin-bottom: 16px;
}

.sheet-actions {
  position: sticky;
  bottom: -18px;
  z-index: 2;
  margin: 18px -18px -18px;
  padding: 13px 18px calc(13px + var(--safe-bottom));
  border-top: 1px solid rgba(220, 223, 214, 0.82);
  background: rgba(255, 254, 250, 0.94);
  backdrop-filter: blur(12px);
}

.capture-card,
.result-card,
.detail-card,
.field,
.expiry-box,
.ocr-details {
  border: 1px solid rgba(220, 223, 214, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, 0.92);
  box-shadow: 0 8px 22px rgba(111, 94, 70, 0.052);
}

.capture-card,
.result-card,
.detail-card,
.expiry-box,
.ocr-details {
  padding: 14px;
}

.photo-preview {
  display: grid;
  place-items: center;
  min-height: 188px;
  overflow: hidden;
  border: 1px dashed rgba(171, 205, 183, 0.9);
  border-radius: var(--radius-small);
  background: rgba(238, 245, 237, 0.72);
  color: var(--muted);
  text-align: center;
}

.photo-preview span {
  margin-bottom: 8px;
  color: var(--mint-deep);
  font-size: 28px;
  font-weight: 800;
}

.photo-preview p {
  margin: 0;
  padding: 0 14px;
  line-height: 1.6;
}

.photo-preview img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: var(--radius-small);
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.primary-button,
.soft-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid rgba(63, 101, 85, 0.22);
  background: var(--mint-deep);
  color: #fffefa;
  box-shadow: 0 10px 24px rgba(63, 101, 85, 0.18);
}

.soft-button {
  border: 1px solid rgba(220, 223, 214, 0.9);
  color: var(--text);
}

.soft-button.mint {
  background: rgba(171, 205, 183, 0.36);
}

.soft-button.lavender {
  background: rgba(205, 197, 223, 0.33);
}

.ghost-button {
  border: 1px solid rgba(220, 223, 214, 0.9);
  background: rgba(255, 254, 250, 0.88);
  color: var(--muted);
}

.danger-button {
  border: 1px solid rgba(231, 185, 185, 0.65);
  background: rgba(231, 185, 185, 0.22);
  color: #934f4f;
}

.status-text,
.error-text,
.expiry-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.expiry-hint {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-small);
  background: rgba(236, 208, 164, 0.22);
}

.error-text {
  padding: 12px 14px;
  border: 1px solid rgba(231, 185, 185, 0.68);
  border-radius: var(--radius-small);
  background: rgba(231, 185, 185, 0.18);
  color: #7f4646;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--mint-deep);
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding: 12px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea,
.ocr-details textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  resize: vertical;
}

.field textarea,
.ocr-details textarea {
  line-height: 1.6;
}

.expiry-box {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
}

.switch-row strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.switch-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

input[type="checkbox"] {
  width: 46px;
  height: 28px;
  margin: 0;
  appearance: none;
  border: 1px solid rgba(220, 223, 214, 0.95);
  border-radius: 999px;
  background: #e8e9e2;
  position: relative;
  flex: 0 0 auto;
  transition: background 0.18s ease;
}

input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fffefa;
  box-shadow: 0 2px 6px rgba(80, 74, 60, 0.18);
  transition: transform 0.18s ease;
}

input[type="checkbox"]:checked {
  background: var(--mint);
}

input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

.findings-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.finding-card {
  padding: 12px;
  border: 1px solid rgba(220, 223, 214, 0.82);
  border-radius: var(--radius-small);
  background: rgba(238, 245, 237, 0.55);
}

.finding-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  margin-bottom: 8px;
}

.finding-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.finding-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.finding-card small {
  display: block;
  margin-top: 7px;
  color: var(--soft-muted);
  line-height: 1.45;
}

.group-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.severity-info {
  color: var(--muted);
  background: rgba(173, 191, 202, 0.2);
}

.severity-caution {
  color: #725a28;
  background: rgba(236, 208, 164, 0.34);
}

.severity-warning {
  color: #8b4b4b;
  background: rgba(231, 185, 185, 0.32);
}

.ocr-details {
  margin-top: 12px;
}

.ocr-details summary {
  color: var(--mint-deep);
  font-weight: 800;
  cursor: pointer;
}

.ocr-details textarea {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(220, 223, 214, 0.82);
}

.detail-stack {
  display: grid;
  gap: 12px;
}

.detail-card h3 {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 17px;
}

.detail-photo {
  width: 100%;
  max-height: 440px;
  object-fit: contain;
  border-radius: var(--radius-small);
  background: rgba(238, 245, 237, 0.6);
}

.detail-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(220, 223, 214, 0.72);
}

.detail-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.detail-row span:first-child {
  color: var(--muted);
  font-weight: 800;
}

.detail-row span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.body-text {
  color: var(--text);
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

@media (min-width: 720px) {
  .app-shell {
    padding-top: 30px;
  }

  .sheet-panel {
    padding: 22px;
  }

  .sheet-actions {
    margin: 20px -22px -22px;
    padding-left: 22px;
    padding-right: 22px;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
  }

  .summary-card {
    gap: 8px;
    padding: 10px;
  }

  .summary-card div {
    padding: 10px 8px;
  }

  .summary-card span {
    font-size: 21px;
  }

  .item-row {
    grid-template-columns: 52px minmax(0, 1fr) 16px;
    gap: 10px;
    padding: 10px;
  }

  .thumb {
    width: 52px;
    height: 52px;
  }

  .type-pill {
    display: none;
  }

  .sheet {
    width: min(100% - 10px, 720px);
    max-height: 92vh;
  }

  .sheet-panel {
    max-height: 92vh;
    padding: 14px;
    border-radius: 23px;
  }

  .sheet-actions {
    margin: 16px -14px -14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .detail-row {
    grid-template-columns: 4.8rem minmax(0, 1fr);
  }
}
