/* All styles in this sheet are needed on page load */

/* Layout */

html,
body {
    margin: 0;
    display: flex;
    flex-direction: column;
    width: 100vw;
    overflow-x: hidden;
    overscroll-behavior: none;
    overflow-y: hidden;
    transition: color 300ms;
}

body {
    height: 100%;
}

html {
    height: 100%;
}

.fw {
    width: 100%;
}

.p-1 {
    padding: 5px;
}

.p-2 {
    padding: 10px;
}

.pb-0 {
    padding-bottom: 0;
}

.mx-1 {
    margin-left: 5px;
    margin-right: 5px;
}

.m-1 {
    margin: 5px;
}

.cursive {
    font-style: italic;
}

.wrap {
    display: flex;
    flex-wrap: wrap;
}

.wrap-reverse {
    display: flex;
    flex-wrap: wrap-reverse;
}

.grow {
    display: flex;
    flex-grow: 1;
}

.grow-2 {
    display: flex;
    flex-grow: 2;
}

.grow-5 {
    display: flex;
    flex-grow: 5;
}

.shrink {
    display: flex;
    flex-shrink: 1;
}

.flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.space-evenly {
    justify-content: space-evenly;
}

.space-between {
    justify-content: space-between;
}

.row {
    display: flex;
    flex-direction: row;
}

.row-reverse {
    display: flex;
    flex-direction: row-reverse;
}

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

.center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.full {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.pointer {
    cursor: pointer;
}

header {
    position: relative;
    align-items: baseline;
    padding: 12px 20px;
    box-sizing: border-box;
    width: 100vw;
    z-index: 20;
    top: 0;
    right: 0;
    min-height: 56px;
}

header.overflow-hidden {
    overflow: hidden;
}

header:not(.overflow-expanded) {
    height: 56px;
}

header > * {
    margin-left: 4px;
    margin-right: 4px;
}

header > * {
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    touch-action: manipulation;
}

header > .icon-button,
header > button.icon-button {
    height: 40px;
}

/* Invisible mode — compact label left of Share via Link (header uses row-reverse). */
header > .header-invisible-hint {
    display: none;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 4px;
    max-width: 108px;
    padding: 2px 2px 0;
    margin-top: 2px;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.15;
    text-transform: none;
    color: rgba(var(--text-color), 0.55);
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}
header > .header-invisible-hint:not([hidden]) {
    display: flex;
}
.header-invisible-hint-icon {
    width: 15px;
    height: 15px;
    flex: none;
    fill: currentColor;
    opacity: 0.75;
}
.header-invisible-hint-text {
    display: block;
    line-height: 1.15;
    word-break: break-word;
    hyphens: auto;
}

header * {
    transition: all 300ms;
}

#theme-wrapper > div {
    display: flex;
    flex-direction: column;
}

/* expand theme buttons */
#theme-wrapper:not(:hover) .icon-button:not(.selected) {
    height: 0;
    opacity: 0;
}

#theme-wrapper:hover::before {
    border-radius: 20px;
    background: var(--primary-color);
    opacity: 0.2;
    transition: opacity 300ms;
    content: '';
    position: absolute;
    width: 40px;
    height: 120px;
    top: 0;
    margin-top: 8px;
    margin-bottom: 8px;
}

@media (hover: hover) and (pointer: fine) {
    #theme-wrapper:hover .icon-button:not(.selected):hover:before {
        opacity: 0.3;
    }

    #theme-wrapper:hover .icon-button.selected::before {
        opacity: 0.3;
    }
}

@media (hover: none) and (pointer: coarse) {
    #theme-wrapper:before {
        opacity: 0.3 !important;
        height: 40px !important;
    }

    #theme-wrapper .icon-button:before {
        opacity: 0;
    }

    #theme-wrapper .icon-button:not(.selected) {
        height: 0;
        opacity: 0;
        pointer-events: none;
    }

    #theme-wrapper > div {
        flex-direction: column-reverse;
    }
}

#expand > .icon {
    transition: transform 150ms ease-out
}

html:not([dir="rtl"]) #expand.flipped  > .icon {
    transform: rotate(-90deg);
}

html[dir="rtl"] #expand.flipped  > .icon {
    transform: rotate(90deg);
}

[hidden] {
    display: none !important;
}


/* Typography */

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-variant-ligatures: common-ligatures;
    font-kerning: normal;
}

h1 {
    font-size: 34px;
    font-weight: 400;
    letter-spacing: -.01em;
    line-height: 40px;
    margin: 0 0 4px;
}

h2 {
    font-size: 22px;
    font-weight: 400;
    letter-spacing: -.012em;
    line-height: 32px;
    color: var(--primary-color);}

h3 {
    font-size: 20px;
    font-weight: 500;
    margin: 16px 0;
    color: var(--primary-color);
}

.font-subheading {
    font-size: 14px;
    font-weight: 400;
    line-height: 18px;
    word-break: normal;
}

.text-center {
    text-align: center;
}

.text-white {
    color: white !important;
}

.font-body1,
body {
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
}

.font-body2 {
    font-size: 12px;
    line-height: 18px;
}

a,
.icon-button {
    text-decoration: none;
    color: currentColor;
    cursor: pointer;
}

input {
    cursor: pointer;
}

input[type="checkbox"] {
    min-width: 13px;
}

x-noscript {
    background: var(--primary-color);
    color: white;
    z-index: 2;
}


/* Icons */

.icon {
    width: var(--icon-size);
    height: var(--icon-size);
    fill: currentColor;
}



/* Shadows */

[shadow="1"] {
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 4px 16px rgba(0, 0, 0, 0.06);
}

[shadow="2"] {
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.06),
        0 12px 32px rgba(0, 0, 0, 0.08);
}

.overflowing {
    background:
        /* Shadow covers */
            linear-gradient(rgb(var(--shadow-color-cover-rgb)) 30%, rgba(var(--shadow-color-cover-rgb), 0)),
            linear-gradient(rgba(var(--shadow-color-cover-rgb), 0), rgb(var(--shadow-color-cover-rgb)) 70%) 0 100%,
                /* Shadows */
            radial-gradient(farthest-side at 50% 0, rgba(var(--shadow-color-rgb), .2), rgba(var(--shadow-color-rgb), 0)),
            radial-gradient(farthest-side at 50% 100%, rgba(var(--shadow-color-rgb), .2), rgba(var(--shadow-color-rgb), 0))
            0 100%;
    background-repeat: no-repeat;
    background-size: 100% 60px, 100% 60px, 100% 24px, 100% 24px;
    background-attachment: local, local, scroll, scroll;
}


/* Animations */

/* Opacity for elements at keyframe 100% is set on element (default 1) */
@keyframes fade-in {
    0% {
        opacity: 0;
    }
}

#center {
    position: relative;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
    overscroll-behavior-x: none;
}

.files-view-zone {
    display: flex;
    flex-direction: column-reverse;
    flex-grow: 1;
    min-height: 0;
    justify-content: space-around;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
    width: 100%;
}


/* Peers  */

x-peers {
    position: relative;
    display: flex;
    flex-flow: row wrap;

    z-index: 2;
    transition: background-color 0.5s ease;
    overflow-y: scroll;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    scrollbar-width: none;

    --peers-per-row: 6; /* default if browser does not support :has selector */
    --x-peers-width: min(100vw, calc(var(--peers-per-row) * (var(--peer-width) + 25px) - 16px));
    width: var(--x-peers-width);
}

/* Empty Peers List */

x-no-peers {
    display: flex;
    flex-direction: column;
    padding: 8px;
    height: 137px;
    text-align: center;
}

x-no-peers h2,
x-no-peers a {
    color: var(--primary-color);
    margin-bottom: 5px;
}

x-peers:not(:empty)+x-no-peers {
    display: none;
}

x-no-peers::before {
    color: var(--primary-color);
    font-size: 24px;
    font-weight: 400;
    letter-spacing: -.012em;
    line-height: 32px;
}

x-no-peers[drop-bg]::before {
    content: attr(data-drop-bg);
}

x-no-peers[drop-bg] * {
    display: none;
}

/* Footer */

footer {
    position: relative;
    z-index: 2;
    align-items: center;
    text-align: center;
    cursor: default;
    margin: auto 5px 5px;
}

footer .logo {
    --icon-size: 80px;
    margin-bottom: 8px;
    color: var(--primary-color);
    margin-top: -10px;
}

.border {
    border: 2px solid var(--border-color);
}

.panel {
    font-size: 14px;
    padding: 2px;
    background-color: rgb(var(--bg-color));
    transition: background-color 0.5s ease;
    min-height: 24px;
}

.panel.column {
    border-radius: 20px;
}

.panel.row {
    border-radius: 18px;
}

.panel > div:first-of-type {
    padding-left: 4px;
    padding-right: 4px;
}

/* You can be discovered wrapper */
.discovery-wrapper {
    margin: 15px auto auto;
}

.discovery-wrapper .badge {
    word-break: keep-all;
    margin: 2px;
}

.badge {
    border-radius: 0.4rem;
    padding-right: 0.3rem;
    padding-left: 0.3em;
    background-color: var(--badge-color);
    color: white;
    white-space: nowrap;
}

.badge-room-ip {
    --badge-color: var(--primary-color);
}

.badge-room-secret {
    --badge-color: var(--paired-device-color);
}

.badge-room-public-id {
    --badge-color: var(--public-room-color);
}

.known-as-wrapper {
    font-size: 16px; /* prevents auto-zoom on edit */
}

#display-name {
    position: relative;
    display: inline-block;
    text-align: left;
    border: none;
    outline: none;
    height: 20px;
    max-width: 15em;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    cursor: text;
    margin-bottom: -6px;
    padding-bottom: 0.1rem;
    border-radius: 1.3rem/30%;
    border-right: solid 1rem transparent;
    border-left: solid 1rem transparent;
    background-clip: padding-box;
    z-index: 1;
}

.edit-pen {
    width: 1rem;
    height: 1rem;
    margin-bottom: -2px;
    position: relative;
}

#display-name:focus::before {
    display: none;
}

html:not([dir="rtl"]) #display-name,
html:not([dir="rtl"]) .edit-pen {
    margin-left: -1rem;
}

html[dir="rtl"] #display-name,
html[dir="rtl"] .edit-pen {
    margin-right: -1rem;
}

html[dir="rtl"] .edit-pen {
    transform: rotateY(180deg);
}

/* Dialogs needed on page load */
x-dialog:not([show]) x-background {
    opacity: 0;
}

/* Button */

.btn {
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    padding: 2px 16px 0;
    box-sizing: border-box;
    font-size: 14px;
    line-height: 24px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    background: inherit;
    color: var(--accent-color);
    overflow: hidden;
}

.btn-small {
    font-size: 12px;
    line-height: 22px;
}

.btn[disabled] {
    color: var(--btn-disabled-color);
    cursor: not-allowed;
}


.btn,
.icon-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    touch-action: manipulation;
    border: none;
    outline: none;
}

.btn:before,
.icon-button:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    background-color: var(--accent-color);
    transition: opacity 300ms;
}

.icon-button:before {
    z-index: -1;
}

.btn:not([disabled]):hover:before,
.icon-button:hover:before {
    opacity: 0.3;
}

.btn[selected],
.icon-button[selected] {
    opacity: 0.3;
}

.btn:focus:before,
.icon-button:focus:before {
    opacity: 0.4;
}

.btn-round {
    border-radius: 50%;
}

.btn-rounded {
    border-radius: 14px;
}

.btn-small.btn-rounded {
    border-radius: 10px;
}

.btn-grey {
    background-color: var(--bg-color-secondary);
}

.btn-dark {
    background-color: #2c2c2e;
}

.btn-primary {
    background: var(--primary-color);
    color: rgb(var(--bg-color));
}

button::-moz-focus-inner {
    border: 0;
}


/* Icon Button */
.icon-button {
    width: 40px;
    height: 40px;
}

.icon-button:before {
    border-radius: 50%;
}


/* Info Animation */
#about {
    color: white;
    z-index: 32;
    overflow: hidden;
    pointer-events: none;
    text-align: center;
}

#about header {
    z-index: 1;
}

#about:not(.about-is-open) header {
    transition-delay: 400ms;
}

#about.about-is-open header {
    transition-delay: 100ms;
}

#about > * {
    transition: opacity 300ms ease 300ms;
    will-change: opacity;
    pointer-events: all;
}

#about:not(.about-is-open) > header,
#about:not(.about-is-open) > section {
    opacity: 0;
    pointer-events: none;
    transition-delay: 0s;
}

#about .logo {
    --icon-size: 96px;
}

#about .title-wrapper {
    display: flex;
    align-items: baseline;
}

#about .title-wrapper > div {
    margin-left: 0.4em;
}

#about x-background {
    position: absolute;
    --size: max(max(230vw, 230vh), calc(150vh + 150vw));
    --size-half: calc(var(--size)/2);
    top: calc(28px - var(--size-half));
    width: var(--size);
    height: var(--size);
    z-index: -1;
    background: var(--primary-color);
    background-image: radial-gradient(circle at calc(50% - 36px), var(--primary-color) 0%, black 80%);
    --crop-size: 0px;
    clip-path: circle(var(--crop-size));
    /* For clients < iOS 13.1 */
    -webkit-clip-path: circle(var(--crop-size));
}

html:not([dir="rtl"]) #about x-background {
    right: calc(36px - var(--size-half));
}

html[dir="rtl"] #about x-background {
    left: calc(36px - var(--size-half));
}


/* Hack such that initial scale(0) isn't animated */
#about x-background {
    will-change: clip-path;
    transition: clip-path 800ms cubic-bezier(0.77, 0, 0.175, 1);
}

#about.about-is-open x-background {
    --crop-size: var(--size);
}

#about .row a {
    margin: 8px 8px -16px;
}

#about section {
    flex-grow: 1;
}

canvas.circles {
    width: 100vw;
    position: absolute;
    z-index: -10;
    top: 0;
    left: 0;
}

/* Generic placeholder */
[placeholder]:empty:before {
    content: attr(placeholder);
}

/* Toast */

.toast-container {
    padding: 0 8px 24px;
    overflow: hidden;
    pointer-events: none;
}

x-toast {
    display: flex;
    justify-content: space-between;
    position: absolute;
    min-height: 48px;
    top: 50px;
    max-width: 400px;
    background-color: rgb(var(--text-color));
    color: var(--dialog-bg-color);
    align-items: center;
    box-sizing: border-box;
    padding: 8px;
    z-index: 40;
    transition: opacity 200ms, transform 300ms ease-out;
    cursor: default;
    line-height: 24px;
    border-radius: 12px;
    pointer-events: all;
}

x-toast.top-row {
    top: 3px;
}

x-toast:not([show]) {
    opacity: 0;
    transform: translateY(calc(-100% + -55px));
}

x-toast span {
    flex-grow: 1;
    margin: auto 4px auto 10px
}

x-dialog[show] ~ div x-toast {
    background-color: var(--lt-dialog-bg-color);
    color: rgb(var(--lt-text-color));
}

/* Instructions */

x-instructions {
    display: flex;
    position: relative;
    opacity: 0.5;
    text-align: center;
    margin-right: 10px;
    margin-left: 10px;
    min-height: max(6vh, 40px);
    flex-direction: column;
    justify-content: end;
}

x-instructions:not([drop-peer]):not([drop-bg]):before {
    content: attr(mobile);
}

x-instructions[drop-peer]:before {
    content: attr(data-drop-peer);
}

x-instructions[drop-bg]:not([drop-peer]):before {
    content: attr(data-drop-bg);
}


x-peers:empty,
x-peers:empty~x-instructions {
    display: none;
}

@media (hover: none) and (pointer: coarse) {
    x-peer {
        transform: scale(0.95);
        padding: 4px;
    }
}

/* Prevent Cumulative Layout Shift */

.fade-in {
    animation: fade-in 600ms;
    animation-fill-mode: backwards;
}

.no-animation-on-load {
    animation-iteration-count: 0;
}

.opacity-0 {
    opacity: 0;
}

/* Responsive Styles */

@media screen and (min-height: 800px) {
    footer {
        padding-bottom: 10px;
    }
}

@media (hover: hover) and (pointer: fine) {
    x-instructions:not([drop-peer]):not([drop-bg]):before {
        content: attr(desktop);
    }
}

/* PWA Standalone styles */
@media all and (display-mode: standalone) {
    footer {
        padding-bottom: 34px;
    }
}

/* Constants */

:root {
    --icon-size: 24px;
    --peer-width: 120px;
    color-scheme: light dark;
}

/*
    Color Themes
*/

/* Default colors */
body {
    /* Constant colors — minimalist accent (Apple-style blue) */
    --primary-color: #007aff;
    --paired-device-color: #00a69c;
    --public-room-color: #ed9d01;
    --accent-color: var(--primary-color);
    --ws-peer-color: #ff6b6b;
    --btn-disabled-color: #5B5B66;

    /* shadows */
    --shadow-color-rgb: var(--text-color);
    --shadow-color-cover-rgb: var(--bg-color);

    /* Light theme colors */
    --lt-text-color: 28,28,30;
    --lt-dialog-bg-color: rgba(255, 255, 255, 0.82);
    --lt-bg-color: 255,255,255;
    --lt-bg-color-secondary: 242,242,247;
    --lt-border-color: rgba(60, 60, 67, 0.18);
    --lt-badge-color: 99,99,102;
    --lt-lang-hr-color: #DDD;

    --lt-shadow-color-secondary-rgb: 0,0,0;
    --lt-shadow-color-secondary-cover-rgb: 242,242,242;
    --lt-shadow-color-dialog-rgb: 0,0,0;
    --lt-shadow-color-dialog-cover-rgb: 242,242,242;

    /* Dark theme colors */
    --dt-text-color: 235,235,245;
    --dt-dialog-bg-color: rgba(28, 28, 30, 0.88);
    --dt-bg-color: 0,0,0;
    --dt-bg-color-secondary: 44,44,46;
    --dt-border-color: rgba(235, 235, 245, 0.16);
    --dt-badge-color: 142,142,147;
    --dt-lang-hr-color: #404040;

    --dt-shadow-color-secondary-rgb: 255,255,255;
    --dt-shadow-color-secondary-cover-rgb: 38,38,38;
    --dt-shadow-color-dialog-rgb: 255,255,255;
    --dt-shadow-color-dialog-cover-rgb: 38,38,38;
}

/* Light theme colors */
body {
    --text-color: var(--lt-text-color);
    --dialog-bg-color: var(--lt-dialog-bg-color);
    --bg-color: var(--lt-bg-color);
    --bg-color-secondary: var(--lt-bg-color-secondary);
    --border-color: var(--lt-border-color);
    --badge-color: var(--lt-badge-color);
    --lang-hr-color: var(--lt-lang-hr-color);

    --shadow-color-secondary-rgb: var(--lt-shadow-color-secondary-rgb);
    --shadow-color-secondary-cover-rgb: var(--lt-shadow-color-secondary-cover-rgb);
    --shadow-color-dialog-rgb: var(--lt-shadow-color-dialog-rgb);
    --shadow-color-dialog-cover-rgb: var(--lt-shadow-color-dialog-cover-rgb);
}

/* Dark theme colors */
body.dark-theme {
    --text-color: var(--dt-text-color);
    --dialog-bg-color: var(--dt-dialog-bg-color);
    --bg-color: var(--dt-bg-color);
    --bg-color-secondary: var(--dt-bg-color-secondary);
    --border-color: var(--dt-border-color);
    --badge-color: var(--dt-badge-color);
    --lang-hr-color: var(--dt-lang-hr-color);

    --shadow-color-secondary-rgb: var(--dt-shadow-color-secondary-rgb);
    --shadow-color-secondary-cover-rgb: var(--dt-shadow-color-secondary-cover-rgb);
    --shadow-color-dialog-rgb: var(--dt-shadow-color-dialog-rgb);
    --shadow-color-dialog-cover-rgb: var(--dt-shadow-color-dialog-cover-rgb);
}

/* Styles for users who prefer dark mode at the OS level */
@media (prefers-color-scheme: dark) {

    /* defaults to dark theme */
    body {
        --text-color: var(--dt-text-color);
        --dialog-bg-color: var(--dt-dialog-bg-color);
        --bg-color: var(--dt-bg-color);
        --bg-color-secondary: var(--dt-bg-color-secondary);
        --border-color: var(--dt-border-color);
        --badge-color: var(--dt-badge-color);
        --lang-hr-color: var(--dt-lang-hr-color);

        --shadow-color-secondary-rgb: var(--dt-shadow-color-secondary-rgb);
        --shadow-color-secondary-cover-rgb: var(--dt-shadow-color-secondary-cover-rgb);
        --shadow-color-dialog-rgb: var(--dt-shadow-color-dialog-rgb);
        --shadow-color-dialog-cover-rgb: var(--dt-shadow-color-dialog-cover-rgb);
    }


    /* Override dark mode with light mode styles if the user decides to swap */
    body.light-theme {
        --text-color: var(--lt-text-color);
        --dialog-bg-color: var(--lt-dialog-bg-color);
        --bg-color: var(--lt-bg-color);
        --bg-color-secondary: var(--lt-bg-color-secondary);
        --border-color: var(--lt-border-color);
        --badge-color: var(--lt-badge-color);
        --lang-hr-color: var(--lt-lang-hr-color);

        --shadow-color-secondary-rgb: var(--lt-shadow-color-secondary-rgb);
        --shadow-color-secondary-cover-rgb: var(--lt-shadow-color-secondary-cover-rgb);
        --shadow-color-dialog-rgb: var(--lt-shadow-color-dialog-rgb);
        --shadow-color-dialog-cover-rgb: var(--lt-shadow-color-dialog-cover-rgb);
    }
}

/* Colored Elements */
body {
    color: rgb(var(--text-color));
    background-color: rgb(var(--bg-color));
    transition: background-color 0.5s ease;
}

/* Gradient for wifi-tether icon */
#primaryGradient .start-color {
    stop-color: var(--primary-color);
}

@supports (stop-color: color-mix(in srgb, blue 50%, black)) {
    #primaryGradient .start-color {
        stop-color: color-mix(in srgb, var(--primary-color) 80%, white);
    }
}

#primaryGradient .stop-color {
    stop-color: var(--primary-color);
}


/*
    Edge specific styles
*/
@supports (-ms-ime-align: auto) {

    html,
    body {
        overflow: hidden;
    }
}

/*
    Browser specific styles
*/

body {
    /* mobile viewport bug fix */
    min-height: -moz-available;          /* WebKit-based browsers will ignore this. */
    min-height: -webkit-fill-available;  /* Mozilla-based browsers will ignore this. */
    min-height: fill-available;
}

html {
    min-height: -moz-available;          /* WebKit-based browsers will ignore this. */
    min-height: -webkit-fill-available;  /* Mozilla-based browsers will ignore this. */
    min-height: fill-available;
}

/* webkit scrollbar style*/

::-webkit-scrollbar{
    width: 0;
    height: 0;
}

::-webkit-scrollbar-thumb{
    background: #bfbfbf;
    border-radius: 4px;
}

::-moz-selection,
::selection {
    color: black;
    background: var(--primary-color);
}

/* make elements with attribute contenteditable editable on older iOS devices.
See note here: https://developer.mozilla.org/en-US/docs/Web/CSS/user-select */
[contenteditable] {
    -webkit-user-select: text;
    user-select: text;
}

/* ----- AnyDrop: view toggle + notepad + refined chrome ----- */

.view-mode-toolbar {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 20px 14px;
    z-index: 5;
}

.segmented-control {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: min(280px, calc(100vw - 40px));
    padding: 4px;
    border-radius: 999px;
    background: rgba(var(--text-color), 0.06);
    border: 1px solid rgba(var(--text-color), 0.08);
    box-sizing: border-box;
}

.segmented-control[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
    width: min(360px, calc(100vw - 32px));
}

body.dark-theme .segmented-control {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.segmented-highlight {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    border-radius: 999px;
    background: rgb(var(--bg-color));
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 0 0 0.5px rgba(var(--text-color), 0.06);
    transition: transform 0.28s cubic-bezier(0.25, 0.1, 0.25, 1),
        box-shadow 0.28s ease;
    z-index: 0;
    pointer-events: none;
}

.segmented-control[data-columns="3"] .segmented-highlight {
    width: calc((100% - 8px) / 3);
}

.segmented-control[data-active="notepad"] .segmented-highlight {
    transform: translateX(100%);
}

.segmented-control[data-columns="3"][data-active="connect"] .segmented-highlight {
    transform: translateX(0%);
}

.segmented-control[data-columns="3"][data-active="chat"] .segmented-highlight {
    transform: translateX(100%);
}

.segmented-control[data-columns="3"][data-active="notepad"] .segmented-highlight {
    transform: translateX(200%);
}

.segmented-option {
    position: relative;
    z-index: 1;
    border: none;
    background: transparent;
    color: rgb(var(--text-color));
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    padding: 10px 16px;
    border-radius: 999px;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.segmented-option:hover {
    opacity: 0.85;
}

.segmented-option[aria-selected="true"] {
    opacity: 1;
    color: var(--primary-color);
}

.notepad-view-zone {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0 20px 16px;
    box-sizing: border-box;
    gap: 8px;
}

/* Shared Notes — presence row (who's collaborating on this note right now) */
.shared-notes-presence {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 4px 4px 0;
    min-height: 22px;
}

.shared-notes-presence .presence-label {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: rgba(var(--text-color), 0.5);
}

.shared-notes-presence .presence-empty {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: rgba(var(--text-color), 0.45);
}

.shared-notes-presence .presence-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
}

.shared-notes-presence .presence-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px 2px 4px;
    border-radius: 999px;
    background: rgba(var(--text-color), 0.05);
    border: 1px solid rgba(var(--text-color), 0.06);
    color: rgba(var(--text-color), 0.78);
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.4;
    max-width: 180px;
    box-sizing: border-box;
    transition: background 0.15s ease;
}

.shared-notes-presence .presence-badge:hover {
    background: rgba(var(--text-color), 0.08);
}

.shared-notes-presence .presence-badge.is-typing {
    background: color-mix(in srgb, var(--primary-color) 10%, transparent);
    border-color: color-mix(in srgb, var(--primary-color) 28%, transparent);
    color: color-mix(in srgb, rgb(var(--text-color)) 85%, var(--primary-color) 15%);
}

.shared-notes-presence .presence-avatar {
    width: 18px;
    height: 18px;
    flex: none;
    border-radius: 50%;
    background: rgba(var(--text-color), 0.1);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: rgba(var(--text-color), 0.7);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.shared-notes-presence .presence-avatar .icon {
    width: 10px;
    height: 10px;
    fill: currentColor;
    transition: opacity 0.15s ease;
}

.shared-notes-presence .presence-avatar.has-avatar {
    background-color: transparent;
}

.shared-notes-presence .presence-avatar.has-avatar .icon {
    opacity: 0;
}

.shared-notes-presence .presence-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}

.shared-notes-presence .presence-typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 22%, transparent);
    margin-left: 2px;
    flex: none;
    animation: presence-pulse 1.2s ease-in-out infinite;
}

@keyframes presence-pulse {
    0%, 100% { opacity: 0.35; transform: scale(0.85); }
    50%      { opacity: 1;    transform: scale(1); }
}

.notepad-editor {
    flex: 1 1 auto;
    align-self: center;
    min-height: 200px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 24px 32px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    outline: none;
    resize: none;
    background-color: var(--dialog-bg-color);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: rgb(var(--text-color));
    font: inherit;
    font-size: 17px;
    font-weight: 400;
    line-height: 1.55;
    letter-spacing: -0.011em;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.notepad-editor::placeholder {
    color: rgba(var(--text-color), 0.28);
}

.notepad-editor:focus {
    border-color: color-mix(in srgb, var(--primary-color) 40%, var(--border-color));
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.06),
        0 0 0 3px color-mix(in srgb, var(--primary-color) 22%, transparent);
}

body.dark-theme .notepad-editor {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

body.dark-theme .notepad-editor:focus {
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.45),
        0 0 0 3px color-mix(in srgb, var(--primary-color) 35%, transparent);
}

@supports not (border-color: color-mix(in srgb, red 50%, blue)) {
    .notepad-editor:focus {
        border-color: var(--primary-color);
        box-shadow:
            0 4px 12px rgba(0, 0, 0, 0.06),
            0 0 0 3px rgba(0, 122, 255, 0.22);
    }

    body.dark-theme .notepad-editor:focus {
        box-shadow:
            0 4px 24px rgba(0, 0, 0, 0.45),
            0 0 0 3px rgba(0, 122, 255, 0.35);
    }
}

/* ----- AnyDrop: chat (WhatsApp-style workspace) ----- */

.chat-view-zone {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: 16px;
    padding: 0 20px 16px;
    box-sizing: border-box;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.chat-list {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--dialog-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.chat-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px 8px 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
    min-height: 0;
    flex-shrink: 0;
}
.chat-list-header .icon-button {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}
.chat-list-header .btn {
    flex-shrink: 0;
}
.chat-list-header-actions,
.chat-thread-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
/* Secondary “Manage” control next to Add Contact (list + thread toolbars). */
.chat-manage-contacts-toolbar-btn {
    flex-shrink: 0;
    margin: 0;
    padding: 2px 10px;
    min-height: 28px;
    height: auto;
    font-size: 10.5px;
    line-height: 1.2;
    letter-spacing: 0.06em;
    white-space: nowrap;
    background: rgba(var(--text-color), 0.08);
    color: rgb(var(--text-color));
    border: 1px solid rgba(var(--text-color), 0.14);
}
body.dark-theme .chat-manage-contacts-toolbar-btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgb(var(--text-color));
}
.chat-manage-contacts-toolbar-btn:not([disabled]):hover {
    background: rgba(var(--text-color), 0.12);
}
body.dark-theme .chat-manage-contacts-toolbar-btn:not([disabled]):hover {
    background: rgba(255, 255, 255, 0.12);
}
/* Permanent “Add Contact” pill next to Conversations (and same style in thread header). */
.chat-add-contact-toolbar-btn {
    margin: 0;
    padding: 2px 12px;
    min-height: 28px;
    height: auto;
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 0.06em;
    white-space: nowrap;
}
.chat-thread-header .chat-add-contact-toolbar-btn {
    flex-shrink: 0;
}
.chat-list-header .chat-list-title {
    flex: 1 1 auto;
    min-width: 0;
}

.chat-list-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(var(--text-color), 0.55);
}

.chat-list-items {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 6px;
}

.chat-list-empty {
    padding: 24px 20px;
    text-align: center;
    color: rgba(var(--text-color), 0.55);
}
.chat-list-empty-title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: rgb(var(--text-color));
}
.chat-list-empty-subtitle {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.4;
}

.chat-list-item {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 12px;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: rgb(var(--text-color));
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}
.chat-list-item + .chat-list-item { margin-top: 2px; }
.chat-list-item:hover {
    background: rgba(var(--text-color), 0.05);
}
.chat-list-item[aria-selected="true"] {
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
}

.chat-list-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--text-color), 0.08);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: rgba(var(--text-color), 0.7);
    position: relative;
    flex: none;
    overflow: visible;
}
.chat-list-avatar .icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: opacity 0.15s ease;
}
.chat-list-avatar.has-avatar { background-color: transparent; }
.chat-list-avatar.has-avatar .icon { opacity: 0; }
.chat-list-avatar.online::after {
    content: '';
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #34c759;
    border: 2px solid rgb(var(--bg-color));
}

.chat-list-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}
.chat-list-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.chat-list-name {
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-list-time {
    font-size: 11.5px;
    color: rgba(var(--text-color), 0.45);
    flex: none;
}
.chat-list-preview {
    font-size: 12.5px;
    color: rgba(var(--text-color), 0.55);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Thread panel ---------------------------------------------------- */

.chat-thread {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    background: var(--dialog-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    /* visible so the emoji picker (above the composer) is not clipped */
    overflow: visible;
}

.chat-thread-header {
    /* This node is a <header>; undo global `header { … }` / `header > *` rules
       meant for the app chrome — those forced column layout on children (stacking
       avatar above the name) and `width: 100vw` which breaks the chat panel. */
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--dialog-bg-color) 85%, transparent);
    width: 100%;
    max-width: 100%;
    min-height: unset;
    box-sizing: border-box;
    position: relative;
    z-index: auto;
}

.chat-thread-header > * {
    display: flex;
    flex-direction: row;
    align-items: center;
    align-self: center;
    margin-left: 0;
    margin-right: 0;
    touch-action: manipulation;
}

.chat-thread-header > .chat-back-btn {
    height: 40px;
}

.chat-back-btn {
    display: none;
    border: 0;
    background: transparent;
    color: rgb(var(--text-color));
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
}
.chat-back-btn .icon { width: 18px; height: 18px; fill: currentColor; transform: rotate(90deg); }

.chat-peer-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}
.chat-peer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--text-color), 0.08);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: rgba(var(--text-color), 0.72);
    flex: none;
    overflow: hidden;
}
.chat-peer-avatar .icon {
    width: 22px;
    height: 22px;
    fill: currentColor;
    transition: opacity 0.15s ease;
}
.chat-peer-avatar.has-avatar { background-color: transparent; }
.chat-peer-avatar.has-avatar .icon { opacity: 0; }
.chat-peer-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chat-peer-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Connection state communicated via a soft ring around the avatar, so the
   header stays a single-line composition and doesn't clash with the first
   message bubble. */
.chat-peer-avatar[data-online="true"] {
    box-shadow: 0 0 0 2px #34c759 inset;
}

.chat-security-label {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, #34c759 40%, transparent);
    background: color-mix(in srgb, #34c759 14%, transparent);
    color: color-mix(in srgb, rgb(var(--text-color)) 86%, #1f7a36 14%);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.chat-security-label[hidden] {
    display: none;
}

@media (max-width: 560px) {
    .chat-security-label {
        max-width: 44vw;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.chat-empty-state {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px;
    text-align: center;
    color: rgba(var(--text-color), 0.55);
}
.chat-empty-icon {
    width: 42px;
    height: 42px;
    fill: rgba(var(--text-color), 0.28);
}
.chat-empty-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: rgb(var(--text-color));
}
.chat-empty-subtitle {
    margin: 0;
    font-size: 13px;
    max-width: 280px;
}

.chat-thread[data-active="true"] .chat-empty-state { display: none; }

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

.chat-thread[data-active="false"] .chat-messages { display: none; }

/* Bubbles --------------------------------------------------------- */

.chat-bubble {
    max-width: 68%;
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.4;
    letter-spacing: -0.005em;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.chat-bubble-sent {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 6px;
}
.chat-bubble-received {
    align-self: flex-start;
    background: rgba(var(--text-color), 0.08);
    color: rgb(var(--text-color));
    border-bottom-left-radius: 6px;
}
body.dark-theme .chat-bubble-received {
    background: rgba(255, 255, 255, 0.10);
}

.chat-bubble-content {
    white-space: pre-wrap;
}
.chat-bubble-meta {
    margin-top: 4px;
    font-size: 10.5px;
    opacity: 0.65;
    text-align: right;
}
.chat-bubble-received .chat-bubble-meta {
    opacity: 0.55;
}

@keyframes chat-bubble-in {
    from { opacity: 0; transform: translateY(4px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}
.chat-bubble-enter {
    animation: chat-bubble-in 0.18s ease-out;
}

/* File bubbles ---------------------------------------------------- */

.chat-bubble-file {
    padding: 10px 12px;
}

.chat-file-card {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 10px;
    align-items: center;
    min-width: 240px;
}

.chat-file-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-file-icon .icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}
.chat-bubble-received .chat-file-icon {
    background: rgba(var(--text-color), 0.08);
}

.chat-file-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chat-file-name {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-file-sub {
    font-size: 11.5px;
    opacity: 0.7;
}
.chat-file-progress {
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.22);
    overflow: hidden;
    margin-top: 4px;
}
.chat-file-progress > span {
    display: block;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    transition: width 0.18s ease;
}
.chat-bubble-received .chat-file-progress {
    background: rgba(var(--text-color), 0.14);
}
.chat-bubble-received .chat-file-progress > span {
    background: var(--primary-color);
}

.chat-file-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: inherit;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.14);
    transition: background 0.15s ease;
}
.chat-file-download:hover { background: rgba(255, 255, 255, 0.24); }
.chat-bubble-received .chat-file-download {
    background: rgba(var(--text-color), 0.08);
}
.chat-bubble-received .chat-file-download:hover {
    background: rgba(var(--text-color), 0.14);
}
.chat-file-download .icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Composer -------------------------------------------------------- */

.hidden {
    display: none !important;
}

/* Emoji picker (emoji-picker-element) ---------------------------------- */

#emoji-picker-container {
    position: absolute;
    right: 12px;
    /* One-line composer ≈ padding + row height; keeps panel just above the bar */
    bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    z-index: 50;
    border-radius: 14px;
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    max-width: calc(100% - 24px);
}

#emoji-picker-container emoji-picker {
    --background: var(--dialog-bg-color);
    --button-hover-background: rgb(var(--bg-color-secondary));
    height: 360px;
    max-height: min(360px, 45vh);
    width: min(352px, 100%);
    display: block;
}

.chat-composer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--dialog-bg-color) 92%, transparent);
}

/* Make chat use more vertical real-estate on large screens and keep
   the typing row visible by reducing footer chrome only in chat mode. */
body[data-view-mode="chat"] footer {
    margin-top: 4px;
}
body[data-view-mode="chat"] footer .logo {
    display: none;
}
body[data-view-mode="chat"] .known-as-wrapper {
    margin-top: 2px;
}

.chat-attach-btn,
.chat-emoji-btn,
.chat-mic-btn,
.chat-send-btn {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: rgba(var(--text-color), 0.7);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.chat-attach-btn:hover,
.chat-emoji-btn:hover,
.chat-mic-btn:hover { background: rgba(var(--text-color), 0.08); color: rgb(var(--text-color)); }

.chat-attach-btn .icon,
.chat-emoji-btn .icon,
.chat-mic-btn .icon,
.chat-send-btn .icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.chat-send-btn {
    background: var(--primary-color);
    color: white;
}
.chat-send-btn:disabled {
    background: rgba(var(--text-color), 0.12);
    color: rgba(var(--text-color), 0.35);
    cursor: not-allowed;
}
.chat-send-btn:not(:disabled):hover { transform: translateY(-1px); }

.chat-input {
    box-sizing: border-box;
    flex: 1 1 auto;
    align-self: center;
    resize: none;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 14px;
    background: rgb(var(--bg-color));
    color: rgb(var(--text-color));
    font: inherit;
    font-size: 15px;
    line-height: 1.4;
    outline: none;
    max-height: 160px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.chat-input:focus {
    border-color: color-mix(in srgb, var(--primary-color) 50%, var(--border-color));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 18%, transparent);
}
body.dark-theme .chat-input {
    background: rgba(255, 255, 255, 0.06);
}

/* Responsive layout (single panel stack on narrow screens) -------- */

@media (max-width: 720px) {
    /* Collapse to a single panel; the list/thread swap is driven by the
       `thread-open` class on `.chat-view-zone`. */
    .chat-view-zone {
        grid-template-columns: 1fr;
        padding: 0 10px 10px;
        gap: 10px;
    }
    .chat-view-zone.thread-open .chat-list { display: none; }
    .chat-view-zone:not(.thread-open) .chat-thread { display: none; }
    .chat-back-btn { display: inline-flex; }

    /* Tighter header for mobile; the soft blur lets underlying bubbles peek
       through when the peer name row sits right above the first message. */
    .chat-thread-header {
        padding: 10px 12px;
        gap: 8px;
        background: color-mix(in srgb, var(--dialog-bg-color) 94%, transparent);
        -webkit-backdrop-filter: saturate(140%) blur(14px);
        backdrop-filter: saturate(140%) blur(14px);
    }
    .chat-thread-header > .chat-back-btn {
        margin-left: -6px;
        height: 40px;
        width: 40px;
    }

    /* Slightly more compact peer identity block. */
    .chat-peer-info { gap: 10px; }
    .chat-peer-avatar { width: 36px; height: 36px; }
    .chat-peer-avatar .icon { width: 20px; height: 20px; }
    .chat-peer-name { font-size: 15px; }

    /* Security chip stays informative but stops fighting the name for space. */
    .chat-security-label {
        padding: 4px 9px;
        font-size: 10.5px;
        max-width: 40vw;
    }

    /* Reduce message gutter so bubbles breathe into the viewport. */
    .chat-messages {
        padding: 12px 12px 16px;
        gap: 4px;
    }

    /* Comfortable bubble width + larger text for one-handed reading. */
    .chat-bubble { max-width: 82%; font-size: 15px; line-height: 1.42; }
    .chat-bubble-meta { font-size: 10px; }

    /* File cards: drop the desktop min-width (was 240px — forced overflow on
       narrow phones) and tighten the column layout. */
    .chat-file-card {
        min-width: 0;
        grid-template-columns: 32px 1fr auto;
        gap: 10px;
    }
    .chat-file-icon { width: 32px; height: 32px; border-radius: 8px; }
    .chat-file-icon .icon { width: 16px; height: 16px; }
    .chat-file-name { font-size: 13.5px; }
    .chat-file-sub  { font-size: 11px; }
    .chat-file-download { width: 30px; height: 30px; }

    /* Composer: bigger touch targets, iOS-safe 16px input (prevents auto-zoom
       on focus) and real safe-area padding so the send button doesn't hide
       behind the home indicator. */
    .chat-composer {
        padding: 8px 10px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        gap: 6px;
    }
    .chat-attach-btn,
    .chat-emoji-btn,
    .chat-mic-btn,
    .chat-send-btn {
        width: 38px;
        height: 38px;
    }
    .chat-input {
        font-size: 16px;
        padding: 9px 14px;
        border-radius: 22px;
    }

    /* Emoji picker follows the shorter composer. */
    #emoji-picker-container {
        right: 10px;
        bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    }

    /* Conversation list: tighter rows, bigger avatar for thumb-sized taps. */
    .chat-list-header { padding: 8px 10px 8px 12px; }
    .chat-list-title  { font-size: 12px; }
    .chat-list-items  { padding: 4px; }
    .chat-list-item   { padding: 10px; gap: 10px; grid-template-columns: 44px 1fr; }
    .chat-list-avatar { width: 44px; height: 44px; }
    .chat-list-avatar .icon { width: 22px; height: 22px; }
    .chat-list-name   { font-size: 15px; }
    .chat-list-preview{ font-size: 13px; }

    /* Claim the space the footer uses on desktop — in chat view the hero,
       known-as editor and discovery badges live on the Connect tab, so we hide
       them here to give the conversation its full vertical budget. */
    body[data-view-mode="chat"] .view-mode-toolbar {
        padding: 6px 12px 8px;
    }
    body[data-view-mode="chat"] footer {
        margin: 0;
        padding: 0;
        min-height: 0;
    }
    body[data-view-mode="chat"] footer .logo,
    body[data-view-mode="chat"] .known-as-wrapper,
    body[data-view-mode="chat"] .discovery-wrapper {
        display: none;
    }
}

/* True phones: go edge-to-edge for a native-app feel, drop panel chrome. */
@media (max-width: 520px) {
    .chat-view-zone {
        padding: 0;
        gap: 0;
    }
    .chat-list,
    .chat-thread {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        box-shadow: none;
    }
    /* The panel fills the viewport, so the thread border would only appear as
       a single visible seam at the top under the toolbar. Keep a subtle divider
       there, but drop radii that would round into invisible corners. */
    .chat-thread { border-top-width: 1px; }
    .chat-list   { border-top-width: 1px; }

    /* Reclaim horizontal space on very narrow devices. */
    .chat-messages { padding: 10px 10px 14px; }
    .chat-bubble   { max-width: 86%; }

    /* Below a certain width the header is crowded — collapse the security
       chip to avoid wrapping/truncating the peer name. The connection state
       is still communicated visually by the green ring around the avatar. */
    .chat-security-label { display: none; }
}

/* =====================================================================
   Welcome hero (Connect view)
   ===================================================================== */

.connect-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 640px;
    width: calc(100% - 32px);
    margin: 12px auto 4px;
    padding: 16px 18px;
    border-radius: 18px;
    background: var(--dialog-bg-color);
    border: 1px solid var(--border-color);
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.12), /* wide ambient shadow for elevation */
        0 8px 16px rgba(0, 0, 0, 0.08), /* mid-tier shadow for depth */
        0 2px 4px rgba(0, 0, 0, 0.04), /* tight shadow for physical edge */
        inset 0 1px 0 rgba(255, 255, 255, 0.08); /* top light-catch */
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    color: rgb(var(--text-color));
    box-sizing: border-box;
}

.connect-hero[hidden] { display: none; }

.connect-hero .hero-avatar {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary-color) 14%, transparent);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.connect-hero .hero-avatar:hover {
    transform: scale(1.03);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.connect-hero .hero-avatar .hero-avatar-icon {
    width: 26px;
    height: 26px;
    fill: var(--primary-color);
    transition: opacity 0.15s ease;
}
.connect-hero .hero-avatar.has-avatar {
    background-color: transparent;
}
.connect-hero .hero-avatar.has-avatar .hero-avatar-icon {
    opacity: 0;
}

/* Camera overlay — revealed on hover or focus to cue "click to change". */
.connect-hero .hero-avatar-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.connect-hero .hero-avatar-overlay .icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}
.connect-hero .hero-avatar:hover .hero-avatar-overlay,
.connect-hero .hero-avatar:focus-within .hero-avatar-overlay {
    opacity: 1;
}

.connect-hero .hero-body {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.connect-hero .hero-eyebrow {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(var(--text-color), 0.5);
}

.connect-hero .hero-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.connect-hero .hero-display-name {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: rgb(var(--text-color));
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
    outline: none;
    padding: 2px 6px;
    margin-left: -6px;
    border-radius: 8px;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    min-width: 1ch;
    max-width: 100%;
}

.connect-hero .hero-display-name:hover {
    background: rgba(var(--text-color), 0.06);
}

.connect-hero.is-editing .hero-display-name,
.connect-hero .hero-display-name:focus {
    background: rgba(var(--text-color), 0.08);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary-color) 35%, transparent);
    overflow: visible;
    white-space: normal;
    word-break: break-word;
}

.connect-hero.is-editing .hero-edit-btn {
    color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
}

.connect-hero .hero-edit-btn {
    flex: none;
    border: 0;
    background: transparent;
    color: rgba(var(--text-color), 0.55);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.connect-hero .hero-edit-btn:hover {
    background: rgba(var(--text-color), 0.08);
    color: rgb(var(--text-color));
}
.connect-hero .hero-edit-btn .icon {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.connect-hero .hero-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(var(--text-color), 0.6);
}

.connect-hero .hero-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34c759;
    box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.18);
    flex: none;
}
.connect-hero[data-online="false"] .hero-dot {
    background: rgba(var(--text-color), 0.35);
    box-shadow: 0 0 0 3px rgba(var(--text-color), 0.08);
}

/* Invisible Mode: warm-amber indicator so it reads as "private, not offline" */
.connect-hero[data-invisible="true"][data-online="true"] .hero-dot {
    background: #ff9f0a;
    box-shadow: 0 0 0 3px rgba(255, 159, 10, 0.2);
}

/* ----- Invisible Mode privacy row + iOS-style toggle ----- */
.connect-hero .hero-privacy {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    padding: 8px 10px 8px 12px;
    border-radius: 12px;
    background: rgba(var(--text-color), 0.04);
    border: 1px solid rgba(var(--text-color), 0.06);
    transition: background 0.2s ease, border-color 0.2s ease;
}
.connect-hero[data-invisible="true"] .hero-privacy {
    background: color-mix(in srgb, var(--primary-color) 8%, transparent);
    border-color: color-mix(in srgb, var(--primary-color) 24%, transparent);
}

.connect-hero .hero-privacy-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}
.connect-hero .hero-privacy-title {
    font-size: 13px;
    font-weight: 600;
    color: rgb(var(--text-color));
    letter-spacing: -0.005em;
    line-height: 1.2;
}
.connect-hero .hero-privacy-sub {
    font-size: 11.5px;
    color: rgba(var(--text-color), 0.55);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The switch: a tap-friendly label wrapping a hidden checkbox + pill track. */
.connect-hero .hero-switch {
    position: relative;
    flex: none;
    display: inline-block;
    width: 44px;
    height: 26px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.connect-hero .hero-switch-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.connect-hero .hero-switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(var(--text-color), 0.18);
    transition: background 0.22s ease, box-shadow 0.22s ease;
}
.connect-hero .hero-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.22),
        0 0 0 0.5px rgba(0, 0, 0, 0.04);
    transition: transform 0.24s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.connect-hero .hero-switch-input:checked ~ .hero-switch-track {
    background: var(--primary-color);
}
.connect-hero .hero-switch-input:checked ~ .hero-switch-track .hero-switch-thumb {
    transform: translateX(18px);
}
.connect-hero .hero-switch-input:focus-visible ~ .hero-switch-track {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 28%, transparent);
}
body.dark-theme .connect-hero .hero-switch-track {
    background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 520px) {
    .connect-hero {
        padding: 14px 14px;
        gap: 12px;
    }
    .connect-hero .hero-avatar {
        width: 44px;
        height: 44px;
    }
    .connect-hero .hero-avatar .icon {
        width: 22px;
        height: 22px;
    }
    .connect-hero .hero-display-name {
        font-size: 19px;
    }
    .connect-hero .hero-privacy {
        padding: 8px 10px;
        margin-top: 8px;
    }
    .connect-hero .hero-privacy-sub {
        /* Subtitle can wrap on narrow screens rather than disappear behind the
           ellipsis; the row is still compact because the switch is fixed-width. */
        white-space: normal;
    }
}

/* =====================================================================
   Unread indicator on the Chat segmented-control tab
   ===================================================================== */

.segmented-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}
.segmented-option > .segmented-option-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

.segmented-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 99px;
    background: #ff3b30;
    color: white;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-sizing: border-box;
    animation: badge-pulse 0.5s ease;
}
.segmented-badge[hidden] { display: none; }
@keyframes badge-pulse {
    0%   { transform: scale(0.6); opacity: 0; }
    60%  { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1);   opacity: 1; }
}

/* =====================================================================
   In-page banner toast (new chat message)
   ===================================================================== */

.chat-banner {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translate(-50%, -20px);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    min-width: 280px;
    max-width: min(420px, calc(100vw - 24px));
    border-radius: 14px;
    background: var(--dialog-bg-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.14);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    color: rgb(var(--text-color));
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.chat-banner[hidden] { display: none; }
.chat-banner.chat-banner-visible {
    transform: translate(-50%, 0);
    opacity: 1;
    pointer-events: auto;
}

.chat-banner-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary-color) 14%, transparent);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    color: var(--primary-color);
    overflow: hidden;
}
.chat-banner-avatar .icon { width: 18px; height: 18px; fill: currentColor; transition: opacity 0.15s ease; }
.chat-banner-avatar.has-avatar { background-color: transparent; }
.chat-banner-avatar.has-avatar .icon { opacity: 0; }

.chat-banner-body { min-width: 0; flex: 1 1 auto; }
.chat-banner-name {
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: rgb(var(--text-color));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-banner-preview {
    font-size: 13px;
    color: rgba(var(--text-color), 0.7);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-banner-close {
    flex: none;
    border: 0;
    background: transparent;
    color: rgba(var(--text-color), 0.5);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-banner-close:hover { background: rgba(var(--text-color), 0.08); color: rgb(var(--text-color)); }
.chat-banner-close .icon { width: 12px; height: 12px; fill: currentColor; }

/* =====================================================================
   Inline file-transfer request / sender cancel / declined bubbles
   ===================================================================== */

.chat-bubble-file-request {
    max-width: 86%;
    padding: 10px 12px;
    align-self: flex-start;
    background: rgba(var(--text-color), 0.08);
    color: rgb(var(--text-color));
    border-radius: 18px;
    border-bottom-left-radius: 6px;
}
body.dark-theme .chat-bubble-file-request {
    background: rgba(255, 255, 255, 0.10);
}

.chat-request-card {
    grid-template-columns: 72px 1fr;
    align-items: center;
    gap: 12px;
}

.chat-request-thumb {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(var(--text-color), 0.08);
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-request-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* When a request bubble has no thumbnail, scale the file-icon card so the
   layout still reads as a preview tile rather than a tiny square. */
.chat-request-card > .chat-file-icon {
    width: 72px;
    height: 72px;
    border-radius: 12px;
}
.chat-request-card > .chat-file-icon .icon {
    width: 28px;
    height: 28px;
    opacity: 0.75;
}

/* Sender-side file bubble thumbnail (optional, for image files). Reuses the
   existing .chat-file-icon slot but renders an <img> so we get a preview. */
.chat-file-icon.chat-file-icon-thumb {
    padding: 0;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
}
.chat-file-icon.chat-file-icon-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.chat-bubble-received .chat-file-icon.chat-file-icon-thumb {
    background: rgba(var(--text-color), 0.08);
}

.chat-file-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

.chat-file-action {
    border: 0;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.005em;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s ease, color 0.15s ease;
    background: rgba(var(--text-color), 0.10);
    color: rgb(var(--text-color));
}
.chat-file-action:hover { background: rgba(var(--text-color), 0.16); }
.chat-file-action:active { transform: scale(0.97); }

.chat-file-accept {
    background: var(--primary-color);
    color: white;
}
.chat-file-accept:hover {
    background: color-mix(in srgb, var(--primary-color) 88%, black);
}

.chat-file-decline {
    background: transparent;
    color: rgba(var(--text-color), 0.7);
    box-shadow: inset 0 0 0 1px rgba(var(--text-color), 0.15);
}
.chat-file-decline:hover {
    background: rgba(255, 59, 48, 0.08);
    color: #ff3b30;
    box-shadow: inset 0 0 0 1px rgba(255, 59, 48, 0.35);
}

.chat-file-cancel {
    background: transparent;
    color: #ff3b30;
    box-shadow: inset 0 0 0 1px rgba(255, 59, 48, 0.28);
}
.chat-file-cancel:hover {
    background: rgba(255, 59, 48, 0.10);
}

/* Chat bubble sender context: "Cancel" sits inside a sent bubble */
.chat-bubble-sent .chat-file-cancel {
    color: rgba(255, 255, 255, 0.92);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.chat-bubble-sent .chat-file-cancel:hover {
    background: rgba(255, 255, 255, 0.14);
}

.chat-request-result {
    margin-top: 6px;
    font-style: italic;
    font-size: 12.5px;
    opacity: 0.75;
}

/* Terminal / cancelled states: fade + strikethrough feel */
.chat-bubble[data-file-status="declined"],
.chat-bubble[data-file-status="cancelled"],
.chat-bubble[data-file-status="cancelled-by-sender"] {
    opacity: 0.68;
}
.chat-bubble[data-file-status="declined"] .chat-file-name,
.chat-bubble[data-file-status="cancelled"] .chat-file-name,
.chat-bubble[data-file-status="cancelled-by-sender"] .chat-file-name {
    text-decoration: line-through;
    text-decoration-color: rgba(var(--text-color), 0.35);
}

/* Keep the composer safely below the banner on narrow screens */
@media (max-width: 520px) {
    .chat-banner {
        top: 10px;
        min-width: 0;
        width: calc(100% - 24px);
    }
}

/* --- NEW PREMIUM DIALOG STYLES --- */
x-dialog x-paper {
    border-radius: 28px !important;
    background: var(--dialog-bg-color) !important;
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid rgba(128, 128, 128, 0.15) !important;
    box-shadow: 0 24px 48px rgba(0,0,0,0.12), 0 0 0 1px rgba(255,255,255,0.05) inset !important;
    overflow: hidden;
    max-width: 380px;
    padding: 16px;
}

/* Kill the legacy Teal/Yellow headers */
x-dialog .row.center.p-2:first-child {
    background: transparent !important;
    padding: 12px 16px 4px !important;
}
.dialog-title {
    font-size: 20px !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em !important;
    color: rgb(var(--text-color)) !important;
    margin: 0 !important;
    border: none !important;
}

/* Subtitles / Instructions */
.key-instructions { margin: 8px 0 20px !important; display: flex; flex-direction: column; gap: 4px; }
.key-instructions .font-subheading {
    font-size: 14px !important;
    color: rgba(var(--text-color), 0.6) !important;
    line-height: 1.4 !important;
}

/* QR Code Card */
.key-qr-code {
    background: #ffffff !important;
    padding: 16px !important;
    border-radius: 20px !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04) !important;
    margin: 0 auto 16px !important;
    display: inline-block !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.key-qr-code:hover { transform: scale(1.03); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }

/* The Text Key */
h1.key {
    font-size: 38px !important;
    font-weight: 800 !important;
    letter-spacing: 0.2em !important;
    color: var(--primary-color) !important;
    margin: 0 0 24px !important;
    font-variant-numeric: tabular-nums;
}

/* iOS 2FA Style Inputs */
.input-key-container { gap: 8px !important; margin: 0 auto 16px !important; justify-content: center !important; }
.input-key-container .textarea {
    width: 48px !important;
    height: 56px !important;
    border-radius: 14px !important;
    background: rgba(var(--text-color), 0.04) !important;
    border: 1px solid rgba(var(--text-color), 0.08) !important;
    font-size: 26px !important;
    font-weight: 700 !important;
    color: rgb(var(--text-color)) !important;
    text-align: center !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02) !important;
    transition: all 0.2s ease !important;
}
.input-key-container .textarea:focus {
    background: rgba(var(--text-color), 0.06) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 20%, transparent) !important;
    transform: translateY(-2px);
}

/* Modal Buttons */
x-dialog .btn-row { gap: 12px; margin-top: 16px; width: 100%; }
x-dialog .btn-row .btn {
    border-radius: 14px !important;
    padding: 14px !important;
    font-size: 15px !important;
    flex: 1 1 0 !important;
}

/* Chat voice notes */
.chat-mic-btn.is-recording {
    color: #ff3b30 !important;
    animation: mic-pulse 1.2s infinite;
}
@keyframes mic-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
.chat-audio-player {
    height: 36px;
    outline: none;
    border-radius: 18px;
    max-width: 240px;
    margin: 4px 0;
}
.chat-bubble-sent .chat-audio-player {
    filter: invert(1) hue-rotate(180deg) brightness(1.5);
}

/* --- Clipboard staging (Apple-style drawer) --- */
.clipboard-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.clipboard-overlay[aria-hidden="false"] { opacity: 1; pointer-events: auto; }
.clipboard-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 340px; max-width: 100vw; background: var(--dialog-bg-color); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); border-left: 1px solid var(--border-color); z-index: 100; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0,0,0,0.1); }
.clipboard-drawer[aria-hidden="false"] { transform: translateX(0); }
.clipboard-header { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--border-color); }
.clipboard-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.clipboard-empty { text-align: center; color: rgba(var(--text-color), 0.5); font-size: 14px; margin-top: 40px; }
.clipboard-empty[hidden] { display: none !important; }
.clipboard-title { margin: 0; font-size: 16px; font-weight: 600; color: rgb(var(--text-color)); letter-spacing: -0.02em; }

.clipboard-card { background: rgba(var(--text-color), 0.04); border: 1px solid rgba(var(--text-color), 0.08); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; position: relative; transition: background 0.2s; cursor: pointer; }
.clipboard-card:hover { background: rgba(var(--text-color), 0.08); }
.clipboard-text { font-size: 14px; color: rgb(var(--text-color)); line-height: 1.4; white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.clipboard-card.expanded .clipboard-text { -webkit-line-clamp: unset; }
.clipboard-actions { display: flex; justify-content: flex-end; gap: 8px; opacity: 0; transition: opacity 0.2s; }
.clipboard-card:hover .clipboard-actions { opacity: 1; }
.clipboard-actions .btn-action { background: rgb(var(--bg-color-secondary)); border: none; border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 600; color: rgb(var(--text-color)); cursor: pointer; }
.clipboard-actions .btn-action.trash { color: #ff3b30; }

body:has(#clipboard-drawer[aria-hidden="false"]) {
    overflow: hidden;
}

/* Header clipboard toggle: native <button> reset */
header button.icon-button {
    border: none;
    background: transparent;
    padding: 0;
    font: inherit;
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
}

@media (max-width: 720px) {
    .clipboard-drawer {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 70vh;
        border-left: none;
        border-top: 1px solid var(--border-color);
        border-radius: 24px 24px 0 0;
        transform: translateY(100%);
    }
    .clipboard-drawer[aria-hidden="false"] {
        transform: translateY(0);
    }
}

/* --- Motion: Apple-style polish --- */

/* Phase 1: Spring modals */
@keyframes modal-spring {
    0% { opacity: 0; transform: scale(0.95) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
x-dialog x-paper {
    animation: modal-spring 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Phase 2: Chat bubble slide-in */
@keyframes bubble-slide-up {
    0% { opacity: 0; transform: translateY(12px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-bubble.chat-bubble-enter {
    animation: bubble-slide-up 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    transform-origin: bottom center;
}

/* Phase 3: Empty state float */
@keyframes gentle-float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
    100% { transform: translateY(0px); }
}
#chat-list-empty .icon,
#chat-empty-state .icon,
.clipboard-empty {
    animation: gentle-float 4s ease-in-out infinite;
    opacity: 0.8;
}

/* Phase 4: Staggered peer appearance */
@keyframes peer-pop {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}
x-peer {
    animation: peer-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.magic-link-container { display: flex; gap: 8px; margin: 16px 0; }
.magic-link-input { flex: 1; padding: 12px; border-radius: 12px; border: 1px solid rgba(var(--text-color), 0.1); background: rgba(var(--text-color), 0.04); color: var(--primary-color); font-family: monospace; font-size: 13px; text-align: center; }
.magic-link-input:focus { outline: none; border-color: var(--primary-color); }

.brand-logo-img { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; margin-right: 12px; }
header .logo {
    display: flex;
    flex-direction: row;
    align-items: center;
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.02em;
    color: rgb(var(--text-color));
    position: absolute;
    left: 20px;
    top: 12px;
    z-index: 1;
}

/* --- ANYDROP MESH GRADIENT BACKGROUND --- */
body {
    background-color: #f5f7fb !important;
    background-image:
        radial-gradient(at 0% 0%, rgba(0, 122, 255, 0.08) 0px, transparent 52%),
        radial-gradient(at 100% 0%, rgba(88, 86, 214, 0.06) 0px, transparent 52%),
        radial-gradient(at 100% 100%, rgba(0, 122, 255, 0.05) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(88, 86, 214, 0.07) 0px, transparent 50%) !important;
    background-attachment: fixed;
    animation: mesh-breathe 15s ease-in-out infinite alternate;
}

body.dark-theme {
    background-color: #050505 !important;
    background-image:
        radial-gradient(at 0% 0%, rgba(0, 122, 255, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(88, 86, 214, 0.10) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 122, 255, 0.08) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(88, 86, 214, 0.12) 0px, transparent 50%) !important;
}

@media (prefers-color-scheme: dark) {
    body:not(.light-theme) {
        background-color: #050505 !important;
        background-image:
            radial-gradient(at 0% 0%, rgba(0, 122, 255, 0.12) 0px, transparent 50%),
            radial-gradient(at 100% 0%, rgba(88, 86, 214, 0.10) 0px, transparent 50%),
            radial-gradient(at 100% 100%, rgba(0, 122, 255, 0.08) 0px, transparent 50%),
            radial-gradient(at 0% 100%, rgba(88, 86, 214, 0.12) 0px, transparent 50%) !important;
    }
}

@keyframes mesh-breathe {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

/* Disable legacy animated canvas background under mesh theme */
.circles {
    display: none !important;
}

/* --- ZERO STATE DASHBOARD --- */
.feature-grid { display: flex; gap: 16px; margin-top: 48px; max-width: 760px; justify-content: center; flex-wrap: wrap; }
.feature-card { background: rgba(var(--text-color), 0.03); border: 1px solid rgba(var(--text-color), 0.06); border-radius: 20px; padding: 24px; width: 220px; text-align: left; display: flex; flex-direction: column; gap: 12px; transition: transform 0.3s ease, background 0.3s ease; }
.feature-card:hover { transform: translateY(-4px); background: rgba(var(--text-color), 0.06); }
.feature-card .icon { width: 24px; height: 24px; color: var(--primary-color); opacity: 0.8; }
.feature-card h3 { font-size: 15px; font-weight: 600; margin: 0; color: rgb(var(--text-color)); letter-spacing: -0.01em; }
.feature-card p { font-size: 13px; margin: 0; color: rgba(var(--text-color), 0.5); line-height: 1.4; }

/* --- HEADER REFINEMENTS --- */
header .icon-button .icon { opacity: 0.6; transition: opacity 0.2s ease, transform 0.2s ease; }
header .icon-button:hover .icon { opacity: 1; transform: scale(1.05); }

/* --- GEMSHI WATERMARK --- */
.gemshi-watermark { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; opacity: 0.3; transition: opacity 0.3s ease; pointer-events: auto; z-index: 10; text-decoration: none; color: inherit; cursor: pointer; }
.gemshi-watermark:hover,
.gemshi-watermark:focus-within { opacity: 0.8; }
.gemshi-watermark span { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: rgb(var(--text-color)); }
.gemshi-logo-container { width: 80px; height: 24px; background-size: contain; background-repeat: no-repeat; background-position: center; }

/* Theme-aware logo switching */
:root { --gemshi-logo: url('../images/GemshiLogoLight.png'); }
@media (prefers-color-scheme: dark) { :root { --gemshi-logo: url('../images/GemshiLogoDark.png'); } }
body.dark-theme { --gemshi-logo: url('../images/GemshiLogoDark.png'); }
body.light-theme { --gemshi-logo: url('../images/GemshiLogoLight.png'); }

.gemshi-logo-container { background-image: var(--gemshi-logo); }

/* =====================================================================
   PREMIUM CHAT UI OVERRIDES (NATIVE WINDOW PARADIGM)
   ===================================================================== */

/* 1. The Unified Glass Window */
.chat-view-zone {
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 auto 16px !important;
    width: calc(100% - 40px) !important;
    max-width: 1200px !important;
    background: var(--dialog-bg-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 24px !important;
    -webkit-backdrop-filter: blur(28px) saturate(180%) !important;
    backdrop-filter: blur(28px) saturate(180%) !important;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.12), /* wide ambient shadow for elevation */
        0 8px 16px rgba(0, 0, 0, 0.08), /* mid-tier shadow for depth */
        0 2px 4px rgba(0, 0, 0, 0.04), /* tight shadow for physical edge */
        inset 0 1px 0 rgba(255, 255, 255, 0.08) !important; /* top light-catch */
    overflow: hidden !important;
}

/* Strip backgrounds from the child panels so the parent glass shows through */
.chat-list {
    background: rgba(var(--text-color), 0.015) !important; /* Extremely subtle tint to separate sidebar */
    border: none !important;
    border-right: 1px solid var(--border-color) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

.chat-thread {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

/* 2. Header Polish & De-emphasizing Loud Buttons */
.chat-list-header, .chat-thread-header {
    background: transparent !important;
    border-bottom: 1px solid rgba(var(--text-color), 0.06) !important;
    padding: 14px 16px !important;
}

.chat-add-contact-toolbar-btn {
    background: rgba(var(--text-color), 0.06) !important;
    color: rgb(var(--text-color)) !important;
    border: 1px solid rgba(var(--text-color), 0.04) !important;
    font-weight: 600 !important;
    box-shadow: none !important;
}
.chat-add-contact-toolbar-btn:hover {
    background: rgba(var(--text-color), 0.12) !important;
}

.chat-security-label {
    background: transparent !important;
    border: none !important;
    color: rgba(var(--text-color), 0.4) !important;
    padding: 0 !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* 3. The Floating Composer */
.chat-composer {
    background: transparent !important;
    border-top: none !important;
    padding: 12px 20px 20px !important;
}

.chat-input {
    background: rgba(var(--text-color), 0.04) !important;
    border: 1px solid rgba(var(--text-color), 0.06) !important;
    border-radius: 24px !important;
    padding: 12px 18px !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02) !important;
}

.chat-input:focus {
    background: rgba(var(--text-color), 0.06) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 20%, transparent) !important;
}

/* 4. Message Bubble Shadows */
.chat-bubble {
    box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important;
}
.chat-bubble-received {
    background: rgba(var(--text-color), 0.05) !important;
    border: 1px solid rgba(var(--text-color), 0.03) !important;
}

/* 5. Mobile Container Adjustments */
@media (max-width: 720px) {
    .chat-view-zone {
        width: calc(100% - 20px) !important;
        margin: 0 auto 10px !important;
        border-radius: 20px !important;
    }
    .chat-list {
        border-right: none !important;
    }
    .chat-composer {
        padding: 8px 12px 16px !important;
    }
}

@media (max-width: 520px) {
    .chat-view-zone {
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
    }
}

/* =====================================================================
   PREMIUM NOTEPAD UI OVERRIDES (NATIVE WINDOW PARADIGM)
   ===================================================================== */

/* 1. The Unified Glass Window */
.notepad-view-zone {
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 auto 16px !important;
    width: calc(100% - 40px) !important;
    max-width: 1200px !important;
    background: var(--dialog-bg-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 24px !important;
    -webkit-backdrop-filter: blur(28px) saturate(180%) !important;
    backdrop-filter: blur(28px) saturate(180%) !important;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.12), /* wide ambient shadow for elevation */
        0 8px 16px rgba(0, 0, 0, 0.08), /* mid-tier shadow for depth */
        0 2px 4px rgba(0, 0, 0, 0.04), /* tight shadow for physical edge */
        inset 0 1px 0 rgba(255, 255, 255, 0.08) !important; /* top light-catch */
    overflow: hidden !important;
}

/* 2. The Integrated Toolbar (Presence Row) */
.shared-notes-presence {
    background: transparent !important;
    border-bottom: 1px solid rgba(var(--text-color), 0.06) !important;
    padding: 14px 20px !important;
    margin: 0 !important;
    min-height: 56px !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none !important; /* Hide scrollbar for clean UI */
}
.shared-notes-presence::-webkit-scrollbar {
    display: none !important;
}

/* Style the "Shared among" label to look like a window header */
.shared-notes-presence .presence-label,
.shared-notes-presence .presence-empty {
    font-size: 12px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    color: rgba(var(--text-color), 0.4) !important;
    margin-right: 12px !important;
    white-space: nowrap !important;
}

/* Modernize the presence badges */
.shared-notes-presence .presence-badge {
    background: rgba(var(--text-color), 0.04) !important;
    border: 1px solid rgba(var(--text-color), 0.08) !important;
    border-radius: 10px !important;
    padding: 6px 12px 6px 8px !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02) !important;
}

/* 3. The Invisible, Seamless Editor */
.notepad-editor {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 32px 40px !important;
    margin: 0 !important;
    max-width: none !important;
    font-size: 16px !important;
    line-height: 1.6 !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    color: rgb(var(--text-color)) !important;
}

/* Remove the glowing focus ring since the whole window is the editor */
.notepad-editor:focus {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* 4. Mobile Adjustments */
@media (max-width: 720px) {
    .notepad-view-zone {
        width: calc(100% - 20px) !important;
        margin: 0 auto 10px !important;
        border-radius: 20px !important;
    }
    .shared-notes-presence {
        padding: 12px 16px !important;
    }
    .notepad-editor {
        padding: 24px 20px !important;
        font-size: 16px !important; /* Prevents iOS auto-zoom */
    }
}

@media (max-width: 520px) {
    .notepad-view-zone {
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
    }
}

/* =====================================================================
   RESPONSIVE HOTFIXES (MOBILE + DESKTOP PARITY)
   ===================================================================== */

/* Home / zero-state readability on small screens */
@media (max-width: 720px) {
    .feature-grid {
        width: 100% !important;
        max-width: 100% !important;
        margin-top: 20px !important;
        padding: 0 10px !important;
        box-sizing: border-box !important;
        gap: 10px !important;
    }
    .feature-card {
        width: 100% !important;
        max-width: 420px !important;
        padding: 16px !important;
    }
}

/* Keep left brand from crowding controls on phones */
@media (max-width: 720px) {
    header {
        padding-left: 96px !important;
    }
    header .logo {
        left: 10px !important;
        top: 10px !important;
        font-size: 13px !important;
    }
    .brand-logo-img {
        width: 22px !important;
        height: 22px !important;
        margin-right: 6px !important;
    }
}

/* Chat: fill #center flex budget so the thread can shrink; .chat-messages scrolls inside.
   (Avoid height:auto + large min-height — they size the pane to all messages so nothing scrolls
   while html/body and #center keep overflow hidden.) */
body[data-view-mode="chat"] .chat-view-zone {
    flex: 1 1 0% !important;
    min-height: 0 !important;
}

body[data-view-mode="chat"] .chat-thread {
    min-height: 0 !important;
}

body[data-view-mode="chat"] .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

@media (max-width: 720px) {
    body[data-view-mode="chat"] .chat-view-zone {
        display: grid !important;
        grid-template-columns: 1fr !important;
        min-height: 0 !important;
        height: 100% !important;
        width: calc(100% - 16px) !important;
        margin: 0 auto 8px !important;
        padding: 0 !important;
        gap: 0 !important;
        overflow: hidden !important;
    }

    body[data-view-mode="chat"] .chat-list,
    body[data-view-mode="chat"] .chat-thread {
        min-height: 0 !important;
        height: 100% !important;
    }

    body[data-view-mode="chat"] .chat-view-zone.thread-open .chat-list {
        display: none !important;
    }
    body[data-view-mode="chat"] .chat-view-zone.thread-open .chat-thread {
        display: flex !important;
    }
    body[data-view-mode="chat"] .chat-view-zone:not(.thread-open) .chat-list {
        display: flex !important;
    }
    body[data-view-mode="chat"] .chat-view-zone:not(.thread-open) .chat-thread {
        display: none !important;
    }

    body[data-view-mode="chat"] .chat-messages {
        padding: 10px 10px 12px !important;
    }
    body[data-view-mode="chat"] .chat-composer {
        padding: 8px 10px max(12px, env(safe-area-inset-bottom)) !important;
    }
}

@media (max-width: 520px) {
    body[data-view-mode="chat"] .chat-view-zone {
        width: 100% !important;
        min-height: 0 !important;
        height: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
    }
}

/* Notepad: preserve premium look but restore practical editing area on mobile */
body[data-view-mode="notepad"] .notepad-view-zone {
    display: flex !important;
    flex-direction: column !important;
    min-height: calc(100dvh - 140px) !important;
}

body[data-view-mode="notepad"] .notepad-editor {
    flex: 1 1 auto !important;
    min-height: 360px !important;
}

@media (max-width: 720px) {
    body[data-view-mode="notepad"] .notepad-view-zone {
        width: calc(100% - 16px) !important;
        min-height: calc(100dvh - 118px) !important;
        margin: 0 auto 8px !important;
    }
    body[data-view-mode="notepad"] .shared-notes-presence {
        min-height: 48px !important;
        padding: 10px 12px !important;
    }
    body[data-view-mode="notepad"] .notepad-editor {
        min-height: 280px !important;
        padding: 18px 14px max(16px, env(safe-area-inset-bottom)) !important;
    }
}

@media (max-width: 520px) {
    body[data-view-mode="notepad"] .notepad-view-zone {
        width: 100% !important;
        min-height: calc(100dvh - 108px) !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
    }
}

/* Keep top mode switch always visible above content panes */
.view-mode-toolbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: color-mix(in srgb, var(--dialog-bg-color) 82%, transparent) !important;
    -webkit-backdrop-filter: blur(14px) saturate(145%) !important;
    backdrop-filter: blur(14px) saturate(145%) !important;
}

/* Ensure view panes render below the sticky toolbar */
.files-view-zone,
.chat-view-zone,
.notepad-view-zone {
    position: relative !important;
    z-index: 1 !important;
}

@media (max-width: 720px) {
    .view-mode-toolbar {
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }
}

/* Main app chrome only: float dropdowns above sticky toolbars. Avoid a global
   `header` rule so full-screen #about (z-index 32) and other <header> panels are
   not covered by the top bar, which blocked the About close control. */
body > header {
    z-index: 90 !important;
}

/* Ensure dialogs and modals always float above the main header */
x-dialog,
x-dialog[show],
#about,
.about-is-open {
    z-index: 110 !important;
}

/* --- ABOUT MODAL LOGO (always dark asset for contrast on modal) --- */
.about-logo-container {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background-size: cover;
    background-position: center;
    background-image: url('../images/AnyDropLogoDark.png');
}

/* Gemshi credit inside About (separate from fixed-page watermark) */
.about-gemshi-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    text-decoration: none !important;
    color: #ffffff;
    opacity: 0.92;
    transition: opacity 0.2s ease;
}
.about-gemshi-footer:hover,
.about-gemshi-footer:focus-visible {
    opacity: 1;
}
.about-gemshi-crafted {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.75);
}
.about-gemshi-brand-img {
    display: block;
    height: auto;
    max-width: 98px;
    width: auto;
    object-fit: contain;
}
.about-gemshi-tagline {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #ffffff;
}
.about-gemshi-year {
    font-weight: 500;
    opacity: 0.85;
}

/* --- GEMSHI WATERMARK LINK STYLING --- */
a.gemshi-watermark {
    text-decoration: none !important;
    cursor: pointer;
    pointer-events: auto !important;
}

/* --- LOGO HOVER SPIN --- */
.brand-logo-img {
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.brand-logo-img:hover {
    transform: rotate(360deg) scale(1.1) !important;
}

/* --- AMBIENT MOUSE GLOW --- */
:root {
    --mouse-x: 50vw;
    --mouse-y: 50vh;
}

#ambient-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 60vmax;
    height: 60vmax;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 122, 255, 0.15) 0%, rgba(88, 86, 214, 0.05) 50%, transparent 70%);
    filter: blur(80px);
    pointer-events: none;
    z-index: -1;
    transform: translate(calc(var(--mouse-x) - 50%), calc(var(--mouse-y) - 50%));
    transition: transform 0.15s ease-out;
    will-change: transform;
}

@media (hover: none) and (pointer: coarse) {
    #ambient-glow {
        animation: mobile-ambient-drift 15s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
        transition: none;
    }
}

@keyframes mobile-ambient-drift {
    0% { transform: translate(-10vw, -10vh) scale(1); }
    50% { transform: translate(40vw, 20vh) scale(1.2); }
    100% { transform: translate(-20vw, 60vh) scale(0.9); }
}

/* --- CHAT & NOTES SHADOW CALIBRATION --- */
.chat-view-zone,
.notepad-view-zone {
    /* 1. Soften the shadow to fix the muddy/harsh rendering */
    box-shadow:
        0 16px 32px rgba(0, 0, 0, 0.06), /* soft, diffused ambient layer */
        0 4px 16px rgba(0, 0, 0, 0.04), /* mid-tier depth layer */
        0 1px 2px rgba(0, 0, 0, 0.02), /* tight edge layer */
        inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;

    /* 2. Increase bottom margin to prevent the shadow from clipping against the viewport edge */
    margin-bottom: 48px !important;
}

/* Mobile adjustments so it doesn't waste too much space on small screens */
@media (max-width: 720px) {
    .chat-view-zone,
    .notepad-view-zone {
        margin-bottom: 24px !important;
        box-shadow:
            0 8px 24px rgba(0, 0, 0, 0.05),
            0 2px 8px rgba(0, 0, 0, 0.03),
            inset 0 1px 0 rgba(255, 255, 255, 0.04) !important;
    }
}
