:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  color: #fff2db;
  background: #101d32;
  accent-color: #e4c17b;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: #e4c17b; }
main { width: min(100%, 56rem); margin: 0 auto; padding: 1rem; }
header { margin: 1rem 0 1.25rem; }
.narrow { max-width: 32rem; }
.brand { color: #e4c17b; font-size: .875rem; letter-spacing: .06em; margin: 0 0 .4rem; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .875rem; }
h1, h2 { font-family: Georgia, serif; font-weight: 400; }
h1 { font-size: clamp(2rem, 7vw, 3.25rem); }
h2 { font-size: 1.65rem; }
h3 { font-size: 1rem; overflow-wrap: anywhere; }
p { margin: 0 0 .75rem; }
section, dialog {
  border: 1px solid #3e526a;
  background: #172740;
  border-radius: .85rem;
  padding: clamp(.875rem, 4vw, 1.5rem);
  margin: 0 0 1rem;
  min-width: 0;
}
dialog { margin: auto; color: inherit; max-width: min(32rem, 92vw); }
dialog::backdrop { background: #080f1ad9; }
nav, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
nav { margin-bottom: 1rem; }
button, nav a, .button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #60768d;
  background: transparent;
  color: #fff2db;
  border-radius: .4rem;
  padding: .45rem .75rem;
  font: inherit;
  font-size: .9rem;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
button.primary { color: #101d32; background: #e4c17b; border-color: #e4c17b; font-weight: 650; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid #fff2db; outline-offset: 3px; }
form, .form-grid { display: grid; gap: .85rem; justify-items: start; }
.form-grid { width: 100%; }
label:not(.check) { display: grid; gap: .3rem; width: 100%; }
label, legend { font-size: .9rem; }
input:not([type="checkbox"], [type="radio"]), select, textarea {
  min-height: 44px;
  font: inherit;
  font-size: 1rem;
  color: #fff2db;
  width: 100%;
  max-width: 100%;
  border: 1px solid #60768d;
  background: #101d32;
  padding: .55rem;
  border-radius: .4rem;
}
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 1.125rem; height: 1.125rem; flex: 0 0 auto; margin: 0; }
.check { min-height: 44px; display: inline-flex; gap: .55rem; align-items: center; cursor: pointer; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
.package { display: inline-flex; align-items: center; border: 1px solid #60768d; padding: 0 .55rem; border-radius: .4rem; }
.package:has(:checked) { border-color: #e4c17b; color: #e4c17b; }
.credits { font-size: 1.15rem; }
.credits strong { font-size: 1.5rem; color: #e4c17b; }
#status, #publish-error { padding: .65rem; background: #294260; border-radius: .4rem; overflow-wrap: anywhere; }
[data-error="true"] { color: #ffd4ca; }
#preview, #activation-result { margin-top: 1rem; }
iframe { width: 100%; height: min(68vh, 52rem); min-height: 260px; border: 1px solid #60768d; border-radius: .5rem; }
.item { border-top: 1px solid #3e526a; padding: 1rem 0 0; margin: 1rem 0 0; min-width: 0; }
.item h3 { margin-bottom: .4rem; }
.item a:not(.button) { overflow-wrap: anywhere; }
.search { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
summary { min-height: 44px; display: list-item; padding: .65rem 0; cursor: pointer; color: #e4c17b; }
details form { margin: .45rem 0 .75rem; }
[id] { scroll-margin-top: 1rem; }
@media (min-width: 43rem) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .wide { grid-column: 1 / -1; }
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.topbar .brand { margin: 0; }
label.ui-language { display: flex; width: auto; align-items: center; gap: .4rem; font-size: .875rem; margin: 0; }
label.ui-language select { width: auto; min-height: 44px; }
label small { color: #c9bfae; font-size: .8rem; line-height: 1.35; }

/* ---- Admin: simple phone-first panel ---- */
body.admin main { padding-bottom: 5.5rem; }
.admin h1 { font-size: 1.9rem; margin-top: .25rem; }
.admin .topbar { margin: .25rem 0 .75rem; }
button.link { background: none; border: 0; color: #e4c17b; min-height: 44px; padding: 0 .25rem; text-decoration: underline; }
a.button.big, button.big { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 56px; font-size: 1.1rem; margin: .5rem 0 1rem; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin: 0 0 1.25rem; }
.stat { display: grid; gap: .1rem; padding: .85rem; border: 1px solid #3e526a; border-radius: .75rem; background: #172740; color: #fff2db; text-decoration: none; }
.stat strong { font-size: 1.75rem; color: #e4c17b; line-height: 1.1; }
.stat span { font-size: .85rem; }
.rows { display: grid; gap: .5rem; margin: 0 0 1rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .75rem .85rem; min-height: 56px; border: 1px solid #3e526a; border-radius: .7rem; background: #172740; color: #fff2db; text-decoration: none; }
a.row:active { background: #1f3352; }
.row-main { display: grid; min-width: 0; }
.row-main span { font-size: .82rem; color: #c9bfae; }
.badge { flex: none; font-size: .75rem; font-weight: 600; padding: .25rem .55rem; border-radius: 999px; white-space: nowrap; }
.badge-waiting { background: #e4c17b; color: #101d32; }
.badge-sent { background: #3e6a9a; color: #fff; }
.badge-active { background: #2f7a55; color: #fff; }
.badge-done { background: #4a5568; color: #fff; }
.badge-refunded { background: #8a3b3b; color: #fff; }
.filters { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; margin: 0 0 .75rem; }
.chip { flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 .85rem; border: 1px solid #3e526a; border-radius: 999px; color: #fff2db; text-decoration: none; font-size: .9rem; }
.chip[aria-selected="true"] { background: #e4c17b; border-color: #e4c17b; color: #101d32; font-weight: 600; }
.packages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.packages .package { justify-content: center; min-height: 52px; font-size: 1.1rem; }
.back { display: inline-flex; align-items: center; min-height: 44px; color: #e4c17b; text-decoration: none; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.detail-head h1 { margin: 0; overflow-wrap: anywhere; }
.notice { padding: .75rem; border-radius: .6rem; background: #2f7a55; color: #fff; }
.steps { margin: 1rem 0; }
.steps textarea { width: 100%; margin: .5rem 0; }
.steps button { margin: 0 .4rem .5rem 0; }
.hint { color: #c9bfae; font-size: .85rem; }
button.danger { background: #8a3b3b; color: #fff; border-color: #8a3b3b; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); background: #0c1626; border-top: 1px solid #3e526a; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabbar a { display: flex; align-items: center; justify-content: center; min-height: 60px; color: #c9bfae; text-decoration: none; font-size: .95rem; }
.tabbar a[aria-current] { color: #e4c17b; font-weight: 700; box-shadow: inset 0 3px 0 #e4c17b; }
.tabbar a { border: 0; border-radius: 0; background: none; margin: 0; }
nav.tabbar { margin: 0; gap: 0; }
a.button.primary { color: #101d32; background: #e4c17b; border-color: #e4c17b; font-weight: 650; text-decoration: none; }

/* ---- Buyer: small card organiser with bottom tabs ---- */
body.buyer main { padding-bottom: 5.5rem; }
.buyer h1 { font-size: 1.8rem; margin-top: .25rem; }
.account.compact { padding: .85rem 1rem; }
.account.compact p { margin-bottom: .4rem; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 0 0 1rem; }
.choice-card { display: grid; gap: .25rem; align-content: start; justify-items: start; text-align: left; min-height: 92px; padding: .85rem; border-radius: .75rem; }
.choice-card strong { font-size: 1.05rem; }
.choice-card span { font-size: .8rem; color: #c9bfae; line-height: 1.3; }
.choice-card[aria-pressed="true"] { border-color: #e4c17b; box-shadow: inset 0 0 0 1px #e4c17b; background: #1f3352; }
.rows .row > input[type="checkbox"] { flex: none; width: 24px; height: 24px; }
.rows .row a.row-main { flex: 1; color: #fff2db; text-decoration: none; min-height: 44px; align-content: center; }
.card-row { border: 1px solid #3e526a; border-radius: .7rem; padding: .75rem .85rem; margin: 0; background: #172740; }
.card-row.is-shared { opacity: .8; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .5rem; }
.card-row .actions { gap: .4rem; }
.tabbar b { font-weight: 400; margin-left: .25rem; }
.preview-overlay { position: fixed; inset: 0; z-index: 20; background: #08172a; display: grid; grid-template-rows: auto 1fr; }
.preview-overlay iframe { width: 100%; height: 100%; border: 0; }
.preview-overlay #close-preview { margin: max(.5rem, env(safe-area-inset-top)) .75rem .5rem; justify-self: end; }
body.previewing { overflow: hidden; }
#share-question { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
#preview.preview-overlay { margin: 0; } .preview-overlay iframe { border-radius: 0; min-height: 0; }
.choice-card > * { justify-self: start; text-align: left; }

/* ---- Wide screens: left sidebar instead of bottom tabs; side-by-side editor and preview ---- */
@media (min-width: 900px) {
  body.admin main, body.buyer main { width: auto; max-width: 64rem; margin: 0 0 0 15rem; padding: 1.5rem 2rem 2rem; }
  .tabbar { top: 0; bottom: 0; right: auto; width: 13rem; grid-template-columns: none; grid-auto-rows: min-content; align-content: start;
    padding: 5rem .75rem 1rem; border-top: 0; border-right: 1px solid #3e526a; gap: .25rem; }
  .tabbar a { justify-content: flex-start; min-height: 48px; padding: 0 1rem; border-radius: .5rem; }
  .tabbar a[aria-current] { box-shadow: none; background: #1f3352; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .admin .topbar, .buyer .topbar { max-width: 64rem; }
}
@media (min-width: 1180px) {
  /* Buyer create screen: form on the left, live card preview fixed on the right. */
  body.buyer[data-tab="create"] main { max-width: none; margin-right: calc(min(30rem, 34vw) + 1rem); }
  body.buyer[data-tab="create"] .preview-overlay { display: grid !important; left: auto; width: min(30rem, 34vw); grid-template-rows: 1fr;
    border-left: 1px solid #3e526a; z-index: 4; }
  body.buyer[data-tab="create"] #close-preview, body.buyer[data-tab="create"] #open-preview { display: none; }
  body.buyer.previewing { overflow: auto; }
}
