:root {
  --paper: #e6dfd2;
  --sheet: #fbf8f2;
  --ink: #1c1915;
  --muted: #6f675c;
  --line: #ddd4c4;
  --need: #8e2a24;
  --need-bg: #f8e4e1;
  --price: #1d4d38;
  --price-bg: #e3f0e8;
  --wait: #8a4b12;
  --wait-bg: #f6ead6;
  --stamp: #9c4221;
  --shadow: 0 1px 0 rgba(28, 25, 21, 0.04), 0 12px 30px rgba(70, 52, 28, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

.boot {
  padding: max(24px, env(safe-area-inset-top)) 20px 24px;
  color: var(--muted);
}

.screen { min-height: 100vh; }

.login-sheet, .sheet, .card, .panel {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-sheet {
  max-width: 440px;
  margin: max(32px, env(safe-area-inset-top)) auto 32px;
  padding: 28px 22px 22px;
}

.eyebrow {
  margin: 0;
  color: var(--stamp);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 6px 0 8px;
  font-size: 40px;
  line-height: 1;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.lede { margin: 0 0 22px; color: var(--muted); }

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 650;
}

input, textarea, select {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

textarea { min-height: 84px; resize: vertical; }

input:focus, textarea:focus, select:focus {
  outline: 2px solid #c4a27a;
  border-color: #c4a27a;
}

.primary, .ghost, .text-btn, .need, .back {
  border-radius: 999px;
  min-height: 44px;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 16px;
  padding: 12px 18px;
  border: 0;
  background: var(--ink);
  color: #fbf8f2;
  font-weight: 650;
}

.primary:disabled { opacity: 0.55; }

.ghost, .text-btn, .back, .need {
  border: 1px solid var(--line);
  background: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: rgba(230, 223, 210, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.who { margin: 2px 0 0; font-weight: 700; }

.text-btn, .back {
  padding: 8px 14px;
  min-height: 40px;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filters button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
}

.filters button.on {
  background: var(--ink);
  color: var(--sheet);
  border-color: var(--ink);
}

.total {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--price-bg);
  color: var(--price);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  text-align: left;
}

.thumb, .photo, .photo-empty {
  border-radius: 12px;
  background: #efe8dc;
}

.thumb {
  width: 84px;
  height: 84px;
  object-fit: cover;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
}

.thumb img, .photo img { width: 100%; height: 100%; object-fit: cover; }

.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-top, .row-between {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.meta, .ask, .hint, .quiet {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.ask { color: var(--need); }

.price-line {
  margin: 6px 0 0;
  color: var(--price);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.pill {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill.you { background: var(--need-bg); color: var(--need); }
.pill.them { background: var(--wait-bg); color: var(--wait); }
.pill.priced { background: var(--price-bg); color: var(--price); }

.add-btn { margin-top: 16px; }

.detail {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow: auto;
  background: var(--paper);
  padding: max(12px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

.detail-inner { max-width: 720px; margin: 0 auto; }

.photo {
  margin-top: 12px;
  overflow: hidden;
  max-height: 360px;
  border: 1px solid var(--line);
}

.photo img { object-fit: contain; background: white; max-height: 360px; }

.photo-empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.banner {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--need-bg);
  color: var(--need);
}

.banner strong { display: block; margin-bottom: 4px; }

.quote {
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--price-bg);
  color: var(--price);
}

.quote .amount {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.field {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--sheet);
}

.field.missing { background: var(--need-bg); border-color: #e3b4ae; }

.field-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.need { padding: 6px 10px; min-height: 36px; color: var(--need); border-color: #e3b4ae; }
.need.on { background: var(--need); color: white; border-color: var(--need); }

.clean {
  margin: 8px 0 0;
  font-size: 13px;
  word-break: break-all;
}

.clean a { color: var(--stamp); }

.thread { margin-top: 18px; }
.thread h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.note {
  margin-top: 8px;
  padding: 10px 12px;
  border-left: 3px solid var(--line);
  background: var(--sheet);
  border-radius: 0 12px 12px 0;
}

.note.supplier { border-color: var(--price); }
.note.buyer { border-color: var(--stamp); }
.note .by { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }

.actions { display: grid; gap: 8px; margin-top: 14px; }
.actions .primary { margin-top: 0; }

.split {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 8px;
}

.error { color: var(--need); min-height: 1.2em; }
.danger {
  margin-top: 22px;
  background: none;
  border: 0;
  color: var(--need);
  min-height: 44px;
  text-decoration: underline;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 5;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
}

.conflict {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--wait-bg);
}

@media (min-width: 800px) {
  .login-sheet { margin-top: 10vh; }
}
