* {
    box-sizing: border-box;
}

:root {
    color-scheme: light;
    --bg: #f7f7f5;
    --surface: #ffffff;
    --surface-soft: #fbfbfa;
    --line: #e7e5e4;
    --line-strong: #d6d3d1;
    --text: #1c1917;
    --muted: #78716c;
    --accent: #111827;
    --accent-soft: #f3f4f6;
    --folder-bg: #fff7ed;
    --folder-line: #fed7aa;
    --folder-text: #9a3412;
    --file-bg: #f5f3ff;
    --file-line: #ddd6fe;
    --file-text: #5b21b6;
    --success-bg: #ecfdf5;
    --success-line: #a7f3d0;
    --success-text: #166534;
    --danger-bg: #fef2f2;
    --danger-line: #fecaca;
    --danger-text: #b91c1c;
    --shadow: 0 18px 40px rgba(28, 25, 23, 0.06);
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 28%),
        linear-gradient(180deg, #fcfcfb, #f7f7f5);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.shell {
    padding: 28px;
}

.auth-page,
.dashboard,
.settings-grid {
    max-width: 1280px;
    margin: 0 auto;
}

.auth-page {
    min-height: calc(100vh - 56px);
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 24px;
    align-items: center;
}

.brand-column,
.panel {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.brand-column {
    padding: 48px;
    background: linear-gradient(180deg, #ffffff, #fcfcfb);
}

.panel {
    padding: 28px;
}

.panel-hero h1,
.panel-hero h2,
.brand-column h1 {
    margin: 8px 0 12px;
    line-height: 1.12;
    color: var(--accent);
}

.brand-column h1 {
    font-size: clamp(38px, 5vw, 60px);
}

.panel-hero h2 {
    font-size: 30px;
}

.page-subtitle,
.panel-hero p,
.brand-column > p {
    color: var(--muted);
}

.eyebrow {
    margin: 0;
    color: #57534e;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 12px;
    font-weight: 600;
}

.feature-list,
.path-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 24px 0 0;
    padding: 0;
    list-style: none;
}

.feature-list li {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    color: var(--muted);
}

.path-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    color: #44403c;
}

.auth-form,
.stack-form,
.upload-form,
.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-row,
.full-width {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 8px;
}

label span,
.muted {
    color: var(--muted);
    font-size: 14px;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px 16px;
    background: #ffffff;
    color: var(--text);
    outline: none;
}

input[readonly] {
    background: #fafaf9;
}

input:focus,
select:focus {
    border-color: #a8a29e;
    box-shadow: 0 0 0 4px rgba(231, 229, 228, 0.9);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox input {
    width: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 14px;
    padding: 12px 18px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    font-weight: 600;
}

.btn-primary:hover {
    background: #292524;
}

.btn-secondary,
.btn-mini {
    background: #ffffff;
    color: #292524;
    border-color: var(--line-strong);
}

.btn-ghost {
    background: #fafaf9;
    border-color: var(--line);
    color: #44403c;
}

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

.btn-block {
    width: 100%;
}

.flash-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    display: grid;
    gap: 12px;
    z-index: 10;
}

.flash {
    min-width: 280px;
    max-width: 420px;
    padding: 14px 18px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    white-space: pre-line;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    opacity: 1;
    animation: flash-fade-out 0.35s ease 5.5s forwards;
    background: var(--surface);
    border: 1px solid var(--line);
}

.flash-message {
    flex: 1;
}

.flash-close {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0.7;
    padding: 0;
}

.flash-close:hover {
    opacity: 1;
}

.flash.is-hiding {
    animation: none;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.flash-success {
    background: var(--success-bg);
    border-color: var(--success-line);
    color: var(--success-text);
}

.flash-error {
    background: var(--danger-bg);
    border-color: var(--danger-line);
    color: var(--danger-text);
}

@keyframes flash-fade-out {
    to {
        opacity: 0;
        transform: translateY(-6px);
        visibility: hidden;
        pointer-events: none;
    }
}

.topbar,
.workspace {
    display: grid;
    gap: 24px;
}

.topbar {
    grid-template-columns: 1fr auto;
    align-items: start;
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 8px 0 8px;
    font-size: 34px;
}

.topbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.workspace {
    grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar,
.content-panel {
    min-height: 520px;
}

.sidebar-block + .sidebar-block {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.badge,
.meta-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 11px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: #374151;
    font-size: 12px;
    border: 1px solid var(--line);
}

.toolbar-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.panel-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    align-items: center;
}

.file-picker {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px dashed var(--line-strong);
    color: #57534e;
    background: #fafaf9;
}

.file-picker input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.file-table th,
.file-table td {
    padding: 16px 12px;
    border-top: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.file-table thead th {
    border-top: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.item-row {
    background: #ffffff;
}

.item-row:hover {
    background: #fcfcfb;
}

.name-cell {
    max-width: 360px;
}

.item-name {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.item-name-body {
    min-width: 0;
}

.item-link {
    display: inline-block;
    color: #111827;
    font-weight: 600;
    word-break: break-all;
}

.item-link-static {
    cursor: default;
}

.item-note {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.item-icon {
    position: relative;
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    border-radius: 4px;
    flex: 0 0 18px;
}

.item-name-folder .item-icon {
    background: var(--folder-bg);
    border: 1px solid var(--folder-line);
}

.item-name-folder .item-icon::before {
    content: "";
    position: absolute;
    top: -3px;
    left: 2px;
    width: 8px;
    height: 5px;
    border-radius: 4px 4px 0 0;
    background: #fdba74;
    border: 1px solid var(--folder-line);
    border-bottom: 0;
}

.item-name-file .item-icon {
    background: var(--file-bg);
    border: 1px solid var(--file-line);
}

.item-name-file .item-icon::before {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    width: 6px;
    height: 6px;
    background: #ede9fe;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid;
    font-size: 12px;
    font-weight: 600;
}

.type-badge-folder {
    background: var(--folder-bg);
    border-color: var(--folder-line);
    color: var(--folder-text);
}

.type-badge-file {
    background: var(--file-bg);
    border-color: var(--file-line);
    color: var(--file-text);
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-details summary {
    list-style: none;
    cursor: pointer;
    color: #44403c;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: #ffffff;
}

.inline-details[open] summary {
    margin-bottom: 8px;
}

.inline-details form {
    display: grid;
    gap: 8px;
    min-width: 180px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafaf9;
}

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 56px 24px;
}

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

.compact-table th,
.compact-table td {
    padding-top: 12px;
    padding-bottom: 12px;
}

@media (max-width: 980px) {
    .auth-page,
    .workspace,
    .settings-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .shell {
        padding: 16px;
    }

    .brand-column,
    .panel {
        padding: 22px;
    }

    .topbar,
    .panel-toolbar {
        grid-template-columns: 1fr;
    }

    .panel-toolbar {
        display: grid;
    }
}
