:root {
  --bg: #FFF5EC;
  --surface: #FFFFFF;
  --surface-2: #FFF0E4;
  --text: #3B2E29;
  --muted: #8C7A70;
  --faint: #C2B3A9;
  --border: #F4E3D7;
  --accent: #E9765B;
  --accent-soft: #FDE6DE;
  --accent-ink: #BF5540;
  --green: #5E9C7D;
  --green-soft: #E3F2E9;
  --amber: #D9973A;
  --amber-soft: #FDF0D8;
  --blue: #7392C4;
  --blue-soft: #E8EEF9;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(120, 70, 50, 0.05), 0 10px 28px rgba(120, 70, 50, 0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: radial-gradient(900px 500px at 15% -10%, #FFE4D4 0%, transparent 60%), radial-gradient(700px 500px at 100% 100%, #FBE9D7 0%, transparent 55%), var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }
a { color: var(--accent-ink); }

/* ---------- stage + phone frame ---------- */
#stage {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 40px;
}
#phone {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#sidenote { display: none; }

@media (min-width: 760px) {
  #stage { padding: 40px 24px; align-items: center; }
  #phone {
    width: 400px;
    min-height: 0;
    height: 820px;
    border-radius: 44px;
    border: 10px solid #3B2E29;
    box-shadow: 0 30px 80px rgba(120, 70, 50, 0.28);
    background: var(--bg);
  }
  #sidenote {
    display: block;
    width: 300px;
    color: var(--muted);
    font-size: 14px;
  }
  #sidenote h1 { font-size: 22px; color: var(--text); margin: 0 0 4px; letter-spacing: -0.01em; }
  #sidenote .tag { color: var(--accent); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
  #sidenote p { margin: 10px 0; }
  #sidenote .roles { margin: 16px 0; display: grid; gap: 8px; }
  #sidenote .roles button {
    text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 10px 12px; color: var(--text);
  }
  #sidenote .roles button.active { border-color: var(--accent); background: var(--accent-soft); }
  #sidenote .roles small { display: block; color: var(--muted); font-weight: 400; }
  #sidenote .foot { font-size: 12px; color: var(--faint); margin-top: 20px; }
}

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 10px;
  background: var(--bg);
}
#topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.01em; font-size: 17px; }
#topbar .brand .dot { width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(135deg, #F49A7E, #E9765B); position: relative; box-shadow: 0 4px 10px rgba(233,118,91,0.35); }
#topbar .brand .dot::after { content: '♥'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; }
#roleBtn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 10px 6px 6px; font-size: 13px; font-weight: 600; color: var(--text);
}
#roleBtn .av { width: 24px; height: 24px; font-size: 10px; }
#roleBtn .rl { max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar .brand { flex: 1; }
.lang { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px; margin-right: 8px; }
.lang button { border: 0; background: none; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; padding: 4px 7px; border-radius: 999px; color: var(--faint); }
.lang button.on { background: var(--accent); color: #fff; }
.lang.big { margin: 10px 0 4px; }
.lang.big button { font-size: 13px; padding: 7px 14px; }
.landing .lang { margin-right: 0; }

/* ---------- main view ---------- */
#view {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 96px;
  -webkit-overflow-scrolling: touch;
}
#view::-webkit-scrollbar { width: 0; }
h2.screen { font-size: 26px; letter-spacing: -0.02em; margin: 6px 0 2px; }
.sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
h3.sec { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
h3.sec .link { float: right; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent-ink); background: none; border: 0; padding: 0; font-size: 13px; }

/* ---------- cards + atoms ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card.flat { box-shadow: none; border: 1px solid var(--border); }
.card.accent { background: linear-gradient(135deg, #F49A7E 0%, #E9765B 60%, #D9634B 100%); color: #fff; box-shadow: 0 12px 30px rgba(233, 118, 91, 0.35); }
.card.accent .muted { color: rgba(255,255,255,0.85); }
.card.accent .av { box-shadow: 0 0 0 3px rgba(255,255,255,0.6); }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.bold { font-weight: 600; }
.title { font-weight: 600; font-size: 15px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack > * + * { margin-top: 8px; }

.av {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: var(--text);
  flex: 0 0 auto; overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.7);
}
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av.lg { width: 64px; height: 64px; font-size: 22px; }
.av.sm { width: 32px; height: 32px; font-size: 12px; }
.av.xs { width: 22px; height: 22px; font-size: 9px; border: 2px solid var(--surface); }
.av-stack { display: inline-flex; }
.av-stack .av + .av { margin-left: -8px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.pill.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.pill.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.pill.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.pill.dark { background: var(--text); color: #fff; border-color: transparent; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }

.vouch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.vouch b { color: var(--text); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 14px; border: 0; font-weight: 600; font-size: 15px;
  background: var(--text); color: #fff; transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: linear-gradient(135deg, #F28D71, #E9765B); box-shadow: 0 8px 20px rgba(233, 118, 91, 0.3); }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn.green { background: var(--green); }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btnrow { display: flex; gap: 8px; margin-top: 12px; }
.btnrow .btn { flex: 1; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: var(--radius-sm); padding: 12px 14px;
  box-shadow: var(--shadow); cursor: pointer;
}
.item .chev { color: var(--faint); font-size: 18px; }

.divider { height: 1px; background: var(--border); margin: 12px 0; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--border); }
.kv .k { color: var(--muted); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .n { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 12px; }
.stat .d { font-size: 12px; font-weight: 600; margin-top: 2px; }
.stat .d.up { color: var(--green); }

/* ---------- swipe deck ---------- */
.deck { position: relative; height: 520px; margin: 6px 0 10px; }
.swipe {
  position: absolute; inset: 0;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
  padding: 18px; display: flex; flex-direction: column;
  touch-action: pan-y; user-select: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  will-change: transform;
}
.swipe.dragging { transition: none; }
.swipe.under { transform: scale(0.96) translateY(10px); opacity: 0.85; }
.swipe.under2 { transform: scale(0.92) translateY(20px); opacity: 0.6; }
.swipe .hero {
  height: 190px; border-radius: 18px; position: relative; overflow: hidden;
  display: flex; align-items: flex-end; padding: 14px;
  background: linear-gradient(135deg, var(--c1, #eee), var(--c2, #ddd));
}
.swipe .hero .bigav {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -60%);
  font-size: 64px; font-weight: 800; color: rgba(31,29,26,0.18); letter-spacing: -0.04em;
}
.swipe .hero .name { position: relative; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.swipe .hero .name small { font-weight: 500; opacity: 0.75; font-size: 15px; }
.swipe .hero.photo { height: 250px; background-size: cover; background-position: center 20%; }
.swipe .hero.photo::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(59,46,41,0) 45%, rgba(59,46,41,0.78) 100%); }
.swipe .hero.photo .name { color: #fff; z-index: 1; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.swipe .hero.photo .name small { opacity: 0.9; }
.swipe .stamp {
  position: absolute; top: 24px; padding: 6px 12px; border-radius: 10px;
  font-weight: 800; font-size: 20px; letter-spacing: 0.05em; border: 3px solid;
  opacity: 0; transform: rotate(-12deg); pointer-events: none;
}
.swipe .stamp.like { right: 24px; color: var(--green); border-color: var(--green); transform: rotate(12deg); }
.swipe .stamp.nope { left: 24px; color: var(--accent); border-color: var(--accent); }
.swipe .body { flex: 1; padding-top: 12px; overflow: hidden; }
.swipe .bio { font-size: 14px; color: var(--muted); margin: 10px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.deckbtns { display: flex; justify-content: center; gap: 18px; }
.deckbtns button {
  width: 60px; height: 60px; border-radius: 50%; border: 0; font-size: 22px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--text);
}
.deckbtns button.like { background: var(--green); color: #fff; }
.deckbtns button.nope { color: var(--accent); }
.deckbtns button.info { width: 48px; height: 48px; font-size: 16px; align-self: center; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 70px; resize: vertical; }
.field .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 500; color: var(--text);
}
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }
.steps { display: flex; gap: 6px; margin: 0 0 14px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--border); }
.steps span.on { background: var(--accent); }

/* ---------- progress / matching ---------- */
.matching { text-align: center; padding: 30px 10px; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 4px solid var(--border); border-top-color: var(--accent); margin: 0 auto 16px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ticks { text-align: left; margin: 20px auto 0; max-width: 280px; }
.ticks div { padding: 6px 0; color: var(--muted); font-size: 14px; }
.ticks div.done { color: var(--text); }
.ticks div::before { content: '○ '; color: var(--faint); }
.ticks div.done::before { content: '✓ '; color: var(--green); }

/* ---------- tab bar ---------- */
#tabbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  background: rgba(255,250,246,0.94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(10px + env(safe-area-inset-bottom));
}
#tabbar button {
  flex: 1; background: none; border: 0; color: var(--faint);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; padding: 4px 0;
}
#tabbar button .ic { font-size: 20px; line-height: 1; }
#tabbar button.on { color: var(--accent); }
#tabbar button .badge {
  position: absolute; margin-left: 22px; margin-top: -4px;
  background: var(--accent); color: #fff; font-size: 10px; border-radius: 999px; padding: 1px 5px;
}

/* ---------- bottom sheet ---------- */
#sheet {
  position: fixed; inset: 0; z-index: 50; display: none;
}
#sheet.open { display: block; }
#sheet .scrim { position: absolute; inset: 0; background: rgba(31,29,26,0.45); }
#sheet .panel {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto;
  width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 20px 28px;
  animation: up 0.22s ease;
}
@media (min-width: 760px) {
  #sheet .panel { bottom: 50%; transform: translateY(50%); border-radius: 24px; max-width: 380px; max-height: 760px; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
#sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 14px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 500; opacity: 0; transition: all 0.25s ease; z-index: 60;
  pointer-events: none; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- role menu ---------- */
#rolemenu {
  position: absolute; top: 54px; right: 14px; z-index: 40; display: none;
  background: var(--surface); border-radius: 16px; box-shadow: 0 12px 40px rgba(31,29,26,0.18);
  padding: 8px; width: 240px; border: 1px solid var(--border);
}
#rolemenu.open { display: block; }
#rolemenu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; padding: 10px; border-radius: 10px; color: var(--text);
}
#rolemenu button:hover, #rolemenu button.on { background: var(--surface-2); }
#rolemenu button small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }

/* ---------- circle graph ---------- */
.graph { position: relative; height: 330px; margin: 6px 0 14px; }
.graph .node { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); font-weight: 600; transform: translate(-50%, -50%); }
.graph svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.graph line { stroke: var(--border); stroke-width: 2; }
.graph line.strong { stroke: var(--accent); opacity: 0.6; }

/* ---------- week availability ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week .day { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; }
.week .slot { height: 34px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.week .slot.on { background: var(--green-soft); border-color: transparent; }
.week .slot.booked { background: var(--accent-soft); border-color: transparent; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }

/* ---------- landing ---------- */
.landing { display: flex; flex-direction: column; min-height: 100%; padding-top: 30px; }
.landing .hero-t { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin: 16px 0 10px; }
.landing .hero-t em { color: var(--accent); font-style: normal; }
.landing .avs { display: flex; margin: 6px 0 22px; }
.landing .avs .av { border: 2px solid var(--bg); margin-left: -8px; box-shadow: none; }
.landing .avs .av:first-child { margin-left: 0; }
.collage { position: relative; height: 150px; margin: 26px 0 14px; }
.collage img { position: absolute; width: 112px; height: 136px; object-fit: cover; border-radius: 28px; border: 4px solid #fff; box-shadow: 0 14px 30px rgba(120, 70, 50, 0.22); }
.collage .c1 { left: 6%; top: 10px; transform: rotate(-7deg); }
.collage .c2 { left: 50%; top: 0; transform: translateX(-50%) rotate(2deg); z-index: 2; width: 122px; height: 146px; }
.collage .c3 { right: 6%; top: 12px; transform: rotate(7deg); }
.collage .heart { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); z-index: 3; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: 0 8px 20px rgba(233,118,91,0.45); border: 3px solid #fff; }
.landing .spacer { flex: 1; }
.landing .invite { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.landing .code { display: flex; gap: 8px; margin-top: 10px; }
.landing .code input { flex: 1; letter-spacing: 0.2em; text-transform: uppercase; font-weight: 700; text-align: center; }

.proto-note { font-size: 12px; color: var(--faint); text-align: center; margin-top: 24px; }
