:root {
    --font-sans: "Noto Sans SC", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB", "Microsoft YaHei UI", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --bg: #f6f6f3;
    --bg-dot: rgba(24, 24, 27, 0.075);
    --bg-glow: rgba(37, 99, 235, 0.07);
    --surface: #ffffff;
    --surface-subtle: #f1f1ed;
    --surface-hover: #ecece6;
    --surface-glass: rgba(255, 255, 255, 0.84);
    --text: #14161a;
    --text-secondary: #4a505c;
    --muted: #68707d;
    --border: rgba(20, 22, 26, 0.11);
    --border-strong: rgba(20, 22, 26, 0.2);
    --inner-highlight: rgba(255, 255, 255, 0.9);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 18px -6px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 22px 48px -12px rgba(15, 23, 42, 0.22);

    --primary: #1d57d8;
    --primary-hover: #1746b3;
    --primary-fg: #ffffff;
    --primary-soft: rgba(29, 87, 216, 0.1);

    --accent: #0f766e;
    --accent-hover: #0b5e57;
    --accent-soft: rgba(15, 118, 110, 0.11);

    --ok: #157347;
    --ok-bg: #ebf7ef;
    --ok-border: rgba(21, 115, 71, 0.24);
    --warn: #925606;
    --warn-bg: #fff6e5;
    --warn-border: rgba(146, 86, 6, 0.26);
    --danger: #c42b2b;
    --danger-bg: #fef0f0;
    --danger-border: rgba(196, 43, 43, 0.26);

    --focus: #2563eb;
    --spotlight: rgba(29, 87, 216, 0.07);
    --checker-a: #f3f4f6;
    --checker-b: #e5e7eb;
    --radius: 14px;
    --radius-sm: 10px;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
    --bg: #09090b;
    --bg-dot: rgba(255, 255, 255, 0.075);
    --bg-glow: rgba(59, 130, 246, 0.11);
    --surface: #111114;
    --surface-subtle: #18181c;
    --surface-hover: #202026;
    --surface-glass: rgba(17, 17, 20, 0.8);
    --text: #f4f4f6;
    --text-secondary: #b9bec9;
    --muted: #8c93a3;
    --border: rgba(255, 255, 255, 0.095);
    --border-strong: rgba(255, 255, 255, 0.18);
    --inner-highlight: rgba(255, 255, 255, 0.06);
    --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 28px -10px rgba(0, 0, 0, 0.65);
    --shadow-lg: 0 28px 64px -14px rgba(0, 0, 0, 0.85);

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-fg: #ffffff;
    --primary-soft: rgba(59, 130, 246, 0.16);

    --accent: #14b8a6;
    --accent-hover: #0d9488;
    --accent-soft: rgba(20, 184, 166, 0.15);

    --ok: #34d399;
    --ok-bg: rgba(16, 185, 129, 0.12);
    --ok-border: rgba(52, 211, 153, 0.25);
    --warn: #fbbf24;
    --warn-bg: rgba(245, 158, 11, 0.12);
    --warn-border: rgba(251, 191, 36, 0.28);
    --danger: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --danger-border: rgba(248, 113, 113, 0.28);

    --focus: #60a5fa;
    --spotlight: rgba(96, 165, 250, 0.1);
    --checker-a: #18181b;
    --checker-b: #27272a;
}

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

::selection {
    background: var(--primary-soft);
    color: var(--text);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.68;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        radial-gradient(ellipse 68% 45% at 50% -10%, var(--bg-glow), transparent 70%),
        radial-gradient(var(--bg-dot) 1px, transparent 1px);
    background-size: 100% 100%, 24px 24px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
}

:focus-visible {
    outline: 2.5px solid var(--focus);
    outline-offset: 2px;
}

.hidden {
    display: none !important;
}

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

.tabular-meta {
    font-variant-numeric: tabular-nums;
}

kbd {
    display: inline-block;
    padding: 0.05rem 0.38rem;
    font-family: var(--font-mono);
    font-size: 0.78em;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface-subtle);
    color: var(--text-secondary);
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--surface-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.72rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.015em;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--primary-soft);
    color: var(--primary);
}

.brand-mark svg {
    width: 18px;
    height: 18px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sync-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.84rem;
    color: var(--text-secondary);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    padding: 0.28rem 0.72rem;
    border-radius: 999px;
}

.sync-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 0 var(--ok-border);
    animation: sync-pulse 2.4s ease-out infinite;
}

.sync-dot.is-warn {
    background: var(--warn);
    animation: none;
}

@keyframes sync-pulse {
    0% { box-shadow: 0 0 0 0 var(--ok-border); }
    70% { box-shadow: 0 0 0 6px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

.logout-form {
    margin: 0;
}

/* Main Workspace */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.15rem;
    align-items: start;
}

.workspace-left {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

@media (min-width: 960px) {
    .workspace-grid {
        grid-template-columns: minmax(360px, 42fr) minmax(0, 58fr);
        gap: 1.25rem;
    }

    .workspace-left {
        position: sticky;
        top: 4.5rem;
    }
}

.surface-panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.2rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: border-color 180ms var(--ease-out);
}

@media (hover: hover) {
    .bento-spotlight::before {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        opacity: 0;
        background: radial-gradient(460px circle at var(--mx, 50%) var(--my, 50%), var(--spotlight), transparent 65%);
        transition: opacity 220ms var(--ease-out);
    }

    .bento-spotlight:hover::before {
        opacity: 1;
    }
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.compact-head {
    align-items: center;
    margin-bottom: 0.55rem;
}

.panel-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.panel-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sub-title {
    font-size: 0.98rem;
}

.panel-sub {
    margin: 0;
    font-size: 0.84rem;
    color: var(--muted);
}

.meta-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.84rem;
    color: var(--muted);
    flex-wrap: wrap;
}

.version-badge,
.count-pill,
.depth-badge,
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.14rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--surface-subtle);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-accent {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: transparent;
}

.badge-warn {
    background: var(--warn-bg);
    color: var(--warn);
    border-color: var(--warn-border);
}

/* Buttons */
.action-group {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.38rem;
    min-height: 38px;
    padding: 0.45rem 0.88rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    touch-action: manipulation;
    overflow: hidden;
    transition:
        background-color 160ms var(--ease-out),
        border-color 160ms var(--ease-out),
        transform 140ms var(--ease-out),
        color 160ms var(--ease-out);
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn:hover:not(:disabled) {
    background: var(--surface-subtle);
    border-color: var(--border-strong);
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.btn-primary::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, 0.22) 50%, transparent 75%);
    transform: translateX(-110%);
    transition: transform 420ms var(--ease-out);
    pointer-events: none;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-primary:hover:not(:disabled)::after {
    transform: translateX(110%);
}

.btn-accent {
    background: var(--accent-soft);
    border-color: rgba(20, 184, 166, 0.28);
    color: var(--accent);
}

.btn-accent:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-subtle);
    border-color: var(--border);
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger-border);
    background: var(--danger-bg);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.btn-sm {
    min-height: 32px;
    padding: 0.28rem 0.68rem;
    font-size: 0.84rem;
}

.btn-lg {
    min-height: 44px;
    padding: 0.6rem 1.15rem;
    font-size: 0.96rem;
}

.btn-icon {
    min-height: 34px;
    width: 34px;
    padding: 0;
}

.btn-block {
    width: 100%;
}

/* Inputs */
.input-control {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.62rem 0.82rem;
    transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

.input-control::placeholder {
    color: var(--muted);
}

.input-control:focus {
    background: var(--surface);
    border-color: var(--focus);
    outline: none;
}

/* Alerts & Empty States */
.alert {
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.89rem;
    margin-bottom: 0.85rem;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-border);
}

.alert-warn {
    background: var(--warn-bg);
    color: var(--warn);
    border-color: var(--warn-border);
}

.alert-ok {
    background: var(--ok-bg);
    color: var(--ok);
    border-color: var(--ok-border);
}

.empty-state {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 1.25rem 1rem;
    text-align: center;
    background: var(--surface-subtle);
}

.empty-title {
    margin: 0 0 0.28rem;
    font-weight: 600;
    color: var(--text);
}

.empty-desc {
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
}

/* Clipboard */
.clipboard-readonly {
    margin: 0;
    padding: 0.9rem 1rem;
    min-height: 6rem;
    max-height: 46vh;
    overflow: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-subtle);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.68;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: text;
    -webkit-user-select: text;
}

.shortcut-hint {
    margin: 0.45rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.text-editor {
    min-height: 11rem;
    resize: vertical;
    line-height: 1.68;
}

.editor-footer {
    margin-top: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.byte-counter {
    font-size: 0.82rem;
    color: var(--muted);
}

.byte-counter.byte-over {
    color: var(--danger);
    font-weight: 700;
}

.conflict-box {
    margin-top: 0.9rem;
    padding: 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--warn-border);
    background: var(--warn-bg);
}

.conflict-title {
    margin: 0 0 0.35rem;
    font-weight: 700;
    color: var(--warn);
}

.conflict-preview {
    background: var(--surface);
    max-height: 9rem;
    margin: 0.45rem 0 0.75rem;
}

/* Quota Bento */
.quota-bar-wrap {
    height: 9px;
    border-radius: 999px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 0.6rem;
}

.quota-bar-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 260ms var(--ease-out);
}

.quota-metrics {
    font-size: 0.86rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.muted-inline {
    font-size: 0.86rem;
    color: var(--muted);
    font-weight: 600;
}

.muted {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

/* Dropzone with Magic UI animated beam */
.dropzone {
    position: relative;
    border-radius: var(--radius-sm);
    padding: 0.95rem 1rem;
    background: var(--surface-subtle);
    border: 1.5px dashed var(--border-strong);
    margin-bottom: 0.85rem;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 180ms var(--ease-out), background-color 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.dropzone-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.dropzone-icon {
    width: 20px;
    height: 20px;
    color: var(--primary);
    flex-shrink: 0;
    transition: transform 200ms var(--ease-out);
}

.dropzone:hover .dropzone-icon,
.dropzone-active .dropzone-icon {
    transform: translateY(-2px);
}

.dropzone-beam {
    position: absolute;
    inset: -2px;
    opacity: 0;
    background: conic-gradient(from 0deg, transparent 0deg, var(--primary) 90deg, var(--accent) 180deg, transparent 270deg);
    transition: opacity 200ms var(--ease-out);
    pointer-events: none;
}

.dropzone-active {
    border-color: transparent;
    background: var(--primary-soft);
}

.dropzone-active .dropzone-beam {
    opacity: 0.65;
    animation: beam-spin 2.2s linear infinite;
}

.dropzone-active::after {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: calc(var(--radius-sm) - 2px);
    background: var(--surface);
    z-index: 0;
}

@keyframes beam-spin {
    to { transform: rotate(360deg); }
}

/* Filter & Search */
.files-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.filter-pills {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.filter-pill {
    border: 1px solid var(--border);
    background: var(--surface-subtle);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 0.28rem 0.72rem;
    font: inherit;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}

.filter-pill:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.filter-pill.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.search-box-wrap {
    position: relative;
    flex: 1 1 190px;
    max-width: 260px;
}

.search-icon {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--muted);
    pointer-events: none;
}

.search-input {
    padding: 0.36rem 0.75rem 0.36rem 2rem;
    font-size: 0.87rem;
    border-radius: 999px;
}

/* Queue & File List */
.queue-list,
.files-list,
.archive-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.58rem;
}

.queue-list {
    margin-bottom: 0.85rem;
}

.queue-item,
.file-row,
.archive-row {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.72rem 0.85rem;
    background: var(--surface);
    transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}

.file-row:hover,
.archive-row:hover {
    border-color: var(--border-strong);
    background: var(--surface-subtle);
}

.queue-item {
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
}

.queue-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.queue-status {
    font-size: 0.82rem;
    color: var(--muted);
}

.progress-wrap {
    height: 7px;
    border-radius: 999px;
    background: var(--surface-subtle);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), #60a5fa, var(--primary));
    background-size: 200% 100%;
    animation: progress-shimmer 1.4s linear infinite;
    transition: width 160ms var(--ease-out);
}

.progress-done {
    background: var(--ok);
    animation: none;
}

.progress-error {
    background: var(--danger);
    animation: none;
}

@keyframes progress-shimmer {
    from { background-position: 200% 0; }
    to { background-position: 0% 0; }
}

.file-row,
.archive-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.file-main {
    display: flex;
    align-items: center;
    gap: 0.72rem;
    min-width: 0;
    flex: 1 1 240px;
}

.file-icon-box {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--surface-subtle);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.file-icon-box svg {
    width: 19px;
    height: 19px;
}

.kind-archive { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.kind-image { color: var(--primary); background: var(--primary-soft); border-color: transparent; }
.kind-video, .kind-audio { color: #b45309; background: var(--warn-bg); border-color: transparent; }
[data-theme="dark"] .kind-video, [data-theme="dark"] .kind-audio { color: var(--warn); }
.kind-dir { color: var(--primary); background: var(--primary-soft); border-color: transparent; }

.file-info {
    min-width: 0;
    flex: 1;
}

.file-name {
    font-weight: 600;
    word-break: break-word;
    line-height: 1.42;
}

.file-name-btn {
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    word-break: break-word;
}

.file-name-btn:hover {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.file-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 0.14rem;
}

.load-more-wrap {
    margin-top: 0.85rem;
}

/* Skeletons */
.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-bottom: 0.75rem;
}

.skeleton-row {
    height: 58px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--surface-subtle) 25%, var(--surface-hover) 50%, var(--surface-subtle) 75%);
    background-size: 200% 100%;
    animation: skeleton-sweep 1.4s ease-in-out infinite;
}

@keyframes skeleton-sweep {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Login Stage */
.auth-stage {
    min-height: calc(100vh - 140px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
}

.auth-card {
    max-width: 420px;
    width: 100%;
    padding: 1.65rem 1.5rem;
}

.auth-header {
    margin-bottom: 1.25rem;
}

.auth-badge {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary);
    margin-bottom: 0.85rem;
}

.auth-badge svg {
    width: 22px;
    height: 22px;
}

.auth-title {
    margin: 0 0 0.25rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field label {
    font-size: 0.89rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.password-wrap {
    position: relative;
}

.password-wrap .input-control {
    padding-right: 2.6rem;
}

.password-toggle {
    position: absolute;
    right: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
}

.auth-error-shake {
    animation: shake-x 320ms var(--ease-out);
}

@keyframes shake-x {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Native Top-Layer Dialog Modals */
.modal-dialog {
    margin: auto;
    padding: 0;
    width: min(960px, calc(100vw - 1.5rem));
    max-height: calc(100dvh - 2rem);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-dialog::backdrop {
    background: rgba(9, 9, 11, 0.58);
    backdrop-filter: blur(6px);
}

.modal-dialog[open] {
    animation: modal-enter 200ms var(--ease-out);
}

@keyframes modal-enter {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-shell {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 2rem);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1.05rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-wrap: wrap;
}

.modal-title-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    flex: 1;
}

.modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    word-break: break-word;
}

.modal-body {
    padding: 1rem 1.05rem;
    overflow: auto;
    flex: 1;
}

/* Archive Modal */
.archive-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.32rem;
    flex-wrap: wrap;
    padding: 0.6rem 1.05rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle);
    font-size: 0.85rem;
}

.crumb-btn {
    border: 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
}

.crumb-btn:hover {
    background: var(--primary-soft);
}

.crumb-btn.is-current {
    color: var(--text);
    cursor: default;
}

.crumb-btn.is-current:hover {
    background: transparent;
}

.crumb-sep {
    color: var(--muted);
}

.archive-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 1.05rem;
    font-size: 0.82rem;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

/* Preview Surface */
.preview-body {
    min-height: 240px;
}

.preview-image-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    max-height: 72dvh;
    overflow: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-image:
        linear-gradient(45deg, var(--checker-a) 25%, transparent 25%),
        linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--checker-b) 75%),
        linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    padding: 0.75rem;
}

.preview-image-stage img {
    display: block;
    max-width: 100%;
    max-height: 68dvh;
    object-fit: contain;
    transition: width 160ms var(--ease-out);
}

.preview-image-stage.is-zoomed {
    display: block;
    text-align: center;
}

.preview-image-stage.is-zoomed img {
    max-width: none;
    max-height: none;
    margin: 0 auto;
}

.preview-video {
    width: 100%;
    max-height: 70dvh;
    border-radius: var(--radius-sm);
    background: #000000;
}

.preview-audio-box {
    padding: 1.5rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    text-align: center;
}

.preview-audio-box audio {
    width: 100%;
    max-width: 520px;
    margin-top: 0.75rem;
}

.pdf-frame {
    width: 100%;
    height: 70dvh;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
}

.code-viewer {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
    overflow: auto;
    max-height: 68dvh;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
}

.code-line {
    display: flex;
    gap: 0.85rem;
    padding: 0.08rem 0.75rem;
}

.code-line:hover {
    background: var(--surface-hover);
}

.code-ln {
    min-width: 3ch;
    text-align: right;
    color: var(--muted);
    user-select: none;
    font-variant-numeric: tabular-nums;
}

.code-txt {
    white-space: pre;
    color: var(--text);
}

.markdown-view {
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
    line-height: 1.72;
    max-width: 75ch;
}

.markdown-view h1, .markdown-view h2, .markdown-view h3 {
    margin: 1rem 0 0.45rem;
    line-height: 1.35;
}

.markdown-view pre {
    padding: 0.75rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.84rem;
}

.markdown-view code {
    font-family: var(--font-mono);
    font-size: 0.86em;
    padding: 0.1rem 0.3rem;
    border-radius: 5px;
    background: var(--surface);
}

.csv-table-wrap {
    overflow: auto;
    max-height: 68dvh;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
    font-variant-numeric: tabular-nums;
}

.csv-table th,
.csv-table td {
    padding: 0.45rem 0.65rem;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.csv-table th {
    position: sticky;
    top: 0;
    background: var(--surface-subtle);
    font-weight: 600;
}

/* Floating Toast Stack */
.toast-container {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(360px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 0.62rem 0.9rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    font-weight: 500;
    animation: toast-in 200ms var(--ease-out);
}

.toast-ok { border-color: var(--ok-border); }
.toast-warn { border-color: var(--warn-border); }
.toast-error { border-color: var(--danger-border); color: var(--danger); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
    .container {
        padding: 0.78rem;
    }

    .surface-panel {
        padding: 0.95rem;
    }

    .btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 36px;
    }

    .search-box-wrap {
        max-width: none;
    }

    .shortcut-hint {
        display: none;
    }

    .modal-dialog {
        width: calc(100vw - 0.75rem);
        max-height: calc(100dvh - 1rem);
    }

    .toast-container {
        right: 0.75rem;
        left: 0.75rem;
        bottom: 0.75rem;
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
