:root {
    --radius-xs: 10px;
    --radius-sm: 14px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --space-1: 0.4rem;
    --space-2: 0.7rem;
    --space-3: 1rem;
    --space-4: 1.35rem;
    --space-5: 1.8rem;
    --space-6: 2.4rem;
    --panel-bg: color-mix(in srgb, var(--surface-solid) 82%, transparent);
    --panel-line: color-mix(in srgb, var(--line) 80%, transparent);
    --soft-highlight: color-mix(in srgb, var(--primary) 14%, transparent);
    --scrollbar-track: color-mix(in srgb, var(--surface-solid) 84%, transparent);
    --scrollbar-thumb: color-mix(in srgb, var(--primary) 55%, #6b7fb2);
    --scrollbar-thumb-hover: color-mix(in srgb, var(--primary-strong) 72%, #5f74a7);
}

html[data-theme="light"] {
    --panel-bg: color-mix(in srgb, #ffffff 84%, transparent);
    --scrollbar-track: color-mix(in srgb, #e8eefc 78%, transparent);
    --scrollbar-thumb: color-mix(in srgb, var(--primary) 42%, #9eb0d8);
    --scrollbar-thumb-hover: color-mix(in srgb, var(--primary-strong) 56%, #8ca2d2);
}

html,
body {
    max-width: 100%;
    overflow-x: clip;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

body {
    padding: 0 var(--space-3) var(--space-5);
    animation: ambient-gradient 12s ease-in-out infinite alternate;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-shell {
    width: min(1180px, 100%);
    margin: 14px auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    border-radius: var(--radius-lg);
    padding: 0.95rem 1.15rem;
    position: sticky;
    top: 14px;
    z-index: 20;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: blur(14px);
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
}

.content-wrap {
    margin-top: 14px;
    flex: 1;
}

.hero {
    border: 1px solid var(--panel-line);
    border-radius: var(--radius-lg);
    background: linear-gradient(155deg, var(--panel-bg), color-mix(in srgb, var(--panel-bg) 88%, var(--soft-highlight)));
    box-shadow: var(--shadow);
    padding: clamp(1.15rem, 2vw, 2rem);
}

.hero-title {
    margin: 0;
    font-size: clamp(1.55rem, 4vw, 2.2rem);
    line-height: 1.3;
}

.hero-subtitle {
    margin: var(--space-2) 0 0;
    color: var(--text-muted);
    max-width: 62ch;
}

.hero-pills {
    margin-top: var(--space-4);
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.hero-pill {
    border: 1px solid var(--panel-line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface-solid) 68%, transparent);
    padding: 0.4rem 0.8rem;
    font-size: 0.83rem;
    color: var(--text-muted);
}

.panel {
    border-radius: var(--radius-lg);
    background: var(--panel-bg);
}

.panel-body {
    padding: clamp(1rem, 2.4vw, 1.8rem);
}

.site-footer {
    border-top-color: var(--panel-line);
    margin-top: var(--space-4);
}

.footer-paste-count {
    font-size: 1.06rem;
    font-weight: 820;
}

.composer {
    margin-top: var(--space-3);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.composer-grid {
    display: grid;
    gap: var(--space-4);
}

.section-heading {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 750;
}

.section-heading-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.field {
    gap: 0.55rem;
}

.hint {
    font-size: 0.8rem;
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--surface-solid) 86%, transparent);
}

textarea {
    min-height: clamp(220px, 38vh, 310px);
}

.split {
    display: grid;
    grid-template-columns: 1fr minmax(260px, 330px);
    gap: var(--space-4);
}

.side-stack {
    display: grid;
    gap: var(--space-3);
    align-content: start;
}

.option-card {
    border: 1px solid var(--panel-line);
    border-radius: var(--radius-md);
    padding: 0.9rem;
    background: color-mix(in srgb, var(--surface-solid) 75%, transparent);
    display: grid;
    gap: 0.5rem;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    cursor: pointer;
}

.switch-row-copy {
    display: grid;
    gap: 0.15rem;
}

.switch-row-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 730;
}

.switch-row-title-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
}

.option-icon {
    width: 1.6rem;
    height: 1.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    flex: 0 0 auto;
}

.option-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.switch-row-desc {
    margin: 0;
    font-size: 0.79rem;
    color: var(--text-muted);
}

.switch {
    --switch-width: 46px;
    --switch-height: 28px;
    position: relative;
    width: var(--switch-width);
    height: var(--switch-height);
    flex: 0 0 auto;
}

.switch input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(137, 151, 187, 0.45);
    transition: background 0.2s ease;
}

.switch-track::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    top: 3px;
    right: 3px;
    background: #fff;
    transition: transform 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.26);
}

.switch input:checked+.switch-track {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.switch input:checked+.switch-track::after {
    transform: translateX(-18px);
}

.toggle-panel {
    display: none;
    margin-top: 0.45rem;
}

.toggle-panel.is-visible {
    display: grid;
    gap: 0.45rem;
}

.visually-hidden-file-input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.file-picker {
    border: 1px dashed var(--panel-line);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
    padding: 0.72rem;
    display: grid;
    justify-items: center;
    gap: 0.2rem;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.file-picker:hover {
    border-color: color-mix(in srgb, var(--primary) 65%, var(--panel-line));
    background: color-mix(in srgb, var(--surface-solid) 72%, transparent);
}

.file-picker-cta {
    font-weight: 700;
    font-size: 0.9rem;
}

.file-picker-caption {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.file-picker-selected {
    margin: 0;
    color: var(--text-muted);
    word-break: break-word;
}

.file-picker.is-dragover,
#attachment_panel.is-dragover .file-picker {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, var(--surface-solid));
}

body.is-file-dragging #attachment_panel.is-visible {
    outline: 2px dashed color-mix(in srgb, var(--primary) 55%, transparent);
    outline-offset: 4px;
    border-radius: var(--radius-sm);
}

.upload-progress {
    margin-top: 0.55rem;
    padding: 0.65rem 0.72rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--panel-line);
    background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
}

.upload-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
    font-size: 0.78rem;
}

.upload-progress-label {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-progress-percent {
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}

.upload-progress-track {
    block-size: 0.42rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 22%, transparent);
    overflow: hidden;
}

.upload-progress-fill {
    block-size: 100%;
    border-radius: inherit;
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--primary) 85%, #fff),
        var(--primary)
    );
    transition: width 0.12s ease-out;
}

.btn-primary:disabled {
    opacity: 0.72;
    cursor: not-allowed;
}

.btn-primary {
    border-radius: 13px;
}

.btn-block {
    width: 100%;
}

.btn-inline {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline: 1rem;
}

.success-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.6rem;
}

.success-url-input {
    flex: 1;
    min-width: min(100%, 12rem);
}

/* Explicit type="text" on the element so global input[type="text"] rules apply; these overrides keep theme inside the success alert. */
input.success-url-input {
    background: var(--surface-solid);
    color: var(--text);
    border: 1px solid var(--panel-line);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 1px 2px color-mix(in srgb, var(--text) 4%, transparent);
    font: inherit;
    padding: 11px 13px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input.success-url-input::placeholder {
    color: var(--text-muted);
}

input.success-url-input:focus {
    border-color: var(--primary);
    box-shadow:
        inset 0 1px 2px color-mix(in srgb, var(--text) 4%, transparent),
        0 0 0 3px color-mix(in srgb, var(--primary) 28%, transparent);
    outline: none;
}

.copy-url-feedback {
    margin: 0.4rem 0 0;
    padding: 0;
    min-height: 1.35em;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary-strong);
    text-align: right;
}

.copy-url-feedback[hidden] {
    display: none !important;
}

.success-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.success-row .btn-secondary {
    white-space: nowrap;
}

.qr-toggle-btn .icon-qr {
    width: 1.15rem;
    height: 1.15rem;
    display: block;
}

.view-hero {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-3);
    align-items: center;
}

/* Paste view: one row — title/meta on the right (RTL start), share URL on the left (RTL end). */
.view-hero.view-hero--split {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: clamp(var(--space-3), 3vw, var(--space-5));
}

.view-hero-top {
    flex: 1 1 auto;
    min-width: min(100%, 16rem);
    text-align: right;
}

.view-hero-share {
    flex: 0 1 26rem;
    min-width: min(100%, 15.5rem);
    border-top: none;
    padding-top: 0;
    margin-top: 0;
    text-align: left;
}

.view-hero-share-feedback {
    margin-top: 0.35rem;
    text-align: right;
    direction: rtl;
}

.view-paste-share-title {
    display: block;
    font-weight: 730;
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
    color: var(--text);
    text-align: right;
    direction: rtl;
}

.paste-qr--in-hero {
    margin-top: 0.65rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--panel-line);
}

.paste-qr--in-hero .paste-qr-caption {
    text-align: center;
}

.paste-qr--in-hero .paste-qr-img {
    max-width: 200px;
}

.paste-body-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.paste-in-pre-toolbar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 90%, transparent);
    backdrop-filter: blur(12px);
}

.paste-in-pre-feedback {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary-strong);
    flex: 1 1 auto;
    text-align: right;
    direction: rtl;
    min-height: 1.25em;
    margin: 0;
}

.paste-in-pre-feedback[hidden] {
    display: none !important;
}

.paste-content-editor .paste-pre-block {
    margin: 0;
    padding: 14px 18px 18px;
}

.meta-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.8rem;
}

.meta-chip {
    border: 1px solid var(--panel-line);
    border-radius: 999px;
    padding: 0.28rem 0.72rem;
    font-size: 0.76rem;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--surface-solid) 72%, transparent);
}

.paste-content {
    border-radius: var(--radius-lg);
    max-height: min(68vh, 760px);
    overflow: auto;
    overscroll-behavior: contain;
}

.attachment-item {
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
}

.error-card {
    margin-top: 42px;
}

.unlock-panel {
    margin-top: 14px;
}

.error-cta {
    margin-top: 1rem;
}

@media (max-width: 980px) {
    .split {
        grid-template-columns: 1fr;
    }

    .side-stack {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    body {
        padding-inline: 0.75rem;
    }

    .site-shell {
        width: 100%;
        margin-top: 14px;
    }

    .topbar {
        border-radius: 16px;
        top: 8px;
    }

    .brand-subtitle {
        display: none;
    }

    .hero-pills {
        gap: 0.5rem;
    }

    .side-stack {
        grid-template-columns: 1fr;
    }

    .view-hero {
        grid-template-columns: 1fr;
    }

    .view-hero.view-hero--split {
        flex-direction: column;
        flex-wrap: wrap;
        align-items: stretch;
    }

    .view-hero-top {
        min-width: 0;
        text-align: right;
    }

    .view-hero-share {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
        border-top: 1px solid var(--panel-line);
        padding-top: var(--space-3);
        margin-top: var(--space-1);
    }

    .paste-content {
        max-height: 62vh;
    }

    .success-row {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .success-url-input {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
    }

    .success-actions {
        flex: 1 1 auto;
        justify-content: stretch;
        width: 100%;
        max-width: 100%;
    }

    .success-actions .btn-secondary {
        flex: 1;
        width: auto;
    }
}