@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Outfit:wght@400;500;600;700&display=swap');

/* A desk for handing a file to another device.
   One copper trace marks live movement. Everything else stays quiet. */
:root {
    --paper: #e7ecef;
    --card: #f7f8f9;
    --ink: #1b242c;
    --muted: #5c6b76;
    --line: #d5dee4;
    --fill: #ffffff;
    --send: #1d4e89;
    --receive: #1a6b58;
    --wire: #c4552a;
    --danger: #9d2c2c;
    --ok: #1a6b58;
    --shadow: 0 18px 40px rgba(27, 36, 44, 0.08);
    --icon-bg: #e7eef3;
    --track: #e1e8ed;
    --chip: #eef3f6;
    color-scheme: light;
}

[data-theme="dark"] {
    --paper: #12181e;
    --card: #1a222b;
    --ink: #e8eef2;
    --muted: #9aabb6;
    --line: #2c3944;
    --fill: #222c36;
    --send: #8eb4de;
    --receive: #7dcebb;
    --wire: #e08a62;
    --danger: #f0a3a0;
    --ok: #7dcebb;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --icon-bg: #2a3642;
    --track: #2c3944;
    --chip: #2a3642;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    padding: 28px 16px;
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--paper);
}

.container {
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 28px 28px 22px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    text-align: left;
}

.app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-title {
    margin: 0;
    min-width: 0;
    font-size: 1.45rem;
    font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--ink);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-mark {
    width: 38px;
    height: 38px;
    flex: none;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.05;
}

.brand-name {
    min-width: 0;
    white-space: nowrap;
    letter-spacing: -0.045em;
}

.brand-tag {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.2;
    white-space: nowrap;
}

.brand-tld {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.62em;
    font-weight: 500;
    letter-spacing: -0.04em;
    color: var(--wire);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 32px;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--fill);
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
    flex: none;
}

.status-pill.connecting .status-dot,
.status-pill.waiting .status-dot { background: var(--wire); }
.status-pill.connected .status-dot { background: var(--ok); }
.status-pill.error .status-dot { background: var(--danger); }

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--fill);
    color: var(--ink);
    cursor: pointer;
}

.icon-button:hover { border-color: var(--send); }

.role-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.role-button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 6px;
    min-height: 240px;
    padding: 22px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--fill);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.role-button:hover { border-color: var(--wire); }

.role-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: auto;
    border-radius: 12px;
    background: var(--icon-bg);
    color: var(--wire);
    font-size: 1.25rem;
}

.role-label {
    font-size: 1.85rem;
    font-weight: 650;
    letter-spacing: -0.04em;
    line-height: 1;
}

.role-hint {
    color: var(--muted);
    font-size: 0.92rem;
}

.role-send {
    background: var(--ink);
    color: var(--card);
    border-color: var(--ink);
}

.role-send .role-icon {
    background: color-mix(in srgb, var(--card) 16%, transparent);
    color: var(--wire);
}

.role-send .role-hint { color: color-mix(in srgb, var(--card) 72%, transparent); }

.share-native {
    display: none;
    width: 100%;
    margin-top: 14px;
    padding: 12px 14px;
    border: 0;
    border-radius: 10px;
    background: var(--send);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.share-native i { margin-right: 8px; }

[data-theme="dark"] .share-native { color: #12202c; }

.share-card,
#host-info,
#client-info {
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    overflow: visible;
}

.share-card {
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--fill);
}

.share-label,
.qrcode-label {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.88rem;
}

.qrcode-label { margin-top: 14px; }

.input-group {
    display: flex;
    gap: 8px;
    width: 100%;
}

#share-link {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.78rem;
    text-align: left;
}

#copy-button {
    flex: none;
    width: 44px;
    border: 0;
    border-radius: 10px;
    background: var(--send);
    color: #fff;
    cursor: pointer;
}

[data-theme="dark"] #copy-button { color: #12202c; }

#qrcode-container {
    display: inline-block;
    padding: 8px;
    background: #fff;
    border-radius: 8px;
    line-height: 0;
}

#qrcode-container img,
#qrcode-container canvas {
    display: block;
    width: 132px !important;
    height: 132px !important;
}

#client-info p {
    margin: 0;
    font-size: 1rem;
}

.join-host {
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--fill);
}

.join-note,
.scanner-status {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.88rem;
}

.join-actions,
.join-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.join-actions { margin-bottom: 12px; }

.join-form { margin: 0; }

#join-link-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.78rem;
}

#scan-qr-button,
#reconnect-host-button,
.join-form button {
    padding: 10px 14px;
    border: 0;
    border-radius: 10px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

#scan-qr-button {
    background: var(--ink);
    color: var(--card);
}

#reconnect-host-button,
.join-form button {
    background: var(--send);
    color: #fff;
}

[data-theme="dark"] #reconnect-host-button,
[data-theme="dark"] .join-form button { color: #12202c; }

#scan-qr-button i,
#reconnect-host-button i { margin-right: 6px; }

.text-button {
    margin-top: 10px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--send);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.scanner-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.scanner-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 24, 30, 0.55);
}

.scanner-panel {
    position: relative;
    width: min(420px, calc(100% - 32px));
    margin: 8vh auto 0;
    padding: 16px;
    background: var(--card);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.scanner-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.scanner-head h3 {
    margin: 0;
    font-size: 1.05rem;
}

.scanner-stage {
    position: relative;
    margin-bottom: 12px;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: #0e141a;
}

#scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.scanner-frame {
    position: absolute;
    inset: 16%;
    border: 2px solid var(--wire);
    border-radius: 12px;
    box-shadow: 0 0 0 999px rgba(8, 12, 16, 0.45);
    pointer-events: none;
}

.scanner-status { margin: 0; }

.drop-zone {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 16px;
    border: 1.5px dashed var(--line);
    border-radius: 14px;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.dragover {
    border-color: var(--wire);
    background: color-mix(in srgb, var(--wire) 8%, transparent);
    outline: none;
}

.upload-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--icon-bg);
    color: var(--wire);
    font-size: 1.15rem;
    flex: none;
}

.drop-text {
    margin: 0;
    color: var(--muted);
}

.linkish {
    color: var(--send);
    font-weight: 600;
}

.feed-section { margin-top: 26px; }

.feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.feed-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.feed-title i { color: var(--muted); margin-right: 6px; }

.filter-chips { display: flex; gap: 6px; }

.chip {
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.chip.active {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--card);
}

.activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#empty-state {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 0;
    margin: 0;
    padding: 16px;
    text-align: left;
    font-style: normal;
    color: var(--muted);
    background: transparent;
    border: 1px dashed var(--line);
    border-radius: 12px;
}

#empty-state i {
    margin: 0;
    font-size: 1rem;
    color: var(--muted);
}

#empty-state p { margin: 0; }

#empty-state.is-hidden { display: none !important; }

.file-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin: 0;
    padding: 12px;
    text-align: left;
    background: var(--fill);
    border: 1px solid var(--line);
    border-left: 3px solid var(--send);
    border-radius: 12px;
    box-shadow: none;
    animation: none;
}

.file-row[data-direction="receive"] { border-left-color: var(--receive); }

.file-row::before { content: none; }

.file-icon {
    width: 40px;
    height: 40px;
    margin: 0;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--icon-bg);
    color: var(--send);
    font-size: 1rem;
    border: 0;
    box-shadow: none;
}

.file-row[data-direction="receive"] .file-icon { color: var(--receive); }

.file-main { min-width: 0; }

.file-topline {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.file-name {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: 0;
    text-shadow: none;
}

.file-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.8rem;
}

.dir-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--send);
    font-size: 0.78rem;
    font-weight: 600;
}

.dir-badge.receive { color: var(--receive); background: none; }

.file-size {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.75rem;
    color: var(--muted);
}

.speed-text:empty { display: none; }

.progress-container {
    position: relative;
    width: 100%;
    height: 4px;
    margin-top: 8px;
    border: 0;
    border-radius: 999px;
    background: var(--track);
    box-shadow: none;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: inherit;
    background: var(--wire);
    box-shadow: none;
}

.status-chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--chip);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-chip.active,
.status-chip.working { color: var(--wire); border-color: color-mix(in srgb, var(--wire) 45%, var(--line)); }
.status-chip.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.status-chip.error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.status-chip.paused { color: var(--send); }

.row-actions {
    display: flex;
    gap: 4px;
    align-self: center;
}

.row-btn {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.row-btn:hover {
    background: var(--icon-bg);
    color: var(--ink);
}

.row-btn.danger:hover { color: var(--danger); }

.app-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    color: var(--muted);
    font-size: 0.8rem;
}

.app-footer p { margin: 0; }

.pulse-circle {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
    flex: none;
}

.hidden,
[hidden] { display: none !important; }

.toast-container {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 30;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    max-width: min(360px, calc(100vw - 32px));
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible { opacity: 1; transform: none; }
.toast-info { border-left: 3px solid var(--send); }
.toast-success { border-left: 3px solid var(--ok); }
.toast-error { border-left: 3px solid var(--danger); }

.settings-drawer {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 24, 30, 0.45);
}

.drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(380px, 92vw);
    padding: 24px;
    background: var(--card);
    color: var(--ink);
    border-left: 1px solid var(--line);
    overflow-y: auto;
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.drawer-head h3 { margin: 0; font-size: 1.15rem; }

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.setting-row span { color: var(--ink); font-size: 0.92rem; }

.setting-row input[type="text"],
.setting-row select {
    width: min(220px, 52vw);
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--fill);
    color: var(--ink);
    font: inherit;
}

.drawer-note {
    margin: 22px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

button:focus-visible,
.drop-zone:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--send);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    body { padding: 12px; }
    .container { padding: 18px 14px 16px; border-radius: 14px; }
    .app-header { grid-template-columns: minmax(0, 1fr) auto; }
    .app-title { grid-column: 1; grid-row: 1; font-size: 1.22rem; }
    .header-tools { grid-column: 2; grid-row: 1; }
    .brand-mark { width: 34px; height: 34px; }
    .brand-tag { font-size: 0.7rem; }
    .status-pill { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
    .role-choice { grid-template-columns: 1fr; }
    .role-button { min-height: 148px; }
    .share-native { display: inline-flex; align-items: center; justify-content: center; }
    .file-row {
        grid-template-columns: 36px minmax(0, 1fr) auto;
        align-items: center;
    }
    .row-actions { align-self: center; }
    .file-name { white-space: normal; }
    .file-topline { align-items: flex-start; }
    #share-link { font-size: 0.72rem; }
    .join-form { flex-direction: column; }
    .join-form button,
    #scan-qr-button,
    #reconnect-host-button { width: 100%; }
    .scanner-panel { margin-top: 4vh; }
    .setting-row { flex-direction: column; align-items: stretch; }
    .setting-row.toggle-row { flex-direction: row; align-items: center; }
    .setting-row input[type="text"],
    .setting-row select { width: 100%; }
    .toast-container {
        position: static;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        width: auto;
        margin: 0 0 12px;
        transform: none;
    }
    .toast-container:not(:has(.toast)) { display: none; }
    .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* One stage at a time. The entry script sets data-screen before first paint. */
#role-choice,
#share-card,
#join-host,
#workspace,
#connection-status,
#reset-button,
.app-footer { display: none; }

html[data-screen="choose"] #role-choice { display: grid; }

html[data-screen="send"] #share-card,
html[data-screen="receive"] #join-host,
html[data-screen="session"] #workspace { display: block; }

html[data-screen="send"] #connection-status,
html[data-screen="receive"] #connection-status,
html[data-screen="session"] #connection-status { display: inline-flex; }

html[data-screen="send"] #reset-button,
html[data-screen="receive"] #reset-button,
html[data-screen="session"] #reset-button { display: inline-flex; }

html[data-screen="send"] .app-footer,
html[data-screen="receive"] .app-footer { display: flex; }
