:root {
  --bg0: #0b1c24;
  --bg1: #102a35;
  --bg2: #163746;
  --line: rgba(120, 190, 210, 0.18);
  --text: #e7f4f7;
  --muted: #8fb3bf;
  --accent: #2ec4b6;
  --accent-2: #f4a261;
  --danger: #e76f51;
  --card: rgba(16, 42, 53, 0.92);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --font: "Noto Sans SC", "Segoe UI", sans-serif;
  --display: "Oxanium", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(46, 196, 182, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(244, 162, 97, 0.12), transparent 50%),
    linear-gradient(160deg, var(--bg0), #0e2530 45%, #0a1820);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(46, 196, 182, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46, 196, 182, 0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
  pointer-events: none;
  z-index: 0;
}

.topbar, main, .drawer { position: relative; z-index: 1; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  background: rgba(11, 28, 36, 0.72);
  position: sticky;
  top: 0;
}

.brand { display: flex; align-items: center; gap: 0.85rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 700;
  color: #062018;
  background: linear-gradient(135deg, var(--accent), #7ee8d8);
  box-shadow: 0 0 0 1px rgba(46,196,182,.35), 0 8px 24px rgba(46,196,182,.25);
}
.brand-name { font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { font-size: 0.75rem; color: var(--muted); font-family: var(--display); }

.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}
.tab.active, .tab:hover {
  color: var(--text);
  border-color: var(--line);
  background: rgba(46, 196, 182, 0.08);
}

main { padding: 1.25rem 1.5rem 2.5rem; max-width: 1280px; margin: 0 auto; }

.view { display: none; animation: fade .35s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.wizard-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1rem;
}
.wiz-filt[hidden] { display: none !important; }

h1, h2, h3 { margin: 0 0 0.5rem; font-family: var(--display); letter-spacing: 0.02em; }
.muted { color: var(--muted); line-height: 1.6; }
.form-panel label {
  display: grid;
  gap: 0.35rem;
  margin: 0.85rem 0;
  font-size: 0.9rem;
  color: #c5dde4;
}
.form-panel select,
.form-panel input[type="number"],
.form-panel input[type="search"],
.browse-bar input,
.browse-bar select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(7, 22, 28, 0.75);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  outline: none;
}
.form-panel select:focus,
.form-panel input:focus,
.browse-bar input:focus,
.browse-bar select:focus {
  border-color: rgba(46, 196, 182, 0.55);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.12);
}

.check { display: flex !important; align-items: center; gap: 0.55rem; grid-template-columns: none; }
.check.compact { margin: 0; white-space: nowrap; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary {
  width: 100%;
  margin-top: 0.5rem;
  color: #062018;
  background: linear-gradient(135deg, #2ec4b6, #7ee8d8);
  box-shadow: 0 10px 28px rgba(46, 196, 182, 0.28);
}
.btn.primary:hover { filter: brightness(1.05); }

.result-head, .browse-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.browse-bar { margin-bottom: 1rem; }
.browse-bar input { flex: 1; min-width: 220px; }
.browse-bar select { width: auto; min-width: 140px; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 0.82rem;
  background: rgba(46, 196, 182, 0.08);
}

.card-list, .card-grid { display: grid; gap: 0.85rem; }
.card-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.empty-hint {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(22, 55, 70, 0.55), rgba(12, 32, 42, 0.7));
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: rgba(46, 196, 182, 0.45);
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
}
.card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}
.model {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  color: #b8fff4;
}
.score { color: var(--accent-2); font-family: var(--display); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.7rem 0; }
.tag {
  font-size: 0.75rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  color: #cde4eb;
}
.desc { color: var(--muted); font-size: 0.88rem; line-height: 1.55; margin: 0; }

.about ul { line-height: 1.8; color: #cde4eb; }
.about li { margin: 0.35rem 0; }
.about-h2 {
  margin-top: 1.6rem;
  margin-bottom: 0.35rem;
  font-size: 1.15rem;
}
.publisher-block {
  margin: 0.9rem 0 1.1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(46, 196, 182, 0.35);
  background: linear-gradient(135deg, rgba(46, 196, 182, 0.12), rgba(12, 32, 42, 0.35));
}
.publisher-line {
  margin: 0;
  color: #e7f4f7;
  font-size: 0.98rem;
  line-height: 1.55;
}
.publisher-line strong {
  color: #b8fff4;
  font-weight: 700;
}
.changelog {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.85rem;
}
.changelog-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: rgba(7, 22, 28, 0.45);
}
.changelog-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  align-items: baseline;
  margin-bottom: 0.35rem;
}
.changelog-item .ver {
  font-family: var(--display);
  color: var(--accent);
  font-weight: 700;
}
.changelog-item .date {
  color: var(--muted);
  font-size: 0.85rem;
}
.changelog-item .title {
  color: #d7eef3;
  font-weight: 600;
}
.changelog-item ul {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
}

.drawer[hidden] { display: none; }
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.drawer-panel {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: min(560px, 100%);
  background: #102a35;
  border-left: 1px solid var(--line);
  padding: 1.4rem;
  overflow: auto;
  box-shadow: var(--shadow);
  animation: slide .25s ease;
}
.wizard-search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: stretch;
  flex-wrap: wrap;
}
.wizard-search-bar input[type="search"] {
  flex: 1 1 220px;
  min-width: 0;
  height: 40px;
  box-sizing: border-box;
  padding: 0 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(7, 22, 28, 0.7);
  color: #e8f4f7;
  font: inherit;
  font-size: 0.92rem;
}
.wizard-search-bar input[type="search"]:focus {
  outline: none;
  border-color: rgba(46, 196, 182, 0.55);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.12);
}
.wizard-search-bar .btn,
.wizard-search-bar .btn.primary,
.wizard-search-bar .btn.ghost {
  width: auto;
  margin-top: 0;
  height: 40px;
  padding: 0 1rem;
  border-radius: 10px;
  flex: 0 0 auto;
  white-space: nowrap;
  box-shadow: none;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}
.card-action {
  font-size: 0.78rem;
  color: var(--accent);
}
.bundle-area { margin-top: 1.2rem; }
.bundle-section { margin-top: 1.1rem; }
.bundle-section h3 {
  font-size: 1rem;
  margin-bottom: 0.55rem;
  color: #b8fff4;
}
.mini-grid {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: 1fr;
}
.driver-line-group { margin-bottom: 0.85rem; }
.driver-line-title {
  font-size: 0.82rem;
  color: var(--accent);
  margin: 0.35rem 0 0.45rem;
  font-weight: 600;
}
.mini-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  background: rgba(7, 22, 28, 0.55);
}
.bom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  margin-bottom: 0.7rem;
}
.bom-table th, .bom-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.35rem;
  text-align: left;
}
.bom-table th { color: var(--muted); font-weight: 500; }
.mono { font-family: var(--display); letter-spacing: 0.02em; }
.warn {
  color: var(--accent-2);
  background: rgba(244, 162, 97, 0.1);
  border: 1px solid rgba(244, 162, 97, 0.28);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font-size: 0.88rem;
}
.btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(46, 196, 182, 0.35);
  padding: 0.45rem 0.8rem;
  width: auto;
}
.btn.tiny { padding: 0.3rem 0.65rem; font-size: 0.78rem; margin-top: 0.4rem; }
.motor-row { display: grid; grid-template-columns: 1fr 110px; gap: 0.6rem; align-items: start; }
.card-thumb {
  width: 100%; height: 140px; object-fit: contain;
  border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: zoom-in; margin: 0.55rem 0;
}
.draw-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}
.draw-gallery.compact { grid-template-columns: 1fr 1fr; }
.gallery-card { margin: 0; }
.gallery-hit {
  display: grid;
  gap: 0.45rem;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 22, 28, 0.55);
  color: inherit;
  padding: 0.55rem;
  cursor: zoom-in;
  text-align: left;
  font: inherit;
}
.gallery-hit img {
  width: 100%; height: 180px; object-fit: contain;
  background: #fff; border-radius: 8px;
}
.gallery-hit:hover { border-color: rgba(46, 196, 182, 0.45); }
.draw-thumb {
  width: 110px; height: 110px; object-fit: contain;
  border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: zoom-in;
}
.draw-full {
  width: 100%; max-height: 360px; object-fit: contain;
  border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: zoom-in; margin: 0.4rem 0;
}
.lightbox[hidden] { display: none !important; }
.lightbox { position: fixed; inset: 0; z-index: 40; display: block; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.72); }
.lightbox-panel {
  position: absolute; inset: 4vh 4vw; background: #0b1c24;
  border: 1px solid var(--line); border-radius: 14px;
  padding: 1rem; overflow: auto; display: grid; gap: 0.6rem;
}
.lightbox-panel img { width: 100%; background: #fff; border-radius: 8px; }
.lightbox-caption { color: var(--accent); font-family: var(--display); font-weight: 600; padding-right: 2rem; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-close {
  position: absolute; right: 0.8rem; top: 0.6rem;
  border: 0; background: transparent; color: var(--muted);
  font-size: 1.6rem; cursor: pointer;
}
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 0.45rem 0.75rem; margin-top: 1rem; }
.kv div:nth-child(odd) { color: var(--muted); }
.kv div:nth-child(even) { color: var(--text); }

@media (max-width: 900px) {
  .wizard-layout { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .motor-row { grid-template-columns: 1fr; }
  .draw-thumb { width: 100%; height: 160px; }
  .bom-layout, .bom-project-fields { grid-template-columns: 1fr; }
}

.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  z-index: 50; background: #123642; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.65rem 1.1rem; box-shadow: var(--shadow);
}
.toast[hidden] { display: none !important; }
.bom-chip {
  border: 1px solid var(--line); background: rgba(46,196,182,.1);
  color: var(--text); border-radius: 999px; padding: 0.4rem 0.8rem;
  cursor: pointer; font: inherit; margin-left: auto;
}
.bom-chip.has-items { border-color: rgba(46,196,182,.5); color: var(--accent); }
.bom-layout {
  display: grid; grid-template-columns: 1fr minmax(220px, 300px); gap: 1rem;
}
.bom-project-fields {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; margin: 0.8rem 0 1rem;
}
.bom-project-fields label, .bom-add-box label {
  display: grid; gap: 0.3rem; font-size: 0.88rem; color: #c5dde4;
}
.bom-project-fields input, .bom-add-box select, .bom-add-box input[type=number],
.bom-edit-table input, .bom-edit-table select {
  width: 100%; border: 1px solid var(--line); background: rgba(7,22,28,.75);
  color: var(--text); border-radius: 10px; padding: 0.55rem 0.7rem; font: inherit;
}
.bom-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.9rem; }
.plc-spec {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  margin: 0.65rem 0 0.35rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(46, 196, 182, 0.28);
  background: rgba(46, 196, 182, 0.06);
}
.plc-spec > div {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  font-size: 0.86rem;
}
.plc-spec .k {
  flex: 0 0 2.4rem;
  color: var(--accent);
  font-weight: 600;
}
.plc-spec .v {
  color: #e7f4f7;
  font-family: var(--display);
  font-weight: 600;
}
.bom-add-box label {
  display: grid;
  gap: 0.35rem;
  margin: 0.65rem 0;
  font-size: 0.88rem;
}
.bom-add-box input[type="number"],
.bom-add-box select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(7, 22, 28, 0.75);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
}
.bom-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.bom-edit-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.bom-edit-table th, .bom-edit-table td {
  padding: 0.55rem 0.45rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle;
}
.bom-edit-table th { color: var(--muted); font-weight: 500; background: rgba(0,0,0,.15); }
.bom-edit-table .empty-row td { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.bom-help ol { line-height: 1.8; color: #cde4eb; padding-left: 1.1rem; }
.bom-add-box {
  border: 1px solid rgba(46,196,182,.28); background: rgba(46,196,182,.06);
  border-radius: 12px; padding: 0.9rem;
}
.bom-add-box .btn.primary { margin-top: 0.6rem; }
.linkish {
  border: 0; background: transparent; color: var(--accent-2); cursor: pointer; font: inherit;
}
@media (max-width: 980px) {
  .bom-layout, .bom-project-fields { grid-template-columns: 1fr; }
}
