:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #eef4ff;
    --text: #14213d;
    --muted: #6f7c96;
    --line: #dfe7f3;
    --blue: #1769ff;
    --blue-dark: #0b4fd1;
    --yellow: #ffc928;
    --danger: #d92d4b;
    --shadow: 0 18px 55px rgba(25, 54, 105, .12);
    --radius: 20px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: radial-gradient(circle at 8% 0%, rgba(23,105,255,.09), transparent 28%), var(--bg); }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.modal-open { overflow: hidden; }

.topbar { height: 76px; padding: 0 clamp(18px, 4vw, 58px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(217,228,243,.9); background: rgba(255,255,255,.86); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand > span:last-child { display: grid; }
.brand b { font-size: 17px; }
.brand small { color: var(--muted); margin-top: 2px; }
.brand-mark { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; color: white; background: linear-gradient(145deg, var(--blue), #55a0ff); font-weight: 900; font-size: 23px; box-shadow: 0 18px 36px rgba(23,105,255,.28); border: 4px solid rgba(255,255,255,.55); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 14px; font-size: 14px; box-shadow: 0 10px 24px rgba(23,105,255,.22); border-width: 2px; }
.btn { border: 0; border-radius: 13px; min-height: 44px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; transition: .2s ease; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { color: white; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); box-shadow: 0 12px 25px rgba(23,105,255,.23); }
.btn.secondary { background: linear-gradient(135deg, var(--yellow), #ffdc5f); color: #3c2d00; }
.btn.ghost { color: var(--text); background: white; border: 1px solid var(--line); }
.btn.danger-soft { background: #fff0f3; color: var(--danger); border: 1px solid #ffd6df; }
.btn.danger { color: white; background: var(--danger); }
.btn.compact { min-height: 38px; padding: 0 14px; font-size: 13px; }
.btn.wide { width: 100%; }

.page-wrap { width: min(1480px, calc(100% - 36px)); margin: 0 auto; padding: 38px 0 70px; }
.hero { border-radius: 30px; padding: clamp(28px, 5vw, 60px); color: white; background: linear-gradient(125deg, #0b3b91 0%, #1769ff 58%, #56a5ff 100%); box-shadow: 0 28px 70px rgba(20,78,180,.25); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; width: 340px; height: 340px; right: -80px; top: -160px; border-radius: 50%; border: 62px solid rgba(255,255,255,.09); }
.public-hero { display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.hero h1 { font-size: clamp(32px, 5vw, 64px); line-height: 1.02; letter-spacing: -.05em; max-width: 760px; margin: 8px 0 18px; }
.hero p { max-width: 700px; color: rgba(255,255,255,.8); font-size: 17px; line-height: 1.7; margin: 0; }
.eyebrow { margin: 0; font-size: 11px; letter-spacing: .18em; font-weight: 900; color: var(--blue); }
.hero .eyebrow, .auth-visual .eyebrow { color: var(--yellow); }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(100px, 1fr)); gap: 12px; min-width: 360px; position: relative; z-index: 2; }
.hero-stats div { padding: 18px; border-radius: 18px; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.15); backdrop-filter: blur(10px); }
.hero-stats strong, .hero-stats span { display: block; }
.hero-stats strong { font-size: 23px; }
.hero-stats span { color: rgba(255,255,255,.72); margin-top: 5px; font-size: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 35px rgba(31,56,103,.06); }
.toolbar { margin-top: 24px; padding: 18px; }
.search-row { display: flex; gap: 10px; }
.search-row input { flex: 1; min-width: 0; height: 46px; border: 1px solid var(--line); border-radius: 13px; padding: 0 15px; color: var(--text); outline: none; background: #fbfdff; }
.search-row input:focus { border-color: rgba(23,105,255,.55); box-shadow: 0 0 0 4px rgba(23,105,255,.09); }
.folder-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip { padding: 9px 14px; border-radius: 999px; font-size: 13px; font-weight: 750; color: var(--muted); background: var(--surface-2); border: 1px solid transparent; }
.chip.active { background: #e5efff; color: var(--blue); border-color: #bed4ff; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 38px 2px 17px; }
.section-heading h2, .panel-title h2, .gallery-toolbar h2 { margin: 4px 0 0; font-size: 25px; letter-spacing: -.03em; }
.count-badge { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; color: var(--blue); background: #eaf2ff; font-weight: 800; font-size: 12px; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.image-card { background: white; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 10px 30px rgba(35,58,103,.07); position: relative; transition: .2s ease; }
.image-card:hover { transform: translateY(-3px); box-shadow: 0 18px 38px rgba(35,58,103,.12); }
.image-preview { width: 100%; aspect-ratio: 1 / .78; padding: 0; border: 0; background: #ecf2f9; overflow: hidden; }
.image-preview img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.image-card:hover .image-preview img { transform: scale(1.025); }
.image-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px; }
.image-meta > div:first-child { min-width: 0; }
.image-meta h3 { margin: 0; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.image-meta p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.icon-btn { border: 1px solid var(--line); background: white; min-width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-weight: 900; color: var(--blue); }
.icon-btn.danger { color: var(--danger); }
.empty-state { text-align: center; padding: 70px 20px; border: 1px dashed #cbd8ea; border-radius: 22px; background: rgba(255,255,255,.68); }
.empty-icon { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 15px; background: #e8f1ff; color: var(--blue); font-size: 26px; }
.empty-state h3 { margin: 0; }
.empty-state p { color: var(--muted); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 10%, rgba(23,105,255,.2), transparent 27%), #07152f; }
.auth-shell { width: min(1080px, 100%); min-height: 640px; display: grid; grid-template-columns: 1.15fr .85fr; border-radius: 34px; overflow: hidden; box-shadow: 0 45px 110px rgba(0,0,0,.38); }
.auth-visual { padding: clamp(38px, 6vw, 76px); color: white; background: linear-gradient(150deg, rgba(7,34,86,.92), rgba(23,105,255,.92)), radial-gradient(circle at top right, #72b2ff, transparent 40%); display: flex; flex-direction: column; justify-content: center; }
.auth-visual h1 { font-size: clamp(38px, 5vw, 65px); line-height: 1.01; letter-spacing: -.055em; margin: 24px 0 20px; }
.auth-copy { color: rgba(255,255,255,.72); font-size: 16px; line-height: 1.7; max-width: 540px; }
.feature-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.feature-pills span { padding: 9px 12px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.09); border-radius: 999px; font-size: 12px; font-weight: 800; }
.auth-card { padding: clamp(34px, 5vw, 62px); background: white; display: flex; flex-direction: column; justify-content: center; }
.auth-card h2, .form-dialog h2 { margin: 8px 0 8px; font-size: 31px; letter-spacing: -.04em; }
.muted { color: var(--muted); line-height: 1.6; }
.stack-form { display: grid; gap: 16px; margin-top: 24px; }
.stack-form label { display: grid; gap: 8px; font-size: 12px; font-weight: 850; }
.stack-form input { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 13px; padding: 0 14px; outline: none; background: #fbfdff; }
.stack-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(23,105,255,.09); }
.back-link { margin-top: 22px; text-align: center; color: var(--muted); font-size: 13px; font-weight: 750; }
.alert { border-radius: 13px; padding: 13px 15px; margin: 12px 0; font-size: 13px; font-weight: 750; position: relative; }
.alert.success { color: #0a6a43; background: #e8fff4; border: 1px solid #b9f1d6; }
.alert.error { color: #9d1f38; background: #fff0f3; border: 1px solid #ffd0d9; }
.alert.dismissible button { position: absolute; right: 8px; top: 6px; border: 0; background: transparent; font-size: 20px; color: inherit; }

.admin-layout { min-height: calc(100vh - 76px); display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar { background: #0a1d42; color: white; padding: 24px 18px; position: sticky; top: 76px; height: calc(100vh - 76px); overflow-y: auto; }
.sidebar-user { display: flex; align-items: center; gap: 12px; padding: 13px; border-radius: 16px; background: rgba(255,255,255,.07); }
.sidebar-user div { display: grid; }
.sidebar-user small { color: rgba(255,255,255,.55); margin-top: 3px; }
.avatar { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--yellow); color: #302400; font-weight: 950; }
.folder-nav { display: grid; gap: 5px; margin: 24px 0; }
.nav-label { color: rgba(255,255,255,.4); font-size: 10px; letter-spacing: .18em; font-weight: 900; margin: 18px 12px 6px; }
.nav-item { min-height: 44px; padding: 0 12px; border-radius: 12px; display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.72); font-size: 13px; font-weight: 750; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.1); }
.nav-item b { margin-left: auto; font-size: 11px; color: rgba(255,255,255,.52); }
.settings-btn { margin-top: 9px; background: transparent !important; color: rgba(255,255,255,.8) !important; border-color: rgba(255,255,255,.16) !important; }
.admin-main { min-width: 0; padding: clamp(22px, 4vw, 50px); }
.dashboard-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.dashboard-head h1 { font-size: clamp(32px, 5vw, 52px); letter-spacing: -.055em; margin: 7px 0 8px; }
.dashboard-head p:last-child { color: var(--muted); margin: 0; }
.folder-actions, .top-actions { display: flex; gap: 8px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 28px 0; }
.stats-grid article { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 19px; display: flex; align-items: center; gap: 13px; box-shadow: 0 10px 30px rgba(31,56,103,.05); }
.stat-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: var(--blue); background: #eaf2ff; font-size: 20px; }
.stats-grid article div { display: grid; }
.stats-grid small { color: var(--muted); font-size: 11px; }
.stats-grid strong { margin-top: 4px; font-size: 20px; }
.upload-panel { padding: 22px; }
.panel-title, .gallery-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.drop-zone { margin: 20px 0 14px; min-height: 210px; border: 2px dashed #bfd0e9; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 25px; background: #f8fbff; transition: .2s; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--blue); background: #edf4ff; }
.drop-zone input { display: none; }
.upload-symbol { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; color: white; background: linear-gradient(135deg, var(--blue), #61a9ff); font-size: 26px; margin-bottom: 14px; box-shadow: 0 12px 25px rgba(23,105,255,.23); }
.drop-zone strong { font-size: 16px; }
.drop-zone small { color: var(--muted); margin-top: 8px; }
.selected-files { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.selected-files span { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 7px 10px; border-radius: 9px; background: #eaf2ff; color: var(--blue-dark); font-size: 11px; font-weight: 750; }
.gallery-panel { margin-top: 34px; }
.gallery-toolbar { margin-bottom: 15px; }
.compact-search { width: min(420px, 100%); }
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; margin-bottom: 12px; border-radius: 14px; background: white; border: 1px solid var(--line); }
.bulk-bar label { font-size: 12px; font-weight: 750; }
.admin-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.select-box { position: absolute; top: 10px; left: 10px; z-index: 3; width: 31px; height: 31px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.92); box-shadow: 0 5px 16px rgba(0,0,0,.13); }
.select-box input { width: 16px; height: 16px; accent-color: var(--blue); }
.card-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.admin-meta { align-items: flex-start; }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; border: 0; background: rgba(5,17,40,.76); backdrop-filter: blur(8px); }
.form-dialog, .preview-dialog { width: min(460px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 24px; background: white; padding: 28px; position: relative; z-index: 2; box-shadow: 0 35px 100px rgba(0,0,0,.3); }
.preview-dialog { width: min(1000px, 100%); padding: 13px; }
.preview-dialog > img { width: 100%; max-height: 75vh; object-fit: contain; border-radius: 17px; background: #edf2f8; }
.preview-footer { min-height: 66px; padding: 12px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.preview-footer strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close { position: absolute; right: 15px; top: 15px; z-index: 4; width: 38px; height: 38px; border-radius: 12px; border: 0; background: rgba(11,24,49,.78); color: white; font-size: 22px; }
.danger-text { color: var(--danger); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 200; color: white; background: #0b1934; border: 1px solid rgba(255,255,255,.13); border-radius: 13px; padding: 12px 18px; box-shadow: 0 18px 45px rgba(0,0,0,.25); font-size: 13px; font-weight: 800; }

@media (max-width: 1050px) {
    .public-hero { align-items: flex-start; flex-direction: column; }
    .hero-stats { width: 100%; min-width: 0; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-layout { grid-template-columns: 220px minmax(0, 1fr); }
}
@media (max-width: 780px) {
    .topbar { height: 68px; padding: 0 14px; }
    .brand small { display: none; }
    .public-topbar .brand b { font-size: 14px; }
    .page-wrap { width: min(100% - 24px, 1480px); padding-top: 18px; }
    .hero { border-radius: 22px; padding: 28px 22px; }
    .hero h1 { font-size: 38px; }
    .hero-stats { grid-template-columns: 1fr; }
    .auth-page { padding: 0; }
    .auth-shell { min-height: 100vh; border-radius: 0; grid-template-columns: 1fr; }
    .auth-visual { min-height: 340px; }
    .auth-card { min-height: 500px; }
    .admin-layout { display: block; }
    .sidebar { position: static; height: auto; padding: 15px; }
    .folder-nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .nav-label { grid-column: 1 / -1; }
    .admin-main { padding: 22px 13px 50px; }
    .dashboard-head, .gallery-toolbar, .panel-title { align-items: flex-start; flex-direction: column; }
    .folder-actions { width: 100%; }
    .folder-actions .btn { flex: 1; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .compact-search { width: 100%; }
}
@media (max-width: 520px) {
    .top-actions .btn:first-child { display: none; }
    .hero-stats { grid-template-columns: 1fr 1fr; }
    .hero-stats div:last-child { grid-column: 1 / -1; }
    .search-row { flex-direction: column; }
    .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .image-meta { padding: 10px; }
    .image-meta h3 { font-size: 11px; }
    .image-meta p { font-size: 9px; }
    .icon-btn { min-width: 32px; height: 32px; }
    .stats-grid { gap: 8px; }
    .stats-grid article { padding: 13px 10px; gap: 8px; }
    .stats-grid strong { font-size: 16px; }
    .stat-icon { width: 35px; height: 35px; }
    .admin-grid { grid-template-columns: 1fr 1fr; }
    .preview-footer { align-items: stretch; flex-direction: column; }
}
