:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #eef2f7;
  --ink: #18202c;
  --muted: #657083;
  --line: #cbd4e1;
  --accent: #0f766e;
  --accent-strong: #0b5d56;
  --oil: #9b5a16;
  --gas: #7c3aed;
  --water: #0b74d1;
  --danger: #a83535;
  --shadow: 0 12px 30px rgba(31, 41, 55, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.nav-actions a,
.home-button,
#downloadPhoto {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  min-height: 34px;
  padding: 7px 10px;
  text-decoration: none;
}

button:hover,
.nav-actions a:hover,
.home-button:hover,
#downloadPhoto:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  min-height: 0;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 16px;
  grid-template-columns: auto 1fr auto;
  padding: 12px 16px;
}

.home-button {
  font-weight: 700;
}

.home-button.icon-only {
  height: 34px;
  justify-content: center;
  min-height: 34px;
  padding: 6px;
  width: 34px;
}

.home-button.icon-only .action-icon {
  display: block;
  height: 20px;
  width: 20px;
}

.action-icon {
  display: none;
  fill: none;
  height: 22px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 22px;
}

.brand-block h1,
.well-summary h2,
.panel-heading h2 {
  font-size: 18px;
  line-height: 1.2;
  margin: 2px 0 0;
}

.brand-block {
  min-width: 0;
}

.title-line {
  align-items: baseline;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

#measureTool.active,
#eyedropperTool.active,
#applyColorMask.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.status-message {
  color: var(--muted);
  flex: 1 1 auto;
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-message.error {
  color: var(--danger);
}

.viewer-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 292px;
  min-height: 0;
}

.app-shell.depth-collapsed .viewer-grid {
  grid-template-columns: 56px minmax(0, 1fr) 292px;
}

.app-shell.tools-collapsed .viewer-grid {
  grid-template-columns: 320px minmax(0, 1fr) 56px;
}

.app-shell.depth-collapsed.tools-collapsed .viewer-grid {
  grid-template-columns: 56px minmax(0, 1fr) 56px;
}

.app-shell.focus-mode {
  grid-template-rows: auto 1fr;
}

.app-shell.focus-mode .active-meta,
.app-shell.focus-mode .photo-choices {
  display: none;
}

.app-shell.focus-mode .viewer-grid {
  grid-template-columns: 224px minmax(0, 1fr);
}

.app-shell.focus-mode.depth-collapsed .viewer-grid {
  grid-template-columns: 56px minmax(0, 1fr);
}

.app-shell.focus-mode .tool-panel {
  display: none;
}

.app-shell.focus-mode .photo-panel {
  grid-template-rows: 1fr;
}

.app-shell.focus-mode .depth-panel {
  padding: 8px;
}

.app-shell.focus-mode .panel-heading {
  margin-bottom: 6px;
}

.app-shell.focus-mode .well-summary {
  margin-bottom: 6px;
}

.app-shell.focus-mode .filters {
  gap: 5px;
  grid-template-columns: 1fr;
  margin-bottom: 8px;
}

.app-shell.focus-mode .filters label {
  font-size: 10px;
}

.app-shell.focus-mode .filters select {
  min-height: 28px;
  padding: 4px 6px;
}

.app-shell.focus-mode .member-notice {
  font-size: 10px;
  margin-bottom: 6px;
}

.app-shell.focus-mode .depth-list {
  gap: 5px;
}

.app-shell.focus-mode .formation-header {
  border-radius: 5px;
  font-size: 10px;
  padding: 5px 7px;
  top: -8px;
}

.app-shell.focus-mode .depth-card {
  gap: 4px;
  padding: 7px;
}

.app-shell.focus-mode .depth-card.has-thumb {
  padding-right: 54px;
}

.app-shell.focus-mode .depth-card strong {
  font-size: 12px;
}

.app-shell.focus-mode .depth-card span,
.app-shell.focus-mode .chip {
  font-size: 10px;
}

.app-shell.focus-mode .chip {
  padding: 1px 5px;
}

.app-shell.focus-mode .depth-thumb {
  height: 34px;
  right: 6px;
  width: 44px;
}

.depth-panel,
.tool-panel,
.photo-panel {
  min-height: 0;
}

.depth-panel,
.tool-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  container-type: inline-size;
  overflow: auto;
  padding: 12px;
}

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

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

.icon-button {
  display: inline-flex;
}

.collapse-toggle {
  gap: 5px;
}

.collapse-arrow {
  fill: none;
  height: 14px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 140ms ease;
  width: 14px;
}

.collapse-toggle[aria-expanded="false"] .collapse-arrow {
  transform: rotate(180deg);
}

.app-shell.tools-collapsed .tool-panel {
  overflow: hidden;
  padding: 8px;
}

.app-shell.depth-collapsed .depth-panel {
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px;
}

.app-shell.depth-collapsed .depth-panel .filters,
.app-shell.depth-collapsed .depth-panel .member-notice,
.app-shell.depth-collapsed .depth-panel .well-summary,
.app-shell.depth-collapsed .depth-panel .depth-card,
.app-shell.depth-collapsed .depth-panel .formation-header,
.app-shell.depth-collapsed .depth-panel .eyebrow,
.app-shell.depth-collapsed .depth-panel h2,
.app-shell.tools-collapsed .tool-panel .tool-section,
.app-shell.tools-collapsed .tool-panel .eyebrow,
.app-shell.tools-collapsed .tool-panel h2 {
  display: none;
}

.app-shell.depth-collapsed #toggleDepthPanel,
.app-shell.tools-collapsed #toggleToolsPanel {
  min-height: 92px;
  padding: 8px 4px;
  writing-mode: vertical-rl;
}

.filters {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 12px;
}

.filters label,
.toolbar label,
.tool-section label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 4px;
}

.filters select,
.toolbar select {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 34px;
  padding: 6px 8px;
}

.member-notice {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.depth-list {
  display: grid;
  gap: 8px;
}

.formation-header {
  border-left: 6px solid var(--accent);
  border-radius: 6px;
  color: var(--ink);
  background-color: var(--panel);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 9px;
  position: sticky;
  top: -12px;
  z-index: 2;
}

.depth-rail-list {
  display: none;
}

.app-shell.depth-collapsed .depth-list {
  display: block;
  margin-top: 8px;
}

.app-shell.depth-collapsed .depth-rail-list {
  display: grid;
  gap: 6px;
}

.depth-rail-item {
  border-left: 4px solid var(--line);
  font-size: 11px;
  justify-content: center;
  min-height: 30px;
  overflow: hidden;
  padding: 4px 2px;
  text-align: center;
  width: 100%;
  writing-mode: vertical-rl;
}

.depth-rail-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.depth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  gap: 6px;
  padding: 10px;
  position: relative;
  text-align: left;
  width: 100%;
}

.depth-card.has-thumb {
  padding-right: 74px;
}

.depth-card strong,
.depth-card > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.depth-thumb {
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 4px;
  height: 42px;
  object-fit: cover;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
}

.app-shell.depth-collapsed .depth-thumb {
  display: none;
}

@container (max-width: 260px) {
  .depth-card.has-thumb {
    padding-right: 10px;
  }

  .depth-thumb {
    display: none;
  }
}

.depth-card.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.depth-card strong {
  font-size: 14px;
}

.depth-card span {
  color: var(--muted);
  font-size: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip {
  background: var(--panel-soft);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 7px;
}

.show-chip {
  color: #ffffff;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.depth-card .show-chip {
  color: #ffffff;
}

.show-chip.oil {
  background: var(--oil);
}

.show-chip.gas {
  background: var(--gas);
}

.show-chip.water {
  background: var(--water);
}

.photo-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
  padding: 12px;
}

.well-summary {
  align-items: start;
  display: block;
  gap: 10px;
  margin: 0 0 10px;
}

.well-summary dl {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-start;
  margin: 0;
}

.well-summary dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.well-summary dd {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  margin: 0;
  padding: 3px 6px;
}

.toolbar {
  display: none;
  align-items: end;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.active-meta {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 2fr 1fr;
  margin-bottom: 10px;
}

.active-meta > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
  padding: 8px;
}

.meta-label {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
}

.active-meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-choices {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.photo-choice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  flex: 0 0 116px;
  padding: 5px;
}

.photo-choice.active {
  border-color: var(--accent);
}

.photo-choice img {
  aspect-ratio: 4 / 3;
  background: var(--panel-soft);
  border-radius: 4px;
  display: block;
  object-fit: cover;
  width: 100%;
}

.photo-choice span {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-stage {
  align-items: center;
  background: #111827;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.image-overlays {
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 4;
}

.overlay-top-left {
  align-items: center;
  display: flex;
  gap: 6px;
  left: 10px;
  pointer-events: auto;
  position: absolute;
  top: 10px;
}

.overlay-select-wrap {
  align-items: center;
  background: rgba(0, 0, 0, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 6px;
  color: #ffffff;
  display: flex;
  gap: 6px;
  min-height: 38px;
  padding: 4px 7px;
}

.overlay-select-wrap span {
  font-size: 12px;
  font-weight: 700;
}

.overlay-select-wrap select {
  background: #ffffff;
  border: 0;
  border-radius: 4px;
  color: #111827;
  min-height: 26px;
}

.overlay-icon-button,
.overlay-arrow {
  align-items: center;
  background: #050505;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 6px;
  color: #ffffff;
  display: inline-flex;
  justify-content: center;
  pointer-events: auto;
  text-decoration: none;
}

.overlay-icon-button {
  height: 38px;
  min-height: 38px;
  padding: 0;
  width: 42px;
}

.overlay-icon-button svg,
.overlay-arrow svg {
  height: 28px;
  width: 28px;
}

.overlay-arrow svg {
  height: 56px;
  width: 34px;
}

.overlay-icon-button svg path,
.overlay-arrow svg path {
  fill: none;
  stroke: #ffffff;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.4;
  paint-order: stroke;
}

.overlay-arrow svg path {
  filter: drop-shadow(0 0 2px #000000) drop-shadow(0 0 4px #000000);
  stroke-width: 5;
}

.overlay-fullscreen {
  position: absolute;
  right: 10px;
  top: 10px;
}

.overlay-arrow {
  border-color: rgba(255, 255, 255, 0.42);
  min-height: 96px;
  padding: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
}

.overlay-prev {
  left: 10px;
}

.overlay-next {
  right: 10px;
}

.overlay-depth-prev,
.overlay-depth-next {
  height: 46px;
  min-height: 46px;
  transform: none;
  width: 46px;
}

.overlay-depth-left {
  left: 10px;
  right: auto;
}

.overlay-depth-right {
  left: auto;
  right: 10px;
}

.overlay-depth-prev {
  bottom: auto;
  top: calc(50% - 100px);
}

.overlay-depth-next {
  bottom: auto;
  top: calc(50% + 54px);
}

.overlay-depth-prev svg,
.overlay-depth-next svg {
  height: 28px;
  width: 34px;
}

.photo-info-overlay {
  bottom: 6px;
  color: #ffffff;
  font-size: 11px;
  left: 8px;
  line-height: 1.3;
  max-width: min(70%, 720px);
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  right: auto;
  text-align: left;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px #000000, 0 0 6px #000000;
  white-space: nowrap;
}

.modal-photo-info-overlay {
  bottom: 8px;
  left: 10px;
  position: fixed;
  z-index: 61;
}

.overlay-arrow:disabled,
.overlay-icon-button:disabled {
  opacity: 0.28;
}

#downloadPhoto.overlay-icon-button,
#modalDownloadPhoto.overlay-icon-button {
  background: #050505;
  color: #ffffff;
}

#downloadPhoto.overlay-icon-button svg path,
#modalDownloadPhoto.overlay-icon-button svg path {
  stroke: #ffffff;
}

.image-loading-bar {
  background: rgba(255, 255, 255, 0.14);
  bottom: 0;
  height: 5px;
  left: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  right: 0;
  transition: opacity 120ms ease;
  z-index: 5;
}

.image-loading-bar.visible {
  opacity: 1;
}

.image-loading-bar::before {
  animation: loadingSweep 1.05s linear infinite;
  background: linear-gradient(90deg, transparent, rgba(245, 247, 251, 0.92), transparent);
  content: "";
  height: 100%;
  left: -45%;
  position: absolute;
  top: 0;
  width: 45%;
}

@keyframes loadingSweep {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(325%);
  }
}

#photoCanvas,
#modalCanvas {
  display: block;
  touch-action: none;
}

.empty-stage {
  color: #e5e7eb;
  font-size: 14px;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.tool-section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 12px 0;
}

.tool-section h3 {
  font-size: 15px;
  margin: 0;
}

.tool-section input[type="range"] {
  width: 100%;
}

.check-row {
  align-items: center;
  display: flex !important;
  flex-direction: row;
}

.tool-readout {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: 0;
}

.modal-viewer {
  background: rgba(10, 15, 23, 0.96);
  display: none;
  inset: 0;
  position: fixed;
  z-index: 50;
}

.modal-viewer.open {
  display: grid;
  grid-template-rows: auto 1fr;
}

.modal-toolbar {
  color: white;
  padding: 0;
  pointer-events: none;
  position: relative;
}

.modal-toolbar .overlay-top-left {
  left: 12px;
  position: fixed;
  top: 12px;
  z-index: 60;
}

.modal-toolbar .overlay-arrow {
  position: fixed;
  z-index: 60;
}

.modal-toolbar .overlay-prev {
  left: 12px;
}

.modal-toolbar .overlay-next {
  right: 12px;
}

.modal-toolbar .overlay-depth-prev,
.modal-toolbar .overlay-depth-next {
  transform: none;
}

.modal-toolbar .overlay-depth-left {
  left: 12px;
  right: auto;
}

.modal-toolbar .overlay-depth-right {
  left: auto;
  right: 12px;
}

.modal-toolbar .overlay-depth-prev {
  top: calc(50% - 100px);
}

.modal-toolbar .overlay-depth-next {
  top: calc(50% + 54px);
}

.modal-toolbar strong,
#modalReset {
  display: none;
}

.modal-toolbar #modalClose {
  min-height: 42px;
  min-width: 42px;
  position: fixed;
  right: 12px;
  top: 12px;
  z-index: 61;
}


@media (max-width: 1100px) {
  .viewer-grid {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .tool-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-column: 1 / -1;
    max-height: 240px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .well-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .viewer-grid {
    display: block;
  }

  .app-shell.depth-collapsed .viewer-grid,
  .app-shell.tools-collapsed .viewer-grid,
  .app-shell.depth-collapsed.tools-collapsed .viewer-grid,
  .app-shell.focus-mode .viewer-grid {
    display: block;
  }

  .depth-panel,
  .tool-panel,
  .photo-panel {
    border: 0;
    max-height: none;
  }

  .depth-panel {
    overflow: visible;
  }

  .depth-panel > .panel-heading {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    margin: -12px -12px 10px;
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .app-shell.depth-collapsed .depth-panel {
    overflow: visible;
  }

  .app-shell.depth-collapsed .depth-panel .depth-list,
  .app-shell.depth-collapsed .depth-panel .depth-rail-list {
    display: none;
  }

  .app-shell.depth-collapsed .depth-panel > .panel-heading {
    margin: -8px -8px 0;
    padding: 8px;
  }

  .app-shell.depth-collapsed #toggleDepthPanel,
  .app-shell.tools-collapsed #toggleToolsPanel {
    min-height: 34px;
    padding: 7px 10px;
    writing-mode: horizontal-tb;
  }

  .photo-panel {
    min-height: 70vh;
  }

  .well-summary {
    grid-template-columns: 1fr;
  }

  .well-summary dl {
    justify-content: flex-start;
  }

  .active-meta {
    grid-template-columns: 1fr;
  }

  .canvas-stage {
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 8px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 8px;
  }

  .brand-block .eyebrow {
    display: none;
  }

  .brand-block h1 {
    font-size: 14px;
  }

  .title-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 1px;
  }

  .status-message {
    font-size: 11px;
    max-width: 100%;
  }

  .nav-actions {
    flex-wrap: nowrap;
    gap: 5px;
  }

  .home-button,
  .focus-button,
  .nav-actions button,
  .nav-actions a {
    height: 40px;
    justify-content: center;
    min-height: 40px;
    padding: 0;
    width: 40px;
  }

  .action-icon {
    display: block;
  }

  .button-label {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }
}

@media (max-width: 390px) {
  .brand-block h1 {
    font-size: 12px;
    line-height: 1.15;
  }

  .home-button,
  .focus-button,
  .nav-actions button,
  .nav-actions a {
    height: 38px;
    min-height: 38px;
    width: 38px;
  }
}
