/* PickOnTheWay prototype — responsive (mobile + desktop) */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d23;
  --text-secondary: #5c6370;
  --text-muted: #8b929e;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --primary: #1f4b99;
  --primary-soft: #e8eef8;
  --primary-pressed: #163a78;
  --success: #1a7f4b;
  --success-soft: #e6f5ed;
  --warning: #9a6700;
  --warning-soft: #fff6e0;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --info: #2d6a9f;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --nav-h: 56px;
  --banner-h: 28px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

/* App shell: full-bleed on all sizes; content width handled inside */
.app-shell {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

.proto-banner {
  height: var(--banner-h);
  background: #2b2f36;
  color: #e8eaed;
  font-size: 11px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 100;
}
.proto-banner span { opacity: 0.85; }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header .back {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; color: var(--text); flex-shrink: 0;
}
.app-header .back:hover { background: var(--bg); text-decoration: none; }
.app-header h1 {
  margin: 0; font-size: 17px; font-weight: 600; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header .actions { display: flex; gap: 4px; }

.app-main {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(16px + var(--nav-h) + var(--safe-bottom));
  overflow-y: auto;
}
.app-main.no-nav { padding-bottom: 24px; }

/* Bottom nav */
.bottom-nav {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  z-index: 50;
  margin-top: auto;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-muted); font-size: 11px; font-weight: 500;
  text-decoration: none; min-height: 44px;
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav .nav-ico { font-size: 20px; line-height: 1; }

/* Typography */
.brand { font-weight: 700; letter-spacing: -0.02em; }
.muted { color: var(--text-secondary); }
.tiny { font-size: 12px; color: var(--text-muted); }
.h2 { margin: 0 0 8px; font-size: 20px; font-weight: 650; }
.h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.lead { color: var(--text-secondary); margin: 0 0 16px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card.clickable { cursor: pointer; transition: border-color 0.15s; display: block; color: inherit; text-decoration: none; }
.card.clickable:hover { border-color: var(--primary); text-decoration: none; }
.card-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-weight: 600; font-size: 15px; margin: 0 0 4px; }
.card-meta { font-size: 13px; color: var(--text-secondary); margin: 0; }
.card-footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* Badges / tags */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 560; padding: 2px 8px;
  border-radius: 999px; background: var(--bg); color: var(--text-secondary);
  white-space: nowrap;
}
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 560; font-size: 15px;
  cursor: pointer; text-decoration: none; background: var(--bg); color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-pressed); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #f5c6c2; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn:disabled, .btn.disabled { opacity: 0.5; pointer-events: none; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* Forms */
.form-section { margin-bottom: 20px; }
.form-section-title {
  font-size: 13px; font-weight: 650; color: var(--text-secondary);
  text-transform: none; letter-spacing: 0.02em; margin: 0 0 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 13px; font-weight: 560; margin-bottom: 6px; color: var(--text);
}
.field label .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.seg.three { grid-template-columns: 1fr 1fr 1fr; }
.seg-item {
  min-height: 44px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 500;
  padding: 8px; text-align: center;
}
.seg-item.active {
  border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600;
}
.checkbox-row {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px;
  background: var(--bg); border-radius: var(--radius-sm); margin-bottom: 10px;
}
.checkbox-row input { margin-top: 3px; width: 18px; height: 18px; flex-shrink: 0; }
.checkbox-row label { font-size: 13px; margin: 0; font-weight: 400; }

/* Tabs */
.tabs {
  display: flex; gap: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
  margin-bottom: 12px;
}
.tab {
  flex: 1; min-height: 44px; display: flex; align-items: center; justify-content: center;
  font-weight: 560; font-size: 14px; color: var(--text-secondary); cursor: pointer;
  border: none; background: transparent; text-decoration: none;
}
.tab.active { background: var(--primary-soft); color: var(--primary); }
.tab:hover { text-decoration: none; }

/* Filters */
.filters {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
}
.filters-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .field { margin-bottom: 0; }
.filters .field label { font-size: 12px; color: var(--text-muted); }
.filters input, .filters select { min-height: 40px; font-size: 14px; padding: 8px 10px; }

/* Empty state */
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-secondary);
}
.empty .empty-ico { font-size: 36px; margin-bottom: 8px; opacity: 0.6; }
.empty p { margin: 0 0 8px; }
.empty .tiny { margin-bottom: 16px; }

/* Hero / home */
.hero {
  background: linear-gradient(160deg, #1f4b99 0%, #2a5fb5 55%, #3a6fc4 100%);
  color: #fff; border-radius: var(--radius); padding: 24px 20px; margin-bottom: 16px;
}
.hero h2 { margin: 0 0 8px; font-size: 22px; font-weight: 700; color: #fff; }
.hero p { margin: 0 0 16px; opacity: 0.92; font-size: 14px; line-height: 1.55; }
.hero .btn-primary { background: #fff; color: var(--primary); }
.hero .btn-secondary { background: transparent; border-color: rgba(255,255,255,0.45); color: #fff; }
.safety-line {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warning-soft); border: 1px solid #f0e0b0;
  border-radius: var(--radius-sm); padding: 12px; margin-bottom: 16px; font-size: 13px;
}
.safety-line .ico { flex-shrink: 0; }

/* Chat */
.chat-thread {
  display: flex; flex-direction: column; gap: 10px;
  padding-bottom: 80px;
}
.bubble {
  max-width: 82%; padding: 10px 12px; border-radius: 14px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--border);
}
.bubble.me { align-self: flex-end; background: var(--primary-soft); border-color: #c5d4ee; }
.bubble.them { align-self: flex-start; }
.bubble .time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.struct-card {
  align-self: stretch; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 14px; margin: 4px 0;
}
.struct-card .sc-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-weight: 650; font-size: 14px;
}
.struct-card .sc-body { font-size: 13px; color: var(--text-secondary); }
.struct-card .sc-body p { margin: 4px 0; }
.struct-card .price-hl {
  font-size: 20px; font-weight: 700; color: var(--text); margin: 8px 0;
}
.chat-composer {
  position: sticky; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + var(--safe-bottom));
  display: flex; gap: 8px; align-items: center;
  margin: 0 -16px -16px; /* counteract app-main padding when used inside */
}
.chat-composer input {
  flex: 1; min-height: 40px; border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 8px 14px; outline: none;
}
.msg-item {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border); color: inherit; text-decoration: none;
}
.msg-item:hover { text-decoration: none; background: transparent; }
.msg-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 650; flex-shrink: 0;
}
.msg-body { flex: 1; min-width: 0; }
.msg-body .top { display: flex; justify-content: space-between; gap: 8px; }
.msg-body .name { font-weight: 600; }
.msg-body .preview { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.unread-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 6px;
}

/* Agreement timeline / status */
.status-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--primary-soft); border-radius: var(--radius-sm);
  margin-bottom: 14px; font-size: 13px; font-weight: 560; color: var(--primary);
}
.timeline { border-left: 2px solid var(--border); margin: 8px 0 8px 8px; padding-left: 16px; }
.timeline-item { position: relative; padding-bottom: 14px; }
.timeline-item::before {
  content: ""; position: absolute; left: -21px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border-strong); border: 2px solid var(--surface);
}
.timeline-item.done::before { background: var(--success); }
.timeline-item.current::before { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.timeline-item .ti-title { font-weight: 560; font-size: 14px; }
.timeline-item .ti-desc { font-size: 12px; color: var(--text-muted); }

/* Photo upload mock */
.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0;
}
.photo-slot {
  aspect-ratio: 1; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text-muted); font-size: 12px; cursor: pointer;
}
.photo-slot.filled {
  border-style: solid; background: #eef2f7; color: var(--text-secondary); font-weight: 560;
}
.photo-slot .plus { font-size: 22px; line-height: 1; margin-bottom: 2px; }

/* Price callouts */
.price-box {
  background: var(--bg); border-radius: var(--radius-sm); padding: 12px; margin: 8px 0;
}
.price-box .label { font-size: 12px; color: var(--text-muted); }
.price-box .amount { font-size: 22px; font-weight: 700; }
.price-box .note { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.ref-price {
  background: #f7f8fa; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); padding: 12px; font-size: 13px;
}
.ref-price .ref-title { font-weight: 600; margin-bottom: 4px; }
.ref-price .disclaimer { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

/* Profile list */
.list-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  color: inherit; text-decoration: none; min-height: 48px;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg); text-decoration: none; }
.list-item .chev { color: var(--text-muted); }

.notice {
  font-size: 12px; color: var(--text-secondary); background: var(--bg);
  border-radius: var(--radius-sm); padding: 10px 12px; margin: 12px 0;
}
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.stack-gap > * + * { margin-top: 12px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 6px 0; }
.kv .k { color: var(--text-muted); flex-shrink: 0; }
.kv .v { text-align: right; font-weight: 500; }

.otp-boxes {
  display: flex; gap: 8px; justify-content: center; margin: 16px 0;
}
.otp-boxes input {
  width: 44px; height: 48px; text-align: center; font-size: 20px; font-weight: 650;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.otp-boxes input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }

.home-steps { display: block; }

/* —— Mobile defaults (≤767px): bottom nav, single column —— */
@media (max-width: 767px) {
  .app-main { max-width: 100%; }
  .desktop-only { display: none !important; }
}

/* —— Desktop / tablet landscape (≥768px) —— */
@media (min-width: 768px) {
  .mobile-only { display: none !important; }

  .proto-banner {
    position: sticky;
    top: 0;
    justify-content: space-between;
    padding: 0 24px;
  }
  .proto-banner .layout-hint {
    opacity: 0.7;
    font-size: 11px;
  }

  /* Top navigation (repurpose bottom-nav) */
  .bottom-nav {
    order: 1;
    position: sticky;
    top: var(--banner-h);
    bottom: auto;
    margin-top: 0;
    height: 52px;
    padding: 0 24px;
    padding-bottom: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    border-top: none;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    z-index: 60;
  }
  .bottom-nav a {
    flex-direction: row;
    gap: 8px;
    font-size: 14px;
    padding: 0 14px;
    min-height: 40px;
    border-radius: 8px;
    color: var(--text-secondary);
  }
  .bottom-nav a:hover {
    background: var(--bg);
    text-decoration: none;
    color: var(--text);
  }
  .bottom-nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
  }
  .bottom-nav .nav-ico { font-size: 16px; }

  .proto-banner { order: 0; }
  .app-header { order: 2; }
  .app-main { order: 3; }
  /* pages without bottom-nav still work */

  .app-header {
    padding: 12px 32px;
    max-width: 1120px;
    width: 100%;
    margin: 0 auto;
    border-bottom: 1px solid var(--border);
  }
  .app-header h1 { font-size: 18px; }

  .app-main {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 32px 48px;
    padding-bottom: 48px;
  }
  .app-main.no-nav { padding-bottom: 48px; }

  /* Home: wider hero + side-by-side how-it-works */
  .hero {
    padding: 36px 40px;
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
    align-items: center;
  }
  .hero h2 { font-size: 28px; }
  .hero p { font-size: 15px; max-width: 36em; }
  .hero .btn-row { margin-top: 8px; }
  .hero-aside {
    display: none;
  }

  .home-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 8px;
  }
  .home-steps .card { margin-bottom: 0; height: 100%; }

  /* Hall: filters in one row, cards in 2 columns */
  .filters-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
  .hall-list,
  [data-hall-list] {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  [data-hall-list] .card,
  .hall-list .card {
    margin-bottom: 0;
  }

  /* Forms readable measure */
  .form-section,
  .field,
  form,
  .publish-wrap {
    max-width: 640px;
  }
  .field-row { gap: 16px; }

  /* Detail / agreement: two-column where useful */
  .detail-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
    align-items: start;
  }
  .detail-layout .detail-side {
    position: sticky;
    top: calc(var(--banner-h) + 64px);
  }

  /* Messages: list denser */
  .msg-item { padding: 14px 8px; border-radius: 8px; }
  .msg-item:hover { background: var(--surface); }

  /* Chat: constrain width for readability */
  .chat-thread {
    max-width: 720px;
    margin: 0 auto;
    padding-bottom: 24px;
  }
  .chat-composer {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    border-radius: 12px 12px 0 0;
    margin-bottom: 0;
  }

  .btn-row { max-width: 480px; }
}

/* Large desktop */
@media (min-width: 1100px) {
  .app-main { padding-left: 40px; padding-right: 40px; }
  .hall-list,
  [data-hall-list] {
    grid-template-columns: 1fr 1fr;
  }
}
