:root {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--bg); isolation: isolate; }
.cabinet-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  color: var(--accent);
  transition: color .35s ease;
}
.cabinet-backdrop::before,
.cabinet-backdrop::after {
  position: absolute;
  content: "";
}
.cabinet-backdrop::before {
  inset: 0 0 auto 0;
  height: min(28rem, 52vh);
  background: radial-gradient(circle, currentColor .75px, transparent 1.05px) 0 0 / 1.25rem 1.25rem;
  mask-image: radial-gradient(ellipse at 80% 7%, #000 8%, transparent 72%);
  opacity: .18;
}
.cabinet-backdrop::after {
  top: -11rem;
  right: clamp(-12rem, -9vw, -4rem);
  width: clamp(17rem, 40vw, 34rem);
  aspect-ratio: 1;
  border: 1px solid currentColor;
  outline: 1px solid currentColor;
  outline-offset: 1.2rem;
  border-radius: 50%;
  opacity: .18;
  transform: translate(var(--background-x, 0px), var(--background-y, 0px));
  transition: transform .6s ease-out;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
button, summary, .button { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 6vw, 2.25rem); line-height: 1.1; letter-spacing: -.035em; }
h2 { font-size: 1.08rem; line-height: 1.3; letter-spacing: -.012em; }
h3 { font-size: .98rem; line-height: 1.3; }

.shell {
  width: min(100%, 50rem);
  margin: auto;
  padding:
    max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px))
    max(.9rem, env(safe-area-inset-right, 0px), var(--tg-content-safe-area-inset-right, 0px))
    max(2.75rem, calc(1.5rem + env(safe-area-inset-bottom, 0px)), calc(1.5rem + var(--tg-content-safe-area-inset-bottom, 0px)))
    max(.9rem, env(safe-area-inset-left, 0px), var(--tg-content-safe-area-inset-left, 0px));
}
.top {
  position: relative;
  z-index: 3;
  min-height: 4rem;
  display: flex;
  align-items: center;
  gap: .65rem;
  font-weight: 660;
}
.mascot-menu {
  position: relative;
  flex: none;
  border: 0;
}
.mascot-menu > summary {
  display: grid;
  width: 46px;
  min-height: 46px;
  place-items: center;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--surface);
}
.mascot-menu > summary::-webkit-details-marker { display: none; }
.mascot-menu[open] > summary { border-color: var(--accent); background: var(--soft); }
.mascot-avatar, .banner-mascot { display: block; object-fit: contain; }
.mascot-menu[open] .mascot-avatar { animation: mascot-greeting .45s ease-out; }
.mascot-help {
  position: absolute;
  inset: var(--mascot-help-top, calc(100% + .35rem)) auto auto 0;
  width: min(17rem, calc(100vw - 2rem));
  display: grid;
  gap: .25rem;
  padding: .65rem .8rem .25rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: var(--surface);
  color: var(--ink);
  font-size: .87rem;
  font-weight: 450;
}
.mascot-help p { margin: 0; }
.mascot-help .link-button { justify-self: start; }
@keyframes mascot-greeting {
  0%, 100% { transform: translateY(0) rotate(0); }
  35% { transform: translateY(-3px) rotate(-9deg); }
  68% { transform: translateY(0) rotate(5deg); }
}
.cat-stage {
  --cat-size: 3.4rem;
  position: relative;
  width: min(12rem, 100%);
  height: var(--cat-size);
  margin: -.65rem .15rem .55rem auto;
}
.cat-stage::before {
  position: absolute;
  right: .4rem;
  bottom: .2rem;
  left: .4rem;
  height: 1px;
  background: var(--line);
  pointer-events: none;
  content: "";
}
.cat-pet {
  position: absolute;
  left: calc((100% - var(--cat-size)) * var(--cat-position, .07));
  bottom: 0;
  width: var(--cat-size);
  height: var(--cat-size);
  padding: 0;
  border: 0;
  border-radius: .5rem;
  background: transparent;
  transition: left var(--cat-travel, 0ms) linear;
}
.cat-sprite {
  display: block;
  width: 100%;
  height: 100%;
  background: url('/cat-poses.png') 57.142857% 0 / 800% 100% no-repeat;
}
.cat-pet[data-pose="walk"] .cat-sprite { animation: cat-steps .56s steps(1, end) infinite; }
.cat-pet[data-pose="walk"][data-direction="left"] .cat-sprite { transform: scaleX(-1); }
.cat-pet[data-pose="blink"] .cat-sprite { background-position: 71.428571% 0; }
.cat-pet[data-pose="sleep"] .cat-sprite { background-position: 85.714286% 0; }
.cat-pet[data-pose="greet"] .cat-sprite { background-position: 100% 0; }
@keyframes cat-steps {
  0%, 100% { background-position: 0 0; }
  25% { background-position: 14.285714% 0; }
  50% { background-position: 28.571429% 0; }
  75% { background-position: 42.857143% 0; }
}
.top > span { flex: none; white-space: nowrap; }
.identity {
  min-width: 0;
  overflow: hidden;
  margin-left: auto;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .85rem;
  font-weight: 500;
}
.top-actions { display: flex; align-items: center; flex: 0 1 auto; min-width: 0; gap: .4rem; margin-left: auto; }
.theme-menu { position: relative; flex: none; border: 0; padding: 0; }
.theme-menu > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  min-width: 44px;
  padding: .45rem .65rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: var(--surface);
  color: var(--ink);
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  list-style: none;
}
.theme-menu > summary::-webkit-details-marker { display: none; }
.theme-icon {
  width: .88rem;
  height: .88rem;
  flex: none;
  border: 1.4px solid currentColor;
  border-radius: 50%;
  box-shadow: inset .34rem 0 currentColor;
}
.theme-options {
  position: absolute;
  inset: calc(100% + .35rem) 0 auto auto;
  z-index: 1;
  min-width: 10rem;
  display: grid;
  gap: .15rem;
  padding: .3rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--surface);
}
.theme-options button {
  min-height: 44px;
  padding: .45rem .7rem;
  border: 0;
  border-radius: .4rem;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: .88rem;
}
.theme-options button[aria-pressed="true"] {
  background: var(--soft);
  color: var(--accent);
  font-weight: 660;
}

nav {
  position: sticky;
  top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  z-index: 2;
  display: flex;
  gap: .2rem;
  margin: 0 0 1.1rem;
  padding: .15rem 0 .5rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
nav button, .tab-button {
  min-height: 44px;
  border: 0;
  border-radius: .48rem;
  background: transparent;
  color: var(--muted);
  font-weight: 620;
}
nav button {
  min-width: 0;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  padding: .32rem .1rem;
  font-size: clamp(.66rem, 2.9vw, .84rem);
}
.nav-label { max-width: 100%; overflow-wrap: anywhere; line-height: 1.2; }
nav button[aria-current="page"], .tab-button[aria-current="page"] {
  background: var(--soft);
  color: var(--accent);
}
.nav-icon { position: relative; width: 19px; height: 18px; flex: none; }
.nav-icon::before, .nav-icon::after { position: absolute; content: ""; }
.nav-icon--account::before {
  inset: 3px 1px 2px;
  border: 1.4px solid currentColor;
  border-radius: 3px;
}
.nav-icon--account::after {
  width: 4px;
  height: 2px;
  right: 3px;
  top: 8px;
  border-radius: 1px;
  background: currentColor;
}
.nav-icon--invites::before {
  width: 6px;
  height: 6px;
  top: 2px;
  left: 4px;
  border: 1.4px solid currentColor;
  border-radius: 50%;
  box-shadow: 7px 0 0 -1px currentColor;
}
.nav-icon--invites::after {
  width: 11px;
  height: 6px;
  bottom: 2px;
  left: 1px;
  border: 1.4px solid currentColor;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  box-shadow: 6px -1px 0 -2px currentColor;
}
.nav-icon--support::before {
  inset: 2px 1px 4px;
  border: 1.4px solid currentColor;
  border-radius: 4px;
}
.nav-icon--support::after {
  width: 5px;
  height: 4px;
  bottom: 2px;
  left: 5px;
  border-left: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  transform: skewY(-29deg);
}
.nav-icon--info::before {
  inset: 1px 2px 1px 1px;
  border: 1.4px solid currentColor;
  border-radius: 50%;
}
.nav-icon--info::after {
  content: "i";
  inset: 0 1px 0 0;
  font: 700 11px/18px system-ui, sans-serif;
  text-align: center;
}
.nav-icon--admin::before {
  inset: 2px 2px 1px;
  border: 1.4px solid currentColor;
  border-radius: 3px;
}
.nav-icon--admin::after {
  width: 6px;
  height: 1px;
  left: 7px;
  top: 6px;
  background: currentColor;
  box-shadow: 0 3px currentColor, 0 6px currentColor;
}
.tab-button { padding: .4rem .7rem; }

.stack { display: grid; gap: .8rem; }
.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem .85rem;
  min-width: 0;
  margin: .15rem 0 .25rem;
}
.section-heading > * { min-width: 0; }
.summary, .card {
  display: grid;
  min-width: 0;
  gap: .75rem;
  padding: .9rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: var(--surface);
}
.summary { border-top: 3px solid var(--accent); }
.card.compact { gap: .45rem; }
.summary-price {
  font-size: clamp(1.6rem, 6vw, 2.15rem);
  line-height: 1.1;
  font-weight: 730;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}
.summary-status, .inline-status { color: var(--accent); font-size: .85rem; font-weight: 650; }
.summary-detail { color: var(--muted); font-size: .9rem; }
.row, .action-row { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: .83rem; }
.tag {
  display: inline-block;
  max-width: 100%;
  padding: .17rem .4rem;
  border-radius: .35rem;
  background: var(--soft);
  color: var(--accent);
  overflow-wrap: anywhere;
  font-size: .8rem;
  font-weight: 650;
}

.button, .link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: 44px;
  padding: .5rem .75rem;
  border: 1px solid var(--outline);
  border-radius: .48rem;
  background: var(--surface);
  color: var(--ink);
  font-size: .9rem;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
}
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.button.ghost { background: transparent; }
.link-button { border-color: transparent; background: transparent; color: var(--accent); padding-inline: 0; }
.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .45rem .85rem;
  min-height: 44px;
}
.settings-row .link-button { text-align: left; }
form, label.field { display: grid; gap: .5rem; min-width: 0; }
label.field { font-size: .87rem; font-weight: 620; }
input:not([type="checkbox"]), select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .5rem .65rem;
  border: 1px solid var(--outline);
  border-radius: .45rem;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 450;
}
textarea { resize: vertical; min-height: 5.3rem; }
input[readonly] { background: var(--subtle); color: var(--muted); }
.plan-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.option { display: flex; align-items: center; gap: .5rem; min-height: 44px; font-size: .88rem; }
.option input { margin: 0; accent-color: var(--accent); }

.items { margin: 0; padding: 0; list-style: none; }
.items li {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .35rem .65rem;
  min-height: 2.6rem;
  padding: .55rem 0;
}
.items li + li { border-top: 1px solid var(--line); }
.items li > * { min-width: 0; overflow-wrap: anywhere; }
.ticket-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .15rem .35rem;
  border: 0;
  border-radius: .38rem;
  background: transparent;
  color: var(--ink);
  overflow-wrap: anywhere;
  text-align: left;
}
.ticket-row > :first-child { display: grid; min-width: 0; }
.ticket-row > [aria-hidden="true"] { color: var(--accent); font-size: 1.2rem; }
.items li:has(> .ticket-row) { padding-block: .12rem; }
.empty-state { color: var(--muted); font-size: .9rem; }
.thread { display: grid; align-content: start; gap: .55rem; max-height: 46vh; overflow-y: auto; padding: .15rem; }
.bubble {
  justify-self: start;
  max-width: min(95%, 33rem);
  padding: .5rem .68rem;
  border-radius: .45rem;
  background: var(--subtle);
}
.bubble.staff { justify-self: end; background: var(--soft); }
.message { white-space: pre-wrap; overflow-wrap: anywhere; }
details { border-bottom: 1px solid var(--line); }
summary { font-weight: 650; }
details p { margin: .3rem 0 .75rem; }
.card > .faq:last-child { border-bottom: 0; }
.faq summary { min-height: 44px; padding-block: .62rem; }
.notice {
  position: fixed;
  z-index: 4;
  inset: auto .85rem max(.8rem, env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
  width: auto;
  max-width: 38rem;
  margin: auto;
  padding: .72rem .9rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: var(--ink);
  color: var(--bg);
  font-size: .9rem;
}

.banner-dialog {
  width: min(calc(100% - 2rem), 26rem);
  max-height: calc(100% - 2rem);
  margin: auto;
  overflow: auto;
  padding: clamp(1.15rem, 5vw, 1.65rem);
  border: 1px solid var(--line);
  border-radius: .85rem;
  background: var(--surface);
  color: var(--ink);
  isolation: isolate;
}
.banner-dialog::backdrop { background: rgb(12 15 15 / .61); }
.banner-dialog::before {
  position: absolute;
  z-index: -1;
  inset: .7rem .7rem auto auto;
  width: 8rem;
  height: 4.5rem;
  content: "";
  pointer-events: none;
  background: radial-gradient(circle, var(--accent) .7px, transparent 1px) 0 0 / .8rem .8rem;
  mask-image: radial-gradient(ellipse at 82% 20%, #000, transparent 76%);
  opacity: .26;
  transform: translate(var(--background-x, 0px), var(--background-y, 0px));
  transition: transform .6s ease-out;
}
.banner-dialog h2 { margin: .28rem 0 .6rem; font-size: clamp(1.3rem, 5vw, 1.7rem); }
.banner-dialog h2:focus { outline: none; }
.banner-dialog .message { line-height: 1.55; }
.banner-dialog .action-row { justify-content: flex-end; margin-top: 1.05rem; }
.banner-dialog[open] .banner-mascot { animation: mascot-greeting .45s ease-out; }
.banner-mascot { margin-bottom: .3rem; }
.banner-dialog #banner-error { margin-top: .6rem; }
.banner-dialog #banner-next { min-width: 8rem; }

@media (prefers-reduced-motion: reduce) {
  .cabinet-backdrop,
  .cabinet-backdrop::after,
  .banner-dialog::before { transform: none; transition: none; }
  .mascot-menu[open] .mascot-avatar,
  .banner-dialog[open] .banner-mascot,
  .cat-pet[data-pose="walk"] .cat-sprite { animation: none; }
  .cat-pet { transition: none; }
}

@media (hover: hover) {
  .ticket-row:hover, .theme-options button:not([aria-pressed="true"]):hover { background: var(--subtle); }
}

@media (min-width: 38rem) {
  .shell { padding-inline: 1.3rem; }
  .top { min-height: 4.35rem; }
  nav { justify-content: start; gap: .35rem; margin-bottom: 1.3rem; }
  nav button {
    flex: 0 1 auto;
    flex-direction: row;
    gap: .45rem;
    padding: .55rem .75rem;
    font-size: .87rem;
  }
  .summary, .card { padding: 1.08rem; }
}
