:root {
  --rail: #1b1d22;
  --rail-2: #2c2f37;
  --rail-text: #c9c6bf;
  --gold: #e8c27a;
  --gold-deep: #9a7330;
  --bg: #f5f3ef;
  --card: #ffffff;
  --line: #e2ddd3;
  --ink: #1b1d22;
  --muted: #7a756b;
  --good: #4f8a5b;
  --warn: #b7792b;
  --bad: #b04a4a;
  --radius: 12px;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-text); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { font-family: var(--serif); font-size: 30px; color: var(--gold); padding: 0 10px 18px; letter-spacing: -0.02em; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; font-size: 14px; transition: background .15s, color .15s; }
.rail-nav a i { font-size: 19px; }
.rail-nav a:hover { background: #24272e; color: #fff; }
.rail-nav a.on { background: var(--rail-2); color: #fff; }
.rail-nav a.on i { color: var(--gold); }
.rail-pet { margin-top: auto; background: var(--rail-2); border-radius: 12px; padding: 10px; display: flex; gap: 10px; align-items: center; transition: background .15s; }
.rail-pet:hover { background: #343844; }
.rail-pet .nm { color: #fff; font-size: 14px; font-weight: 500; }
.rail-pet .st { font-size: 12px; }
.rail-pet .pet-thumb { background: #383c46; border-radius: 10px; }

.main { padding: 28px 32px 48px; max-width: 1080px; width: 100%; }
.main-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; }
.coin-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 8px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.coin { width: 14px; height: 14px; flex: 0 0 auto; }
.coin-pill .coin, .coin { width: 16px; height: 16px; border-radius: 50%; background: var(--gold); border: 2px solid var(--gold-deep); display: inline-block; }

.topbar, .pet-strip, .tabbar { display: none; }

/* ---------- building blocks ---------- */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gauto { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card h2, .card h3 { margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; }
.link { color: var(--gold-deep); font-size: 13px; font-weight: 500; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 9px; padding: 8px 14px; font-size: 14px; font-weight: 500; transition: background .15s, transform .08s; }
.btn:hover { background: #f0ede6; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--rail); color: #fff; border-color: var(--rail); }
.btn.primary:hover { background: #2c2f37; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #3a2a0c; }
.btn.gold:hover { background: #ddb466; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: #973c3c; }
.btn.ghost-danger { border-color: transparent; background: transparent; color: var(--bad); }
.btn.ghost-danger:hover { background: #f5dddd; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -6px 0 14px; }
.tabs button { border: 0; background: transparent; padding: 9px 14px; font-size: 15px; font-weight: 500; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button i { font-size: 18px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn i { font-size: 17px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #f0ede6; color: #5d584f; }
.chip.gold { background: #f6e6c4; color: #6e4f15; }
.chip.violet { background: #e8e2f6; color: #47386e; }
.chip.green { background: #dfeedd; color: #2f5a33; }
.chip.red { background: #f5dddd; color: #7a2b2b; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #ebe7df; border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.ico { width: 38px; height: 38px; border-radius: 10px; background: #f0ede6; display: grid; place-items: center; font-size: 20px; color: #5d584f; flex: 0 0 auto; }
.ico.dye { background: #e8e2f6; color: #47386e; }
.ico.charm { background: #f6e6c4; color: #6e4f15; }
.ico.toy { background: #dfeedd; color: #2f5a33; }

.meter { height: 7px; background: #ebe7df; border-radius: 4px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--good); transition: width .4s; }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }
.meter.xp > span { background: var(--gold); }
.top-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--rail-2); color: #fff; display: grid; place-items: center; font-size: 18px; }
.stat { display: flex; justify-content: space-between; font-size: 13px; margin: 8px 0 4px; }
.stat b { font-weight: 500; }

.pet-stage { background: linear-gradient(#eef1ee, #e6e9e3); border-radius: 12px; display: grid; place-items: center; position: relative; overflow: hidden; }
.pet-stage.dark { background: linear-gradient(#2c2f37, #23252b); }
.pet-svg { display: block; }
.pet-bob .pet-svg { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* adoption cards */
.adopt-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; cursor: pointer; }
.adopt-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(27,29,34,.08); }
.adopt-card .pet-stage { border-radius: 0; height: 150px; }
.adopt-card .body { padding: 10px 12px 12px; }
.adopt-card .nm { font-family: var(--serif); font-size: 17px; }
.adopt-card .by { font-size: 12px; color: var(--muted); }
.adopt-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px; }
.heart { border: 0; background: transparent; color: var(--muted); display: inline-flex; gap: 3px; align-items: center; font-size: 13px; padding: 2px; }
.heart.on { color: #c2456a; }
.ribbon { position: absolute; top: 8px; left: 8px; }

/* maker */
.maker { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.opt-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.opt-row:first-of-type { border-top: 0; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; }
.stepper span { min-width: 92px; text-align: center; font-size: 14px; font-weight: 500; }
.species-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.species-pick button { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 6px 4px 8px; font-size: 13px; font-weight: 500; display: flex; flex-direction: column; align-items: center; }
.species-pick button.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.egg-wrap { animation: wobble .5s ease-in-out 3; }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.reveal { animation: pop .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

input[type=text], input[type=number], select { font: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; background: #fff; width: 100%; color: var(--ink); }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
input[type=range] { width: 100%; accent-color: var(--ink); }
label.field { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.err { color: var(--bad); font-size: 13px; margin-top: 6px; min-height: 1em; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(20,21,25,.5); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { background: var(--card); border-radius: 16px; width: min(440px, 100%); max-height: 90vh; overflow: auto; padding: 20px; animation: up .2s ease-out; }
.modal .x { float: right; border: 0; background: transparent; font-size: 20px; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(12px); opacity: 0; } }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--rail); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); }

#update-bar { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 70; background: var(--gold); color: #3a2a0c; border-radius: 999px; padding: 6px 6px 6px 16px; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; box-shadow: 0 4px 14px rgba(0,0,0,.15); white-space: nowrap; }
#update-bar[hidden] { display: none; }
#update-bar button { border: 0; background: var(--rail); color: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 500; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.daily { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.daily:first-of-type { border-top: 0; }
.daily .grow { flex: 1; }
.news p { margin: 0 0 10px; font-size: 14px; }
.news .d { font-size: 12px; color: var(--muted); }
.hero { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: center; }

.rail-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 8px 4px 0; }
.rail-foot button { border: 0; background: transparent; color: var(--rail-text); font-size: 18px; padding: 4px; border-radius: 6px; }
.rail-foot button:hover { color: #fff; background: #24272e; }
.rail-pet { margin-top: auto; }
button:disabled { opacity: .55; cursor: default; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 12px; }
label.check input { width: 18px; height: 18px; accent-color: var(--ink); }
input[type=password], input[type=email] { font: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; background: #fff; width: 100%; color: var(--ink); }
textarea:focus { outline: 2px solid var(--gold); }
textarea.grow-box { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; resize: none; min-height: 84px; max-height: 320px; overflow-y: auto; color: var(--ink); background: #fff; line-height: 1.5; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stats .card { padding: 12px 14px; }
.stats .num { font-size: 24px; font-weight: 500; }

/* guest landing */
.guest .shell { grid-template-columns: 1fr; }
.guest .rail, .guest .tabbar, .guest .pet-strip, .guest .coin-pill, .guest .main-head { display: none !important; }
.guest .main { margin: 0 auto; }
.landing { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; align-items: center; min-height: calc(100vh - 80px); }
.land-logo { font-family: var(--serif); font-size: 40px; color: var(--gold-deep); margin-bottom: 8px; }
.land-copy h1 { font-size: 34px; line-height: 1.15; margin-bottom: 12px; }
.land-copy p { font-size: 16px; max-width: 46ch; }
.land-pets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.land-pets .pet-stage { height: 130px; }
.auth { padding: 22px; }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .shell { display: block; padding-bottom: 72px; }
  .rail, .main-head .coin-pill { display: none; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; background: var(--rail); justify-content: space-between; align-items: center; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); }
  .topbar .logo { font-size: 24px; padding: 0; }
  .topbar .coin-pill { background: var(--rail-2); border-color: var(--rail-2); color: #fff; }
  .pet-strip { display: flex; gap: 10px; align-items: center; background: var(--card); border-bottom: 1px solid var(--line); padding: 6px 16px; }
  .pet-strip .grow { flex: 1; min-width: 0; }
  .pet-strip .nm { font-weight: 500; font-size: 14px; }
  .main { padding: 18px 16px 24px; }
  .main-head { margin-bottom: 14px; }
  h1 { font-size: 23px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--rail); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11px; color: var(--rail-text); }
  .tabbar a i { font-size: 22px; }
  .tabbar a.on { color: var(--gold); }
  .g2, .g3, .maker, .hero { grid-template-columns: minmax(0, 1fr); }
  .gauto { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .adopt-card .pet-stage { height: 120px; }
  .species-pick { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stepper span { min-width: 80px; }
  .hero .pet-stage { height: 190px; }
  .modal-bg { align-items: end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; width: 100%; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  #toast { bottom: auto; top: 64px; transform: translateX(-50%) translateY(-20px); }
  #toast.show { transform: translateX(-50%) translateY(0); }
  .guest .shell { padding-bottom: 0; }
  .guest .topbar { display: none; }
  .landing { grid-template-columns: minmax(0, 1fr); gap: 20px; min-height: 0; }
  .land-copy h1 { font-size: 27px; }
  .land-pets { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .land-pets .pet-stage { height: 80px; }
  .land-pets .pet-svg { width: 76px; height: 76px; }
}
