@font-face {
  font-family: "Gothic UI";
  src: local("DIN Condensed"), local("DINCondensed-Bold"), local("Arial Narrow");
  font-weight: 400 800;
  font-style: normal;
}

:root {
  color-scheme: dark;
  --bg: #0d0f11;
  --panel: #15181b;
  --panel-2: #1b1f23;
  --line: #30363b;
  --line-strong: #454d53;
  --text: #f2f0e9;
  --muted: #9ca3a8;
  --amber: #e6ad45;
  --amber-dark: #5b431c;
  --cyan: #58b9c1;
  --red: #db7068;
  --green: #70bf8c;
  font-family: Georgia, "Palatino Linotype", Palatino, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: url("assets/gothic-lock-workshop.png");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  isolation: isolate;
}

body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: rgba(5, 6, 7, .7); }

button, input { font: inherit; }
button { color: inherit; }

.app-header {
  min-height: 112px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid #6c4e25;
  background: rgba(7, 8, 9, .82);
  position: sticky;
  top: 0;
  z-index: 10;
  isolation: isolate;
}

.app-header::before { content: ""; position: absolute; inset: 0; z-index: -1; background: rgba(5, 6, 7, .24); }

.app-header .icon-button { margin-left: auto; }

.logo-lockup { width: 184px; display: grid; justify-items: center; gap: 8px; }
.logo-lockup img { display: block; width: 178px; height: auto; object-fit: contain; }
.logo-lockup span { color: #e9ded0; font-family: Georgia, "Palatino Linotype", serif; font-size: 16px; line-height: 1; text-transform: uppercase; text-shadow: 0 2px 2px #000; }

.brand-mark {
  width: 38px;
  height: 38px;
  border: 2px solid var(--amber);
  border-radius: 5px;
  position: relative;
  display: grid;
  place-items: center;
  background: #181713;
}

.brand-mark::before {
  content: "";
  width: 19px;
  height: 15px;
  border: 3px solid var(--amber);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  position: absolute;
  top: -11px;
}

.brand-mark span { width: 5px; height: 13px; background: var(--amber); border-radius: 3px; }

main { width: min(1180px, calc(100% - 40px)); margin: 28px auto 64px; }

.workspace, .results {
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(21, 24, 27, .96);
  margin-bottom: 18px;
}

.section-heading, .results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.section-heading > div:first-child, .results-header > div:first-child { display: flex; align-items: center; gap: 12px; }
h2, h3 { margin: 0; letter-spacing: 0; }
h2 { font-size: 25px; font-weight: 700; text-transform: uppercase; color: #f1ded0; }
h3 { font-size: 15px; }
.step-label { color: var(--amber); font: 700 12px/1 "Gothic UI", "Arial Narrow", sans-serif; }
.depth-key { color: #c4b8af; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.depth-key b { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid #665238; color: var(--amber); }
.depth-key i { display: block; width: 34px; height: 1px; background: #665238; }

.lock-position-panel {
  position: relative;
  overflow: hidden;
  border-color: #4a4032;
  background-color: rgba(18, 19, 19, .97);
}

.lock-position-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(230,173,69,.1);
}

.fixed-specs { display: flex; gap: 10px; margin: -6px 0 18px; }
.config-control { min-width: 220px; display: grid; grid-template-columns: 1fr 112px; align-items: center; gap: 12px; min-height: 48px; padding: 6px 8px 6px 12px; border: 1px solid #4a4032; background: #111314; color: #cfc4bb; font-size: 15px; }
.config-stepper { height: 34px; display: grid; grid-template-columns: 34px 44px 34px; border: 1px solid #4b4f50; background: #090a0b; }
.config-stepper button, .config-stepper output { display: grid; place-items: center; border: 0; background: transparent; }
.config-stepper button { cursor: pointer; color: #d8ccc3; font-size: 21px; }
.config-stepper button:hover { background: #2a2218; color: var(--amber); }
.config-stepper output { color: var(--amber); font-size: 18px; font-weight: 700; }

.lock-diagram {
  overflow-x: auto;
  padding: 4px 4px 10px;
  scrollbar-color: #665238 #17191a;
}

.position-scale, .lock-row {
  min-width: 600px;
  display: grid;
  grid-template-columns: 108px minmax(390px, 1fr) 56px;
  align-items: center;
  gap: 14px;
}

.position-scale { margin-bottom: 7px; color: #aaa19b; font: 14px Georgia, "Palatino Linotype", serif; }
.position-scale > div { display: grid; grid-template-columns: repeat(var(--positions, 7), 1fr); text-align: center; }
.position-scale b { font-weight: 500; }
.position-scale .target { color: var(--amber); }
.position-scale > span:last-child { text-align: center; }

.lock-row {
  min-height: 58px;
  margin-bottom: 6px;
  padding: 5px 10px 5px 6px;
  border: 1px solid #3f4344;
  border-left-color: #716044;
  background: #1a1c1d;
  box-shadow: inset 0 1px rgba(255,255,255,.035), inset 0 -8px rgba(0,0,0,.13);
}

.plate-label { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; }
.plate-label b { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #665238; background: #111314; color: var(--amber); font: 700 16px Georgia, "Palatino Linotype", serif; }
.plate-label span { color: #d0c5bd; font-size: 14px; }

.hole-track { display: grid; grid-template-columns: repeat(var(--positions, 7), 1fr); align-items: center; min-height: 38px; border: 1px solid #0b0c0d; background: #111314; box-shadow: inset 0 2px 7px #050606; }
.lock-hole { width: 28px; height: 28px; margin: 0 auto; padding: 0; border: 0; border-radius: 50%; background: #070809; cursor: pointer; position: relative; box-shadow: inset 0 2px 4px #000, 0 0 0 1px #363a3a; }
.lock-hole::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #16191a; }
.lock-hole:hover { box-shadow: inset 0 2px 4px #000, 0 0 0 2px #8f6b35; }
.lock-hole.target-hole { box-shadow: inset 0 2px 4px #000, 0 0 0 1px #716044, 0 0 0 3px rgba(230,173,69,.08); }
.lock-hole.target-hole::before { content: ""; position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--amber); top: 2px; left: 12px; }
.lock-hole.selected { background: #8c6b39; box-shadow: inset 0 1px rgba(255,255,255,.35), inset 0 -4px rgba(43,25,9,.42), 0 0 0 2px #d29a44, 0 3px 8px #000; }
.lock-hole.selected::after { inset: 8px; background: #d9b26f; box-shadow: 0 0 6px rgba(230,173,69,.55); }
.lock-row output { color: var(--amber); text-align: center; font: 700 19px Georgia, "Palatino Linotype", serif; }

.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 8px; color: var(--muted); font-size: 12px; }

.stepper {
  height: 42px;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 5px;
  overflow: hidden;
}

.stepper button, .stepper input { border: 0; background: transparent; color: var(--text); text-align: center; }
.stepper button { cursor: pointer; color: var(--muted); font-size: 20px; }
.stepper button:hover { background: #252a2e; color: var(--amber); }
.stepper input { width: 100%; min-width: 0; font-weight: 700; appearance: textfield; }
.stepper input::-webkit-inner-spin-button { appearance: none; }

.risk-fieldset { border: 0; padding: 0; margin: 22px 0 0; }
.risk-fieldset legend { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.segmented-control { display: inline-flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.segmented-control label { cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: block; padding: 10px 14px; color: var(--muted); font-size: 13px; border-right: 1px solid var(--line); }
.segmented-control label:last-child span { border-right: 0; }
.segmented-control input:checked + span { background: var(--amber-dark); color: #ffd98d; }

.subsection { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.subsection-title { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; margin-bottom: 18px; }
.subsection-title span, .section-note { color: var(--muted); font-size: 12px; }
.section-note { margin: -12px 0 18px; }

.pins-grid { display: grid; grid-template-columns: repeat(var(--pin-cols, 5), minmax(92px, 1fr)); gap: 10px; }
.pin-control {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
}
.pin-number { display: grid; place-items: center; width: 26px; min-height: 26px; border: 1px solid var(--line-strong); color: var(--muted); font-size: 12px; }
.pin-number b { font-weight: 600; }
.pin-number small { display: none; }
.pin-control output { color: var(--amber); font-weight: 800; text-align: center; }
input[type="range"] { width: 100%; accent-color: var(--amber); min-width: 0; }

.legend { display: flex; gap: 18px; color: #c7bdb6; font-size: 15px; }
.legend span { white-space: nowrap; }
.legend b { display: inline-block; margin-right: 3px; color: var(--muted); }
.legend .left { color: var(--red); }
.legend .right { color: var(--cyan); }

.matrix-wrap { overflow-x: auto; padding-bottom: 4px; }
.influence-matrix { border-collapse: separate; border-spacing: 5px; width: 100%; min-width: 500px; table-layout: fixed; }
.influence-matrix th { color: #c7bdb6; font-size: 14px; font-weight: 600; height: 38px; }
.influence-matrix th small { display: block; margin-top: 4px; color: var(--amber); font-size: 12px; font-weight: 600; }
.influence-matrix th:first-child { width: 126px; text-align: left; }
.influence-matrix .row-title { color: var(--text); text-align: left; font-size: 15px; white-space: nowrap; }
.matrix-cell {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-2);
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
}
.matrix-cell:hover { border-color: var(--line-strong); background: #22272b; }
.matrix-cell[data-value="-1"] { color: var(--red); background: rgba(219,112,104,.09); border-color: rgba(219,112,104,.35); }
.matrix-cell[data-value="1"] { color: var(--cyan); background: rgba(88,185,193,.09); border-color: rgba(88,185,193,.35); }
.matrix-cell.diagonal { color: var(--muted); background: #121518; border-color: #252a2e; cursor: default; box-shadow: inset 0 0 0 1px rgba(230,173,69,.12); }

.solve-bar { display: flex; justify-content: flex-end; align-items: center; gap: 18px; margin: 22px 0; }
.validation-message { color: var(--red); font-size: 13px; flex: 1; }
.primary-button, .text-button, .icon-button { border: 0; cursor: pointer; border-radius: 5px; }
.primary-button { min-height: 46px; padding: 0 22px; background: var(--amber); color: #17130c; font-size: 18px; font-weight: 800; display: inline-flex; align-items: center; gap: 9px; }
.primary-button:hover { background: #f0bd5e; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.text-button { padding: 8px 10px; background: transparent; color: var(--amber); font-size: 15px; }
.text-button:hover { background: rgba(230,173,69,.1); }
.icon-button { width: 38px; height: 38px; background: var(--panel-2); border: 1px solid var(--line); font-size: 20px; }
.icon-button:hover { border-color: var(--amber); color: var(--amber); }

.results { border-color: rgba(112,191,140,.35); }
.results-header { margin-bottom: 18px; }
.summary-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.summary-strip span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; color: #c7bdb6; font-size: 15px; }
.summary-strip strong { color: var(--text); }
.solution-list { list-style: none; padding: 0; margin: 0; counter-reset: solution; display: grid; gap: 7px; }
.solution-list li { counter-increment: solution; display: grid; grid-template-columns: 34px minmax(220px, 1fr) auto; align-items: center; gap: 10px; padding: 11px 12px; background: var(--panel-2); border-left: 2px solid var(--amber); }
.solution-list li::before { content: counter(solution, decimal-leading-zero); color: var(--muted); font: 13px "Gothic UI", "Arial Narrow", sans-serif; }
.solution-list strong { font-size: 17px; }
.solution-list code { color: #bdb4ad; font: 15px Georgia, "Palatino Linotype", serif; white-space: nowrap; }
.direction-left { color: var(--red); }
.direction-right { color: var(--cyan); }

.timeline { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.timeline summary { cursor: pointer; color: #c7bdb6; font-size: 16px; }
#timelineList { margin-top: 12px; display: grid; gap: 4px; }
.timeline-row { display: grid; grid-template-columns: 42px 190px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(48,54,59,.55); color: #c7bdb6; font-size: 15px; }
.timeline-row code { color: var(--text); }

@media (max-width: 760px) {
  .app-header { min-height: 88px; padding-inline: 16px; }
  .logo-lockup { width: 152px; }
  .logo-lockup img { width: 148px; }
  .logo-lockup span { font-size: 14px; }
  main { width: calc(100% - 24px); margin-top: 14px; }
  .workspace, .results { padding: 20px 16px; }
  .settings-grid { grid-template-columns: 1fr; }
  .pins-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading { align-items: flex-start; }
  .lock-position-panel .section-heading { display: block; }
  .depth-key { margin-top: 12px; }
  .fixed-specs { display: grid; grid-template-columns: 1fr; }
  .config-control { min-width: 0; }
  .influence-section .section-heading { display: block; }
  .legend { margin-top: 14px; flex-wrap: wrap; }
  .subsection-title { display: block; }
  .subsection-title span { display: block; margin-top: 6px; }
  .solve-bar { display: grid; }
  .primary-button { width: 100%; justify-content: center; }
  .solution-list li { grid-template-columns: 28px 1fr; }
  .solution-list code { grid-column: 2; overflow-x: auto; }
  .timeline-row { grid-template-columns: 32px 1fr; }
  .timeline-row code { grid-column: 2; overflow-x: auto; }
}

@media (max-width: 410px) {
  .pins-grid { grid-template-columns: 1fr; }
  .segmented-control { display: grid; width: 100%; }
  .segmented-control span { border-right: 0; border-bottom: 1px solid var(--line); text-align: center; }
  .segmented-control label:last-child span { border-bottom: 0; }
  h2 { font-size: 21px; }
}
