/* Diving console: the brass is structural; labels stay dark on light surfaces. */
#options-dialog {
  width: min(900px, calc(100% - 24px - var(--safe-left) - var(--safe-right)));
  height: min(720px, calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom)));
  max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
  overflow: hidden;
  padding: 0;
  border: 6px solid #b39350;
  border-radius: 20px;
  color: #172f29;
  background: #f4edcf;
  box-shadow: 0 0 0 3px #243f35, inset 0 0 0 2px #e7cb80, 0 18px 65px #102b2673;
}

#options-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.notebook-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 4px solid #b39350;
  color: #fff8dc;
  background: #29473b;
}

.notebook-porthole {
  display: grid;
  flex: 0 0 66px;
  place-items: center;
  width: 66px;
  height: 66px;
  border: 5px solid #d4b568;
  border-radius: 50%;
  background: #e6d59f;
  box-shadow: inset 0 0 0 3px #526447, 0 0 0 2px #162f28;
}

.notebook-porthole svg {
  width: 46px;
  height: 38px;
  fill: #d6ac59;
  stroke: #253e32;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

#options-dialog .eyebrow {
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.1em;
}

#options-dialog h2 {
  margin: 3px 0 0;
  color: #fff8dc;
  font-size: clamp(23px, 3vw, 32px);
  font-weight: 700;
  line-height: 1.15;
}

.notebook-body {
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
  min-height: 0;
}

.notebook-tabs {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 10px;
  border-right: 4px solid #b39350;
  background: #334f40;
  scrollbar-color: #d4b568 #334f40;
}

#options-dialog .notebook-tab {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  min-height: 64px;
  padding: 10px;
  border: 3px solid #b39350;
  border-radius: 9px;
  color: #172f29;
  background: #f0e6bd;
  box-shadow: 0 3px 0 #152f26;
  font: 700 14px/1.3 Arial, sans-serif;
  text-align: left;
  cursor: pointer;
}

.notebook-tab svg {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#options-dialog .notebook-tab:hover {
  background: #fff6d5;
}

#options-dialog .notebook-tab[aria-selected="true"] {
  border-color: #f2cf79;
  color: #fff8dc;
  background: #173a2e;
  box-shadow: inset 5px 0 0 #f2cf79, 0 3px 0 #152f26;
}

#options-dialog :focus-visible {
  outline: 3px solid #a24e21;
  outline-offset: 3px;
}

#options-dialog .notebook-tab:focus-visible {
  outline-color: #fff8dc;
  outline-offset: 2px;
}

.notebook-pages {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #6d7651 #f4edcf;
  scrollbar-gutter: stable;
}

#options-dialog .notebook-panel {
  min-width: 0;
  margin: 0;
  padding: 24px;
  border: 0;
}

#options-dialog .notebook-panel[hidden] {
  display: none;
}

#options-dialog .notebook-panel:focus-visible {
  outline-offset: -5px;
}

#options-dialog h3 {
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 3px solid #b39350;
  color: #172f29;
  font: 700 24px/1.25 Georgia, serif;
}

#options-dialog label {
  margin: 20px 0 9px;
  font: 700 14px/1.4 Arial, sans-serif;
}

#options-dialog select {
  min-height: 46px;
  padding: 10px;
  border: 2px solid #53684a;
  border-radius: 6px;
  color: #172f29;
  background: #fffbed;
  font: 14px/1.4 Arial, sans-serif;
}

.notebook-submarine-preview {
  margin: 18px 0;
  overflow: hidden;
  border: 5px solid #b39350;
  border-radius: 10px;
  background: #173a36;
  box-shadow: inset 0 0 0 3px #526447, 0 3px 0 #243f35;
}

.notebook-submarine-preview figcaption {
  padding: 9px 14px 0;
  color: #fff8dc;
  font: 700 13px/1.4 Arial, sans-serif;
}

.notebook-submarine-preview canvas {
  display: block;
  width: 100%;
  height: clamp(160px, 28vh, 250px);
}

#options-dialog p,
#options-dialog .option-controls .key-guide {
  color: #293e30;
  font: 14px/1.6 Arial, sans-serif;
  overflow-wrap: anywhere;
}

.notebook-briefing {
  margin: 18px 0;
  padding: 4px 16px;
  border: 2px solid #a4a17b;
  border-left: 5px solid #60764b;
  border-radius: 6px;
  background: #fff9e3;
}

#options-dialog #level-objective {
  font-weight: 700;
}

#options-dialog .notebook-launch,
#options-dialog #close-options {
  min-height: 46px;
  padding: 11px 18px;
  border: 3px solid #b39350;
  border-radius: 8px;
  color: #fff8dc;
  background: #234636;
  font: 700 14px/1.4 Arial, sans-serif;
  cursor: pointer;
}

#options-dialog .notebook-launch {
  display: block;
  width: 100%;
  margin: 22px 0 12px;
}

#options-dialog .notebook-launch:hover,
#options-dialog #close-options:hover {
  background: #365c42;
}

#options-dialog .editor-link {
  border: 2px solid #60764b;
  font: 700 13px/1.5 Arial, sans-serif;
}

#options-dialog .binding-grid {
  padding: 12px;
  border: 2px solid #a4a17b;
}

#options-dialog .binding-grid legend {
  font: 700 14px/1.4 Arial, sans-serif;
}

#options-dialog .binding-field {
  margin: 4px 0;
  font-size: 13px;
}

#options-dialog .binding-field button,
#options-dialog .secondary-control {
  min-height: 44px;
  padding: 8px;
  border-width: 2px;
  font: 13px/1.4 Arial, sans-serif;
}

#options-dialog .photo-archive-list {
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
  max-height: none;
  overflow: visible;
  gap: 14px;
}

#options-dialog .photo-archive-card {
  border: 2px solid #53684a;
  border-radius: 8px;
}

#options-dialog .photo-archive-caption {
  font: 12px/1.5 Arial, sans-serif;
}

.notebook-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 20px;
  border-top: 4px solid #b39350;
  background: #e1d8ae;
}

#options-dialog #save-status {
  margin: 0;
  font: 700 12px/1.5 Arial, sans-serif;
}

@media (max-width: 600px) {
  .notebook-header {
    gap: 12px;
    padding: 14px;
  }

  .notebook-porthole {
    flex-basis: 52px;
    width: 52px;
    height: 52px;
    border-width: 4px;
  }

  .notebook-porthole svg {
    width: 36px;
    height: 30px;
  }

  .notebook-body {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .notebook-tabs {
    gap: 8px;
    padding: 10px 6px;
    border-right-width: 3px;
  }

  #options-dialog .notebook-tab {
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-height: 72px;
    padding: 8px 4px;
    font-size: 12px;
    text-align: center;
  }

  #options-dialog .notebook-panel {
    padding: 16px 12px;
  }

  #options-dialog h3 {
    font-size: 21px;
  }

  .notebook-briefing {
    padding: 2px 10px;
  }

  .notebook-submarine-preview canvas {
    height: clamp(140px, 24vh, 200px);
  }

  .notebook-footer {
    gap: 10px;
    padding: 10px 12px;
  }
}

@media (max-height: 500px) {
  .notebook-header {
    gap: 12px;
    padding: 9px 16px;
  }

  .notebook-porthole {
    display: none;
  }

  #options-dialog h2 {
    font-size: 23px;
  }

  .notebook-footer {
    padding: 7px 14px;
  }

  #options-dialog .notebook-tab {
    min-height: 46px;
  }
}
