:root {
    --bg: #f6efe4;
    --bg-accent: #dfeee4;
    --surface: rgba(255, 251, 245, 0.9);
    --surface-strong: #fff8f0;
    --ink: #11322d;
    --muted: #526963;
    --border: rgba(17, 50, 45, 0.12);
    --accent: #9f3817;
    --accent-strong: #7f2a0f;
    --accent-soft: rgba(229, 103, 63, 0.12);
    --success: #2e7d68;
    --danger: #9e3b2c;
    --shadow: 0 24px 70px rgba(17, 50, 45, 0.12);
}

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

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(229, 103, 63, 0.18), transparent 32%),
        radial-gradient(circle at right 20%, rgba(46, 125, 104, 0.18), transparent 30%),
        linear-gradient(180deg, var(--bg) 0%, #f7f4ee 100%);
}

a {
    color: inherit;
}

button,
input,
textarea {
    font: inherit;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.landing-page,
.chat-page {
    padding: 24px;
}

.landing-shell,
.chat-shell {
    max-width: 1180px;
    margin: 0 auto;
}

.landing-shell {
    min-height: calc(100vh - 48px);
    display: grid;
    place-items: center;
}

.landing-card,
.sidebar-card,
.chat-card,
.modal-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.landing-card {
    width: min(1040px, 100%);
    padding: 42px;
    border-radius: 36px;
}

.pairing-wait-card {
    width: min(760px, 100%);
}

.pairing-code-card {
    width: min(560px, 100%);
}

.eyebrow {
    margin: 0 0 14px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.76rem;
    color: var(--muted);
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.02;
}

h1 {
    font-size: clamp(2.05rem, 5.6vw, 3.9rem);
    max-width: 13ch;
}

h2 {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
}

h3 {
    font-size: 1.8rem;
}

.landing-card h1 {
    font-size: clamp(1.35rem, 2.8vw, 2.05rem);
    max-width: 21ch;
    line-height: 1.08;
    text-wrap: normal;
}

.sidebar-card h1 {
    font-size: clamp(1.2rem, 1.8vw, 1.65rem);
    max-width: none;
    line-height: 1.08;
    overflow-wrap: normal;
    word-break: normal;
    text-wrap: normal;
}

.chat-card h2 {
    font-size: clamp(1.35rem, 2.35vw, 2.05rem);
    line-height: 1.05;
    text-wrap: balance;
}

.lead,
.lead-small,
.microcopy,
.hint-card p,
.empty-state p,
.message-text,
.file-meta small {
    color: var(--muted);
}

.lead {
    margin: 22px 0 28px;
    max-width: 44ch;
    font-size: 1.08rem;
    line-height: 1.7;
}

.landing-top-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(360px, 440px);
    gap: 22px;
    align-items: start;
}

.landing-hero {
    min-width: 0;
    container: landing-hero / inline-size;
}

.landing-hero .lead {
    margin-bottom: 0;
    max-width: 46ch;
}

.landing-flow {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 24px;
}

.landing-step {
    min-width: 0;
    padding: 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border);
}

.empty-step-list span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 800;
    font-size: 0.9rem;
}

.landing-step-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 32px;
    align-items: center;
    gap: 6px;
}

.landing-step strong {
    display: block;
    margin: 0;
    font-size: 1rem;
    line-height: 1.25;
}

.landing-step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.landing-step-icon svg {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@container landing-hero (max-width: 490px) {
    .landing-flow {
        grid-template-columns: 1fr;
    }
}

.landing-step p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.5;
    font-size: 0.95rem;
}

.landing-actions-stack {
    display: grid;
    gap: 16px;
}

.action-panel {
    padding: 22px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.56);
    border: 1px solid var(--border);
}

.action-panel h2 {
    font-size: clamp(1.35rem, 2.6vw, 1.95rem);
}

.lead-small {
    margin: 16px 0 0;
    line-height: 1.6;
}

.pairing-entry-card {
    margin: 0 0 28px;
    padding: 22px;
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.56);
    border: 1px solid var(--border);
}

.pairing-entry-card h2 {
    font-size: clamp(1.4rem, 3vw, 2rem);
}

.pairing-entry-card-compact {
    margin: 0;
    padding: 20px;
}

.pairing-entry-card-compact h2 {
    font-size: clamp(1.3rem, 2.4vw, 1.8rem);
}

.pairing-entry-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin-top: 18px;
}

.pairing-entry-form input {
    min-height: 56px;
    padding: 0 18px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.82);
    color: var(--ink);
    font-size: 1.2rem;
    letter-spacing: 0.18em;
    text-align: center;
}

.pairing-entry-form-compact {
    gap: 10px;
    margin-top: 14px;
}

.pairing-entry-form-compact input {
    min-width: 0;
    min-height: 52px;
    font-size: 1.08rem;
}

.pairing-entry-status {
    margin-top: 16px;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(46, 125, 104, 0.12);
    border: 1px solid rgba(46, 125, 104, 0.2);
}

.pairing-entry-status.error {
    background: rgba(158, 59, 44, 0.12);
    border-color: rgba(158, 59, 44, 0.2);
}

.form-error {
    margin-top: 10px;
    padding: 11px 14px;
    border-radius: 14px;
    border: 1px solid rgba(158, 59, 44, 0.22);
    background: rgba(158, 59, 44, 0.08);
    color: var(--danger);
    font-size: 0.95rem;
    line-height: 1.45;
}

.pairing-entry-status strong {
    display: block;
    margin-bottom: 8px;
}

.pairing-entry-status p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.microcopy {
    margin: 22px 0 0;
    line-height: 1.6;
}

.help-section {
    margin-top: 36px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.help-disclosure {
    margin-top: 30px;
}

.help-disclosure-summary,
.create-options-summary {
    list-style: none;
    cursor: pointer;
}

.help-disclosure-summary::-webkit-details-marker,
.create-options-summary::-webkit-details-marker {
    display: none;
}

.help-disclosure-summary::marker,
.create-options-summary::marker {
    content: '';
}

.help-disclosure-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.help-disclosure-copy {
    min-width: 0;
}

.help-disclosure-copy strong {
    display: block;
    font-size: clamp(1.05rem, 1.8vw, 1.32rem);
    line-height: 1.2;
    color: var(--ink);
    white-space: nowrap;
}

.help-disclosure-summary::after {
    content: '';
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    margin-top: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    opacity: 0.8;
    transition: transform 0.18s ease;
    transform: rotate(45deg);
}

.help-disclosure[open] .help-disclosure-summary::after {
    transform: rotate(-135deg);
}

.help-head {
    margin-bottom: 18px;
}

.help-head h2,
.help-disclosure-summary h2 {
    max-width: 18ch;
}

.help-disclosure-body {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.help-disclosure .help-grid {
    margin-top: 0;
}

.help-card {
    padding: 20px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.56);
    border: 1px solid var(--border);
}

.help-card h3 {
    margin-bottom: 12px;
    font-size: 1.15rem;
}

.help-card-wide {
    grid-column: 1 / -1;
}

.help-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.help-list {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
    line-height: 1.65;
}

.help-card-wide .help-list {
    columns: 2;
    column-gap: 28px;
}

.help-list li + li {
    margin-top: 8px;
}

.help-card-wide .help-list li {
    break-inside: avoid;
}

.create-options-card {
    margin: 18px 0 0;
    padding: 24px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.56);
    border: 1px solid var(--border);
}

.create-options-disclosure {
    padding: 0;
    overflow: hidden;
}

.create-options-head {
    margin-bottom: 18px;
}

.create-options-head h2 {
    max-width: 16ch;
}

.create-options-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
}

.create-options-summary::after {
    content: '';
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    opacity: 0.8;
    transition: transform 0.18s ease;
    transform: rotate(45deg);
}

.create-options-disclosure[open] .create-options-summary::after {
    transform: rotate(-135deg);
}

.create-options-summary strong,
.create-options-summary small {
    display: block;
}

.create-options-summary strong {
    font-size: 1rem;
}

.create-options-summary small {
    margin-top: 4px;
    color: var(--muted);
}

.create-options-body {
    padding: 2px 18px 18px;
    border-top: 1px solid var(--border);
}

.option-toggle + .option-toggle {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px dashed rgba(17, 50, 45, 0.12);
}

.create-options-body .microcopy {
    margin-top: 10px;
}

.option-check {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
}

.option-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    margin: 0;
}

.option-fields {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.option-fields input {
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.82);
    color: var(--ink);
}

.action-row {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
}

.compact-action-row {
    margin: 18px 0 0;
}

.compact-action-row .primary-button {
    width: 100%;
}

.primary-button,
.secondary-button,
.ghost-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 0 22px;
    border-radius: 18px;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.primary-button {
    background: linear-gradient(135deg, var(--accent) 0%, #aa421d 100%);
    color: #fff;
    box-shadow: 0 14px 30px rgba(229, 103, 63, 0.28);
    font-weight: 800;
}

.secondary-button {
    background: var(--surface-strong);
    border-color: var(--border);
    color: var(--ink);
    font-weight: 700;
}

.ghost-link {
    width: fit-content;
    padding: 0;
    min-height: auto;
    border: 0;
    color: var(--muted);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-link:hover {
    transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

.limits-card {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.compact-limits {
    gap: 12px;
}

.compact-limits div {
    padding: 16px;
}

.help-limits {
    margin-bottom: 0;
}

.landing-note {
    margin: 0;
}

.help-intro {
    margin: 0;
    max-width: none;
}

.limits-card div,
.countdown-card,
.hint-card,
.share-card {
    padding: 18px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.56);
    border: 1px solid var(--border);
}

.limits-card span,
.countdown-card span,
.hint-card span,
.share-card label {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
    margin-bottom: 10px;
    line-height: 1.25;
    text-wrap: balance;
}

.limits-card strong,
.countdown-card strong,
.hint-card strong {
    font-size: 1.1rem;
}

.chat-shell {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    gap: 24px;
    height: calc(100vh - 48px);
    min-height: 0;
}

.sidebar-card,
.chat-card {
    border-radius: 30px;
    padding: 22px;
    min-height: 0;
}

.sidebar-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    border-radius: 26px;
    overflow: auto;
}

.sidebar-top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
}

.sidebar-create-button {
    width: 100%;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 700;
}

.icon-button {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 14px;
}

.icon-button svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: currentColor;
}

.danger-icon-button {
    color: var(--danger);
    border-color: rgba(158, 59, 44, 0.2);
    background: rgba(158, 59, 44, 0.08);
}

.help-icon-button {
    color: var(--muted);
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.8);
}

.sidebar-card .eyebrow {
    margin-bottom: 10px;
}

.sidebar-card .lead-small {
    margin-top: 10px;
    font-size: 0.97rem;
    line-height: 1.55;
}

.share-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
}

.share-actions .secondary-button,
.share-actions .primary-button {
    width: 100%;
    min-height: 52px;
    padding: 12px 16px;
    white-space: normal;
    line-height: 1.25;
    text-align: center;
}

.share-actions .secondary-button:last-child {
    grid-column: auto;
}

.invite-button {
    min-height: 56px;
    border-radius: 18px;
    font-size: 1.02rem;
    font-weight: 900;
    box-shadow: 0 16px 30px rgba(229, 103, 63, 0.22);
}

.share-card-compact {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.share-card-head small {
    display: block;
    color: var(--muted);
    margin: 0;
    line-height: 1.45;
}

.invite-option {
    margin: 0;
    padding: 12px 0;
    border-top: 1px solid rgba(17, 50, 45, 0.08);
    border-bottom: 1px solid rgba(17, 50, 45, 0.08);
}

.invite-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 0;
    cursor: pointer;
}

.invite-toggle-copy {
    min-width: 0;
}

.invite-toggle-copy strong,
.invite-toggle-copy small {
    display: block;
}

.invite-toggle-copy strong {
    color: var(--ink);
    font-size: 0.98rem;
    line-height: 1.25;
}

.invite-toggle-copy small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.35;
}

.invite-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-control {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    width: 48px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid rgba(17, 50, 45, 0.16);
    background: rgba(80, 107, 98, 0.14);
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.switch-control::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 3px 9px rgba(17, 50, 45, 0.18);
    transition: transform 0.18s ease;
}

.invite-toggle input:checked + .switch-control {
    border-color: rgba(229, 103, 63, 0.45);
    background: rgba(229, 103, 63, 0.82);
    box-shadow: 0 8px 18px rgba(229, 103, 63, 0.18);
}

.invite-toggle input:checked + .switch-control::after {
    transform: translateX(20px);
}

.invite-toggle:focus-within .switch-control {
    outline: 3px solid rgba(229, 103, 63, 0.22);
    outline-offset: 3px;
}

.share-help {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(17, 50, 45, 0.14);
}

.share-help summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    color: var(--muted);
    font-weight: 700;
    list-style: none;
}

.share-help summary::-webkit-details-marker {
    display: none;
}

.share-help summary::marker {
    content: '';
}

.share-help summary::after {
    content: '';
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    opacity: 0.8;
    transition: transform 0.18s ease;
    transform: rotate(45deg);
}

.share-help[open] summary::after {
    transform: rotate(-135deg);
}

.share-help .microcopy {
    margin-top: 10px;
}

.owner-card {
    display: grid;
    gap: 12px;
}

.owner-card .danger-button {
    width: 100%;
    color: var(--danger);
    border-color: rgba(158, 59, 44, 0.2);
    background: rgba(158, 59, 44, 0.08);
}

.short-link-box {
    margin-top: 14px;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(255, 248, 240, 0.88);
    border: 1px dashed rgba(17, 50, 45, 0.18);
}

.short-link-box span,
.short-link-box strong,
.short-link-box small {
    display: block;
}

.short-link-box span {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.short-link-box strong {
    font-size: 2rem;
    letter-spacing: 0.08em;
    overflow-wrap: anywhere;
}

.short-link-box small {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.qr-code-box {
    margin-top: 0;
    text-align: center;
}

.qr-code-box strong {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    letter-spacing: 0.12em;
}

.hidden {
    display: none !important;
}

.hint-card p {
    margin: 12px 0 0;
    line-height: 1.6;
}

.sidebar-card .countdown-card,
.sidebar-card .hint-card,
.sidebar-card .share-card {
    padding: 14px;
    border-radius: 20px;
}

.error-copy {
    color: var(--danger);
}

.gate-shell {
    max-width: 760px;
    min-height: calc(100vh - 48px);
    margin: 0 auto;
    display: grid;
    place-items: center;
}

.password-gate-card {
    width: min(760px, 100%);
}

.gate-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.chat-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 16px;
}

.chat-header-chips {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.status-chip {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(17, 50, 45, 0.08);
    color: var(--muted);
    white-space: nowrap;
}

.status-chip.online {
    background: rgba(46, 125, 104, 0.12);
    color: var(--success);
}

.status-chip.offline {
    background: rgba(158, 59, 44, 0.12);
    color: var(--danger);
}

.status-chip.busy {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.participants-chip {
    background: rgba(17, 50, 45, 0.06);
    color: var(--ink);
}

.upload-feedback {
    margin-bottom: 18px;
    padding: 18px 20px;
    border-radius: 22px;
    border: 1px solid rgba(229, 103, 63, 0.22);
    background: linear-gradient(135deg, rgba(229, 103, 63, 0.1), rgba(243, 144, 88, 0.16));
}

.pairing-requests {
    margin-bottom: 18px;
    padding: 18px 20px;
    border-radius: 22px;
    border: 1px solid rgba(17, 50, 45, 0.12);
    background: rgba(255, 255, 255, 0.58);
}

.pairing-requests-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.pairing-requests-head span {
    color: var(--muted);
    font-size: 0.94rem;
}

.pairing-request-list {
    display: grid;
    gap: 12px;
}

.pairing-request-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 248, 240, 0.8);
}

.pairing-request-copy strong,
.pairing-request-copy small {
    display: block;
}

.pairing-request-copy small {
    margin-top: 6px;
    color: var(--muted);
}

.pairing-request-actions {
    display: flex;
    gap: 10px;
}

.upload-stop-button {
    margin-top: 12px;
    min-height: 44px;
    padding: 0 18px;
}

.upload-feedback-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.upload-feedback strong {
    font-size: 1.05rem;
}

.upload-feedback p {
    margin: 10px 0 14px;
    color: var(--muted);
    line-height: 1.5;
}

.upload-feedback span {
    white-space: nowrap;
    color: var(--accent-strong);
    font-weight: 800;
}

.upload-progress {
    width: 100%;
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(17, 50, 45, 0.08);
}

.upload-progress-bar {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent) 0%, #aa421d 100%);
    transition: width 0.18s ease;
}

/* Keep navigation out of the scroll flow so showing it does not move the text. */
.message-history {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
}

.new-messages-button {
    position: absolute;
    right: 20px;
    bottom: 12px;
    z-index: 1;
    min-height: 44px;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    border-radius: 999px;
    box-shadow: 0 4px 18px rgba(17, 50, 45, 0.18);
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
    padding-right: 8px;
}

.chat-card.is-drop-target {
    border-color: rgba(229, 103, 63, 0.26);
    box-shadow:
        var(--shadow),
        inset 0 0 0 2px rgba(229, 103, 63, 0.2);
}

.chat-card.is-drop-target .messages,
.chat-card.is-drop-target .file-picker,
.chat-card.is-drop-target .composer textarea {
    border-color: rgba(229, 103, 63, 0.32);
    background: rgba(255, 249, 243, 0.92);
}

.empty-state {
    display: grid;
    place-items: center;
    gap: 18px;
    min-height: 100%;
    padding: 36px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.42);
}

.empty-state strong {
    font-size: 1.3rem;
}

.empty-state-guide {
    place-items: stretch;
    align-content: center;
    text-align: left;
}

.empty-state-main {
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
}

.empty-state-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(46, 125, 104, 0.12);
    color: var(--success);
    font-size: 0.86rem;
    font-weight: 800;
}

.empty-actions {
    display: flex;
    justify-content: center;
}

.empty-step-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
}

.empty-step-list div {
    min-width: 0;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 248, 240, 0.72);
    border: 1px solid var(--border);
}

.empty-step-list p {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.45;
    font-size: 0.94rem;
}

.message-card {
    flex-shrink: 0;
    width: min(74%, 760px);
    min-width: min(100%, 320px);
    overflow: hidden;
    align-self: flex-start;
    padding: 0;
    border-radius: 22px 22px 22px 8px;
    border: 1px solid var(--border);
    border-left: 5px solid rgba(46, 125, 104, 0.52);
    background: rgba(255, 255, 255, 0.78);
    margin: 0;
    box-shadow: 0 12px 26px rgba(17, 50, 45, 0.06);
}

.message-card.is-mine {
    align-self: flex-end;
    border-left-width: 1px;
    border-right: 5px solid rgba(229, 103, 63, 0.58);
    border-color: rgba(229, 103, 63, 0.24);
    border-radius: 22px 22px 8px 22px;
    background: rgba(255, 248, 240, 0.88);
}

.message-head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(46, 125, 104, 0.1);
}

.message-card.is-mine .message-head {
    flex-direction: row-reverse;
    text-align: right;
    background: rgba(229, 103, 63, 0.13);
}

.message-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(46, 125, 104, 0.16);
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 900;
}

.message-card.is-mine .message-avatar {
    background: rgba(229, 103, 63, 0.18);
    color: var(--accent-strong);
}

.message-head-copy {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.message-copy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
    box-shadow: none;
}

.message-copy-button svg { width: 18px; height: 18px; }
.message-copy-button:hover:not(:disabled) { color: var(--ink); background: rgba(255, 255, 255, 0.6); }
.message-copy-button:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.message-copy-button:disabled { opacity: 0.45; cursor: default; }
.message-copy-status { margin: 8px 0 0; font-size: 0.8rem; line-height: 1.4; color: var(--success); overflow-wrap: anywhere; }
.message-copy-status.error-copy { color: var(--accent-strong); }

.message-author {
    display: block;
    max-width: 320px;
    min-width: 0;
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 900;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-card.is-mine .message-author {
    color: var(--accent-strong);
}

.message-body {
    padding: 14px 16px 16px;
}

.message-text {
    white-space: pre-wrap;
    tab-size: 4;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.message-text a {
    color: var(--accent-strong);
}

.message-text-encrypted {
    color: var(--muted);
}

.message-image-link {
    display: block;
    margin-top: 14px;
}

.message-image {
    display: block;
    width: min(100%, 420px);
    max-height: 360px;
    object-fit: cover;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.file-card {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
    padding: 14px;
    border-radius: 18px;
    text-decoration: none;
    background: rgba(255, 248, 240, 0.92);
    border: 1px solid var(--border);
}

.file-card.is-encrypted {
    border-style: dashed;
    background: rgba(243, 144, 88, 0.08);
}

.file-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 800;
}

.file-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.file-meta strong,
.file-meta small {
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-meta {
    display: block;
    font-size: 0.8rem;
    line-height: 1.2;
    color: var(--muted);
}

.composer {
    flex: 0 0 auto;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.composer textarea {
    width: 100%;
    min-height: 110px;
    resize: vertical;
    padding: 18px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.76);
    color: var(--ink);
}

.composer-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 14px;
    margin-top: 14px;
    min-width: 0;
}

.file-picker {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    width: 100%;
    min-height: 52px;
    padding: 0 18px;
    border-radius: 18px;
    border: 1px dashed rgba(17, 50, 45, 0.22);
    background: rgba(255, 255, 255, 0.54);
    cursor: pointer;
    color: var(--muted);
    max-width: 100%;
    overflow: hidden;
}

.file-picker input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0.01;
    pointer-events: none;
}

.file-picker:focus-within {
    border-color: rgba(17, 50, 45, 0.42);
    box-shadow: 0 0 0 4px rgba(46, 125, 104, 0.12);
}

#file-name {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#send-button {
    min-width: 168px;
    width: auto;
}

.modal.hidden {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 16px;
    overscroll-behavior: contain;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 50, 45, 0.45);
    backdrop-filter: blur(8px);
}

.modal-panel {
    position: relative;
    width: min(460px, 100%);
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 30px;
    border-radius: 30px;
    z-index: 1;
    text-align: center;
    max-height: 100%;
    overflow: auto;
    overscroll-behavior: contain;
}

.modal-close {
    position: sticky;
    top: -16px;
    float: right;
    margin: -16px -16px -24px 0;
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 1.4rem;
}

.qr-code {
    display: grid;
    place-items: center;
    min-height: 0;
    padding: 12px;
    margin: 20px 0 12px;
    border-radius: 28px;
    background: #f6efe4;
    border: 1px solid var(--border);
}

.qr-code img,
.qr-code canvas {
    max-width: 100%;
    height: auto;
}

.invite-link-output {
    width: 100%;
    min-height: 48px;
    margin: 0 0 12px;
    padding: 0 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.82);
    color: var(--ink);
    text-align: center;
}

.qr-caption {
    margin-bottom: 0;
}

.help-modal-panel {
    width: min(560px, 100%);
    text-align: left;
}

.help-modal-panel h3 {
    font-size: clamp(1.2rem, 2vw, 1.55rem);
    margin-bottom: 14px;
}

.help-modal-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.help-modal-stats div,
.help-modal-card {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.56);
    border: 1px solid var(--border);
}

.help-modal-stats span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.86rem;
}

.help-modal-stats strong {
    font-size: 1rem;
}

.help-modal-grid {
    display: grid;
    gap: 10px;
}

.help-modal-card h4 {
    margin: 0 0 8px;
    font-size: 1rem;
    line-height: 1.25;
}

.help-modal-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

@media (max-width: 940px) {
    .landing-top-grid {
        grid-template-columns: 1fr;
    }

    .landing-flow,
    .empty-step-list {
        grid-template-columns: 1fr;
    }

    .chat-shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }

    .chat-card {
        order: 1;
        height: calc(100vh - 48px);
        height: calc(100svh - 48px);
        height: calc(100dvh - 48px);
    }

    .sidebar-card {
        order: 2;
    }

    .help-modal-stats {
        grid-template-columns: 1fr;
    }

    .messages {
        max-height: none;
    }

    .message-card {
        width: min(92%, 680px);
        min-width: 0;
    }
}

@media (max-width: 680px) {
    .landing-page {
        padding: 14px;
    }

    .chat-page {
        padding: 8px;
    }

    .landing-card,
    .sidebar-card {
        padding: 22px;
        border-radius: 24px;
    }

    .chat-card {
        height: calc(100vh - 16px);
        height: calc(100svh - 16px);
        height: calc(100dvh - 16px);
        padding: 10px;
        border-radius: 18px;
    }

    .landing-card {
        width: 100%;
    }

    .landing-card h1 {
        max-width: none;
    }

    .help-disclosure-copy strong {
        white-space: normal;
    }

    .limits-card {
        grid-template-columns: 1fr;
    }

    .help-grid {
        grid-template-columns: 1fr;
    }

    .help-card-wide .help-list {
        columns: 1;
    }

    .action-row {
        display: grid;
    }

    .pairing-entry-form,
    .pairing-request-card {
        grid-template-columns: 1fr;
    }

    .pairing-request-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .chat-header {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
    }

    .chat-header > div:first-child {
        min-width: 0;
    }

    .chat-header .eyebrow {
        display: none;
    }

    .chat-card h2 {
        font-size: 0.95rem;
        line-height: 1.15;
        white-space: nowrap;
    }

    .chat-header-chips {
        flex: 1 1 auto;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .status-chip {
        padding: 6px 9px;
        font-size: 0.78rem;
        line-height: 1.1;
    }

    #status-chip {
        max-width: 92px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .messages {
        gap: 8px;
        padding-right: 3px;
    }

    .new-messages-button {
        right: 8px;
        bottom: 8px;
        min-height: 40px;
        padding: 8px 12px;
        font-size: 0.84rem;
    }

    .message-card {
        width: 100%;
        border-left-width: 3px;
        border-radius: 14px 14px 14px 5px;
        box-shadow: 0 5px 14px rgba(17, 50, 45, 0.05);
    }

    .message-card.is-mine {
        border-right-width: 3px;
        border-radius: 14px 14px 5px 14px;
    }

    .message-head {
        gap: 8px;
        padding: 6px 9px;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.82rem;
    }

    .message-head-copy {
        gap: 1px;
    }

    .message-author {
        font-size: 0.82rem;
    }

    .message-meta {
        font-size: 0.7rem;
    }

    .message-copy-button {
        flex-basis: 36px;
        width: 36px;
        height: 36px;
        padding: 6px;
        border-radius: 8px;
    }

    .message-copy-button svg {
        width: 16px;
        height: 16px;
    }

    .message-body {
        padding: 8px 10px 9px;
    }

    .message-text {
        font-size: 0.92rem;
        line-height: 1.45;
    }

    .message-copy-status {
        margin-top: 5px;
        font-size: 0.74rem;
    }

    .message-image-link,
    .file-card {
        margin-top: 8px;
    }

    .message-image {
        max-height: 240px;
        border-radius: 12px;
    }

    .file-card {
        gap: 10px;
        padding: 9px;
        border-radius: 12px;
    }

    .file-badge {
        width: 40px;
        height: 40px;
        border-radius: 11px;
        font-size: 0.78rem;
    }

    .composer {
        margin-top: 8px;
        padding-top: 8px;
    }

    .composer textarea {
        field-sizing: content;
        height: 52px;
        min-height: 52px;
        max-height: 132px;
        padding: 12px 13px;
        border-radius: 14px;
        line-height: 1.4;
        resize: none;
        overflow-y: auto;
    }

    .composer-footer {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        margin-top: 8px;
    }

    .file-picker {
        max-width: none;
        min-height: 44px;
        padding: 0 12px;
        border-radius: 13px;
        font-size: 0.86rem;
    }

    #send-button {
        min-width: 108px;
        min-height: 44px;
        padding: 0 14px;
        border-radius: 13px;
        font-size: 0.9rem;
    }
}
