:root {
  --paper: #F7F8F4;
  --ink: #202722;
  --ink-soft: #4A554F;
  --muted: #6F7A74;
  --brand: #254B3D;
  --brand-deep: #1B3A2F;
  --lime: #DCECAB;
  --lime-ink: #254B3D;
  --gold: #E7BD68;
  --gold-soft: rgba(231, 189, 104, 0.22);
  --surface: #FFFFFF;
  --line: rgba(32, 39, 34, 0.1);
  --line-strong: rgba(32, 39, 34, 0.16);
  --shadow: 0 1px 0 rgba(255,255,255,0.65) inset, 0 8px 24px rgba(32, 39, 34, 0.05);
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; background: none; }
[hidden] { display: none !important; }

body {
  min-height: 100%;
  background:
    radial-gradient(720px 420px at 100% 0%, rgba(220, 236, 171, 0.35), transparent 55%),
    radial-gradient(640px 380px at 0% 100%, rgba(37, 75, 61, 0.06), transparent 50%),
    var(--paper);
}

.stage {
  width: min(1280px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 0 16px 12px;
  gap: 8px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 8px;
  animation: fade 0.4s ease both;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
}
.brand-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--brand);
}
.brand-name::after {
  content: "·";
  margin-left: 2px;
  color: var(--lime-ink);
  background: var(--lime);
  border-radius: 50%;
  font-size: 0.55em;
  padding: 0 0.28em;
  vertical-align: 0.35em;
  line-height: 1;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
}
.nav-link {
  color: var(--ink-soft);
  padding: 8px 4px;
}
.nav-link:hover { color: var(--brand); }
.user-label {
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
}
.nav-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.86rem;
}
.nav-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 14px;
  min-height: 0;
  height: calc(100dvh - 78px);
  animation: rise 0.45s ease both;
}

.shelf {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.shelf-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.shelf-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.shelf-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}
.shelf-count {
  flex: none;
  color: var(--lime-ink);
  background: var(--lime);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
}
.shelf-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}
.shelf-grid {
  overflow-y: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  align-content: start;
}

.pick {
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.2s ease;
  animation: rise 0.35s ease both;
}
.pick:hover {
  border-color: rgba(37, 75, 61, 0.28);
  transform: translateY(-2px);
}
.pick.is-primary {
  border-color: rgba(37, 75, 61, 0.35);
  box-shadow: 0 0 0 1px rgba(37, 75, 61, 0.12), var(--shadow);
}
.pick-media {
  position: relative;
  aspect-ratio: 1;
  background: #EEF1EA;
}
.pick-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pick-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--lime);
  color: var(--lime-ink);
  font-size: 0.68rem;
  font-weight: 700;
}
.pick-body {
  display: grid;
  gap: 6px;
  padding: 12px;
  align-content: start;
}
.pick-verdict {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.35;
}
.pick-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pick-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
}
.pick-price {
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.pick-perk {
  color: var(--brand-deep);
  background: var(--gold-soft);
  font-size: 0.74rem;
  font-weight: 650;
  padding: 2px 7px;
  border-radius: 7px;
}
.pick-reason,
.pick-tradeoff {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}
.pick-tradeoff {
  color: var(--ink-soft);
}
.pick-buy {
  margin-top: 4px;
  justify-self: stretch;
  min-height: 38px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.86rem;
  transition: background 0.15s ease, transform 0.15s ease;
}
.pick-buy:hover {
  background: var(--brand-deep);
  transform: translateY(-1px);
}
.pick-buy:disabled {
  background: #D6DBD6;
  color: var(--muted);
  transform: none;
}

.chat {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.thread {
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.msg {
  max-width: 100%;
  line-height: 1.65;
  animation: rise 0.3s ease both;
}
.msg.user {
  align-self: flex-end;
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  background: var(--brand);
  color: #F7F8F4;
  font-size: 0.92rem;
}
.msg.assistant {
  align-self: stretch;
  color: var(--ink-soft);
  font-size: 0.94rem;
}
.msg.assistant.welcome strong {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  line-height: 1.25;
}
.msg.assistant.welcome .bubble {
  color: var(--ink-soft);
}
.msg.assistant .bubble { margin: 0; }

.dock {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: rgba(247, 248, 244, 0.75);
}
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.quick button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 12px;
  color: var(--ink-soft);
  font-size: 0.82rem;
}
.quick button:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: #fff;
}
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 6px 6px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.composer:focus-within {
  border-color: rgba(37, 75, 61, 0.4);
  box-shadow: 0 0 0 3px rgba(220, 236, 171, 0.55);
}
.composer input {
  border: 0;
  outline: none;
  min-height: 42px;
  background: transparent;
}
.composer input::placeholder { color: #8A948E; }
.composer button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
}
.composer button:hover { background: var(--brand-deep); }
.composer button:disabled { opacity: 0.5; cursor: wait; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(32, 39, 34, 0.4);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 40;
}
.modal-card {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--line);
  padding: 24px;
  display: grid;
  gap: 12px;
  box-shadow: 0 24px 48px rgba(32, 39, 34, 0.16);
}
.modal-card h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
}
.modal-lead { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.modal-card label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.modal-card input {
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: var(--paper);
}
.modal-card input:focus {
  outline: none;
  border-color: rgba(37, 75, 61, 0.45);
  box-shadow: 0 0 0 3px rgba(220, 236, 171, 0.55);
}
.code-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.code-row button, .modal-actions button {
  border-radius: 12px;
  min-height: 46px;
  padding: 0 14px;
  font-weight: 650;
}
.code-row button, #login-submit {
  background: var(--brand);
  color: #fff;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions .ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.status { margin: 0; min-height: 1.2em; font-size: 0.86rem; color: var(--muted); }
.status.error { color: #B42318; }
.status.ok { color: var(--brand); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spark {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231, 189, 104, 0); }
  40% { box-shadow: 0 0 0 6px rgba(231, 189, 104, 0.28); }
}
.pick-perk.spark { animation: spark 1.2s ease 1; }

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 42vh) minmax(320px, 1fr);
    height: calc(100dvh - 72px);
  }
  .shelf-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 560px) {
  .stage { padding: 0 10px 8px; }
  .brand-name { font-size: 1.15rem; }
  .user-label { display: none; }
}
