:root {
  --bg: #e2e8f1;
  --panel: #f1f4f9;
  --ink: #172033;
  --muted: #6b7484;
  --blue: #1a73e8;
  --primary-ink: #fff;
  --red: #d93025;
  --line: #c7d1df;
  --shadow: 0 18px 50px rgba(25, 35, 55, .10);
  --field: #e8edf5;
  --soft: #d5deeb;
  --hover: #d0deef;
  --danger-bg: #feeceb;
  --success-bg: #e6f4ea;
  --photo-thumb-width: 175px;
  --album-thumb-width: 190px;
}

:root[data-theme="dark"] {
  --bg: #0f1724;
  --panel: #172033;
  --ink: #edf3ff;
  --muted: #a7b1c2;
  --blue: #8ab4f8;
  --primary-ink: #08111f;
  --red: #f28b82;
  --line: #2b364a;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
  --field: #111a2b;
  --soft: #202b3e;
  --hover: #23385b;
  --danger-bg: #4a1f22;
  --success-bg: #173827;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
img { display: block; max-width: 100%; }

.sidebar { position: fixed; inset: 0 auto 0 0; width: 230px; padding: 20px; background: color-mix(in srgb, var(--panel) 86%, transparent); backdrop-filter: blur(18px); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 24px; }
.mobile-topbar { display: contents; }
.brand { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 9px; }
.brand img { width: 30px; height: 30px; object-fit: contain; }
.menu-toggle { display: none; }
.sidebar-menu { display: contents; }
nav { display: grid; gap: 8px; }
nav a { padding: 10px 12px; border-radius: 16px; color: var(--ink); display: flex; align-items: center; gap: 11px; }
nav a:hover, nav a.active { background: var(--hover); color: var(--blue); }
.nav-icon { width: 20px; height: 20px; flex: 0 0 20px; color: var(--muted); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
nav a:hover .nav-icon, nav a.active .nav-icon { color: var(--blue); }
nav a.disabled { color: var(--muted); cursor: not-allowed; opacity: .65; }
nav a.disabled:hover { background: transparent; color: var(--muted); }
.nav-vault-heading { padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--soft); box-shadow: inset 0 1px 0 color-mix(in srgb, var(--panel) 75%, transparent); display: grid; gap: 5px; }
.nav-section-label { color: var(--muted); text-transform: uppercase; letter-spacing: .13em; font-size: 12px; font-weight: 900; }
.nav-vault-name { overflow-wrap: anywhere; line-height: 1.2; }
.profile { margin-top: auto; padding: 14px; border-radius: 18px; background: var(--soft); display: grid; gap: 3px; }
.profile small, .muted { color: var(--muted); }
.profile a { color: var(--blue); font-weight: 700; }
.content { margin-left: 230px; padding: 28px; }

.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.hero-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero h1, .setup-card h1 { font-size: clamp(30px, 4.4vw, 56px); line-height: .95; margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .13em; color: var(--blue); font-size: 12px; font-weight: 800; }
.primary, .ghost, .danger, .theme-toggle { border: 0; border-radius: 999px; padding: 9px 15px; cursor: pointer; font-weight: 800; }
.primary { background: var(--blue); color: var(--primary-ink); box-shadow: 0 12px 25px rgba(26, 115, 232, .25); }
.ghost, .theme-toggle { background: var(--soft); color: var(--ink); }
.theme-toggle { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; font-size: 22px; line-height: 1; }
.danger { background: var(--danger-bg); color: var(--red); }
h2 { margin: 28px 0 14px; }
.timeline-day-title { position: relative; display: block; line-height: .95; }
.timeline-day-title { margin-top: 52px; margin-bottom: 18px; }
.timeline-day-title:first-child { margin-top: 12px; }
.day-select { position: absolute; top: 50%; margin-left: 10px; transform: translateY(-50%); display: none; width: 28px; height: 28px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.day-select span { display: block; width: 28px; height: 28px; border: 2px solid color-mix(in srgb, var(--ink) 28%, transparent); border-radius: 50%; background: var(--field); box-shadow: 0 6px 18px rgba(0, 0, 0, .08); }
.day-select.selected span { background: var(--blue); border-color: var(--blue); position: relative; }
.day-select.selected span::after { content: ""; position: absolute; left: 9px; top: 5px; width: 6px; height: 11px; border: solid var(--primary-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.selection-mode .day-select { display: inline-block; }

.photo-controls { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 58px; margin: -8px 0 24px; flex-wrap: wrap; }
.photo-controls[hidden] { display: none; }
.photo-controls .gallery-toolbar { margin: 0; }
.photo-controls > .selection-bar { margin: 0; display: none; }
.photo-controls > .selection-bar.visible { display: flex; }
.photo-controls.selection-active > :not(.selection-bar) { display: none; }
.photo-controls.selection-active { justify-content: flex-end; }
.view-toggle { padding: 4px; border-radius: 999px; background: var(--soft); display: flex; gap: 4px; }
.view-toggle a { padding: 9px 16px; border-radius: 999px; color: var(--muted); font-weight: 800; }
.view-toggle button { border: 0; background: transparent; padding: 9px 16px; border-radius: 999px; color: var(--muted); font-weight: 800; cursor: pointer; }
.view-toggle a.active, .view-toggle button.active { background: var(--blue); color: var(--primary-ink); }
.photo-controls label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 800; }
.photo-controls select { border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; background: var(--field); color: var(--ink); font-weight: 800; }
.size-control { display: flex; align-items: center; gap: 6px; }
.size-control span { min-width: 48px; text-align: center; color: var(--muted); font-weight: 800; }
.size-control button { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; }

.album-grid { display: grid; grid-template-columns: repeat(auto-fill, var(--album-thumb-width)); justify-content: start; gap: 16px; }
.album-card, .photo-card, .upload-panel, .table-card, .setup-card, .profile-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.album-card { border-radius: 5px; }
.album-preview { position: relative; }
.album-cover { display: block; aspect-ratio: 16 / 10; overflow: hidden; }
.album-card img, .empty-cover { width: 100%; height: 100%; object-fit: cover; background: linear-gradient(135deg, #dfeaff, #fff4d8); display: grid; place-items: center; color: var(--muted); font-weight: 800; }
.album-card strong, .album-card small { display: block; padding: 0 16px; }
.album-card strong { padding-top: 12px; padding-bottom: 9px; font-weight: 600; }
.album-card small { padding-bottom: 18px; color: var(--muted); }
.album-create { margin-bottom: 22px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.album-edit-toggle { position: absolute; right: 10px; bottom: 10px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--panel) 88%, transparent); color: var(--ink); box-shadow: 0 8px 20px rgba(0, 0, 0, .18); cursor: pointer; font-weight: 900; z-index: 2; }
.album-edit { padding: 20px; display: grid; gap: 14px; }
.album-edit h2 { margin: 0; }
.album-edit label { display: grid; gap: 7px; font-weight: 700; }
.album-edit input, .album-edit select { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--field); color: var(--ink); }
.album-edit small { padding: 0; }
.album-edit div { display: flex; gap: 7px; flex-wrap: wrap; }
.album-options-dialog { width: min(430px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); opacity: 0; transform: translateY(8px) scale(.98); transition: opacity .16s ease, transform .16s ease; }
.album-options-dialog.visible { opacity: 1; transform: translateY(0) scale(1); }
.album-options-dialog::backdrop { background: rgba(3, 8, 18, 0); backdrop-filter: blur(0); transition: background .16s ease, backdrop-filter .16s ease; }
.album-options-dialog.visible::backdrop { background: rgba(3, 8, 18, .58); backdrop-filter: blur(6px); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, var(--photo-thumb-width)); justify-content: start; align-items: start; gap: 12px; }
.photo-grid:not(.cropped) { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
.photo-grid.cropped { grid-template-columns: repeat(auto-fill, var(--photo-thumb-width)); }
.photo-card { width: var(--photo-thumb-width); margin: 0; border-radius: 10px; }
.photo-grid:not(.cropped) .photo-card { width: auto; }
.photo-grid.cropped .photo-card { margin: 0; }
.photo-card img { width: 100%; height: auto; border-radius: 10px; }
.photo-grid:not(.cropped) .photo-card img { width: auto; height: calc(var(--photo-thumb-width) * .72); max-width: min(360px, calc(var(--photo-thumb-width) * 1.8)); object-fit: contain; }
.photo-grid:not(.cropped) .photo-open { width: auto; }
.photo-grid.cropped .photo-card img { aspect-ratio: 16 / 10; height: 100%; object-fit: cover; }
.photo-grid.cropped .photo-open { height: 100%; }
.photo-actions { padding: 10px; display: grid; gap: 8px; }
.photo-actions form { display: flex; gap: 7px; flex-wrap: wrap; }

.setup-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.setup-card { width: min(720px, 100%); padding: 32px; }
.login-card { width: min(430px, 100%); }
.login-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.login-brand { display: flex; align-items: center; gap: 12px; font-size: clamp(38px, 7vw, 64px); line-height: 1; font-weight: 800; }
.login-brand img { width: .9em; height: .9em; object-fit: contain; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid label { display: grid; gap: 7px; color: var(--ink); font-weight: 700; }
.form-grid input, .form-grid select { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--field); color: var(--ink); }
.form-grid input:disabled { color: var(--muted); opacity: 1; }
.form-grid hr { width: 100%; border: 0; border-top: 1px solid var(--line); }
.profile-panel { padding: 22px; max-width: 760px; }
.form-actions { display: flex; align-items: end; }

.upload-panel { padding: 22px; display: grid; gap: 20px; }
.vault-panel { margin-bottom: 22px; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.vault-panel:has(.vault-workspace:not([hidden])) { padding: 0; background: transparent; border: 0; box-shadow: none; }
.vault-panel h2 { margin-top: 0; }
.vault-unlock .form-grid { margin-bottom: 18px; }
.remember-vault, .form-grid .remember-vault { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 800; }
.remember-vault + .remember-vault { margin-top: 6px; }
.remember-vault input { position: relative; width: 28px !important; height: 28px; flex: 0 0 28px; padding: 0; margin: 0; appearance: none; border: 2px solid color-mix(in srgb, var(--ink) 28%, transparent); border-radius: 50%; background: var(--field); box-shadow: 0 6px 18px rgba(0, 0, 0, .08); cursor: pointer; }
.remember-vault input:checked { background: var(--blue); border-color: var(--blue); }
.remember-vault input:checked::after { content: ""; position: absolute; left: 9px; top: 5px; width: 6px; height: 11px; border: solid var(--primary-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.vault-cover-icon { display: grid; place-items: center; }
.vault-cover-icon svg { width: 64px; height: 64px; overflow: visible; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.vault-cover-icon [data-lock-shackle] { transform-origin: 8px 10px; transition: transform .16s ease; }
.vault-cover-icon.unlocked svg { stroke: var(--blue); }
.vault-cover-icon.unlocked [data-lock-shackle] { transform: translate(6px, 0); }
.vault-toolbar { display: flex; justify-content: flex-end; }
.vault-hero { flex-direction: row; align-items: center; }
.vault-hero-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.secure-album-card .album-cover { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; line-height: 0; }
.secure-album-card .album-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.vault-album-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.vault-album-heading h2 { margin: 0; }
.vault-controls { margin: -8px 0 24px; }
.vault-panel .gallery-toolbar { margin-top: 14px; }
.vault-panel .selection-bar { margin-top: 14px; }
.vault-panel .photo-controls > .gallery-toolbar,
.vault-panel .photo-controls > .selection-bar { margin: 0; align-self: center; }
.vault-list { margin-top: 18px; }
.vault-delete-form { padding: 0 16px 16px; }
.vault-delete-form .danger { width: 100%; }
.secure-selection-form.selection-mode .gallery-toolbar { display: none; }
.secure-selection-form.selection-mode .select-check { opacity: 1; transform: scale(1); pointer-events: auto; }
.secure-selection-form.selection-mode .photo-open { cursor: pointer; }
.secure-photo-grid { min-height: 80px; }
.vault-dialog { width: min(520px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.vault-dialog::backdrop { background: rgba(3, 8, 18, .58); backdrop-filter: blur(6px); }
.vault-dialog-content { padding: 22px; display: grid; gap: 16px; }
.vault-dialog-content h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.vault-upload-form { margin: 0; }
.vault-upload-form .upload-progress { margin-top: 14px; }
.secure-photo-loading { display: grid; min-height: 110px; place-items: center; color: var(--muted); font-weight: 800; }
.secure-photo-card .photo-open { min-height: 110px; }
.drop-zone { border: 1px solid var(--line); border-radius: 26px; background: var(--field); padding: 54px 22px; display: grid; place-items: center; text-align: center; gap: 10px; cursor: pointer; }
.drop-zone.drag { background: var(--hover); border-color: var(--blue); }
.drop-zone input { display: none; }
.drop-zone span { font-size: 22px; font-weight: 900; }
.drop-zone small { color: var(--muted); }
.folder-picker { border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; background: var(--field); font-weight: 800; color: var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.folder-picker input { max-width: 260px; }
.upload-progress { display: none; align-items: center; gap: 12px; }
.upload-progress.visible { display: flex; }
.upload-progress div { flex: 1; height: 10px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.upload-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--blue); transition: width .15s ease; }
.upload-progress small { min-width: 190px; color: var(--muted); font-weight: 800; text-align: right; }

.alert { margin: 0 0 18px; padding: 13px 16px; border-radius: 16px; font-weight: 700; }
.alert.error { background: var(--danger-bg); color: var(--red); }
.alert.success { background: var(--success-bg); color: #34a853; }
.vault-unlock .form-grid + .alert { margin-top: 18px; }
.vault-unlock .alert:last-child { margin-bottom: 0; }
.vault-unlock:has(.alert:last-child) { padding-bottom: 18px; }
.table-card { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px; border-bottom: 1px solid var(--line); }
.user-form { grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: end; margin-bottom: 20px; }
.admin-panel { margin-bottom: 22px; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.admin-panel h2 { margin-top: 0; }
.user-create-form { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.user-search { display: flex; align-items: end; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.user-search label { flex: 1; min-width: min(320px, 100%); display: grid; gap: 7px; font-weight: 800; }
.user-search input { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--field); color: var(--ink); }
.user-list { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--field); }
.user-list-row { display: grid; grid-template-columns: minmax(180px, 1.4fr) minmax(210px, 1.5fr) 90px 140px auto minmax(160px, auto); align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.user-list-row:last-child { border-bottom: 0; }
.user-list-row:hover { background: var(--hover); }
.user-list-name { display: grid; gap: 3px; }
.user-list-name small { color: var(--muted); }
.user-list-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.user-list-actions .ghost { padding: 7px 12px; }
.user-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.user-admin-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--field); display: grid; gap: 14px; }
.user-list-card { transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease; }
.user-list-card:hover { border-color: var(--blue); transform: translateY(-2px); box-shadow: var(--shadow); }
.user-list-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-weight: 800; }
.user-list-meta span { padding: 6px 10px; border-radius: 999px; background: var(--soft); }
.user-edit-panel { width: 100%; display: grid; gap: 18px; }
.user-admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.user-admin-head strong, .user-admin-head small { display: block; }
.user-admin-head small { color: var(--muted); margin-top: 3px; }
.status-pill { border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 900; }
.status-pill.ok { background: var(--success-bg); color: #34a853; }
.status-pill.off { background: var(--danger-bg); color: var(--red); }
.user-admin-form { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.user-limit-panel { display: grid; gap: 12px; }
.user-limit-panel h2 { margin: 0; }
.user-limit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.user-limit-overview { display: grid; gap: 14px; }
.profile-panel + .user-limit-overview { margin-top: 22px; }
.user-limit-overview h2 { margin: 0; }
.limit-usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.limit-usage-grid div { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--field); display: grid; gap: 4px; }
.limit-usage-grid strong { overflow-wrap: anywhere; }
.check-row { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 10px !important; font-weight: 800; cursor: pointer; }
.check-row input { position: relative; width: 28px !important; height: 28px; flex: 0 0 28px; margin: 0; appearance: none; border: 2px solid color-mix(in srgb, var(--ink) 28%, transparent); border-radius: 50%; background: var(--field); box-shadow: 0 6px 18px rgba(0, 0, 0, .08); cursor: pointer; }
.check-row input:checked { background: var(--blue); border-color: var(--blue); }
.check-row input:checked::after { content: ""; position: absolute; left: 9px; top: 5px; width: 6px; height: 11px; border: solid var(--primary-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.user-view-panel { display: grid; gap: 18px; }
.user-view-grid, .user-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.user-view-grid div, .user-stats-grid div { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--field); display: grid; gap: 4px; }
.user-view-grid strong { overflow-wrap: anywhere; }
.user-stats-grid strong { font-size: 28px; line-height: 1; }
.user-stats-grid span, .user-vault-list span { color: var(--muted); font-weight: 800; }
.admin-photo-preview { margin-top: 10px; }
.user-vault-list { display: grid; gap: 10px; }
.user-vault-list div { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--field); display: grid; gap: 4px; }

.selection-form { position: relative; }
.gallery-toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.selection-form > .gallery-toolbar { display: none; }
.photo-controls > .gallery-toolbar { display: flex; }
.selection-mode .gallery-toolbar { display: none; }
.selection-bar { position: sticky; top: 18px; z-index: 5; width: fit-content; margin: 0 0 14px auto; padding: 0; border-radius: 999px; display: none; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.selection-bar.visible { display: flex; }
.timeline-selection-form .gallery-toolbar { min-height: 34px; visibility: visible; }
.timeline-selection-form.selection-mode .gallery-toolbar { visibility: hidden; display: flex; }
.timeline-selection-form .selection-bar { position: absolute; top: 0; right: 0; height: 34px; margin: 0; overflow: visible; }
.timeline-selection-form .selection-bar.visible { display: flex; }
.timeline-selection-form .timeline-day-title, .timeline-selection-form.selection-mode .timeline-day-title, .vault-panel .timeline-day-title { margin: 52px 0 18px; }
.timeline-selection-form .timeline-day-title:first-child, .timeline-selection-form.selection-mode .timeline-day-title:first-child, .vault-panel .timeline-day-title:first-child { margin-top: 12px; }
.timeline-selection-form .timeline-day-title + .photo-grid { margin-top: 0; }
.selection-bar span { padding: 9px 15px; border-radius: 999px; background: var(--soft); font-weight: 800; line-height: 1.2; }
.selection-bar .ghost, .selection-bar .danger { padding: 9px 15px; line-height: 1.2; }
.selection-form .selection-bar, .photo-controls:not(.selection-active) > .selection-bar { display: none !important; }
.selection-bar[hidden] { display: none !important; }
.photo-controls.selection-active > .selection-bar.visible { display: flex !important; }
.album-dialog, .download-dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.album-dialog::backdrop, .download-dialog::backdrop { background: rgba(3, 8, 18, .58); backdrop-filter: blur(6px); }
.album-dialog > div, .download-dialog > div { padding: 22px; display: grid; gap: 16px; }
.album-dialog h2, .download-dialog h2 { margin: 0; }
.album-dialog p, .download-dialog p { margin: 0; }
.album-dialog label { display: grid; gap: 8px; font-weight: 800; }
.album-dialog .radio-row { display: flex; grid-template-columns: none; align-items: center; gap: 10px; }
.album-dialog .radio-row input { width: auto; }
.album-dialog select { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--field); color: var(--ink); }
.album-dialog div div, .download-dialog div div { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.download-dialog div div { justify-content: center; }
.download-dialog { opacity: 0; transform: translateY(8px) scale(.98); transition: opacity .16s ease, transform .16s ease; }
.download-dialog.visible { opacity: 1; transform: translateY(0) scale(1); }
.download-dialog::backdrop { background: rgba(3, 8, 18, 0); backdrop-filter: blur(0); transition: background .16s ease, backdrop-filter .16s ease; }
.download-dialog.visible::backdrop { background: rgba(3, 8, 18, .58); backdrop-filter: blur(6px); }
.sharing-tabs { width: fit-content; margin: -8px 0 22px; }
.sharing-panel { display: grid; gap: 14px; }
.sharing-list { display: grid; gap: 10px; }
.sharing-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--field); }
.sharing-row span:first-child { display: grid; gap: 4px; min-width: 0; }
.sharing-row small { color: var(--muted); font-weight: 800; overflow-wrap: anywhere; }
.sharing-row form { margin: 0; }
.share-link-field { width: min(520px, 100%); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; background: var(--panel); color: var(--ink); font-size: 13px; }
.share-public-shell { align-items: start; padding-top: 32px; }
.share-public-card { width: min(980px, 100%); }
.share-public-card h1 { margin: 18px 0 8px; }
.share-password-form { margin-top: 22px; max-width: 420px; }
.public-share-grid { margin-top: 22px; }
.photo-card { position: relative; }
.photo-card.selected { outline: 3px solid var(--blue); outline-offset: -3px; }
.photo-open { display: block; width: 100%; padding: 0; border: 0; border-radius: 10px; background: transparent; cursor: zoom-in; color: inherit; }
.selection-mode .photo-open { cursor: pointer; }
.select-check { position: absolute; z-index: 2; top: 10px; left: 10px; width: 28px; height: 28px; cursor: pointer; opacity: 0; transform: scale(.84); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.selection-mode .select-check { opacity: 1; transform: scale(1); pointer-events: auto; }
.select-check input { position: absolute; opacity: 0; pointer-events: none; }
.select-check span { display: block; width: 28px; height: 28px; border: 2px solid #fff; border-radius: 50%; background: rgba(15, 23, 36, .42); box-shadow: 0 6px 18px rgba(0, 0, 0, .22); }
.select-check input:checked + span { background: var(--blue); border-color: var(--blue); }
.select-check input:checked + span::after { content: ""; position: absolute; left: 9px; top: 5px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.lightbox { position: fixed; inset: 0; z-index: 30; background: rgba(3, 8, 18, .94); display: none; align-items: center; justify-content: center; padding: 28px 78px; }
.lightbox.open { display: flex; animation: lightboxFade .18s ease both; }
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; display: grid; gap: 14px; justify-items: center; }
.lightbox img { max-width: min(100%, 1400px); max-height: calc(100vh - 130px); object-fit: contain; border-radius: 14px; }
.lightbox.loading img { visibility: hidden; }
.lightbox figcaption { color: #fff; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.lightbox figcaption span { color: #cbd5e1; }
.lightbox-close, .lightbox-nav, .lightbox-edit { position: absolute; border: 0; color: #fff; background: rgba(255, 255, 255, .14); cursor: pointer; }
.lightbox-close { top: 22px; right: 22px; width: 44px; height: 44px; border-radius: 50%; font-size: 30px; line-height: 1; }
.lightbox-edit { top: 22px; right: 78px; min-height: 44px; padding: 0 18px; border-radius: 999px; font-weight: 900; font-size: 15px; }
.lightbox-nav { top: 50%; width: 54px; height: 74px; border-radius: 20px; transform: translateY(-50%); font-size: 54px; line-height: 1; }
.lightbox-nav.prev { left: 18px; }
.lightbox-nav.next { right: 18px; }
.lightbox-close:hover, .lightbox-nav:hover, .lightbox-edit:hover { background: rgba(255, 255, 255, .24); }
.lightbox-loader { position: absolute; width: 54px; height: 54px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .22); border-top-color: #fff; animation: loaderSpin .8s linear infinite; display: none; }
.lightbox.loading .lightbox-loader { display: block; }
.photo-editor-dialog { width: min(1280px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.photo-editor-dialog::backdrop { background: rgba(3, 8, 18, .68); backdrop-filter: blur(6px); }
.photo-editor { padding: 22px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); grid-template-areas: "head controls" "canvas controls" "actions controls"; gap: 18px; align-items: start; }
.photo-editor-head h2, .photo-editor-head p { margin: 0; }
.photo-editor-head { grid-area: head; }
.photo-editor-canvas-wrap { grid-area: canvas; position: sticky; top: 18px; width: 100%; max-height: calc(100vh - 190px); border-radius: 16px; overflow: hidden; background: #111827; display: grid; place-items: center; }
.photo-editor canvas { width: 100%; max-height: calc(100vh - 190px); object-fit: contain; border-radius: 16px; background: #111827; touch-action: none; }
.photo-editor .photo-editor-tool-canvas { position: absolute; display: block; width: auto; max-width: none; max-height: none; border-radius: 0; pointer-events: none; z-index: 2; background: transparent !important; }
.photo-editor-crop-overlay { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
.photo-editor-canvas-wrap.tool-active canvas { cursor: crosshair; }
.crop-shade { position: absolute; background: rgba(0, 0, 0, .45); pointer-events: none; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(0, 0, 0, .25); cursor: move; }
.crop-box::before, .crop-box::after { content: ""; position: absolute; inset: 33.333% 0 auto; border-top: 1px solid rgba(255, 255, 255, .65); }
.crop-box::after { inset: 66.666% 0 auto; }
.crop-box span { position: absolute; width: 16px; height: 16px; border: 2px solid #fff; background: var(--blue); border-radius: 50%; box-shadow: 0 3px 10px rgba(0, 0, 0, .35); }
.crop-box [data-crop-handle="nw"] { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-box [data-crop-handle="n"] { left: 50%; top: -8px; transform: translateX(-50%); cursor: ns-resize; }
.crop-box [data-crop-handle="ne"] { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-box [data-crop-handle="e"] { right: -8px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.crop-box [data-crop-handle="se"] { right: -8px; bottom: -8px; cursor: nwse-resize; }
.crop-box [data-crop-handle="s"] { left: 50%; bottom: -8px; transform: translateX(-50%); cursor: ns-resize; }
.crop-box [data-crop-handle="sw"] { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-box [data-crop-handle="w"] { left: -8px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.photo-editor-controls { grid-area: controls; max-height: calc(100vh - 76px); overflow: auto; padding-right: 4px; display: grid; gap: 12px; align-self: stretch; }
.photo-editor-controls label:not(.check-row) { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 10px; font-weight: 800; }
.photo-editor-controls select { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--field); color: var(--ink); font-weight: 800; }
.photo-editor-controls input[type="range"] { width: 100%; }
.editor-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.editor-check { margin-left: auto; }
.editor-icon-button { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
.editor-icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.photo-editor-controls .ghost.active { background: var(--blue); color: var(--primary-ink); }
.editor-crop-panel { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--soft); display: grid; gap: 12px; }
.editor-crop-panel[hidden] { display: none; }
.editor-crop-panel p { margin: 0; }
.editor-crop-panel button { justify-self: start; }
.editor-tool-panel, .editor-advanced-panel { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--soft); display: grid; gap: 12px; }
.editor-tool-panel strong, .editor-advanced-panel strong { display: block; }
.editor-tool-panel p { margin: 0; }
.photo-editor > .dialog-actions { grid-area: actions; justify-content: flex-start; }

@media (max-width: 980px) {
  .photo-editor { grid-template-columns: 1fr; grid-template-areas: "head" "canvas" "controls" "actions"; }
  .photo-editor-canvas-wrap { position: relative; top: auto; max-height: 52vh; }
  .photo-editor canvas { max-height: 52vh; }
  .photo-editor-controls { max-height: none; overflow: visible; }
}

@keyframes lightboxFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes loaderSpin {
  to { transform: rotate(360deg); }
}

@media (max-width: 760px) {
  .sidebar { position: sticky; top: 0; z-index: 20; width: auto; padding: 14px 20px; border-right: 0; border-bottom: 1px solid var(--line); gap: 0; }
  body.menu-open { overflow: hidden; }
  .mobile-topbar { display: flex; align-items: center; justify-content: space-between; }
  .menu-toggle { width: 42px; height: 42px; border: 0; border-radius: 999px; background: var(--soft); display: grid; place-items: center; gap: 0; padding: 11px; cursor: pointer; }
  .menu-toggle span { display: block; width: 20px; height: 2px; background: var(--ink); border-radius: 999px; transition: transform .18s ease, opacity .18s ease; }
  .menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .menu-toggle.open span:nth-child(2) { opacity: 0; }
  .menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .sidebar-menu { position: absolute; left: 0; right: 0; top: 100%; display: grid; gap: 18px; max-height: 0; padding: 0 20px; opacity: 0; overflow: hidden; background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); transform: translateY(-8px); transition: max-height .26s ease, opacity .18s ease, transform .22s ease, padding-top .22s ease, padding-bottom .22s ease; }
  .sidebar-menu.open { padding-top: 18px; padding-bottom: 32px; opacity: 1; transform: translateY(0); }
  .sidebar-menu .profile { margin-bottom: 0; padding: 18px; }
  .content { margin: 0; padding: 20px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .photo-controls { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 12px; }
  .view-toggle { width: 100%; }
  .view-toggle a { flex: 1; text-align: center; padding: 9px 10px; }
  .order-control { min-width: 0; }
  .order-control select { min-width: 0; width: 100%; }
  .photo-size-control { justify-content: flex-end; }
  .photo-size-control span { min-width: 44px; }
  .photo-size-control button { width: 34px; height: 34px; }
  .form-grid.two, .user-form, .user-create-form, .user-admin-form, .user-limit-grid { grid-template-columns: 1fr; }
  .user-list-row { grid-template-columns: 1fr; gap: 8px; }
  .user-list-actions { justify-content: flex-start; }
  .sharing-row { grid-template-columns: 1fr; }
  .user-search { display: grid; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(150px, var(--photo-thumb-width))); }
  .folder-picker { align-items: flex-start; flex-direction: column; }
  .gallery-toolbar { justify-content: flex-start; }
  .selection-bar { top: 8px; margin-left: 0; justify-content: flex-start; }
  .lightbox { padding: 70px 12px 24px; }
  .lightbox-nav { width: 44px; height: 58px; font-size: 42px; }
  .lightbox-nav.prev { left: 8px; }
  .lightbox-nav.next { right: 8px; }
}
