:root {
  --bg: #0d0e10;
  --panel: #121316;
  --panel-2: #17181c;
  --border: #292b30;
  --text: #f2f2f2;
  --secondary: #a7a7aa;
  --muted: #777a80;
  --gold: #d3a752;
  --gold-light: #e6c06a;
  --green: #72c985;
  --red: #e2846a;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% -20%, rgba(211, 167, 82, .12), transparent 36rem),
    var(--bg);
  color: var(--text);
  font: 15px/1.65 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
html.hws-miniapp body,
body.hws-miniapp {
  padding-top: max(env(safe-area-inset-top, 0px), var(--hws-tg-safe-top, 0px));
}
main {
  flex: 1 0 auto;
  padding-bottom: max(env(safe-area-inset-bottom, 0px), var(--hws-tg-safe-bottom, 0px));
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }
button, input { font: inherit; }

.public-nav {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 36px; height: 36px; display: block;
  border: 1px solid rgba(211, 167, 82, .35); border-radius: 10px;
  background: rgba(211, 167, 82, .12);
  object-fit: cover;
}
.brand strong, .brand small { display: block; line-height: 1.25; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.public-nav nav { display: flex; align-items: center; gap: 22px; }
.public-nav nav a { color: var(--secondary); font-size: 13px; font-weight: 500; }
.public-nav nav a:hover { color: var(--text); }
.public-nav .nav-studio { padding: 8px 15px; border: 1px solid var(--border); border-radius: 999px; color: var(--text); }

.config-warning {
  padding: 10px 20px;
  background: rgba(226, 132, 106, .08);
  border-block: 1px solid rgba(226, 132, 106, .22);
  color: #eeb3a3;
  text-align: center;
  font-size: 13px;
}

.shell { width: min(1080px, calc(100% - 32px)); margin: 0 auto; }
.shell-narrow { width: min(820px, calc(100% - 32px)); margin: 0 auto; }
.hero { padding: 76px 0 46px; text-align: center; }
.hero.compact { padding: 58px 0 30px; }
.eyebrow {
  margin: 0 0 13px; color: var(--gold); font-size: 11px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase;
}
.hero h1 { max-width: 820px; margin: 0 auto 16px; font-size: clamp(32px, 6vw, 58px); line-height: 1.08; letter-spacing: -.045em; }
.hero.compact h1 { font-size: clamp(29px, 5vw, 44px); }
.hero p { max-width: 690px; margin: 0 auto; color: var(--secondary); font-size: 16px; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }

.button {
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 20px; border: 1px solid transparent; border-radius: 999px;
  background: linear-gradient(180deg, #e0b85d, #c7953e); color: #0d0e10;
  font-weight: 700; cursor: pointer; transition: transform 120ms ease, opacity 120ms ease;
}
.button:hover { color: #0d0e10; transform: translateY(-1px); }
.button.secondary { background: transparent; border-color: var(--border); color: var(--text); }
.button.secondary:hover { color: var(--text); border-color: rgba(211, 167, 82, .45); }
.button:disabled { cursor: not-allowed; opacity: .46; transform: none; }

.grid { display: grid; gap: 14px; }
.feature-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 58px; }
.feature, .tariff, .panel, .doc-card {
  background: linear-gradient(180deg, rgba(255,255,255,.016), transparent), var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.feature { padding: 22px; }
.feature b { display: block; margin-bottom: 7px; font-size: 14px; }
.feature p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.section { padding: 8px 0 58px; }
.section-heading { margin-bottom: 20px; text-align: center; }
.section-heading h2 { margin: 0 0 7px; font-size: 25px; letter-spacing: -.025em; }
.section-heading p { max-width: 630px; margin: 0 auto; color: var(--muted); font-size: 13px; }
.tariff-grid { grid-template-columns: repeat(4, 1fr); }
.tariff { padding: 25px 21px; display: flex; flex-direction: column; }
.tariff.featured { border-color: rgba(211, 167, 82, .55); box-shadow: 0 18px 50px rgba(0,0,0,.17); }
.tariff-name { font-weight: 700; }
.tariff-desc { min-height: 42px; margin: 8px 0 18px; color: var(--muted); font-size: 12px; }
.tariff-price { font-size: 28px; font-weight: 700; letter-spacing: -.04em; }
.tariff-period { margin-bottom: 20px; color: var(--muted); font-size: 12px; }
.tariff .button { width: 100%; margin-top: auto; }
.tariff-actions { display: grid; gap: 8px; margin-top: auto; }
.tariff-actions .button { margin-top: 0; }
.tariff-error { grid-column: 1/-1; padding: 30px; text-align: center; color: var(--muted); }

.tariff-hero { padding-bottom: 38px; }
.tariff-metrics {
  width: min(760px, 100%);
  margin: 28px auto 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.tariff-metrics div {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.tariff-metrics span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.tariff-metrics b { display: block; font-size: 18px; line-height: 1.3; }
.tariff-section .feature-grid { margin-bottom: 0; }
.tariff-detail-panel { padding: 28px; }
.owner-panel-inline h2, .purchase-panel h2 { margin: 0 0 8px; }
.owner-panel-inline p, .purchase-panel p { margin: 0; color: var(--secondary); }
.owner-panel-inline .button { margin-top: 18px; }
.purchase-panel {
  padding: 30px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  align-items: center;
}

.owner-panel {
  padding: 36px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 30px;
  border-color: rgba(211, 167, 82, .32);
  background: linear-gradient(135deg, rgba(211,167,82,.11), rgba(211,167,82,.018)), var(--panel);
}
.owner-panel h2 { margin: 0 0 8px; font-size: 24px; }
.owner-panel p { max-width: 680px; margin: 0; color: var(--secondary); }
.owner-price { margin-top: 13px; color: var(--gold-light); font-size: 20px; font-weight: 700; }

.doc-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; align-items: start; padding-bottom: 64px; }
.doc-toc { position: sticky; top: 18px; padding: 18px; }
.doc-toc strong { display: block; margin-bottom: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.doc-toc a { display: block; padding: 5px 0; color: var(--secondary); font-size: 12px; }
.doc-card { padding: clamp(24px, 5vw, 48px); }
.doc-card h2 { margin: 34px 0 10px; padding-top: 25px; border-top: 1px solid var(--border); font-size: 19px; letter-spacing: -.015em; }
.doc-card h2:first-child { margin-top: 0; padding-top: 0; border: 0; }
.doc-card h3 { margin: 22px 0 7px; font-size: 15px; }
.doc-card p, .doc-card li { color: var(--secondary); }
.doc-card ul, .doc-card ol { padding-left: 22px; }
.doc-card li { margin: 7px 0; }
.doc-card strong { color: var(--text); }
.doc-meta { margin-bottom: 22px; color: var(--muted); font-size: 12px; }
.notice { padding: 16px 18px; margin: 18px 0; border: 1px solid rgba(211, 167, 82, .28); border-radius: 9px; background: rgba(211, 167, 82, .06); color: var(--secondary); }
.notice.error { border-color: rgba(226,132,106,.3); background: rgba(226,132,106,.06); }

.details { width: 100%; border-collapse: collapse; }
.details th, .details td { padding: 12px 0; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.details th { width: 38%; padding-right: 16px; color: var(--muted); font-size: 12px; font-weight: 500; }
.details td { color: var(--text); }

.redeem-wrap { width: min(620px, calc(100% - 32px)); margin: 0 auto 64px; }
.redeem-card { padding: clamp(24px, 5vw, 38px); }
.redeem-card h2 { margin: 0 0 9px; }
.redeem-card p { color: var(--secondary); }
.gift-wrap { width: min(620px, calc(100% - 32px)); margin: 0 auto 64px; }
.gift-card { padding: clamp(24px, 5vw, 38px); }
.field-label {
  display: block;
  margin: 18px 0 7px;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.select-control,
.text-control {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: #101114;
  color: var(--text);
}
.select-control:focus,
.text-control:focus { border-color: var(--gold); }
.gift-submit { width: 100%; margin-top: 22px; }
.form-row { display: flex; gap: 9px; margin-top: 22px; }
.form-row input {
  min-width: 0; flex: 1; padding: 11px 16px; border: 1px solid var(--border);
  border-radius: 999px; outline: none; background: #101114; color: var(--text);
  font-family: ui-monospace, monospace; text-transform: uppercase; letter-spacing: .08em;
}
.form-row input:focus { border-color: var(--gold); }
.form-hint { margin-top: 9px; color: var(--muted); font-size: 11px; }
.message { display: none; padding: 13px 15px; margin-top: 15px; border-radius: 9px; font-size: 13px; }
.message.show { display: block; }
.message.success { background: rgba(114,201,133,.08); border: 1px solid rgba(114,201,133,.25); color: var(--green); }
.message.error { background: rgba(226,132,106,.08); border: 1px solid rgba(226,132,106,.25); color: var(--red); }

.modal {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px;
  background: rgba(0,0,0,.76); backdrop-filter: blur(8px);
}
.modal.hidden { display: none; }
.modal .panel,
.modal-card {
  max-height: calc(100svh - 32px - env(safe-area-inset-bottom, 0px));
  overflow: auto;
}
[hidden] { display: none !important; }

.miniapp-notice {
  width: min(1120px, calc(100% - 32px));
  margin: 18px auto 0;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(211, 167, 82, .34);
  border-radius: 8px;
  background: rgba(211, 167, 82, .08);
  color: var(--text);
  transition: opacity .45s ease, transform .45s ease;
}

.miniapp-notice.is-hiding {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.miniapp-notice__text {
  display: grid;
  gap: 4px;
}

.miniapp-notice__text b {
  font-size: 14px;
}

.miniapp-notice__text span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.miniapp-notice__text code {
  color: var(--text);
  word-break: break-all;
}

.miniapp-notice__actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.miniapp-notice__copy {
  padding: 9px 12px;
  border: 1px solid rgba(211, 167, 82, .45);
  border-radius: 6px;
  background: rgba(211, 167, 82, .14);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.miniapp-notice__copy:hover {
  background: rgba(211, 167, 82, .2);
}

.miniapp-notice__close {
  min-width: 86px;
  height: 34px;
  padding: 0 12px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 6px;
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.miniapp-notice__close:hover {
  background: rgba(255, 255, 255, .11);
}

@media (max-width: 720px) {
  .miniapp-notice {
    align-items: stretch;
    flex-direction: column;
  }

  .miniapp-notice__actions {
    width: 100%;
  }

  .miniapp-notice__copy {
    flex: 1 1 auto;
    min-width: 0;
  }

  .miniapp-notice__close {
    flex: 0 0 auto;
    min-width: 92px;
    height: 38px;
  }
}
.modal-card { width: min(410px, 100%); padding: 30px; text-align: center; }
.modal-card h2 { margin-top: 0; }
.modal-card p { color: var(--secondary); font-size: 13px; }
.modal-card .button.secondary { margin-top: 15px; }

.status-card { width: min(500px, calc(100% - 32px)); margin: 80px auto; padding: 42px; text-align: center; }
.status-card h1 { margin: 0 0 10px; font-size: 28px; }
.status-card p { color: var(--secondary); }
.status-line { min-height: 24px; margin: 20px 0; color: var(--muted); font-size: 13px; }

.account-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 68px;
}
.account-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.account-head h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.08;
  letter-spacing: -.035em;
}
.account-login {
  padding: clamp(24px, 5vw, 38px);
}
.account-login h2,
.account-panel h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -.015em;
}
.account-login p {
  max-width: 520px;
  margin: 8px 0 22px;
  color: var(--secondary);
}
#telegramWidgetHost {
  min-height: 48px;
}
.account-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  align-items: stretch;
}
.account-panel {
  grid-column: span 4;
  padding: 22px;
}
.account-wide {
  grid-column: span 6;
}
.account-summary {
  border-color: rgba(211, 167, 82, .38);
}
.account-kv {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px 14px;
  margin-top: 16px;
}
.account-kv span,
.account-row span,
.account-panel p {
  color: var(--muted);
  font-size: 12px;
}
.account-kv b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.account-status {
  min-height: 56px;
  margin: 15px 0 18px;
  color: var(--secondary);
  font-size: 16px;
  line-height: 1.45;
}
.account-action {
  width: 100%;
}
.limit-ring {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 12px 0 4px;
}
.limit-ring span {
  color: var(--gold-light);
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.035em;
}
.limit-ring small {
  color: var(--muted);
  font-size: 13px;
}
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-title-row a {
  color: var(--secondary);
  font-size: 12px;
  font-weight: 700;
}
.account-list {
  display: grid;
  gap: 8px;
}
.account-row,
.empty-row {
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.065);
  border-radius: 8px;
  background: rgba(255,255,255,.025);
}
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.account-row div {
  min-width: 0;
}
.account-row b,
.account-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-row b {
  font-size: 13px;
}
.account-row em {
  flex: 0 0 auto;
  color: var(--gold-light);
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}
.account-row-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.account-session-row span {
  max-width: min(620px, 58vw);
}
.empty-row {
  display: grid;
  place-items: center start;
  color: var(--muted);
  font-size: 12px;
}
.compact-button {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .feature-grid, .tariff-grid { grid-template-columns: repeat(2, 1fr); }
  .doc-layout { grid-template-columns: 1fr; }
  .doc-toc { display: none; }
  .account-panel,
  .account-wide { grid-column: span 12; }
  .account-panel:not(.account-wide) { grid-column: span 6; }
}
@media (max-width: 680px) {
  body { min-height: 100svh; }
  main { padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
  .public-nav { padding: 13px 0; align-items: flex-start; }
  .public-nav nav { justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
  .public-nav nav a:not(.nav-studio) { display: none; }
  .hero { padding-top: 52px; }
  .feature-grid, .tariff-grid { grid-template-columns: 1fr; }
  .tariff-metrics, .purchase-panel { grid-template-columns: 1fr; }
  .purchase-panel .button { width: 100%; }
  .tariff-actions,
  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .tariff-actions .button,
  .tariff-actions button,
  .hero-actions .button {
    width: 100%;
  }
  .owner-panel { grid-template-columns: 1fr; padding: 26px; }
  .form-row { flex-direction: column; }
  .details th, .details td { display: block; width: 100%; }
  .details th { padding-bottom: 3px; border-bottom: 0; }
  .details td { padding-top: 0; }
  .account-shell { padding-top: 30px; }
  .account-head { align-items: stretch; flex-direction: column; }
  .account-head .button { width: 100%; }
  .account-grid { grid-template-columns: 1fr; }
  .account-panel,
  .account-panel:not(.account-wide),
  .account-wide { grid-column: 1; }
  .account-kv { grid-template-columns: 1fr; }
  .account-kv b { text-align: left; }
  .panel-title-row { align-items: flex-start; flex-direction: column; }
  .compact-button { width: 100%; }
  .account-row { align-items: flex-start; flex-direction: column; gap: 6px; }
  .account-row-actions { width: 100%; }
  .account-row em { white-space: normal; }
  .account-session-row span { max-width: 100%; white-space: normal; }
}
