:root {
  color-scheme: dark;
  --bg: #10110f;
  --surface: #191a17;
  --surface-2: #22231f;
  --surface-3: #2b2b26;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f3efe7;
  --muted: #b6afa3;
  --soft: #8c8579;
  --accent: #d5b46f;
  --accent-2: #8fb59d;
  --danger: #d48478;
  --tap: 48px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

html {
  min-height: 100%;
  overscroll-behavior-y: contain;
  -webkit-text-size-adjust: 100%;
}

a,
button,
.button,
.wide-button,
.icon-button,
.tool-button,
.media-card,
.album-button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(213, 180, 111, 0.20);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(6px + env(safe-area-inset-top)) 14px 6px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 17, 15, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--accent);
  font-weight: 900;
  background: #151612;
}

.brand-title,
.brand-subtitle {
  display: block;
}

.brand-title {
  font-size: 14px;
  font-weight: 900;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 11px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.button,
.wide-button,
.icon-button {
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 800;
  font-size: 13px;
}

.topbar .button {
  min-height: var(--tap);
  padding: 7px 11px;
}

.button:hover,
.wide-button:hover,
.icon-button:hover {
  border-color: rgba(213, 180, 111, 0.6);
  background: rgba(213, 180, 111, 0.11);
}

.button.primary,
.wide-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #14130f;
}

.button.danger {
  color: var(--danger);
}

.wide-button {
  width: 100%;
  text-align: left;
  margin-top: 8px;
}

.wide-button.danger,
.icon-button {
  color: var(--danger);
}

button:disabled,
button:disabled:hover,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 330px;
  min-height: calc(100vh - 52px);
}

.sidebar,
.inspector {
  border-right: 1px solid var(--line);
  background: #131411;
  padding: 14px;
}

.inspector {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.workspace {
  min-width: 0;
  padding: 14px;
}

.quick-guide {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--accent);
  background: rgba(213, 180, 111, 0.09);
}

.quick-guide h1 {
  margin-bottom: 8px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
}

.quick-guide p {
  color: var(--muted);
  line-height: 1.5;
}

.quick-guide ol {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quick-guide li {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.045);
}

.quick-guide strong {
  color: var(--text);
}

.quick-guide span,
.eyebrow {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 14px;
  margin-bottom: 14px;
}

.sticky-panel {
  position: sticky;
  top: 66px;
}

.bottom-toolbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  min-height: 68px;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px max(14px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-right));
  border-top: 1px solid var(--line);
  background: rgba(16, 17, 15, 0.96);
  backdrop-filter: blur(16px);
}

.tool-button {
  min-width: 106px;
  min-height: 52px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 7px 10px;
  text-align: left;
  font-size: 12px;
  font-weight: 900;
}

.tool-button:hover {
  border-color: rgba(213, 180, 111, 0.65);
  background: rgba(213, 180, 111, 0.12);
}

.tool-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #151612;
  color: var(--accent);
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
}

.pill {
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 800;
}

.library-meta {
  margin: -4px 0 12px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.drop-zone {
  min-height: 112px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 6px;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.drop-zone strong {
  color: var(--text);
}

.drop-zone.is-over {
  border-color: var(--accent);
  background: rgba(213, 180, 111, 0.1);
}

.album-list {
  display: grid;
  gap: 7px;
}

.album-button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  min-height: var(--tap);
  padding: 10px;
  text-align: left;
}

.album-button.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(213, 180, 111, 0.09);
}

.album-button span:last-child {
  color: var(--soft);
}

.album-actions {
  margin-top: 10px;
}

.album-actions .wide-button {
  margin-top: 6px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 170px;
  gap: 8px;
  margin-bottom: 14px;
}

.bulk-bar {
  display: grid;
  grid-template-columns: auto auto minmax(145px, 0.55fr) minmax(150px, 1fr) 145px auto auto auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.bulk-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.bulk-bar .button {
  min-height: 40px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #10110f;
  color: var(--text);
  min-height: var(--tap);
  padding: 10px;
  font-size: 16px;
}

textarea {
  resize: vertical;
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 30px;
  text-align: center;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--surface);
}

.empty-art {
  width: min(260px, 76vw);
  max-height: 210px;
  object-fit: contain;
}

.empty-art[hidden] {
  display: none;
}

.empty-state h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 76px);
  line-height: 0.95;
}

.empty-state p {
  max-width: 620px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
}

.media-card {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  text-align: left;
  padding: 0;
  overflow: hidden;
  position: relative;
}

.media-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(213, 180, 111, 0.18);
}

.media-card.selected {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(143, 181, 157, 0.18);
}

.media-select {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(6, 7, 6, 0.72);
}

.media-check {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--accent-2);
}

.media-thumb {
  aspect-ratio: 1 / 0.78;
  display: grid;
  place-items: center;
  background: #0b0c0b;
  overflow: hidden;
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-badge {
  border: 1px solid var(--line);
  color: var(--accent-2);
  padding: 8px 10px;
  font-weight: 900;
}

.media-info {
  padding: 11px;
}

.media-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.media-sub {
  display: block;
  margin-top: 4px;
  color: var(--soft);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.no-selection {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  padding: 22px;
}

.meta-form {
  display: grid;
  gap: 12px;
}

.meta-form label,
.edit-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.preview-frame {
  min-height: 190px;
  display: grid;
  place-items: center;
  background: #0b0c0b;
  border: 1px solid var(--line);
  overflow: hidden;
}

.preview-frame img,
.preview-frame video {
  max-width: 100%;
  max-height: 260px;
  display: block;
}

.edit-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  padding: 12px;
}

.edit-panel legend {
  padding: 0 6px;
  color: var(--accent);
  font-weight: 900;
}

.inspector-actions,
.modal-actions,
.slide-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal {
  width: min(420px, calc(100% - 28px));
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 20px;
}

.modal::backdrop,
.slideshow-modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal form {
  display: grid;
  gap: 16px;
}

.slideshow-modal {
  width: min(1100px, calc(100% - 28px));
  height: min(780px, calc(100vh - 28px));
  border: 1px solid var(--line);
  background: #050505;
  color: var(--text);
  padding: 0;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  padding: 8px 11px;
}

.slide-stage {
  height: calc(100% - 70px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.slide-stage img,
.slide-stage video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.slide-controls {
  height: 70px;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--line);
}

.slide-status,
.toast {
  color: var(--muted);
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(24px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  background: #050505;
  padding: 10px 14px;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 50;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .bulk-bar {
    grid-template-columns: auto auto minmax(140px, 1fr) minmax(150px, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .sticky-panel {
    position: static;
  }
}

@media (max-width: 780px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 6px 10px;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .top-actions::-webkit-scrollbar {
    display: none;
  }

  .brand-subtitle {
    display: none;
  }

  .app-shell,
  .toolbar,
  .bulk-bar,
  .quick-guide,
  .quick-guide ol {
    grid-template-columns: 1fr;
  }

  .bulk-count {
    white-space: normal;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace,
  .sidebar,
  .inspector {
    padding: 10px;
  }

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

  .bottom-toolbar {
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .tool-button {
    min-width: 92px;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 4px;
  }
}

@media (max-width: 440px) {
  .media-grid {
    grid-template-columns: 1fr;
  }

  .empty-state {
    min-height: 330px;
    padding: 18px;
  }

  .empty-state h1 {
    font-size: 34px;
  }
}

.album-context-scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.36);
}

.album-context-sheet {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 81;
  display: grid;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  background: rgba(19, 20, 17, 0.98);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.34);
  transform: translateY(20px);
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
}

.album-context-sheet.open {
  transform: translateY(0);
  opacity: 1;
}

.album-context-title {
  padding: 4px 4px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.album-context-action {
  min-height: var(--tap);
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font: inherit;
  font-weight: 900;
  text-align: left;
  padding: 12px;
}

.album-context-action.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #14130f;
}
