@import url('https://fonts.googleapis.com/css2?family=PT+Serif:wght@400;600;700&display=swap');

:root {
  --navy: #324C63;
  --cream: #F0E8D8;
  --cream-dark: #E8DDC7;
  --text: #28343D;
  --muted: #66717A;
  --border: #D9D5CC;
  --grid: #C8BBA5;
  --white: #FFFFFF;
  --danger: #9B2C2C;
  font-family: "PT Serif", Georgia, serif;
  color: var(--text);
  background: var(--white);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }
body { background: var(--white); }
button, input, select { font: inherit; }
button, input, select { min-height: 36px; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  color: var(--cream);
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,0.14);
}

.app-header h1 {
  margin: 0 0 5px;
  font-size: clamp(1.55rem, 2.3vw, 2.25rem);
  line-height: 1.1;
  color: var(--cream);
}

.app-header p {
  margin: 0;
  max-width: 860px;
  color: rgba(240,232,216,0.88);
  font-size: 0.98rem;
  line-height: 1.45;
}

.header-link {
  flex: 0 0 auto;
  color: var(--cream);
  text-decoration: none;
  border: 1px solid rgba(240,232,216,0.65);
  border-radius: 6px;
  padding: 9px 12px;
  font-weight: 700;
}
.header-link:hover { background: rgba(255,255,255,0.08); }

.sim-layout {
  display: flex;
  width: 100%;
  align-items: flex-start;
  min-height: calc(100vh - 94px);
  padding: 18px 18px 32px;
  background: var(--white);
}

.sidebar-pane {
  flex: 0 0 330px;
  width: 330px;
  min-width: 255px;
  max-width: 650px;
  align-self: flex-start;
  background: var(--navy);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 16px 17px 18px;
  overflow-x: hidden;
  color: var(--white);
  box-shadow: 0 3px 12px rgba(30, 45, 58, 0.10);
}

.sidebar-pane h2,
.sidebar-pane strong,
.sidebar-pane .field-label,
.sidebar-pane .graph-details summary,
.sidebar-pane .section-title,
.sidebar-pane .study-type {
  color: var(--white);
}

.sidebar-section {
  padding: 3px 0 12px;
  margin-bottom: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.20);
}

.sidebar-section h2 {
  margin: 4px 0 9px;
  font-size: 1.2rem;
  line-height: 1.18;
  font-weight: 700;
}

.study-type {
  margin: 0 0 13px;
  font-size: 0.91rem;
  line-height: 1.25;
  font-weight: 700;
}

.run-button {
  width: 100%;
  min-height: 46px;
  margin: 0 0 16px;
  padding: 9px 12px;
  border: 1px solid var(--cream-dark);
  border-radius: 9px;
  background: var(--cream-dark);
  color: #111;
  font-size: 0.98rem;
  line-height: 1.15;
  font-weight: 700;
  cursor: pointer;
}
.run-button:hover:not(:disabled) { filter: brightness(0.98); }
.run-button:disabled { opacity: 0.72; cursor: wait; }

.progress-wrap {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--white);
}
.progress-track {
  height: 7px;
  margin-bottom: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.20);
  overflow: hidden;
}
.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--cream-dark);
  transition: width 0.12s linear;
}

.validation-message {
  padding: 9px 10px;
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 5px;
  background: rgba(155,44,44,0.30);
  color: #fff;
  font-size: 0.88rem;
  line-height: 1.35;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(112px, 44%) minmax(0, 56%);
  column-gap: 12px;
  align-items: center;
  margin-bottom: 9px;
}
.field-row.align-start { align-items: start; }
.field-label {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
  text-align: left;
}
.field-control { min-width: 0; }

.sidebar-pane input[type='text'],
.sidebar-pane input[type='number'],
.sidebar-pane select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 6px 9px;
  border: 1px solid #c7cdd2;
  border-radius: 6px;
  color: #222;
  background: #fff;
  font-size: 0.90rem;
  line-height: 1.2;
}
.sidebar-pane input::placeholder { color: #777; }
.sidebar-pane input:focus,
.sidebar-pane select:focus,
.sidebar-pane button:focus-visible,
.header-link:focus-visible {
  outline: 2px solid var(--cream-dark);
  outline-offset: 2px;
}

.checkbox-control { display: flex; align-items: center; }
.checkbox-control input,
.cutoff-grid input,
.radio-stack input {
  min-height: auto;
  width: 17px;
  height: 17px;
}

.range-control {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 8px;
  align-items: center;
}
.range-control input[type='range'] { width: 100%; min-width: 0; }
.range-control output {
  min-width: 43px;
  text-align: right;
  color: var(--white);
  font-weight: 700;
  font-size: 0.80rem;
}

.alpha-control {
  grid-template-rows: auto 22px;
}
.alpha-control input { grid-column: 1; grid-row: 1; }
.alpha-control output { grid-column: 2; grid-row: 1; }
.alpha-ticks {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  height: 20px;
  margin: -2px 3px 0;
  font-size: 0.56rem;
  line-height: 1;
  color: rgba(255,255,255,0.88);
}
.alpha-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}
.alpha-tick::before {
  content: '';
  display: block;
  width: 1px;
  height: 5px;
  margin: 0 auto 1px;
  background: rgba(255,255,255,0.75);
}
.alpha-tick.first { transform: none; text-align: left; }
.alpha-tick.last { transform: translateX(-100%); text-align: right; }

.section-box {
  padding: 10px;
  margin: 8px 0 11px;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
}
.section-title {
  margin-bottom: 8px;
  font-size: 0.84rem;
  font-weight: 700;
}
.cutoff-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
}
.cutoff-grid label,
.radio-stack label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--white);
  font-size: 0.79rem;
}
.radio-stack { display: grid; gap: 6px; }

.graph-details { margin: 3px 0 2px; }
.graph-details summary {
  cursor: pointer;
  font-size: 0.94rem;
  line-height: 1.2;
  font-weight: 700;
  padding: 3px 0 7px;
  user-select: none;
  list-style: none;
}
.graph-details summary::-webkit-details-marker { display: none; }
.graph-details summary::before {
  content: '▶';
  display: inline-block;
  width: 18px;
  margin-right: 4px;
  font-size: 12px;
}
.graph-details[open] summary::before { content: '▼'; }

.resize-handle {
  flex: 0 0 12px;
  cursor: col-resize;
  position: relative;
  align-self: stretch;
  background: transparent;
}
.resize-handle::after {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 5px;
  width: 2px;
  border-radius: 2px;
  background: rgba(50,76,99,0.20);
}
.resize-handle:hover::after,
body.resizing .resize-handle::after {
  width: 3px;
  left: 3.5px;
  background: #9aa3ad;
}
body.resizing { cursor: col-resize !important; user-select: none; }

.main-pane {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 0 36px 8px;
  background: var(--white);
}

.panel-card {
  background: var(--cream);
  border: 1px solid #e3e0d8;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.empty-state {
  padding: 42px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}
.plot-card { overflow: hidden; }
.plot-title-row h2 {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 1.32rem;
}

.facet-grid {
  display: grid;
  gap: 14px;
  align-items: start;
}
.facet-grid.flex-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.facet-cell {
  min-width: 0;
  border: 1px solid rgba(50,76,99,0.20);
  border-radius: 7px;
  overflow: hidden;
  background: var(--cream);
}
.facet-strip {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(50,76,99,0.18);
  background: rgba(255,255,255,0.42);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
}
.facet-strip .scenario-label {
  color: var(--muted);
  font-weight: 600;
  text-align: right;
}
.histogram-svg {
  display: block;
  width: 100%;
  height: auto;
  background: var(--cream);
}
.plot-global-x-label {
  margin-top: 4px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
}

@media (max-width: 960px) {
  .facet-grid.flex-layout { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .app-header { align-items: flex-start; padding: 17px 18px; }
  .app-header { flex-direction: column; }
  .sim-layout {
    display: block;
    min-height: 0;
    padding: 14px;
  }
  .sidebar-pane {
    width: 100% !important;
    max-width: none;
    min-width: 0;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
  }
  .resize-handle { display: none; }
  .main-pane { padding: 14px 0 0; }
}

@media (max-width: 430px) {
  .field-row { grid-template-columns: 1fr; row-gap: 5px; }
  .range-control { grid-template-columns: minmax(0,1fr) auto; }
  .cutoff-grid { grid-template-columns: repeat(4, auto); justify-content: start; }
}


/* Compact sidebar rhythm to match the Real Depth Simulator controls. */
.sidebar-pane > .sidebar-section:first-of-type { padding-top: 1px; }
.sidebar-pane .field-row:last-child { margin-bottom: 0; }
.sidebar-pane .range-row { margin-top: 2px; margin-bottom: 11px; }
.sidebar-pane input[type='range'] { min-height: 30px; }
.sidebar-pane hr { border: 0; border-top: 1px solid rgba(255,255,255,0.20); }
