:root {
  --bg: #111315;
  --surface: #191c20;
  --surface-2: #22262c;
  --surface-3: #2b3038;
  --text: #f7f4ed;
  --muted: #b6bbc4;
  --line: #3c434e;
  --line-strong: #596372;
  --primary: #f3efe2;
  --primary-text: #151515;
  --accent: #6fc3a1;
  --warning: #d7a64b;
  --danger: #ff7373;
  --danger-bg: #3a2024;
  --radius: 8px;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

html {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  background: var(--bg);
  color: var(--text);
}

body.lightbox-open {
  overflow: hidden;
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(111, 195, 161, 0.52);
  outline-offset: 2px;
}

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

h2 {
  margin-bottom: 12px;
  font-size: clamp(1rem, 5vw, 1.18rem);
  line-height: 1.15;
}

.app-shell {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: max(10px, env(safe-area-inset-top)) 10px calc(78px + env(safe-area-inset-bottom));
  gap: 10px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(25, 28, 32, 0.97);
  box-shadow: var(--shadow);
}

.brand-logo {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.brand-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: var(--primary-text);
  font-size: 0.86rem;
  font-weight: 900;
}

.brand-text {
  min-width: 0;
  color: var(--text);
  font-size: clamp(1.08rem, 6vw, 1.35rem);
  font-weight: 900;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.topbar-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 9px max(10px, env(safe-area-inset-left)) calc(9px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
  border-top: 1px solid var(--line);
  background: rgba(17, 19, 21, 0.98);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.34);
}

.tabs {
  display: contents;
}

.nav-button,
.tab,
.secondary,
.import-label {
  background: var(--surface-3);
  color: var(--text);
}

.nav-button.active,
.tab.active,
.primary {
  background: var(--primary);
  color: var(--primary-text);
}

.danger {
  background: var(--danger-bg);
  color: #ffd4d4;
}

.tiny,
.small {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 0.92rem;
}

main,
.view,
.panel,
form,
.form-section,
.equipment-notes-grid,
.record-main,
.record-details,
.record-lower,
.record-info-grid {
  min-width: 0;
}

main {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  width: 100%;
  max-width: 100%;
  padding: 0;
  background: transparent;
}

form {
  position: relative;
  display: grid;
  gap: 12px;
}

.form-section,
.shoot-record,
.section-head,
.clear-data-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
}

.form-section {
  padding: 14px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.form-grid,
.setup-grid,
.status-grid,
.photo-grid,
.time-inputs,
.split-inputs,
.paid-split-inputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-width: 0;
}

.split-inputs > span,
.time-inputs > span {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.sub-label,
.group-title {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  max-width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 12px;
  font-size: 1rem;
  outline: none;
}

input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

input[type="date"],
input[type="time"],
input[type="number"] {
  color-scheme: dark;
}

input[type="file"],
.browser-import-input {
  display: none;
}

#imageDirectoryInput {
  display: none;
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.4;
}

.date-input-wrap {
  position: relative;
  display: block;
  min-width: 0;
}

.date-input-wrap .native-date-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.date-input-wrap #dateDisplay {
  padding-right: 42px;
  pointer-events: none;
}

.date-input-wrap::after {
  content: "Date";
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  pointer-events: none;
}

.paid-amount-wrap {
  position: relative;
  min-width: 0;
}

.paid-pound {
  position: absolute;
  left: 12px;
  top: 50%;
  z-index: 1;
  transform: translateY(-50%);
  color: var(--text);
  font-weight: 900;
  pointer-events: none;
}

.paid-amount-wrap input {
  padding-left: 27px;
}

.paid-amount-wrap:has(input:disabled) .paid-pound {
  display: none;
}

.paid-amount-wrap:has(input:disabled) input {
  padding-left: 12px;
}

.equipment-notes-section {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.equipment-notes-grid {
  display: grid;
  gap: 12px;
}

.equipment-setup-panel,
.shoot-notes-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.setup-divider {
  height: 1px;
  margin: 14px 0;
  background: var(--line);
}

.notes-count {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-align: right;
}

.image-folder-section {
  display: grid;
  gap: 12px;
}

.database-panel-head {
  align-items: start;
}

.database-panel-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
}

.database-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.image-folder-head {
  display: grid;
  gap: 12px;
}

.image-folder-head h2 {
  margin-bottom: 6px;
}

.image-folder-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.4;
}

.image-folder-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.folder-upload-label {
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.image-folder-status {
  min-height: 36px;
  display: grid;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.photo-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.photo-slot {
  display: block;
  min-width: 0;
  cursor: pointer;
}

.photo-preview {
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  min-height: 132px;
  aspect-ratio: 1 / 1;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 900;
  text-align: center;
  overflow: hidden;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.photo-preview.has-photo {
  border-style: solid;
  color: transparent;
}

.button-row {
  position: sticky;
  bottom: calc(64px + env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(25, 28, 32, 0.98);
  box-shadow: var(--shadow);
}

.edit-nav-arrow {
  position: fixed;
  top: auto;
  bottom: calc(144px + env(safe-area-inset-bottom));
  z-index: 25;
  display: none;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
  font-weight: 900;
}

.edit-nav-arrow.is-visible {
  display: grid;
  place-items: center;
}

.edit-nav-arrow:disabled {
  opacity: 0.35;
}

.edit-nav-prev {
  left: 14px;
}

.edit-nav-next {
  right: 14px;
}

.section-head {
  display: grid;
  gap: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.directory-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.directory-title-row h2 {
  margin-bottom: 0;
}

.directory-status {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 900;
  opacity: 0;
}

.directory-status.active {
  opacity: 1;
}

.tools-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-width: 0;
}

.search {
  width: 100%;
}

.shoot-register {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 100%;
}

.shoot-register.empty {
  min-height: 180px;
  place-items: center;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.shoot-register.empty p {
  margin: 0;
}

.clear-data-row {
  display: grid;
  margin-top: 12px;
  padding: 12px;
}

.clear-data-btn {
  width: 100%;
  border: 1px solid #694149;
  background: rgba(255, 115, 115, 0.12);
  color: #ffd0d0;
}

.load-more-btn {
  width: 100%;
}

.shoot-record {
  display: grid;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}

.record-main,
.record-details,
.record-lower,
.record-info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.record-title-box,
.record-date-box,
.record-time-box,
.record-field,
.record-photo-panel {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
}

.record-title-box span,
.record-date-box span,
.record-time-box span,
.record-field span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.record-title {
  margin-bottom: 0;
  color: var(--text);
  font-size: 1.08rem;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.record-field strong,
.record-date,
.record-start-time,
.record-end-time,
.record-image-count,
.record-video-count,
.record-set-no,
.record-model-release,
.record-id-photo {
  display: block;
  margin-bottom: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 850;
  line-height: 1.32;
  white-space: normal;
  overflow-wrap: anywhere;
}

.record-time-box {
  display: grid;
  gap: 10px;
}

.record-time-values,
.record-stat-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.record-stat-box {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.record-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.record-info-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record-equipment-box,
.record-photo-panel,
.record-model-box,
.record-styles-box,
.record-stat-box {
  grid-column: 1 / -1;
}

.equipment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.equipment-chip,
.equipment-empty {
  display: inline-flex;
  max-width: 100%;
  min-height: 28px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.equipment-empty {
  color: var(--muted);
}

.record-photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-height: 72px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

.record-photos img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: zoom-in;
}

.dynamic-dropdown-menu {
  position: fixed;
  z-index: 80;
  max-width: calc(100vw - 20px);
  max-height: 260px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #1c2026;
  box-shadow: var(--shadow);
}

.dynamic-dropdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 4px;
}

.dynamic-dropdown-value,
.dynamic-dropdown-delete {
  background: transparent;
  color: var(--text);
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.dynamic-dropdown-delete {
  color: #ffd0d0;
  text-align: center;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 54px 14px 20px;
  background: rgba(5, 6, 8, 0.9);
}

.image-lightbox[hidden] {
  display: none;
}

.image-lightbox img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 86px);
  object-fit: contain;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #0c0d11;
  box-shadow: var(--shadow);
}

.image-lightbox-close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
  font-size: 1.4rem;
}

@media (min-width: 360px) {
  .database-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tools-row {
    grid-template-columns: 1fr 1fr;
  }

  .tools-row .search {
    grid-column: 1 / -1;
  }
}

@media (min-width: 430px) {
  .split-inputs,
  .time-inputs,
  .paid-split-inputs,
  .setup-grid,
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 520px) {
  .image-folder-head {
    grid-template-columns: minmax(0, 1fr) minmax(160px, 0.7fr);
    align-items: start;
  }
}

@media (min-width: 700px) {
  .app-shell {
    max-width: 980px;
    margin: 0 auto;
    padding-inline: 16px;
  }

  .form-grid,
  .setup-grid,
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-grid,
  .record-photos {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .record-main,
  .record-details,
  .record-lower {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .record-title-box,
  .record-time-box,
  .record-photo-panel {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1024px) {
  .app-shell {
    max-width: 1180px;
    padding-bottom: 18px;
  }

  .topbar-actions {
    position: static;
    grid-template-columns: auto auto auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .button-row {
    bottom: 14px;
  }

  .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .equipment-notes-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  }

  .status-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tools-row {
    grid-template-columns: minmax(220px, 1fr) auto auto;
  }

  .tools-row .search {
    grid-column: auto;
  }

  .record-main {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .record-details,
  .record-lower {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .record-info-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
