/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Segoe UI, Arial, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f0f2f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: #0078d4;
  color: #fff;
  padding: 10px 24px;
  flex-shrink: 0;
}
.header-inner { display: flex; align-items: center; gap: 16px; }
.logo         { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
.header-title { font-size: 14px; opacity: 0.88; }

/* ── Main layout ── */
main {
  display: flex;
  flex: 1;
  gap: 0;
  overflow: hidden;
  height: calc(100vh - 48px - 36px); /* viewport minus header and footer */
}

/* ── Controls panel ── */
.controls-panel {
  width: 280px;
  min-width: 240px;
  background: #fff;
  border-right: 1px solid #dde3ea;
  overflow-y: auto;
  padding: 12px;
  flex-shrink: 0;
}

.card {
  background: #f7f9fc;
  border: 1px solid #dde3ea;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.card h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #0078d4;
  margin-bottom: 10px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #444;
  margin-top: 8px;
  margin-bottom: 3px;
}

select, input[type="number"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #c8d0db;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  color: #1a1a1a;
  appearance: none;
}
select:focus, input[type="number"]:focus {
  outline: none;
  border-color: #0078d4;
  box-shadow: 0 0 0 2px rgba(0,120,212,0.15);
}

.info-row {
  font-size: 11px;
  color: #666;
  margin-top: 6px;
}

.preset-info {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
  height: 14px;
}

.toggle-row {
  margin-top: 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.toggle-row input { width: auto; }

.hidden { display: none !important; }

/* Download card */
.download-card { text-align: center; }

.btn-download {
  width: 100%;
  padding: 9px;
  background: #0078d4;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s;
}
.btn-download:hover { background: #005fa3; }

/* ── Download popup menu ── */
.dl-wrap {
  position: relative;
  margin-bottom: 6px;
}
.dl-wrap:last-child { margin-bottom: 0; }

.dl-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #c8d0db;
  border-radius: 5px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.13);
  z-index: 200;
  overflow: hidden;
}

.dl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
  color: #1a1a1a;
  text-align: left;
}
.dl-item:last-child { border-bottom: none; }
.dl-item:hover:not(.dl-item-soon) { background: #eef3f9; color: #0078d4; }

.dl-item-soon {
  color: #aaa;
  cursor: default;
}

.dl-soon-tag {
  font-size: 10px;
  background: #f3f4f6;
  color: #9ca3af;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  font-weight: 400;
}

/* ── Preview panel ── */
.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid #dde3ea;
  background: #f7f9fc;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  flex-shrink: 0;
}
.preview-header span:last-child { font-weight: 400; color: #666; font-size: 12px; }

.preview-tab {
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #c8d0db;
  border-radius: 4px;
  background: #f0f2f5;
  color: #555;
  cursor: pointer;
}
.preview-tab.active {
  background: #0078d4;
  color: #fff;
  border-color: #0078d4;
}
.preview-tab:hover:not(.active) { background: #e2e8f0; }

.preview-box {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
  background: #fafbfc;
}

.preview-box svg {
  max-width: 100%;
  max-height: 100%;
}

.preview-placeholder {
  color: #bbb;
  font-size: 14px;
}

.preview-footer {
  padding: 6px 16px;
  font-size: 11px;
  color: #888;
  border-top: 1px solid #eee;
  background: #f7f9fc;
  flex-shrink: 0;
  height: 28px;
}

/* ── Footer ── */
footer {
  background: #1a1a2e;
  color: #aaa;
  font-size: 11px;
  text-align: center;
  padding: 8px;
  flex-shrink: 0;
  height: 36px;
}
footer a { color: #6ab3e8; text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Drive bar ── */
.drive-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 6px 16px;
  background: #eef3f9;
  border-bottom: 1px solid #d0dae6;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.drive-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
}
.drive-toggle input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: #0078d4;
}

.drive-spacing {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #444;
}
.drive-spacing label {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: #444;
  white-space: nowrap;
}
.drive-spacing input[type="number"] {
  width: 90px;
  padding: 4px 6px;
  font-size: 12px;
}
#gear_ratio { width: 75px; }

.ratio-arrows {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ratio-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 16px;
  padding: 0;
  font-size: 9px;
  line-height: 1;
  background: #e8edf3;
  border: 1px solid #c8d0db;
  border-radius: 3px;
  cursor: pointer;
  color: #444;
}
.ratio-btn:hover { background: #d0daea; border-color: #0078d4; color: #0078d4; }
.reset-btn {
  margin-left: auto;
  padding: 3px 10px;
  font-size: 12px;
  background: #f1f3f5;
  border: 1px solid #c8d0db;
  border-radius: 4px;
  cursor: pointer;
  color: #555;
  white-space: nowrap;
}
.reset-btn:hover { background: #fee2e2; border-color: #f87171; color: #b91c1c; }
.drive-note {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
}

/* ── Panel title ── */
.panel-title {
  font-size: 13px;
  font-weight: 700;
  color: #0078d4;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 2px 10px;
  border-bottom: 2px solid #0078d4;
  margin-bottom: 10px;
}

/* ── Belt lock info card ── */
.belt-lock-info {
  font-size: 12px;
  color: #333;
  padding: 8px 12px;
  background: #eef3f9;
  border-color: #c2d4e8;
}

/* ── Dual layout: main becomes 3-column ── */
main.dual {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
}
main.dual .controls-panel {
  border-right: 1px solid #dde3ea;
}
main.dual #panel2 {
  border-left: 1px solid #dde3ea;
  border-right: none;
}

/* ── Help button ── */
.help-btn-row {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  padding: 6px 2px 2px;
  background: linear-gradient(to bottom, transparent, #fff 40%);
}

.btn-help {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid #c8d0db;
  background: #f0f4f9;
  color: #0078d4;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.btn-help:hover {
  background: #0078d4;
  border-color: #0078d4;
  color: #fff;
}

/* Help icon in drive bar */
.drive-help {
  display: flex;
  align-items: center;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  main { flex-direction: column; height: auto; }
  main.dual { grid-template-columns: 1fr; }
  .controls-panel { width: 100%; border-right: none; border-bottom: 1px solid #dde3ea; }
  .preview-panel { min-height: 360px; }
  .drive-bar { gap: 10px; }
}
