:root {
  --brand-color: #5EADFF;
  --ddrkest-color: #18181b;
  --dark-color: #3a3a42;
  --mid-color: #a1a1aa;
  --light-color: #d2d2df;
  --lightest-color: #f8f8f8;
}

* {
  box-sizing: border-box;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;
}
body {
  background: #0d0d0d;
  color: #e8e8e8;
  padding: 1rem;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}
.app-container {
  max-width: 1450px;
  width: 100%;
}
h1 {
  text-align: center;
  font-size: 2.4rem;
  font-weight: 600;
  margin: 0.5rem 0 0.3rem 0;
  background: var(--brand-color);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}
.subtitle {
  text-align: center;
  color: var(--mid-color);
  font-size: 1.25rem;
  /* margin-top: -0.3rem; */
  margin-bottom: 1.8rem;
}
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}
@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .app-container {
    max-width: 100%;
  }
  .panel-card {
    padding: 0.8rem 1rem !important;
  }
  .head-map {
    padding: 0.8rem !important;
  }
  .cylinder-grid {
    max-width: 100% !important;
    gap: 1rem !important;
  }
  .valve-btn {
    padding: 0.4rem 0.2rem !important;
    min-height: 56px !important;
    font-size: 0.65rem !important;
  }
  .valve-btn .valve-data {
    font-size: 1rem !important;
  }
  h1 {
    font-size: 1.8rem;
  }
  .subtitle {
    font-size: 0.9rem;
  }
  .input-row {
    grid-template-columns: 1fr !important;
    gap: 0.3rem !important;
  }
  .instructions-grid {
    grid-template-columns: 1fr !important;
  }
  .instruction-image-placeholder {
    min-height: 120px !important;
  }
}
@media (max-width: 480px) {
  body {
    padding: 0.3rem;
  }
  .panel-card {
    padding: 0.6rem 0.7rem !important;
  }
  .head-map {
    padding: 0.6rem !important;
  }
  .valve-btn {
    padding: 0.3rem 0.1rem !important;
    min-height: 50px !important;
    font-size: 0.6rem !important;
  }
  .valve-btn .valve-name {
    font-size: .75rem !important;
  }
  .inventory-item {
    padding: 0.2rem 0.1rem !important;
    font-size: 0.6rem !important;
  }
  .summary-grid {
    gap: 0.3rem !important;
  }
  .summary-item {
    padding: 0.2rem 0.3rem !important;
  }
  .instructions-content {
    padding: 0.6rem !important;
  }
  .instruction-step {
    padding: 0.5rem !important;
  }
}

/* ----- How-To Guide / Instructions ----- */
.instructions-container {
  background: #1a1a1a;
  border-radius: 20px;
  border: 1px solid #2c2c2c;
  margin-bottom: 1.2rem;
}
.instructions-header {
  padding: 1rem 1.5rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: 0.2s;
  border-radius: 20px;
}
.instructions-header:hover {
  background: #222;
}
.instructions-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--mid-color);
  letter-spacing: 0.5px;
}
.instructions-header .toggle-icon {
  font-size: 1.2rem;
  transition: transform 0.3s ease;
  color: #666;
}
.instructions-header .toggle-icon.open {
  transform: rotate(180deg);
}
.instructions-content {
  padding: 0 1.5rem 1.5rem 1.5rem;
  display: none;
  border-top: 1px solid #2a2a2a;
}
.instructions-content.open {
  display: block;
}
.instructions-content .intro-text {
  color: var(--light-color);
  font-size: 1rem;
  margin-bottom: 1.2rem;
  line-height: 1.6;
}
.instructions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}
.instruction-step {
  background: #141414;
  border-radius: 14px;
  padding: 0.8rem 1rem;
  border: 1px solid #2a2a2a;
}
.instruction-step .step-number {
  display: inline-block;
  background: #2a4a6a;
  color: #8ab8ff;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.1rem 0.6rem;
  border-radius: 20px;
  margin-bottom: 0.4rem;
}
.instruction-step h4 {
  margin: 0 0 0.3rem 0;
  font-size: 1.25rem;
  color: var(--light-color);
}
.instruction-step p,
.instruction-step li {
  font-size: 1rem;
  color: var(--light-color);
  line-height: 1.5;
  margin: 0.2rem 0;
}
.instruction-step ul {
  margin: 0.3rem 0;
  padding-left: 1.2rem;
}
.instruction-step ul li {
  list-style-type: disc;
}
.spec-box {
  background: #1a2a1a;
  border: 1px solid #2a4a2a;
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  margin-top: 0.4rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.spec-box span {
  font-size: 1rem;
  color: #7ddf7d;
}
.spec-box .spec-label {
  color: var(--light-color);
  font-weight: 400;
}
.spec-box .spec-value {
  color: #4cd964;
  font-weight: 600;
}

/* ----- Instruction Image Placeholders ----- */
.instruction-image-placeholder {
  background: #1a1a2a;
  border: 2px dashed #3a4a6a;
  border-radius: 12px;
  padding: 0.8rem;
  text-align: center;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #5a7a9a;
  font-size: 0.8rem;
  gap: 0.4rem;
  transition: 0.2s;
  margin-top: 0.6rem;
}
.instruction-image-placeholder .placeholder-icon {
  font-size: 2.5rem;
  opacity: 0.5;
}
.instruction-image-placeholder .placeholder-text {
  font-size: 0.7rem;
  color: #4a6a8a;
}
.instruction-image-placeholder .placeholder-hint {
  font-size: 0.6rem;
  color: #3a4a5a;
  font-style: italic;
}
.instruction-image-placeholder img {
  max-width: 100%;
  border-radius: 8px;
}

/* ----- Cylinder Head Map ----- */
.head-map {
  background: #1a1a1a;
  border-radius: 20px;
  padding: 1.8rem;
  border: 1px solid #2c2c2c;
}
.head-map h2 {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 500;
  color: var(light-color);
  margin-top: 0;
  margin-bottom: 1.2rem;
}
.cylinder-grid {
  display: grid;
  grid-template-columns: 1fr;/* 1fr;*/
  gap: 1.2rem;
  margin: 0 auto;
}
.cylinder {
  background: #141414;
  border: 2px solid #2a2a2a;
  border-radius: 16px;
  padding: 0.5rem;
  transition: all 0.3s ease;
}
.cylinder.complete {
  border-color: #4cd964;
  box-shadow: 0 0 20px rgba(76, 217, 100, 0.1);
}
.cylinder.partial {
  border-color: #4a8fd8;
  box-shadow: 0 0 15px rgba(74, 143, 216, 0.08);
}
.cylinder-label {
  text-align: center;
  font-size: .9rem;
  font-weight: 700;
  color: #888;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}
.cylinder-status {
  text-align: center;
  font-size: 0.6rem;
  color: #555;
  margin-top: 0.3rem;
  letter-spacing: 0.5px;
}
.valve-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.valve-btn {
  background: #1f1f1f;
  border: 2px solid #333;
  border-radius: 12px;
  padding: 0.8rem 0.4rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  color: #aaa;
  font-size: 0.8rem;
  font-weight: 500;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}
.valve-btn:hover {
  background: #2a2a2a;
  border-color: #4a6a8a;
  transform: scale(1.03);
}
.valve-btn .valve-name {
  font-size: 1rem;
  text-transform: uppercase;
  opacity: 0.8;
  font-weight: 700;
}
.valve-btn .valve-data {
  font-size: 1rem;
  line-height: 1.4;
}
.valve-btn .status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.valve-btn .status-dot.empty {
  background: #444;
}
.valve-btn .status-dot.measured {
  background: #4a8fd8;
}
.valve-btn .status-dot.corrected {
  background: #4cd964;
}
.valve-btn .status-dot.error {
  background: #ff6b6b;
}
.valve-btn.intake-valve {
  border-color: #2a4a6a;
}
.valve-btn.intake-valve:hover {
  border-color: #4a8fd8;
}
.valve-btn.exhaust-valve {
  border-color: #6a3a2a;
}
.valve-btn.exhaust-valve:hover {
  border-color: #d87a4a;
}
.valve-btn.active {
  border-color: #ffd93d !important;
  background: #2a2a1a;
  box-shadow: 0 0 25px rgba(255, 217, 61, 0.15);
}

/* Colored text for valve data */
.valve-btn .clearance-value {
  color: #4a8fd8;
  font-weight: 600;
}
.valve-btn .current-shim-value {
  color: #999;
  font-weight: 400;
  font-size: 1rem;
}
.valve-btn .required-shim-value {
  color: #4cd964;
  font-weight: 700;
  font-size: 0.75rem;
}
.valve-btn .status-text {
  font-size: 1rem;
}

.legend {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  font-size: 1rem;
  color: var(--light-color);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.legend-dot.empty {
  background: #444;
}
.legend-dot.measured {
  background: #4a8fd8;
}
.legend-dot.corrected {
  background: #4cd964;
}
.legend-dot.error {
  background: #ff6b6b;
}

/* ----- Side Panel ----- */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.panel-card {
  background: #1a1a1a;
  border-radius: 20px;
  padding: 1.5rem 2rem;
  border: 1px solid #2c2c2c;
}
.panel-card h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--light-color);
  margin-top: 0;
  margin-bottom: 1rem;
  letter-spacing: 0.5px;
}
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
}
.input-group label {
  font-size: 0.85rem;
  color: var(--light-color);
  font-weight: 500;
}
.input-group input {
  background: #252525;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  color: white;
  font-size: 1.1rem;
  width: 100%;
  transition: 0.15s;
}
.input-group input:focus {
  outline: none;
  border-color: #4a8fd8;
  box-shadow: 0 0 0 2px #1a3a5a;
}
.input-group input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.btn-primary {
  background: #2d6eb0;
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  font-size: 1rem;
  width: 100%;
}
.btn-primary:hover {
  background: #3a7fc9;
  transform: scale(1.01);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.btn-secondary {
  background: #2a2a2a;
  color: #ccc;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 0.6rem 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: 0.15s;
  font-size: 0.9rem;
}
.btn-secondary:hover {
  background: #3a3a3a;
}
.btn-success {
  background: #2d7a3a;
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.7rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  font-size: 0.95rem;
}
.btn-success:hover {
  background: #3a9a4a;
  transform: scale(1.01);
}
.btn-danger {
  background: #7a2a2a;
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.7rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  font-size: 0.95rem;
}
.btn-danger:hover {
  background: #9a3a3a;
}
.btn-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.btn-row .btn-primary,
.btn-row .btn-secondary,
.btn-row .btn-success,
.btn-row .btn-danger {
  flex: 1;
  min-width: 100px;
}

/* ----- Shim Inventory ----- */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
  padding: 0.3rem 0.3rem 0.3rem 0.3rem;
}
.inventory-item {
  background: #252525;
  border: 2px solid #3a3a3a;
  border-radius: 10px;
  padding: 0.5rem 0.2rem;
  text-align: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: 0.1s;
  position: relative;
}
.inventory-item:hover {
  background: #303030;
  border-color: #555;
  transform: scale(1.02);
}
.inventory-item .thick {
  font-weight: 700;
  color: #ddd;
  font-size: 1rem;
}
.inventory-item .num {
  color: #8ab8ff;
  font-size: 1rem;
}
.inventory-item .delete-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff6b6b;
  color: #fff;
  font-size: 0.6rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
  z-index: 2;
  transition: 0.15s;
  line-height: 1;
  padding: 0;
}
.inventory-item .delete-btn:hover {
  background: #ff4444;
  transform: scale(1.15);
}
.inventory-item.used {
  border-color: #6a4a4a;
}
.inventory-item.auto-added {
  border-color: #2a5a3a;
}
.inventory-item.auto-added::after {
  content: "📦";
  position: absolute;
  top: -8px;
  left: -8px;
  font-size: 0.6rem;
  z-index: 2;
}
.inventory-item .location-tag {
  font-size: 0.75rem;
  color: #ffa94d;
  display: block;
  margin-top: 0.15rem;
  font-weight: 600;
  line-height: 1.2;
}
.inventory-item .shim-id {
  font-size: 0.75rem;
  color: #555;
  display: block;
  margin-top: 0.05rem;
}
.add-inventory-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}
.add-inventory-row input {
  flex: 1;
  background: #252525;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  color: white;
  font-size: 0.9rem;
  min-width: 60px;
}
.add-inventory-row input:focus {
  outline: none;
  border-color: #4a8fd8;
}
.add-inventory-row button {
  background: #2a4a6a;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: 0.15s;
}
.add-inventory-row button:hover {
  background: #3a6a8a;
}

/* ----- Results Summary ----- */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0.6rem;
  font-size: 0.85rem;
}
.summary-item {
  background: #141414;
  border-radius: 10px;
  padding: 0.5rem 0.4rem;
  text-align: center;
  border: 1px solid #2a2a2a;
}
.summary-item .label {
  color: #777;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.summary-item .value {
  font-weight: 700;
  font-size: 1.1rem;
  margin-top: 0.1rem;
}
.summary-item .value.green {
  color: #4cd964;
}
.summary-item .value.blue {
  color: #4a8fd8;
}
.summary-item .value.orange {
  color: #ffa94d;
}
.summary-item .value.red {
  color: #ff6b6b;
}

/* ----- Status messages ----- */
.status-msg {
  padding: 0.7rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  text-align: center;
  border: 1px solid #2a2a2a;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #141414;
  margin-top: 0.6rem;
  overflow: visible;
}
.status-msg.info {
  border-color: #2a4a6a;
  color: #8ab8ff;
}
.status-msg.success {
  border-color: #2a6a3a;
  color: #7ddf7d;
}
.status-msg.error {
  border-color: #6a2a2a;
  color: #ff6b6b;
}
.status-msg.warning {
  border-color: #6a5a2a;
  color: #ffd93d;
}
.status-msg > div {
  max-height: none !important;
  overflow: visible !important;
}

/* misc */
.formula-hint {
  background: #141414;
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font-size: 0.8rem;
  color: var(--mid-color);
  border: 1px solid #2a2a2a;
  margin-block: 0.5rem;
  font-family: monospace;
  font-size: 0.85rem;
}
.empty-inventory-msg {
  color: #555;
  text-align: center;
  font-size: 0.85rem;
  padding: 0.8rem;
  grid-column: 1 / -1;
}
.auto-add-hint {
  background: #1a2a1a;
  border: 1px solid #2a4a2a;
  border-radius: 10px;
  padding: 0.4rem 0.8rem;
  font-size: .9rem;
  color: #6a8a6a;
  text-align: center;
  margin-top: 0.4rem;
}
.badge {
  background: #2a2a2a;
  padding: 0.1rem 0.6rem;
  border-radius: 12px;
  font-size: 0.7rem;
  color: #aaa;
}
.selected-valve-display {
  font-size: 1rem;
  color: #aaa;
  min-height: 2.5rem;
  margin-bottom: 0.5rem;
}
.selected-valve-display strong {
  color: #fff;
  font-size: 1.2rem;
}
.valve-result {
  margin-top: 0.6rem;
  font-size: 0.95rem;
  color: #aaa;
  min-height: 1.8rem;
  font-weight: 500;
}
.cylinder-status-text {
  font-size: 0.75rem;
  text-align: center;
  margin-top: 0.2rem;
  color: #555;
}
.cylinder-status-text.done {
  color: #4cd964;
}
.cylinder-status-text.partial {
  color: #4a8fd8;
}
.inline-flex {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.mt-1 {
  margin-top: 0.6rem;
}
.mb-1 {
  margin-bottom: 0.6rem;
}
.gap-1 {
  gap: 0.6rem;
}
.flex-wrap {
  flex-wrap: wrap;
}
.text-muted {
  color: #666;
  font-size: 0.75rem;
}
footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: #666;
}
.suggest-edit {
  color: #4a8fd8;
  text-decoration: none;
}
.suggest-edit:hover {
  text-decoration: underline;
}