﻿:root {
    --bg: #f4efe4;
    --surface: rgba(255, 252, 247, 0.88);
    --surface-strong: #fffaf1;
    --line: rgba(18, 27, 38, 0.1);
    --line-strong: rgba(18, 27, 38, 0.18);
    --text: #18212c;
    --muted: #677281;
    --accent: #0b6b66;
    --accent-strong: #125d92;
    --danger: #c2410c;
    --shadow-lg: 0 28px 72px rgba(18, 27, 38, 0.14);
    --shadow-md: 0 16px 36px rgba(18, 27, 38, 0.08);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --font-display: "Bahnschrift", "Segoe UI Variable Display", "Microsoft YaHei UI", sans-serif;
    --font-sans: "Aptos", "Segoe UI Variable Text", "Microsoft YaHei UI", sans-serif;
    --font-mono: "Cascadia Code", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font-sans);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(11, 107, 102, 0.15), transparent 26%),
        radial-gradient(circle at top right, rgba(194, 65, 12, 0.12), transparent 20%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 24%),
        linear-gradient(180deg, #f7f2e9, #f1e9dc);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

#loginView[hidden], #appView[hidden] { display: none !important; }
body[data-view="login"] #loginView { display: grid !important; }
body[data-view="login"] #appView { display: none !important; }
body[data-view="app"] #loginView { display: none !important; }
body[data-view="app"] #appView { display: block !important; }
body[data-view="booting"] #loginView,
body[data-view="booting"] #appView {
    visibility: hidden;
}

.login-view, .app-view { min-height: 100vh; }
.login-view {
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-panel, .panel, .rail-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
}
.login-panel {
    width: min(100%, 460px);
    padding: 34px;
}
.eyebrow, .section-kicker, .rail-label {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
}
.login-panel h1, .app-header h1, .section-head h2, .editor-head h3, .preview-head h3 {
    margin: 8px 0 10px;
    font-family: var(--font-display);
    letter-spacing: -0.04em;
}
.login-panel h1, .app-header h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); }
.login-copy, .section-copy, .gallery-summary, .editor-meta, .empty-state p, .admin-chip small {
    color: var(--muted);
    line-height: 1.6;
}
.login-hint {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin: 22px 0 18px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(11, 107, 102, 0.08);
}
.login-hint strong { font-family: var(--font-mono); }
.stack-form, .client-editor, .upload-panel, .filter-panel { display: grid; gap: 16px; }
.field, .field-grid, .permission-grid { display: grid; gap: 10px; }
.field span:first-child, .switch-field span:first-child { color: var(--muted); font-size: 0.92rem; }
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid rgba(24, 33, 44, 0.12);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.82);
    padding: 13px 14px;
    color: var(--text);
}
.field textarea { resize: vertical; min-height: 110px; }
.field-grid.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-grid.four-cols { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.permission-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.check-tile, .switch-field {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid rgba(24, 33, 44, 0.1);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.78);
}
.inline-switch { width: fit-content; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
}
.button-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #f8fffe;
    box-shadow: 0 16px 36px rgba(11, 107, 102, 0.22);
}
.button-secondary {
    background: rgba(18, 93, 146, 0.08);
    border-color: rgba(18, 93, 146, 0.18);
    color: var(--accent-strong);
}
.button-ghost {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(24, 33, 44, 0.12);
}
.button-danger {
    background: rgba(194, 65, 12, 0.08);
    border-color: rgba(194, 65, 12, 0.16);
    color: var(--danger);
}
.button-block { width: 100%; }
.button:disabled { opacity: 0.55; cursor: wait; }

.app-view { padding: 22px; }
.app-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
    padding: 24px 28px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 32px;
    background: linear-gradient(135deg, rgba(255, 250, 242, 0.94), rgba(255, 245, 232, 0.76));
    box-shadow: var(--shadow-lg);
}
.header-actions { display: flex; gap: 14px; align-items: center; }
.admin-chip {
    padding: 12px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--line);
}
.admin-chip span { display: block; font-weight: 700; }
.app-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; }
.nav-rail { display: grid; gap: 14px; align-content: start; }
.nav-item {
    min-height: 52px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.75);
    text-align: left;
    font-weight: 700;
}
.nav-item.is-active { background: linear-gradient(135deg, rgba(11, 107, 102, 0.12), rgba(18, 93, 146, 0.08)); border-color: rgba(11, 107, 102, 0.2); }
.rail-card { padding: 18px; }
.rail-number { margin: 8px 0 0; font-size: 2rem; font-family: var(--font-display); }
.secret-card { border-color: rgba(194, 65, 12, 0.18); }
.secret-client-name { margin: 8px 0; font-weight: 700; }
.secret-value {
    display: block;
    padding: 14px;
    border-radius: 16px;
    background: #18212c;
    color: #fff7ee;
    font-family: var(--font-mono);
    word-break: break-all;
}
.page-host { display: grid; gap: 20px; }
.page-section { display: none; gap: 18px; }
.page-section.is-active { display: grid; }
.section-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
}
.clients-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; }
.client-list-panel { padding: 14px; }
.client-list { display: grid; gap: 12px; }
.client-item {
    padding: 16px;
    border: 1px solid rgba(24, 33, 44, 0.08);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    cursor: pointer;
}
.client-item.is-active { border-color: rgba(11, 107, 102, 0.2); background: rgba(11, 107, 102, 0.08); }
.client-item h3, .empty-state h3 { margin: 0 0 6px; }
.client-item p { margin: 0; color: var(--muted); }
.client-meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.meta-pill, .mode-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(24, 33, 44, 0.06);
    color: var(--muted);
    font-size: 0.82rem;
}
.mode-pill { background: rgba(194, 65, 12, 0.1); color: var(--danger); }
.client-editor { padding: 24px; }
.editor-head, .preview-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.editor-meta { margin: 0; }

.filter-panel, .upload-panel { padding: 24px; }
.gallery-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.waterfall { column-count: 4; column-gap: 16px; }
.image-card {
    break-inside: avoid;
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface-strong);
    box-shadow: var(--shadow-md);
}
.image-card img { width: 100%; height: auto; background: #eee5d7; }
.image-placeholder {
    display: grid;
    place-items: center;
    min-height: 220px;
    color: var(--muted);
    background: linear-gradient(135deg, rgba(11, 107, 102, 0.08), rgba(194, 65, 12, 0.06));
}
.image-card-body { padding: 14px; display: grid; gap: 10px; }
.image-card h3 { margin: 0; font-size: 1rem; word-break: break-word; }
.image-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.image-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-button {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(24, 33, 44, 0.1);
    background: rgba(255, 255, 255, 0.78);
}
.mini-button.danger { color: var(--danger); border-color: rgba(194, 65, 12, 0.16); }
.empty-state { padding: 28px; }
.load-more-wrap { display: flex; justify-content: center; }
.preview-dialog {
    width: min(90vw, 1100px);
    max-height: 92vh;
    padding: 0;
    border: none;
    border-radius: 28px;
    background: transparent;
}
.preview-dialog::backdrop { background: rgba(24, 33, 44, 0.56); }
.preview-shell {
    overflow: hidden;
    border-radius: 28px;
    background: rgba(255, 250, 244, 0.98);
    box-shadow: var(--shadow-lg);
}
.preview-head { padding: 20px 24px 0; }
.preview-content {
    min-height: 420px;
    display: grid;
    place-items: center;
    padding: 24px;
}
.preview-content img { max-height: calc(92vh - 140px); object-fit: contain; }
.toast-stack {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: grid;
    gap: 10px;
    z-index: 20;
}
.toast {
    min-width: 260px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 16px;
    color: #fff;
    background: rgba(24, 33, 44, 0.92);
    box-shadow: var(--shadow-md);
}
.toast.success { background: rgba(11, 107, 102, 0.95); }
.toast.error { background: rgba(194, 65, 12, 0.95); }

@media (max-width: 1400px) {
    .waterfall { column-count: 3; }
}
@media (max-width: 1200px) {
    .app-layout, .clients-layout, .field-grid.four-cols { grid-template-columns: 1fr; }
    .waterfall { column-count: 2; }
}
@media (max-width: 760px) {
    .app-view { padding: 14px; }
    .app-header, .login-panel, .filter-panel, .upload-panel, .client-editor { padding: 18px; }
    .field-grid.two-cols, .field-grid.three-cols, .permission-grid { grid-template-columns: 1fr; }
    .waterfall { column-count: 1; }
    .section-head, .app-header, .header-actions { display: grid; justify-content: start; }
}
