:root {
  color-scheme: light dark;
  font-family: system-ui, "Segoe UI", sans-serif;
  --canvas: #f8f4ed;
  --surface: #fffdfa;
  --control: #faf6f0;
  --ink: #28201c;
  --muted: #675852;
  --line: color-mix(in srgb, var(--ink) 15%, transparent);
  --accent: #9e411f;
  --accent-hover: #873719;
  --accent-ink: #873719;
  --focus: #c56b45;
  --soft: color-mix(in srgb, #d37149 17%, var(--surface));
  --success-bg: #e6f1e9;
  --success-ink: #255537;
  --warning-bg: #fbefd4;
  --warning-ink: #634813;
  --error-bg: #fce9e6;
  --error-ink: #8c2726;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #1e252c;
    --surface: #262e36;
    --control: #1f272e;
    --ink: #f4f6f8;
    --muted: #aebac5;
    --accent-ink: #ffb995;
    --focus: #e58c65;
    --success-bg: #244234;
    --success-ink: #bce5c7;
    --warning-bg: #403426;
    --warning-ink: #f9d495;
    --error-bg: #452c30;
    --error-ink: #ffc2be;
  }
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable both-edges; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
main { width: min(100% - 2rem, 64rem); margin: 0 auto 3rem; }
h1, h2, p { margin: 0; }
p { line-height: 1.55; }
h1, h2, legend { line-height: 1.2; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.5rem, 4vw, 2.3rem); letter-spacing: -.025em; }
h2, legend { font-size: 1.05rem; font-weight: 680; }
a { color: var(--accent-ink); text-underline-offset: .18em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: .8rem 1rem; min-height: 4.7rem; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: .65rem; min-width: 0; color: inherit; font-weight: 720; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; flex: 0 0 2.55rem; height: 2.55rem; border-radius: .8rem;
  color: #fff; background: var(--accent); font: 700 1.25rem ui-monospace, Consolas, monospace;
}
.brand > span:last-child { overflow-wrap: anywhere; }
.site-language { position: relative; z-index: 1; flex: none; font-size: .9rem; }
.language-flag {
  display: inline-block; flex: 0 0 1.125rem; width: 1.125rem; height: .75rem; border-radius: .15rem;
  box-shadow: 0 0 0 1px var(--line);
  background: url('/language-flags.png') no-repeat var(--flag-position, 0%) center / 500% 100%;
}
.language-flag--ru { --flag-position: 25%; }
.language-flag--zh { --flag-position: 50%; }
.language-flag--fr { --flag-position: 75%; }
.language-flag--de { --flag-position: 100%; }
.site-language > summary {
  display: flex; align-items: center; gap: .45rem; min-height: 2.75rem; padding: .4rem .65rem;
  list-style: none; border: 1px solid var(--line); border-radius: .7rem; background: var(--surface); font-weight: 650;
}
.site-language > summary::-webkit-details-marker { display: none; }
.site-language > summary::after {
  content: ''; width: .38rem; height: .38rem; border: solid var(--muted); border-width: 0 1px 1px 0;
  transform: translateY(-2px) rotate(45deg);
}
.site-language[open] > summary { background: var(--soft); }
.site-language[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.site-language ul {
  position: absolute; inset: calc(100% + .4rem) 0 auto auto; min-width: 9.4rem; width: max-content; margin: 0;
  padding: .25rem; list-style: none; border: 1px solid var(--line); border-radius: .8rem;
  background: var(--surface); box-shadow: 0 .45rem 1.25rem #19141038;
}
.site-language a {
  display: flex; align-items: center; gap: .65rem; min-height: 2.75rem; padding: .45rem .6rem;
  border-radius: .5rem; color: var(--ink); text-decoration: none;
}
.site-language a:hover, .site-language a[aria-current] { background: var(--soft); }
.site-language a[aria-current] { font-weight: 680; }

.hero { margin: 1.65rem 0 1.25rem; }
.hero p { max-width: 43rem; margin-top: .55rem; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.order-toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .55rem;
  margin-bottom: .85rem;
}
.price, .topic-price, .order-reference code { font-variant-numeric: tabular-nums; }

.checkout-grid, .order-grid {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; gap: .9rem;
}
.order-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.checkout-fields { display: grid; gap: .9rem; min-width: 0; }
.panel { min-width: 0; padding: clamp(.8rem, 2.6vw, 1.2rem); border: 1px solid var(--line); border-radius: .95rem; background: var(--surface); }
.checkout-summary h2 { font-size: .9rem; color: var(--muted); }
.price { margin: .25rem 0 .5rem; font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.15; font-weight: 740; overflow-wrap: anywhere; }
.price span { font-size: .9rem; color: var(--muted); }
.price-currency { display: inline-flex; align-items: center; gap: .3rem; vertical-align: .07em; }
.price-currency .currency-icon { flex: none; width: 1.15rem; height: 1.15rem; }
.checkout-usd { margin-inline-start: .4rem; padding-inline-start: .55rem; border-inline-start: 1px solid var(--line); white-space: nowrap; }
.summary-actions { display: grid; gap: .75rem; margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.summary-actions button { width: 100%; }
.hint { color: var(--muted); font-size: .9rem; }

fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
legend { padding: 0; margin-bottom: .75rem; }
.topic-options, .payment-options { display: grid; gap: .55rem; }
.payment-options { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); }
.option {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .5rem .65rem;
  min-width: 0; min-height: 3.6rem; padding: .62rem .7rem; border: 1px solid var(--line); border-radius: .75rem;
  background: var(--control); cursor: pointer;
}
.option input { grid-area: 1 / 3; width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--accent); }
.option:hover, .option:has(input:checked) { background: var(--soft); }
.option:has(input:checked) { border-color: var(--focus); }
.option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.option input:focus-visible { outline-offset: 2px; }
.option strong, .option small { display: block; overflow-wrap: anywhere; }
.option strong { line-height: 1.28; font-size: .96rem; }
.option small { color: var(--muted); font-size: .85rem; line-height: 1.45; white-space: pre-wrap; }
.service-icon {
  display: grid; grid-area: 1 / 1; place-items: center; width: 2.45rem; height: 2.45rem; border-radius: .68rem;
  background: var(--soft); font-size: 1.1rem; font-weight: 700;
}
.currency-icon { display: block; grid-area: 1 / 1; width: 1.95rem; height: 1.95rem; object-fit: contain; }
.topic-details { grid-area: 1 / 2; min-width: 0; }
.topic-details { display: flex; align-items: center; justify-content: space-between; gap: .38rem .75rem; }
.topic-price { flex: none; display: grid; gap: .15rem; text-align: end; color: var(--muted); font-size: .84rem; font-weight: 650; line-height: 1.2; white-space: nowrap; }
.topic-price > span:last-child { font-weight: 500; }
.currency-option input { z-index: 1; align-self: start; margin-top: .15rem; }
.currency-details { display: grid; grid-area: 1 / 2 / 2 / -1; gap: .15rem; min-width: 0; }
.currency-details strong { padding-inline-end: 1.45rem; }
.topic-content { display: grid; grid-column: 1 / -1; gap: .55rem; padding: .15rem 0 .15rem; }
.topic-option:not(:has(input:checked)) .topic-content { display: none; }
.service-photo { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 17rem; object-fit: cover; border-radius: .55rem; }
.linked-service { display: grid; gap: .75rem; }
.linked-service p { white-space: pre-wrap; overflow-wrap: anywhere; }
.linked-heading { display: flex; align-items: center; gap: .66rem; }
.linked-heading .service-icon { flex: none; }
.linked-heading .topic-details { flex: 1; }

form:not(.checkout-grid) { display: grid; gap: .65rem; }
input, textarea, button { font: inherit; }
input:not([type=checkbox]):not([type=radio]), textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: .62rem;
  padding: .7rem; color: var(--ink); background: var(--control);
}
textarea { resize: vertical; }
.check { display: flex; align-items: flex-start; gap: .55rem; font-size: .92rem; cursor: pointer; }
.check input { flex: none; margin: .2rem 0 0; accent-color: var(--accent); }
summary { cursor: pointer; }
.terms { border: 1px solid var(--line); border-radius: .7rem; padding: .65rem .75rem; background: var(--control); }
.terms summary { font-size: .94rem; font-weight: 650; }
.terms p { margin-top: .6rem; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font-size: .9rem; }
button, .action-link, .quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; width: fit-content; min-height: 2.75rem;
  border: 1px solid transparent; border-radius: .65rem; padding: .6rem .9rem; background: var(--accent);
  color: white; cursor: pointer; font-weight: 670; text-align: center; text-decoration: none;
}
button:hover, .action-link:hover { background: var(--accent-hover); }
button:disabled { opacity: .65; cursor: default; }
.quiet { border-color: var(--line); background: var(--control); color: var(--ink); font-size: .88rem; padding-inline: .67rem; }
.quiet:hover { background: var(--soft); }
.catalog-back { background: var(--surface); }
.catalog-back span { font-size: 1.08rem; }
.order-reference { background: var(--surface); gap: .5rem; }
.order-reference-label { color: var(--muted); font-size: .8rem; }
.order-reference code { font-size: .95rem; font-weight: 700; letter-spacing: .015em; white-space: nowrap; }
.order-copy-mark { width: 1rem; color: var(--muted); font-size: 1.05rem; line-height: 1; }
.order-actions { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin-top: .9rem; }
.invoice-status { display: flex; align-items: center; justify-content: space-between; gap: .55rem; }
.invoice-status .refresh { flex: 0 0 2.75rem; padding: 0; font-size: 1.2rem; line-height: 1; }
.status { width: fit-content; border: 1px solid var(--line); border-radius: .55rem; padding: .32rem .6rem; background: var(--soft); font-size: .86rem; font-weight: 650; }
.status[data-status=paid], .status[data-status=completed] { background: var(--success-bg); color: var(--success-ink); }
.status[data-status=payment_review], .payment-note { background: var(--warning-bg); color: var(--warning-ink); }
.payment { display: grid; gap: .7rem; margin: 1rem 0; }
.payment > div + div { padding-top: .65rem; border-top: 1px solid var(--line); }
dt { color: var(--muted); font-size: .88rem; }
dd { min-width: 0; margin: .24rem 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .65rem; overflow-wrap: anywhere; }
.payment .price { margin: 0; }
.invoice-base-price { display: block; margin-top: .45rem; font-size: .9rem; }
.invoice-base-label { margin-inline-end: .3rem; color: var(--muted); }
.invoice-amount-hint { margin-top: .35rem; }
code { min-width: 0; font-size: .9rem; overflow-wrap: anywhere; }
.payment-note, .error { padding: .7rem .8rem; border-radius: .65rem; }
.payment-note { font-size: .9rem; }
.txid-form, .new-invoice { margin-top: .8rem; }
.payment-discovery { margin-top: .65rem; }
.new-invoice { display: inline-block; }
.txid-form label, .conversation label { font-weight: 650; }
.txid-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; }
.conversation h2, .error { margin-bottom: .8rem; }
.error { background: var(--error-bg); color: var(--error-ink); }
.transcript { display: grid; gap: .5rem; list-style: none; margin: 0 0 .9rem; padding: 0; }
.transcript li { width: fit-content; max-width: min(100%, 24rem); padding: .55rem .7rem; border: 1px solid var(--line); border-radius: .7rem; background: var(--control); overflow-wrap: anywhere; }
.transcript .transcript-operator { justify-self: end; background: var(--soft); }
.transcript li strong { color: var(--muted); font-size: .83rem; }
.transcript p { margin-top: .22rem; white-space: pre-wrap; }
.result-panel { max-width: 35rem; margin-top: 1.25rem; }
.result-panel p { margin-top: .65rem; color: var(--muted); }

@media (max-width: 52rem) {
  .checkout-grid, .order-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 32rem) {
  main { width: calc(100% - 1.5rem); margin-bottom: 2rem; }
  .site-header { min-height: 4.25rem; }
  .hero { margin: 1.2rem 0 1rem; }
  .payment-options { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.75rem), 1fr)); }
  .currency-option { gap: .33rem; padding-inline: .48rem; }
  .currency-option input { width: .9rem; height: .9rem; }
  .currency-icon { width: 1.65rem; height: 1.65rem; }
  .txid-entry { grid-template-columns: minmax(0, 1fr); }
  .txid-entry button { width: 100%; }
}
@media (max-width: 23rem) {
  .topic-details { flex-wrap: wrap; }
  .order-reference-label { display: none; }
}
