:root {
    color-scheme: light;
    --bg: #ffffff;
    --ink: #171717;
    --muted: #737373;
    --line: #e5e5e5;
    --soft: #fafafa;
    --accent: #171717;
    --accent-hover: #333333;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
figure {
    margin: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

small {
    font-size: 0.8rem;
}

.container {
    width: 100%;
    max-width: 880px;
    margin-inline: auto;
    padding-inline: 24px;
}

.main {
    flex: 1;
    padding-block: 36px 72px;
}

/* Header */
.site-head {
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}

.head-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 60px;
}

.brand {
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.nav {
    display: flex;
    gap: 20px;
    margin-inline: auto;
    color: var(--muted);
    font-size: 0.88rem;
}

.nav a:hover {
    color: var(--ink);
}

.head-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.balance {
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.balance strong {
    margin-left: 6px;
    color: var(--ink);
    font-weight: 600;
}

.quiet {
    color: var(--muted);
    font-size: 0.85rem;
}

.quiet:hover {
    color: var(--ink);
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.button:hover:not(:disabled) {
    background: var(--accent-hover);
}

.button:disabled {
    background: #ededed;
    color: #a3a3a3;
    cursor: not-allowed;
}

.button-small {
    min-height: 34px;
    padding: 6px 12px;
    font-size: 0.82rem;
}

.button-full {
    width: 100%;
}

.button-quiet {
    background: #fff;
    color: var(--ink);
    border-color: var(--line);
}

.button-quiet:hover:not(:disabled) {
    background: var(--soft);
}

/* Page headings */
.page-head {
    padding-block: 14px 28px;
}

.eyebrow {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.page-head h1 {
    margin-top: 6px;
    font-size: 1.8rem;
    font-weight: 650;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.lede {
    max-width: 58ch;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

.muted {
    color: var(--muted);
}

.small {
    margin-top: 6px;
    font-size: 0.8rem;
    line-height: 1.5;
}

/* Store */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.section-head h2 {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.section-head span {
    color: var(--muted);
    font-size: 0.78rem;
}

.product-list {
    display: grid;
}

.product-row {
    display: flex;
    align-items: center;
    gap: 24px;
    padding-block: 16px;
    border-bottom: 1px solid var(--line);
    transition: background 0.15s ease;
}

.product-row:hover {
    background: var(--soft);
}

.product-main {
    flex: 1;
    min-width: 0;
}

.product-main h3 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.product-main p {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.product-side {
    display: flex;
    align-items: center;
    gap: 16px;
    white-space: nowrap;
}

.price {
    font-size: 0.9rem;
    font-weight: 600;
}

.arrow {
    color: var(--muted);
    font-size: 0.9rem;
}

.tag {
    display: inline-block;
    padding: 2px 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.tag-owned {
    color: #0f7a5a;
    border-color: #c7eadf;
    background: #f3fbf8;
}

.tag-beta {
    color: #92400e;
    border-color: #fde68a;
    background: #fffbeb;
}

/* Product detail */
.back {
    display: inline-block;
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 0.84rem;
}

.back:hover {
    color: var(--ink);
}

.detail {
    max-width: 620px;
}

.detail-copy h1 {
    margin-top: 6px;
    font-size: 2rem;
    font-weight: 650;
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.detail-description {
    max-width: 54ch;
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.95rem;
}

.price-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 12px;
    margin-block: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.price-large {
    font-size: 1.4rem;
    font-weight: 650;
    letter-spacing: -0.03em;
}

.fee-note {
    color: var(--muted);
    font-size: 0.78rem;
}

.form-error {
    min-height: 20px;
    margin-top: 10px;
    color: #b42318;
    font-size: 0.84rem;
}

/* Auth and error */
.auth {
    display: grid;
    place-items: center;
    min-height: 58vh;
    padding-block: 24px;
}

.auth-inner {
    width: 100%;
    max-width: 360px;
}

.auth-inner.centered {
    text-align: center;
}

.auth-inner h1 {
    font-size: 1.6rem;
    font-weight: 650;
    letter-spacing: -0.03em;
}

.auth-inner > .muted {
    margin-top: 6px;
    font-size: 0.9rem;
}

.auth-inner.centered > .muted {
    margin-bottom: 22px;
}

.form {
    display: grid;
    gap: 14px;
    margin-top: 24px;
}

.field {
    display: grid;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 600;
}

.field small {
    color: var(--muted);
    font-weight: 400;
}

.field input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 400;
}

.field input:focus {
    outline: 2px solid #d4d4d4;
    outline-offset: 1px;
    border-color: #a3a3a3;
}

.switch {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.84rem;
    text-align: center;
}

.switch a {
    color: var(--ink);
    font-weight: 600;
}

/* Referrals */
.sections {
    border-top: 1px solid var(--line);
}

.section-row {
    padding-block: 20px;
    border-bottom: 1px solid var(--line);
}

.label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.code-row code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92rem;
    letter-spacing: 0.02em;
    overflow-wrap: anywhere;
}

.split {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    margin-top: 8px;
}

.split div {
    min-width: 80px;
}

.split span {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
}

.split strong {
    display: block;
    margin-top: 2px;
    font-size: 0.95rem;
    font-weight: 600;
}

.two-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 56px;
}

.stat-value {
    margin-top: 4px;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Orders */
.orders {
    border-top: 1px solid var(--line);
}

.order-head,
.order-row {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) 0.6fr 0.6fr 0.9fr;
    gap: 16px;
    align-items: center;
    padding-block: 12px;
}

.order-head {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
}

.order-row {
    border-bottom: 1px solid var(--line);
    font-size: 0.86rem;
}

.order-row:last-child {
    border-bottom: 0;
}

.order-row .tag {
    margin-left: 8px;
}

.empty {
    color: var(--muted);
    font-size: 0.9rem;
}

.empty a {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Success */
.success {
    max-width: 560px;
    margin-inline: auto;
    padding-block: 48px;
    text-align: center;
}

.success h1 {
    margin-top: 6px;
    font-size: 1.8rem;
    font-weight: 650;
    letter-spacing: -0.04em;
}

.success .muted {
    margin-top: 6px;
}

.flag-box {
    margin-block: 24px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--soft);
}

.flag-box code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

/* API docs */
body.docs-page .main.container {
    max-width: 1180px;
    padding-block: 0 48px;
}

body.docs-page .swagger-ui {
    color: var(--ink);
    font-family: inherit;
}

body.docs-page .swagger-ui .wrapper {
    padding: 0;
}

body.docs-page .swagger-ui .info {
    margin-block: 28px;
}

body.docs-page .swagger-ui .info .title {
    color: var(--ink);
    font-family: inherit;
}

body.docs-page .swagger-ui .info .title small {
    border-radius: 4px;
}

body.docs-page .swagger-ui .scheme-container {
    margin-block: 0 24px;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

body.docs-page .swagger-ui .opblock-tag {
    padding: 12px 10px;
    font-family: inherit;
    font-size: 1.15rem;
}

body.docs-page .swagger-ui .opblock {
    border-radius: 6px;
    box-shadow: none;
}

body.docs-page .swagger-ui .opblock .opblock-summary {
    padding: 6px 10px;
}

body.docs-page .swagger-ui .opblock .opblock-summary-method {
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 700;
}

body.docs-page .swagger-ui .filter .operation-filter-input {
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

body.docs-page .swagger-ui .btn,
body.docs-page .swagger-ui select,
body.docs-page .swagger-ui input,
body.docs-page .swagger-ui textarea {
    font-family: inherit;
}

body.docs-page .swagger-ui .btn {
    min-height: auto;
    border-radius: 4px;
}

body.docs-page .swagger-ui table thead tr th,
body.docs-page .swagger-ui .model-box {
    font-family: inherit;
}

@media (max-width: 680px) {
    body.docs-page .main.container {
        padding-inline: 0;
    }

    body.docs-page .swagger-ui .wrapper {
        padding-inline: 16px;
    }

    body.docs-page .swagger-ui .info {
        margin-block: 20px;
    }
}

/* Footer */
.site-foot {
    border-top: 1px solid var(--line);
}

.foot-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-block: 18px;
    color: var(--muted);
    font-size: 0.78rem;
}

.foot-inner a:hover {
    color: var(--ink);
}

/* Responsive */
@media (max-width: 680px) {
    .container {
        padding-inline: 18px;
    }

    .main {
        padding-block: 26px 56px;
    }

    .head-inner {
        flex-wrap: wrap;
        gap: 8px 16px;
        padding-block: 10px;
    }

    .nav {
        order: 3;
        width: 100%;
        margin-inline: 0;
        gap: 16px;
    }

    .head-right {
        margin-left: auto;
    }

    .page-head h1,
    .detail-copy h1,
    .success h1 {
        font-size: 1.6rem;
    }

    .product-row {
        gap: 16px;
    }

    .product-main p {
        display: none;
    }

    .order-head {
        display: none;
    }

    .order-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 4px 12px;
        padding-block: 14px;
    }

    .order-row > span:nth-child(3) {
        display: none;
    }

    .order-row > span:nth-child(4) {
        grid-column: 1 / -1;
    }

    .two-stats {
        gap: 28px;
    }
}

@media (max-width: 400px) {
    .product-row {
        align-items: flex-start;
    }

    .product-side {
        flex-direction: column;
        align-items: flex-end;
        gap: 4px;
    }
}
