/* ===== Belt & Chain Drive Calculator — light engineering theme ===== */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7785;
  --line: #e2e8f0;
  --brand: #1f6feb;
  --brand-d: #1556b8;
  --accent: #0f9d8a;
  --warn: #c2410c;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 6px 20px rgba(15, 23, 42, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, "PingFang SC",
               "Hiragino Sans", "Noto Sans CJK", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 20px;
  background: linear-gradient(180deg, #ffffff, #f7f9fc);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { font-size: 22px; color: var(--brand); }
.brand .title {
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lang {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 8px;
  font-size: 14px;
  cursor: pointer;
}
.btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--brand-d);
  transition: background .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-d); }

.subtitle {
  text-align: center;
  color: var(--muted);
  margin: 14px 0 4px;
  font-size: 14px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 18px;
}
.tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 9px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.tab.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand-d);
}

/* ---------- Layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 0 16px 40px; }
.panel { display: none; }
.panel.active { display: block; }
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
  .brand .title { font-size: 15px; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card h2 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--brand-d);
  border-bottom: 2px solid var(--line);
  padding-bottom: 8px;
}

/* ---------- Fields ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 600;
}
.field label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 0;
  cursor: pointer;
}
.field label.check input { width: 18px; height: 18px; flex: none; cursor: pointer; }
.inrow { display: flex; align-items: center; gap: 8px; }
.inrow input,
.inrow select {
  flex: 1;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}
.inrow input:focus,
.inrow select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}
.unit {
  color: var(--muted);
  font-size: 13px;
  min-width: 34px;
  text-align: left;
}

.btnrow { display: flex; gap: 10px; margin-top: 6px; }
.btnrow button {
  height: 40px;
  padding: 0 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.primary { background: var(--accent); color: #fff; border-color: #0c7d6e; }
.primary:hover { background: #0c7d6e; }
.ghost { background: #fff; color: var(--muted); border-color: var(--line); }
.ghost:hover { background: #f1f5f9; }

/* ---------- Results ---------- */
.results { display: flex; flex-direction: column; gap: 2px; }
.results .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 4px;
  border-bottom: 1px dashed var(--line);
}
.results .row .k { color: var(--muted); font-size: 14px; }
.results .row .val {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.results .row .val .u { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 3px; }

.notes-h { margin: 18px 0 8px; font-size: 14px; color: var(--brand-d); }
.notes { margin: 0; padding-left: 18px; }
.notes li { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.notes li.warn { color: var(--warn); font-weight: 600; }
.notes li.ok { color: var(--accent); font-weight: 600; }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

/* ---------- Drawing / export ---------- */
.draw-card { margin-top: 18px; }
.draw-canvas {
  display: block;
  width: 100%;
  max-width: 680px;
  height: auto;
  margin: 0 auto 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.btnrow.export {
  justify-content: center;
  gap: 12px;
}
.btnrow.export button { min-width: 84px; }

/* ---------- Gear module extras ---------- */
.preview {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 0 auto 16px;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.resblock { margin-top: 16px; }
.resblock h3 {
  font-size: 14px;
  color: var(--brand-d);
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.hint {
  font-size: 12px;
  color: var(--muted);
  margin: -8px 0 14px;
}
.disclaimer {
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.card .actions { margin-top: 8px; }
.btn.alt { background: #fff; color: var(--brand); border-color: var(--line); }
.btn.alt:hover { background: #f1f5f9; }
