/* ===== Design Tokens ===== */
:root {
    /*
     * Primary color source: Telegram-injected CSS variables.
     * Never hardcode a color that Telegram provides — the user may have any theme.
     */
    --bg:       var(--tg-theme-secondary-bg-color,   #F0EEE9); /* page background (the subdued one) */
    --surface:  var(--tg-theme-bg-color,             #FFFFFF); /* cards, sheets, sticky header (the elevated one) */
    --text:     var(--tg-theme-text-color,           #1A1916);
    --text-3:   var(--tg-theme-hint-color,           #A8A49D);
    --accent:   var(--tg-theme-link-color,           #2563EB);
    --btn-bg:   var(--tg-theme-button-color,         #1A1916);
    --btn-text: var(--tg-theme-button-text-color,    #FFFFFF);
    --danger:   var(--tg-theme-destructive-text-color, #DC2626);

    /*
     * Derived tokens — computed from Telegram variables, no hardcoded hex.
     * These automatically adapt to any theme color.
     */
    --surface-2:  color-mix(in srgb, var(--text)   6%, var(--surface)); /* chips, inputs inside cards */
    --border:     color-mix(in srgb, var(--text)   10%, transparent);
    --text-2:     color-mix(in srgb, var(--text)   65%, transparent);

    /*
     * Semantic state colors — Telegram has no equivalents for these.
     * The fixed hues are adjusted for dark mode via a small override block below.
     * Soft (background) variants are always derived from the hue + current --surface.
     */
    --green:       #16A34A;
    --amber:       #D97706;
    --purple:      #7C3AED;
    --green-soft:  color-mix(in srgb, var(--green)  15%, var(--surface));
    --amber-soft:  color-mix(in srgb, var(--amber)  15%, var(--surface));
    --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
    --purple-soft: color-mix(in srgb, var(--purple) 12%, var(--surface));

    /* Spacing (4px grid) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Animation */
    --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
    --dur-fast:    150ms;
    --dur-base:    200ms;
    --dur-medium:  300ms;
    --dur-slow:    400ms;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }

* { -webkit-tap-highlight-color: transparent; }

html { font-size: 15px; }

body {
    font-family: 'Onest', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    padding-bottom: 120px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ===== Page Header ===== */
.page-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* ===== Receipt Header ===== */
.receipt-header {
    background: var(--surface);
    padding: var(--space-5) var(--space-4);
}

.receipt-date {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-3);
    margin-bottom: var(--space-1);
}

.receipt-total {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.03em;
    white-space: nowrap;
    line-height: 1.1;
}

.receipt-total .currency {
    font-size: 22px;
    font-weight: 600;
    margin-left: 3px;
}

.receipt-status { margin-top: var(--space-2); }

/* ===== Status Badge ===== */
.status-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 5px 10px;
    border-radius: 100px;
}

.status-badge.status-open {
    background: var(--green-soft);
    color: var(--green);
}

.status-badge.status-closed {
    background: var(--surface-2);
    color: var(--text-3);
}

.status-badge.status-processing {
    background: var(--amber-soft);
    color: var(--amber);
}

/* ===== Share Button ===== */
.btn-share {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-3);
    border-radius: 8px;
    padding: 4px 10px;
    line-height: 1;
    flex-shrink: 0;
    font-size: 15px;
    transition: opacity var(--dur-fast);
}

.btn-share:active { transform: scale(0.97); opacity: 0.7; }

/* ===== Payer Strip ===== */
.payer-section {
    background: var(--surface);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border);
}

.payer-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.payer-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.btn-payer {
    background: var(--surface-2);
    border: none;
    border-radius: 10px;
    padding: 10px var(--space-4);
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    width: 100%;
    text-align: left;
    transition: opacity var(--dur-fast);
}

.btn-payer:active { transform: scale(0.98); opacity: 0.85; }

/* ===== Avatar System ===== */
.avatar {
    position: relative;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
}

.avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 1;
    transition: opacity var(--dur-fast) ease;
    border-radius: 50%;
}

.avatar img[loading="lazy"] {
    opacity: 0;
}

.avatar img.loaded {
    opacity: 1;
}

/* size — large (payment sheet header) */
.avatar-lg { width: 44px; height: 44px; font-size: 16px; }
/* size — default (payer strip) */
.avatar-md { width: 36px; height: 36px; font-size: 14px; }
/* size — small (claim chips) */
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }

/* ===== Scrollable Content Area ===== */
.content-area {
    padding: var(--space-4);
    padding-bottom: 120px;
}

/* ===== Section Labels ===== */
.section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 0 var(--space-1);
    margin-bottom: var(--space-2);
    margin-top: var(--space-5);
}

.section-label:first-child { margin-top: 0; }

/* ===== Positions List ===== */
.positions-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ===== Position Card ===== */
.position-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    margin-bottom: var(--space-2);
    overflow: hidden;
    transition: border-color var(--dur-base), background-color var(--dur-base);
}

/* Claimed-by-me card tint */
.position-card.card-mine {
    border-color: var(--accent-soft);
    background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}

/* Confirmed card tint */
.position-card.card-confirmed {
    border-color: var(--green-soft);
    background: color-mix(in srgb, var(--green) 4%, var(--surface));
}

.position-row {
    display: flex;
    align-items: center;
    padding: 14px var(--space-4);
    gap: var(--space-2);
}

.position-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}

.position-name-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.position-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
}

.position-comment {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-3);
    background: var(--surface-2);
    border-radius: 8px;
    padding: 2px 8px;
    max-width: 100%;
    word-break: break-word;
}

.position-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-2);
    white-space: nowrap;
    flex-shrink: 0;
    align-self: center;
}

.position-action {
    flex-shrink: 0;
    margin-left: var(--space-1);
    display: flex;
    align-items: center;
}

/* ===== "Взять" Pill Button ===== */
.btn-take {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 100px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    transition: transform var(--dur-fast), filter var(--dur-fast);
}

.btn-take:active {
    transform: scale(0.95);
    filter: brightness(0.88);
}

/* ===== Claim Chips ===== */
.claim-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    animation: claimPulse var(--dur-medium) ease;
}

.claim-chip .chip-name {
    line-height: 1;
}

/* Claimed by me — blue */
.claim-chip.chip-mine {
    background: var(--accent-soft);
    color: var(--accent);
    cursor: pointer;
}

.claim-chip.chip-mine:active { transform: scale(0.97); }

/* Claimed by other — purple */
.claim-chip.chip-other {
    background: var(--purple-soft);
    color: var(--purple);
    cursor: default;
}

/* Confirmed — green */
.claim-chip.chip-confirmed {
    background: var(--green-soft);
    color: var(--green);
    cursor: default;
}

.claim-chip .chip-check {
    font-size: 12px;
    font-weight: 700;
    margin-left: 2px;
}

/* ===== Split Toggle ===== */
.split-toggle-row {
    position: relative;
    padding: 0 var(--space-4) var(--space-3);
}

.btn-split-action {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: opacity var(--dur-fast);
}

.btn-split-action::before {
    content: '';
    position: absolute;
    inset: -8px -16px;
}

.btn-split-action:active { opacity: 0.5; }

/* ===== Split Position Layout ===== */
.split-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 14px var(--space-4) var(--space-2);
    gap: var(--space-2);
}

.split-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    background: var(--surface-2);
    color: var(--text-3);
    padding: 2px 7px;
    border-radius: 6px;
    margin-left: var(--space-1);
    font-weight: 700;
    vertical-align: middle;
}

.split-badge.reversible {
    cursor: pointer;
    color: var(--accent);
    background: var(--accent-soft);
}

.split-parts {
    display: flex;
    flex-direction: column;
}

.split-part-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px var(--space-4) 10px calc(var(--space-4) + var(--space-2));
    border-top: 1px solid var(--border);
}

.split-part-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Part index circle — §6.6 */
.split-part-index {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.split-part-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}

/* ===== Summary Panel (Fixed Footer) ===== */
.summary-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -2px 24px rgba(0, 0, 0, 0.07);
    z-index: 200;
    padding: 14px var(--space-4);
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.summary-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.summary-total {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}

.summary-total .currency {
    font-size: 18px;
    font-weight: 600;
    margin-left: 2px;
}

.summary-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.all-confirmed-msg,
.all-paid-msg {
    text-align: center;
    color: var(--green);
    font-weight: 700;
    font-size: 15px;
    padding: var(--space-2) 0;
}

.summary-empty {
    text-align: center;
    color: var(--text-3);
    font-size: 14px;
    padding: var(--space-2) 0;
}

/* ===== Primary CTA Buttons ===== */
.btn-cta {
    display: block;
    width: 100%;
    height: 54px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--dur-fast), filter var(--dur-fast);
}

.btn-cta:active {
    transform: scale(0.98);
    filter: brightness(0.92);
}

/* Variants */
.btn-cta-default {
    background: var(--btn-bg);
    color: var(--btn-text);
}

.btn-cta-confirm {
    background: var(--accent);
    color: #fff;
}

.btn-cta-paid {
    background: var(--amber);
    color: #fff;
}

.btn-cta-danger {
    background: var(--danger);
    color: #fff;
}

/* ===== Payment Modal ===== */
.payment-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: flex-end;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-medium) ease;
}

.payment-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.payment-sheet {
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    padding: 0 var(--space-5) var(--space-5);
    padding-bottom: max(var(--space-5), env(safe-area-inset-bottom));
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    transform: translateY(100%);
    transition: transform var(--dur-medium) var(--ease-spring);
}

.payment-overlay.visible .payment-sheet {
    transform: translateY(0);
}

/* Drag handle */
.sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px auto var(--space-5);
    flex-shrink: 0;
}

/* Payer row in sheet */
.payment-payer-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-1);
}

.payment-meta-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    margin-bottom: 2px;
}

.payment-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

/* Payment fields */
.payment-field {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px var(--space-4);
    cursor: pointer;
    user-select: none;
    transition: opacity var(--dur-fast);
}

.payment-field:active { opacity: 0.7; }

.payment-field.copied { background: var(--green-soft); }

.payment-field-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    margin-bottom: 3px;
}

.payment-field-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.payment-copy-hint {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 3px;
    transition: color var(--dur-fast);
}

.payment-field.copied .payment-copy-hint { color: var(--green); }

.payment-comment-bubble {
    background: var(--surface-2);
    border-radius: 10px;
    padding: 10px var(--space-3);
    font-size: 13px;
    color: var(--text-3);
    font-style: italic;
    pointer-events: none;
}

/* Divider with text */
.payment-divider {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-3);
    font-size: 12px;
    font-weight: 500;
    margin: var(--space-1) 0;
}

.payment-divider::before,
.payment-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Bank buttons — §6.7 */
.payment-banks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.btn-bank {
    height: 48px;
    border: none;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--dur-fast), filter var(--dur-fast);
    padding: 0;
}

.btn-bank:active {
    transform: scale(0.97);
    filter: brightness(0.92);
}

.btn-tbank { background: #000000; }
.btn-sber  { background: #21A038; }

.bank-logo-img { width: 36px; height: 36px; object-fit: contain; display: block; }

/* ===== Profile / Index Page ===== */
.profile-header {
    background: var(--surface);
    padding: var(--space-5) var(--space-4) var(--space-4);
    border-bottom: 1px solid var(--border);
}

.profile-username {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-3);
}

/* Segmented control */
.seg-control {
    display: flex;
    background: var(--surface-2);
    border-radius: 10px;
    padding: 3px;
    gap: 3px;
    margin-top: var(--space-3);
}

.seg-btn {
    flex: 1;
    border: none;
    border-radius: 8px;
    padding: 7px;
    font-size: 14px;
    font-weight: 600;
    background: transparent;
    color: var(--text-3);
    transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
    font-family: inherit;
}

.seg-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* Form cards (used on profile page) */
.form-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: var(--space-4);
    margin-bottom: var(--space-2);
}

.form-card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    margin-bottom: var(--space-3);
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-bottom: var(--space-3);
}

.form-field:last-child { margin-bottom: 0; }

.form-field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
}

.form-field input {
    background: var(--surface-2);
    color: var(--text);
    border: 1.5px solid transparent;
    border-radius: 10px;
    padding: 12px var(--space-3);
    font-size: 15px;
    font-weight: 400;
    font-family: inherit;
    outline: none;
    transition: border-color var(--dur-fast);
    width: 100%;
}

.form-field input:focus {
    border-color: var(--accent);
}

.form-field input::placeholder { color: var(--text-3); }

.form-hint {
    font-size: 12px;
    color: var(--text-3);
    margin-top: var(--space-1);
}

/* Subscription cards */
.sub-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: var(--space-4);
    margin-bottom: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.sub-tier-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sub-tier-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.sub-meta {
    display: flex;
    gap: var(--space-4);
}

.sub-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sub-meta-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
}

.sub-meta-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.sub-chats-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: var(--space-1);
}

.sub-chat-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sub-chat-item {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.sub-empty {
    font-size: 13px;
    color: var(--text-3);
}

.saved-msg {
    text-align: center;
    color: var(--green);
    font-size: 14px;
    font-weight: 600;
    padding: var(--space-2) 0;
    animation: fadeSlide var(--dur-base) var(--ease-out);
}

/* ===== Animations ===== */
@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes claimPulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes flashBg {
    0%   { background-color: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
    100% { background-color: var(--surface); }
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.anim-in {
    animation: fadeSlide var(--dur-base) var(--ease-out);
}

.flash-highlight {
    animation: flashBg 0.6s var(--ease-out);
}

.position-card.stagger-1 { animation: cardIn var(--dur-slow) var(--ease-out) 50ms both; }
.position-card.stagger-2 { animation: cardIn var(--dur-slow) var(--ease-out) 100ms both; }
.position-card.stagger-3 { animation: cardIn var(--dur-slow) var(--ease-out) 150ms both; }
.position-card.stagger-4 { animation: cardIn var(--dur-slow) var(--ease-out) 200ms both; }
.position-card.stagger-5 { animation: cardIn var(--dur-slow) var(--ease-out) 250ms both; }

/*
 * Dark mode: only the 3 fixed semantic hues need adjustment.
 * Everything else (--surface, --surface-2, soft variants, border…) derives
 * automatically from Telegram-provided variables.
 */
@media (prefers-color-scheme: dark) {
    :root { --green: #22C55E; --amber: #FBBF24; --purple: #A78BFA; }
}
[data-theme="dark"] {
    --green: #22C55E; --amber: #FBBF24; --purple: #A78BFA;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Toast ===== */
.toast-bar {
    position: fixed;
    bottom: calc(var(--summary-h, 120px) + 8px);
    left: var(--space-4);
    right: var(--space-4);
    background: var(--surface);
    color: var(--text);
    border-radius: 12px;
    padding: 12px var(--space-4);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    font-size: 14px;
    font-weight: 600;
    z-index: 250;
    border-left: 3px solid var(--accent);
    animation: fadeSlide var(--dur-base) var(--ease-out);
    pointer-events: none;
}

.toast-bar.toast-error { border-left-color: var(--danger); }
.toast-bar.toast-success { border-left-color: var(--green); }

/* ===== TOS Page ===== */
.tos-body {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-2);
}

.tos-body p { margin: 0 0 var(--space-4); }

.tos-body h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: var(--space-6) 0 var(--space-3);
}

.tos-body h2:first-child { margin-top: 0; }

.tos-body a {
    color: var(--accent);
    text-decoration: none;
}

.tos-body a:hover { text-decoration: underline; }

.tos-meta {
    font-size: 12px;
    color: var(--text-3);
    margin-bottom: var(--space-5) !important;
}

/* ===== Edit Toggle Button ===== */
.btn-edit {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-3);
    border-radius: 8px;
    padding: 4px 10px;
    line-height: 1;
    flex-shrink: 0;
    font-size: 15px;
    transition: color var(--dur-fast), border-color var(--dur-fast);
}

.btn-edit:active { transform: scale(0.97); opacity: 0.7; }

body.edit-mode .btn-edit {
    color: var(--accent);
    border-color: var(--accent);
}

/* ===== Edit Mode State ===== */
body.edit-mode .summary-panel { display: none; }

body.edit-mode .add-position-card { display: flex; }

/* Editable cards get an amber outline */
body.edit-mode .position-card.is-editing {
    border-color: var(--amber);
    background: var(--amber-soft);
}

/* Locked cards (have claims) get muted */
body.edit-mode .position-card:not(.is-editing) {
    opacity: 0.55;
    pointer-events: none;
}

/* ===== Edit Card Inner Layout ===== */
.edit-card-inner {
    padding: 14px var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}

.edit-fields {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.edit-input {
    background: var(--surface-2);
    border: 1.5px solid transparent;
    border-radius: 8px;
    padding: 7px 10px;
    width: 100%;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color var(--dur-fast);
    -webkit-appearance: none;
}

.edit-input:focus {
    border-color: var(--accent);
}

.edit-input.edit-price {
    width: 90px;
    flex-shrink: 0;
    text-align: right;
}

.edit-price-row {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.edit-price-row .edit-comment {
    flex: 1;
    min-width: 0;
}

.edit-split-note {
    font-size: 12px;
    color: var(--text-3);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== Delete Button ===== */
.btn-delete-position {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--danger);
    font-size: 17px;
    padding: var(--space-1);
    line-height: 1;
    opacity: 0.7;
    transition: opacity var(--dur-fast);
    margin-top: 2px;
}

.btn-delete-position:active { opacity: 1; transform: scale(0.93); }

/* ===== Add Position Card ===== */
.add-position-card {
    display: none;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    border: 1.5px dashed var(--border);
    border-radius: 16px;
    padding: 14px var(--space-4);
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: var(--space-2);
    background: transparent;
    transition: background var(--dur-fast), border-color var(--dur-fast);
}

.add-position-card:active { background: var(--accent-soft); }

/* ===== New Position Form Card ===== */
.new-position-form {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.new-position-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    padding: 0 var(--space-4) var(--space-3);
}

.btn-new-cancel {
    background: var(--surface-2);
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
    cursor: pointer;
}

.btn-new-confirm {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: opacity var(--dur-fast);
}

.btn-new-confirm:disabled { opacity: 0.4; }
