:root {
  color-scheme: light;
  --ink: #2a1a14;
  --muted: #6b5a50;
  --paper: #fdf6ec;
  --card: #ffffff;
  --line: #eadfce;
  --brand: #8f1239;
  --brand-dark: #5f0f26;
  --accent: #f59e0b;
  --ok: #166534;
  --warn: #b42318;
  --radius: 14px;
  font-family: 'Mukta', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 17px; line-height: 1.45; }
#app { max-width: 1120px; margin: 0 auto; padding: 0 16px 96px; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 3px solid; border-image: linear-gradient(90deg, var(--brand), var(--accent) 60%, transparent) 1; margin-bottom: 8px; }
.brand { font-family: 'Poppins', 'Mukta', sans-serif; font-weight: 800; font-size: 26px; color: var(--brand); line-height: 1.2; }
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 14px; }
.note a { color: var(--brand); font-weight: 600; }
#login-forgot { display: block; }
.ai-options { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ai-option { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 10px 12px; text-align: left; white-space: pre-line; line-height: 1.45; }
button.plan { width: 100%; font: inherit; text-align: left; cursor: pointer; }
.login-page { max-width: 460px; margin: 12px auto 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.editor-top { justify-content: flex-start; }
.editor-top .brand { font-size: 21px; }
.link-btn { background: none; border: 0; padding: 6px 4px; min-height: 40px; color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.leaders { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.leader { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 104px; }
.leader-main { background: none; border: 0; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.leader-main span { font-size: 14px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; text-align: center; }
.avatar { width: 62px; height: 62px; border-radius: 50%; background: #efe3d2; border: 3px solid transparent; object-fit: cover; display: block; }
.leader-main span.no-photo, .no-photo { display: grid; place-items: center; font-weight: 800; font-size: 24px; color: var(--brand); }
.leader.on .avatar { border-color: var(--brand); }
.leader-edit { background: none; border: 0; color: var(--brand); font-size: 14px; font-weight: 700; text-decoration: underline; padding: 2px 6px; }
.leader-add { flex: none; width: 104px; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 14px; font-weight: 700; color: var(--brand); padding: 0; }
.plus { width: 62px; height: 62px; border-radius: 50%; border: 2px dashed var(--brand); display: grid; place-items: center; font-size: 30px; line-height: 1; }

.cta { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 70%); color: #fff; border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; margin: 4px 0 8px; }
.cta h2 { font-family: 'Poppins', 'Mukta', sans-serif; font-weight: 800; font-size: 25px; line-height: 1.3; }
.cta .btn.primary { background: var(--accent); color: #3b1d03; border-color: var(--accent); }

.section { font-size: 19px; font-weight: 800; margin: 18px 0 10px; }
.quick { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.quick .chip { flex: none; }
.chip { background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 15px; min-height: 44px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 230px)); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 0 10px; display: flex; flex-direction: column; gap: 3px; text-align: left; overflow: hidden; box-shadow: 0 3px 12px rgba(80, 40, 20, .09); }
.card canvas { width: 100%; aspect-ratio: 1; display: block; background: #eee3d3; }
.card-title { font-weight: 700; padding: 5px 10px 0; line-height: 1.3; }
.card-date { font-size: 14px; color: var(--muted); padding: 0 10px; }
.card-date.is-today { color: var(--brand); font-weight: 700; }
/* Today's posters: three across on any phone. */
.grid.today { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 700px) { .grid.today { grid-template-columns: repeat(3, minmax(0, 250px)); gap: 12px; } }
.grid.today .card { padding-bottom: 6px; }
.grid.today .card-title { font-size: 15px; padding: 4px 6px 0; }

.foot { margin-top: 28px; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.foot a, .foot .link-btn { color: var(--brand); font-weight: 600; min-height: 40px; display: inline-flex; align-items: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; background: var(--card); color: var(--ink); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 18px; min-height: 48px; font-weight: 700; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { color: var(--warn); border-color: currentColor; margin-left: auto; }
.btn.small { min-height: 44px; padding: 7px 14px; font-size: 16px; margin-top: 6px; }
.btn:disabled { opacity: .55; cursor: wait; }

.editor { display: flex; flex-direction: column; gap: 14px; }
.stage { display: flex; flex-direction: column; gap: 6px; align-items: center; }
#preview { display: block; max-width: 100%; max-height: 62vh; width: auto; height: auto; border-radius: 8px; box-shadow: 0 4px 18px rgba(60, 30, 10, .22); background: #eee3d3; }
.stage-note { font-size: 15px; color: var(--muted); }
.controls h2 { font-size: 17px; font-weight: 800; margin: 14px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.designs { display: flex; gap: 10px; overflow-x: auto; padding: 3px 2px 8px; }
.design { flex: none; background: none; border: 3px solid transparent; border-radius: 10px; padding: 0; overflow: hidden; }
.design.on { border-color: var(--brand); }
.design { position: relative; }
.design canvas { display: block; height: 118px; width: auto; }
.design-tag { position: absolute; left: 4px; bottom: 4px; background: rgba(30, 15, 5, .85); color: #ffd76a; font-size: 12px; font-weight: 700; line-height: 1.5; padding: 0 6px; border-radius: 6px; }

.field { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; font-weight: 600; }
.field small { font-weight: 400; color: var(--muted); font-size: 14px; }
.field input:not([type=range]):not([type=file]), .field select, .field textarea { background: #fff; border: 1.5px solid #cdbda8; border-radius: 10px; padding: 9px 12px; min-height: 46px; width: 100%; font-weight: 400; }
.field input[type=file] { min-height: 46px; width: 100%; font-weight: 400; font-size: 15px; }
.field input[type=range] { width: 100%; min-height: 40px; accent-color: var(--brand); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-weight: 500; }
.check input { width: 22px; height: 22px; flex: none; margin-top: 2px; accent-color: var(--brand); }
.note { font-size: 15px; color: var(--muted); }
#quality-msg.warn { color: var(--warn); font-weight: 700; }
#quality-msg.ok { color: var(--ok); font-weight: 600; }

.actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(253, 246, 236, .96); border-top: 1px solid var(--line); justify-content: center; z-index: 5; }
.actions .btn { flex: 1; max-width: 300px; padding-left: 8px; padding-right: 8px; }

.sheet-wrap { position: fixed; inset: 0; background: rgba(30, 15, 5, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { background: var(--paper); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.form h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.photo-status { font-size: 15px; font-weight: 600; color: var(--brand-dark); min-height: 0; }
.photo-preview { margin: 8px 0; padding: 8px; background: linear-gradient(135deg, #7a1530, #e0872a); border-radius: 12px; display: flex; justify-content: center; }
.photo-preview img { max-height: 190px; max-width: 100%; display: block; }
.kit-cta { background: var(--card); border: 1.5px solid var(--brand); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; font-weight: 600; }
.kit-cta .btn.small { margin-top: 0; }
.kit-title { font-size: 17px; font-weight: 800; margin: 14px 0 4px; }
.kit-suggest { margin: 8px 0; }
.leader-chip { display: inline-flex; align-items: center; gap: 6px; padding-left: 6px; white-space: normal; text-align: left; }
.leader-chip img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.kit-suggest .chips { margin-top: 6px; }
.kit-list { display: flex; flex-direction: column; gap: 6px; }
.kit-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.kit-face { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; }
.kit-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.kit-text small { color: var(--muted); }
.kit-post { border: 0; border-bottom: 1px dashed #cdbda8; background: transparent; padding: 2px 0; min-height: 30px; width: 100%; font-size: 15px; color: var(--muted); }
.color-row { display: flex; gap: 14px; }
.color-row .field { flex: 1; }
.field input[type=color] { width: 100%; height: 46px; padding: 3px; background: #fff; border: 1.5px solid #cdbda8; border-radius: 10px; }
.plans { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.plan { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 12px; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 14px; color: inherit; text-decoration: none; }
.plan.best { border-color: var(--brand); }
.plan-name { font-weight: 800; }
.plan-price { grid-row: 1 / span 2; grid-column: 2; font-size: 21px; font-weight: 800; color: var(--brand); }
.plan small { color: var(--muted); font-size: 14px; }
.plan-tag { color: var(--ok); font-weight: 700; font-size: 14px; }
.steps { margin: 8px 0; padding-left: 22px; }
.upi-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }


.loading { text-align: center; margin: 25vh 0 0; font-size: 20px; color: var(--brand); }
.start-problem { max-width: 560px; margin: 40px auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.start-problem h1 { font-size: 23px; font-weight: 800; line-height: 1.3; color: var(--brand); }
.start-problem code { display: block; background: #2a1a14; color: #fff; padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: nowrap; font-size: 15px; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #2a1a14; color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 40; width: max-content; max-width: calc(100vw - 32px); font-size: 16px; }
.busy { position: fixed; inset: 0; background: rgba(30, 15, 5, .68); color: #fff; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; z-index: 30; text-align: center; padding: 24px; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

@media (min-width: 900px) {
  .editor { flex-direction: row; align-items: flex-start; gap: 26px; }
  .stage { flex: 1.5; min-width: 0; position: sticky; top: 10px; }
  #preview { max-height: 78vh; }
  .controls { flex: 1; min-width: 320px; }
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 18px; }
}
.wisher-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
.wisher { display: flex; align-items: center; gap: 10px; }
.wisher .avatar.small { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #eee3d3; }
.wisher span { flex: 1; }
#w-photo { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
/* Seldom-used editor controls fold away under a heading. */
details.more { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; }
details.more > summary { cursor: pointer; list-style: none; padding: 12px 14px; font-weight: 800; font-size: 17px; display: flex; align-items: center; justify-content: space-between; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: '+'; font-size: 22px; font-weight: 400; color: var(--brand); line-height: 1; }
details.more[open] > summary::after { content: '−'; }
details.more[open] > summary { border-bottom: 1px solid var(--line); }
details.more > .more-body { padding: 4px 14px 14px; }
details.more h2 { font-size: 17px; margin: 10px 0 6px; }

/* Plans and bills */
.plans-page { max-width: 640px; margin: 0 auto; padding-bottom: 40px; }
.plans-page h2 { margin-top: 18px; }
.plan-state { background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0 4px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.plan-state h2 { margin: 0; font-size: 20px; }
.plan-state.on { border-color: var(--ok); background: #f3fbf4; }
.plan-state.off { border-color: #c9a227; background: #fff9e8; }
.plan-state .pending-note { background: #fff3d6; border-radius: 10px; padding: 8px 10px; font-size: 15px; }
.plan { cursor: pointer; width: 100%; text-align: left; font: inherit; }
.plan:hover, .plan:focus-visible { border-color: var(--brand); }
.pay-big { display: block; width: 100%; text-align: center; font-size: 19px; padding: 14px 18px; margin: 8px 0; }
.upi-qr { display: block; width: 190px; height: 190px; margin: 8px auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.bills { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.bill { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.bill strong { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 18px; color: var(--brand); }
.bill small { color: var(--muted); }
.status.paid { color: var(--ok); font-weight: 700; }
.status.claimed { color: #a65d00; font-weight: 700; }
.status.rejected { color: #b3261e; font-weight: 700; }
.receipt { white-space: pre-wrap; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font: inherit; font-size: 15px; line-height: 1.5; margin: 6px 0; }
.promo { background: #fff7ea; border: 1.5px dashed var(--accent); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.promo p { margin: 2px 0 0; }
