:root {
  color-scheme: dark;
  --bg: #0d1118;
  --bg-soft: #131925;
  --panel: rgba(20, 27, 40, 0.82);
  --panel-solid: #171e2c;
  --line: rgba(199, 214, 235, 0.12);
  --line-strong: rgba(199, 214, 235, 0.22);
  --text: #f4f7fb;
  --muted: #8d9aac;
  --accent: #d7ff6b;
  --accent-deep: #a8ce3b;
  --cyan: #8ce6e4;
  --danger: #ff8e8e;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 25% 0%, #1c2637 0, var(--bg) 40rem); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.5; }
[hidden] { display: none !important; }

.ambient { position: fixed; pointer-events: none; border-radius: 999px; filter: blur(2px); opacity: 0.12; z-index: -1; }
.ambient-one { width: 28rem; height: 28rem; right: -12rem; top: 8rem; background: var(--accent); }
.ambient-two { width: 20rem; height: 20rem; left: -10rem; bottom: 3rem; background: var(--cyan); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 420px); padding: 42px 38px 38px; border: 1px solid var(--line); border-radius: 28px; background: linear-gradient(145deg, rgba(30, 40, 57, 0.92), rgba(15, 20, 30, 0.94)); box-shadow: var(--shadow); }
.brand-mark, .mini-mark { display: grid; place-items: center; background: var(--accent); color: #18210e; font-weight: 900; transform: rotate(-8deg); }
.brand-mark { width: 52px; height: 52px; border-radius: 17px; font-size: 25px; margin-bottom: 34px; }
.mini-mark { width: 32px; height: 32px; border-radius: 10px; font-size: 16px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(30px, 4vw, 48px); letter-spacing: -0.045em; line-height: 1.06; }
h2 { margin-bottom: 0; font-size: 17px; letter-spacing: -0.02em; }
.muted { color: var(--muted); line-height: 1.6; }
.small-text { font-size: 12px; }
.login-copy { margin-bottom: 28px; }

.stack-form { display: grid; gap: 10px; }
.field-label { margin-top: 9px; color: #b9c4d2; font-size: 12px; font-weight: 650; }
.text-input, .text-area, .select-input, .search-box { border: 1px solid var(--line); border-radius: 12px; background: rgba(8, 12, 19, 0.42); color: var(--text); outline: none; transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease; }
.text-input, .select-input { min-height: 44px; padding: 0 13px; }
.text-area { width: 100%; min-height: 170px; resize: vertical; padding: 13px; line-height: 1.55; }
.text-input:focus, .text-area:focus, .select-input:focus, .search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(215, 255, 107, 0.11); background: rgba(8, 12, 19, 0.68); }
.primary-button, .secondary-button, .ghost-button, .danger-button, .text-button, .icon-button, .tiny-button { border: 0; border-radius: 11px; transition: transform 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease; }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover, .danger-button:hover, .text-button:hover, .icon-button:hover, .tiny-button:hover { transform: translateY(-1px); }
.primary-button { min-height: 42px; padding: 0 17px; background: var(--accent); color: #1a230c; font-weight: 800; }
.primary-button:hover { background: #e4ff9a; }
.secondary-button { min-height: 42px; padding: 0 15px; border: 1px solid rgba(215, 255, 107, 0.3); background: rgba(215, 255, 107, 0.09); color: var(--accent); font-weight: 750; }
.secondary-button:hover { background: rgba(215, 255, 107, 0.16); }
.ghost-button { padding: 9px 12px; background: transparent; color: var(--muted); }
.ghost-button:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.danger-button { padding: 8px 0; background: transparent; color: var(--danger); font-size: 12px; font-weight: 700; }
.text-button { padding: 6px 0; background: transparent; color: var(--accent); font-size: 12px; font-weight: 800; }
.icon-button { width: 34px; height: 34px; background: rgba(215, 255, 107, 0.12); color: var(--accent); font-size: 23px; line-height: 1; }
.full-button { width: 100%; margin-top: 13px; }
.form-error { min-height: 20px; margin: 4px 0 0; color: var(--danger); font-size: 12px; }

.workspace-shell { min-height: 100vh; }
.topbar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(18px, 4vw, 64px); border-bottom: 1px solid var(--line); background: rgba(13, 17, 24, 0.68); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 10; }
.topbar-brand, .topbar-actions, .heading-actions, .photo-toolbar-actions, .editor-footer, .sidebar-heading, .card-heading { display: flex; align-items: center; }
.topbar-brand { gap: 11px; }
.topbar-brand strong { font-size: 14px; }
.topbar-brand .eyebrow { margin-bottom: 2px; }
.topbar-actions { gap: 12px; }
.domain-note { color: #627084; font-size: 12px; }
.mobile-ready-chip { display: none; padding: 6px 9px; border: 1px solid rgba(140, 230, 228, 0.24); border-radius: 999px; background: rgba(140, 230, 228, 0.08); color: var(--cyan); font-size: 10px; font-weight: 750; }

.workspace-layout { width: min(1480px, 100%); display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; margin: 0 auto; padding: 26px clamp(18px, 4vw, 64px) 64px; }
.panel { border: 1px solid var(--line); border-radius: 21px; background: var(--panel); box-shadow: 0 12px 45px rgba(0, 0, 0, 0.12); backdrop-filter: blur(18px); }
.sidebar { align-self: start; min-height: calc(100vh - 130px); padding: 20px 14px 14px; position: sticky; top: 104px; }
.sidebar-heading { justify-content: space-between; padding: 0 7px 18px; }
.sidebar-heading h2 { font-size: 20px; }
.sidebar-tools { display: grid; gap: 9px; padding: 0 4px 17px; }
.search-box { min-height: 40px; display: flex; align-items: center; gap: 7px; padding: 0 11px; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.search-box input::placeholder { color: #667386; }
.select-input { width: 100%; color: #c3cfdd; font-size: 12px; }
.folder-list { display: grid; gap: 5px; }
.folder-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 9px; border: 1px solid transparent; border-radius: 14px; background: transparent; color: var(--text); text-align: left; }
.folder-item:hover { background: rgba(255, 255, 255, 0.045); }
.folder-item.active { border-color: rgba(215, 255, 107, 0.25); background: linear-gradient(110deg, rgba(215, 255, 107, 0.13), rgba(215, 255, 107, 0.03)); }
.folder-item-icon { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: rgba(140, 230, 228, 0.11); color: var(--cyan); font-size: 14px; }
.folder-item.active .folder-item-icon { background: rgba(215, 255, 107, 0.18); color: var(--accent); }
.folder-item-copy { min-width: 0; flex: 1; display: grid; gap: 4px; }
.folder-item-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.folder-item-copy small { color: var(--muted); font-size: 10px; }
.folder-item-arrow { color: #536174; font-size: 20px; }
.sidebar-empty { display: grid; place-items: center; gap: 7px; padding: 40px 12px; text-align: center; }
.sidebar-empty p { margin: 0; color: var(--muted); font-size: 13px; }
.empty-glyph { color: #66758a; font-size: 25px; }

.content-area { min-width: 0; }
.content-empty { min-height: 560px; display: grid; align-content: center; justify-items: start; padding: clamp(28px, 6vw, 82px); }
.content-empty h1 { max-width: 500px; }
.content-empty .muted { max-width: 450px; margin-bottom: 25px; }
.empty-orbit { display: grid; place-items: center; width: 62px; height: 62px; margin-bottom: 28px; border: 1px solid rgba(215, 255, 107, 0.35); border-radius: 22px; background: rgba(215, 255, 107, 0.08); color: var(--accent); font-size: 28px; transform: rotate(-10deg); }
.content-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 9px 2px 25px; }
.mobile-back-button { display: none; border: 0; background: transparent; color: var(--accent); font-size: 12px; font-weight: 800; }
.content-heading h1 { margin-bottom: 7px; font-size: clamp(27px, 3.2vw, 43px); }
.content-heading .muted { margin: 0; font-size: 13px; }
.heading-actions { gap: 9px; flex-wrap: wrap; justify-content: end; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 15px; }
.editor-card, .upload-card { padding: 21px; }
.card-heading { justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-heading .eyebrow { margin-bottom: 4px; }
.upload-limit { color: var(--muted); font-size: 11px; }
.editor-footer { justify-content: space-between; gap: 12px; margin-top: 14px; }
.drop-zone { min-height: 236px; display: grid; place-items: center; align-content: center; gap: 9px; padding: 24px; border: 1px dashed rgba(215, 255, 107, 0.36); border-radius: 16px; background: linear-gradient(150deg, rgba(215, 255, 107, 0.08), rgba(140, 230, 228, 0.04)); text-align: center; transition: border-color 160ms ease, background 160ms ease, transform 160ms ease; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--accent); background: rgba(215, 255, 107, 0.13); transform: translateY(-2px); }
.drop-zone input { display: none; }
.drop-icon { display: grid; place-items: center; width: 47px; height: 47px; border-radius: 15px; background: rgba(215, 255, 107, 0.15); color: var(--accent); font-size: 28px; }
.upload-status { display: grid; gap: 8px; margin-top: 14px; }
.progress-track { height: 6px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 160ms ease; }
.photo-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 34px 2px 16px; }
.photo-toolbar .eyebrow { margin-bottom: 4px; }
.photo-toolbar-actions { gap: 12px; }
.check-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
input[type="checkbox"] { accent-color: var(--accent-deep); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.photo-card { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: rgba(22, 29, 42, 0.78); transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease; }
.photo-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: 0 14px 36px rgba(0, 0, 0, 0.2); }
.photo-card.selected { border-color: rgba(215, 255, 107, 0.7); box-shadow: 0 0 0 2px rgba(215, 255, 107, 0.12); }
.photo-image-wrap { aspect-ratio: 4 / 5; position: relative; overflow: hidden; background: #0a0f17; }
.photo-image { width: 100%; height: 100%; display: block; object-fit: cover; cursor: zoom-in; transition: transform 300ms ease; }
.photo-card:hover .photo-image { transform: scale(1.025); }
.photo-check { position: absolute; top: 10px; left: 10px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 9px; background: rgba(7, 10, 15, 0.62); backdrop-filter: blur(8px); cursor: pointer; }
.photo-check input { display: none; }
.photo-check span { width: 13px; height: 13px; border: 1px solid rgba(255, 255, 255, 0.65); border-radius: 4px; }
.photo-check input:checked + span { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px #253013; }
.photo-index { position: absolute; right: 10px; bottom: 9px; color: rgba(255, 255, 255, 0.78); font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-shadow: 0 1px 5px #000; }
.photo-meta { display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 11px; }
.photo-meta > div:first-child { min-width: 0; display: grid; gap: 4px; }
.photo-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.photo-meta small { color: var(--muted); font-size: 10px; }
.photo-actions { display: flex; gap: 5px; }
.tiny-button { padding: 5px 7px; background: rgba(255, 255, 255, 0.06); color: #c7d2e1; font-size: 10px; }
.tiny-button:hover { background: rgba(255, 255, 255, 0.12); }
.danger-text { color: var(--danger); }
.photo-empty { min-height: 190px; display: grid; place-items: center; align-content: center; gap: 7px; text-align: center; }
.photo-empty p { margin: 0; color: #c9d3df; font-size: 14px; }

.modal-backdrop, .preview-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(2, 5, 9, 0.72); backdrop-filter: blur(12px); z-index: 50; }
.modal-card { width: min(100%, 480px); max-height: calc(100dvh - 40px); overflow-y: auto; position: relative; padding: 30px; border: 1px solid var(--line-strong); border-radius: 24px; background: var(--panel-solid); box-shadow: var(--shadow); }
.modal-card h2 { margin-bottom: 18px; font-size: 25px; }
.modal-close, .preview-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.modal-close { position: absolute; top: 17px; right: 18px; font-size: 24px; }
.modal-close:hover, .preview-close:hover { color: var(--text); }
.preview-backdrop { padding: 42px; }
.preview-backdrop img { max-width: min(92vw, 1100px); max-height: 90vh; object-fit: contain; border-radius: 12px; box-shadow: var(--shadow); }
.preview-close { position: fixed; top: 18px; right: 24px; z-index: 2; font-size: 36px; }
.modal-open { overflow: hidden; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: min(360px, calc(100vw - 40px)); padding: 12px 15px; border: 1px solid rgba(215, 255, 107, 0.38); border-radius: 12px; background: #202a1a; color: #efffcf; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity 180ms ease, transform 180ms ease; font-size: 13px; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255, 142, 142, 0.42); background: #351e26; color: #ffd9d9; }

@media (max-width: 1080px) {
  .workspace-layout { grid-template-columns: 250px minmax(0, 1fr); }
  .editor-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .desktop-only { display: none; }
  .mobile-ready-chip { display: inline-flex; }
  .topbar { min-height: 68px; padding: env(safe-area-inset-top) 16px 0; }
  .workspace-layout { display: block; padding: 14px 12px calc(36px + env(safe-area-inset-bottom)); }
  .sidebar { min-height: auto; margin-bottom: 15px; padding: 13px 10px 10px; position: static; }
  .sidebar-heading { padding-bottom: 12px; }
  .sidebar-tools { grid-template-columns: 1fr 120px; padding-bottom: 11px; }
  .folder-list { display: grid; gap: 7px; overflow: visible; padding: 2px 0 3px; }
  .folder-item { width: 100%; min-width: 0; border-color: var(--line); }
  .sidebar-empty { padding: 20px 12px 12px; }
  .content-empty { min-height: 420px; padding: 34px 26px; }
  .content-heading { align-items: start; flex-direction: column; margin-top: 4px; }
  .mobile-folder-open .sidebar { display: none; }
  .mobile-folder-open .workspace-layout { padding-top: 12px; }
  .mobile-back-button { display: inline-flex; align-items: center; min-height: 32px; padding: 0; }
  .heading-actions { width: 100%; justify-content: stretch; }
  .heading-actions button { flex: 1; }
  .editor-card, .upload-card { padding: 16px; }
  .photo-toolbar { align-items: start; flex-direction: column; padding-top: 25px; }
  .photo-toolbar-actions { width: 100%; justify-content: space-between; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .photo-meta { display: block; padding: 9px; }
  .photo-actions { margin-top: 8px; }
  .photo-actions button { flex: 1; }
  .login-card { padding: 32px 24px 28px; }
  button, .drop-zone, .folder-item, .photo-image { touch-action: manipulation; }
}

@media (max-width: 420px) {
  .sidebar-tools { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-meta strong { font-size: 11px; }
  .primary-button, .secondary-button { padding-inline: 11px; font-size: 12px; }
}

/* Keep the folder picker vertical on narrow screens after cached CSS is refreshed. */
@media (max-width: 760px) {
  #folderList {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    overflow: visible !important;
  }

  #folderList .folder-item {
    width: 100% !important;
    min-width: 0 !important;
  }
}
