/* GearCalculator Web — 复刻 APK 移动端布局 */
:root {
  --color-selected: #4bd0fc;
  --color-lite-gray: #ccd1d2;
  --color-dark-gray: #8b979a;
  --color-wheel-unselected: #808080;
  --color-divider: #5c5c5c;
  --tabbar-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #1a1a1a;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #2e3436 url('../assets/bg_light.png') repeat;
}

/* ========== 顶部 Tab 栏 ========== */
#tabbar {
  height: var(--tabbar-h);
  flex: 0 0 var(--tabbar-h);
  display: flex;
  background: url('../assets/tab_bar.png') repeat-x;
  background-size: auto 100%;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px 0;
}
.tab-item.active { background: rgba(255,255,255,0.5); }
.tab-icon { height: 30px; width: auto; pointer-events: none; }
.tab-label {
  font-size: 9px;
  color: #747b7c;
  margin-top: 1px;
  pointer-events: none;
}
.tab-item.active .tab-label { color: #fff; }
#tabbar-shadow {
  height: 6px;
  flex: 0 0 6px;
  background: url('../assets/tab_bar_shadow.png') repeat-x;
  background-size: auto 100%;
  z-index: 5;
}

#page-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========== 主界面：顶部面板 ========== */
.main-top-panel {
  flex: 0 0 auto;
  background: url('../assets/main_top_panel_bg_1.jpg') repeat-x top;
  background-size: auto 100%;
  display: flex;
  padding: 8px 4px 12px;
  position: relative;
}
.main-top-panel::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -8px;
  height: 8px;
  background: url('../assets/main_top_panel_shadow.png') repeat-x;
  background-size: auto 100%;
  pointer-events: none;
}

/* 踏频 / 速度 侧栏 */
.side-col {
  width: 86px;
  flex: 0 0 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.side-title {
  font-size: 11px;
  color: var(--color-dark-gray);
  text-align: center;
  line-height: 1.2;
  min-height: 26px;
}
.side-value {
  font-size: 32px;
  color: var(--color-lite-gray);
  text-align: center;
  line-height: 1.1;
  margin: 2px 0 4px;
}
.side-unit { font-size: 13px; color: var(--color-dark-gray); }
.vslider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 90px;
}
.vslider {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 28px;
  transform: rotate(-90deg);
  background: transparent;
  cursor: pointer;
}
.vslider::-webkit-slider-runnable-track {
  height: 8px;
  background: rgba(0,0,0,0.35);
  border-radius: 4px;
}
.vslider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  margin-top: -9px;
  background: url('../assets/seekbarl_button.png') no-repeat center;
  background-size: contain;
  border: none;
}
.vslider::-moz-range-track {
  height: 8px;
  background: rgba(0,0,0,0.35);
  border-radius: 4px;
}
.vslider::-moz-range-thumb {
  width: 26px; height: 26px;
  background: url('../assets/seekbarl_button.png') no-repeat center;
  background-size: contain;
  border: none;
}
.pm-btns {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.pm-btn {
  width: 34px; height: 34px;
  border: none;
  background: no-repeat center;
  background-size: contain;
  cursor: pointer;
}
.pm-btn:active { opacity: 0.6; }

/* 中央区 */
.center-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 2px;
}
.view-switch {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin: 2px 0 6px;
}
.view-switch img {
  height: 34px;
  cursor: pointer;
}
.view-switch img.inactive {
  filter: grayscale(100%) brightness(0.75);
  opacity: 0.72;
}
.center-rows {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}
.center-row { text-align: center; cursor: pointer; padding: 2px 0; }
.center-row .row-title {
  font-size: 11px;
  color: var(--color-dark-gray);
  letter-spacing: 0.5px;
}
.center-row .row-value {
  font-size: 26px;
  color: var(--color-lite-gray);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.center-row.fixed .row-value { color: var(--color-selected); }

/* ========== 主界面：底部齿轮面板 ========== */
.main-bottom-panel {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
  padding: 10px 0 6px;
  min-height: 200px;
}
.gear-side {
  position: relative;
  width: 50%;
  height: 100%;
  display: flex;
  align-items: center;
}
.gear-img {
  width: 100%;
  max-width: 240px;
  display: block;
  transition: transform 0.15s linear;
}
.gear-left-wrap { justify-content: flex-start; }
.gear-right-wrap { justify-content: flex-end; }
.gear-left-wrap .gear-img { margin-right: -14%; position: relative; z-index: 1; transform: scale(0.92); transform-origin: center center; }
.gear-right-wrap .gear-img { margin-left: -14%; position: relative; z-index: 1; transform: scale(0.78); transform-origin: center center; }

/* 滚轮 */
.wheel-col {
  position: absolute;
  top: 0; bottom: 0;
  width: 34%;
  z-index: 20;
}
.wheel-col.left { left: 0; }
.wheel-col.right { right: 0; }
.wheel {
  position: relative;
  height: 100%;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28%, #000 72%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 28%, #000 72%, transparent 100%);
}
.wheel-list {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  will-change: transform;
}
.wheel-item {
  height: 34px;
  line-height: 34px;
  text-align: center;
  font-size: 20px;
  color: var(--color-wheel-unselected);
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,0.85);
}
.wheel-item.selected {
  color: var(--color-selected);
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 0 6px rgba(0,0,0,0.9), 0 1px 3px rgba(0,0,0,0.9);
}
.wheel-label {
  position: absolute;
  top: 4px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  color: #a8b0b2;
  z-index: 25;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.85);
  letter-spacing: 0.5px;
}

/* 中央齿比面板 */
.ratio-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  text-align: center;
  background: url('../assets/main_top_panel_bg_2.jpg') repeat;
  background-size: auto 100%;
  border-radius: 10px;
  padding: 8px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  pointer-events: none;
}
.ratio-title { font-size: 11px; color: var(--color-dark-gray); letter-spacing: 0.5px; }
.ratio-value { font-size: 42px; color: var(--color-lite-gray); line-height: 1.1; }

/* ========== Compare 对比表 ========== */
.compare-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 18px;
}
.compare-row {
  display: flex;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--color-divider);
}
.compare-row .c-name {
  flex: 1.2;
  font-size: 12px;
  color: var(--color-dark-gray);
}
.compare-row .c-ref, .compare-row .c-cur {
  flex: 1;
  text-align: center;
  font-size: 20px;
  color: var(--color-lite-gray);
}
.compare-row .c-cur { color: var(--color-selected); }
.compare-row.c-header .c-ref, .compare-row.c-header .c-cur {
  font-size: 22px;
  color: var(--color-lite-gray);
}
.compare-row.c-header .c-cur { color: var(--color-selected); }

/* ========== 通用列表 ========== */
.list-page { background: transparent; }
.list-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.list-item {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-lite-gray);
  font-size: 17px;
  cursor: pointer;
}
.list-item:active { background: rgba(75,208,252,0.5); }
.list-item .check {
  width: 22px; height: 22px;
  margin-right: 14px;
  border: 2px solid var(--color-dark-gray);
  border-radius: 3px;
  flex: 0 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #111;
}
.list-item .check.on {
  background: var(--color-selected);
  border-color: var(--color-selected);
}
.list-item .radio {
  width: 20px; height: 20px;
  margin-right: 14px;
  border: 2px solid var(--color-dark-gray);
  border-radius: 50%;
  flex: 0 0 20px;
}
.list-item .radio.on {
  border-color: var(--color-selected);
  background: radial-gradient(circle, var(--color-selected) 0 45%, transparent 50%);
}
.list-item.add-item { color: var(--color-selected); }

/* 列表分组头 */
.group-header {
  padding: 14px 16px 6px;
  font-size: 13px;
  color: var(--color-dark-gray);
  text-transform: uppercase;
  border-bottom: 1px solid var(--color-divider);
  background: rgba(0,0,0,0.25);
}
.group-value { float: right; color: var(--color-selected); }

/* ========== 全屏覆盖子页面 ========== */
#overlay-container { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.overlay {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  background: #2e3436 url('../assets/bg_light.png') repeat;
}
.overlay-header {
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  background: url('../assets/tab_bar.png') repeat-x;
  background-size: auto 100%;
  padding: 0 8px;
}
.overlay-back {
  width: 36px; height: 36px;
  background: url('../assets/main_content_arrow_left.png') no-repeat center;
  background-size: 22px;
  cursor: pointer;
  flex: 0 0 36px;
}
.overlay-back:active { opacity: 0.6; }
.overlay-title {
  flex: 1;
  text-align: center;
  color: #fff;
  font-size: 16px;
  text-transform: uppercase;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-right: 36px;
}
.overlay-actions { display: flex; gap: 4px; padding-right: 4px; }
.overlay-action-btn {
  color: var(--color-selected);
  font-size: 14px;
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.overlay-action-btn:active { opacity: 0.6; }
.overlay-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ========== 图表向导 ========== */
.wizard-body { flex: 1; overflow-y: auto; padding: 16px; }
.wizard-label {
  font-size: 12px;
  color: var(--color-dark-gray);
  margin: 10px 0 6px;
  text-transform: uppercase;
}
.wizard-input, .teeth-input {
  width: 100%;
  background: rgba(255,255,255,0.92);
  border: 1px solid #999;
  border-radius: 4px;
  padding: 10px;
  font-size: 17px;
  color: #222;
}
.teeth-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.teeth-grid .teeth-input { width: calc(33.33% - 6px); }
.teeth-grid.cols5 .teeth-input { width: calc(20% - 7px); padding: 8px 4px; font-size: 15px; }
.wizard-select-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 4px;
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-lite-gray);
  font-size: 16px;
  cursor: pointer;
}
.wizard-select-row .v { color: var(--color-selected); }
.wizard-nav {
  flex: 0 0 auto;
  display: flex;
  background: url('../assets/list_top_panel_bg.png') repeat-x;
  background-size: auto 100%;
}
.wizard-nav button {
  flex: 1;
  padding: 14px;
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.wizard-nav button:disabled { color: #666; }
.wizard-nav button:active:not(:disabled) { background: rgba(255,255,255,0.15); }

/* ========== 图表详情 ========== */
.chart-tabs {
  flex: 0 0 auto;
  display: flex;
  padding: 8px 0;
}
.chart-tab {
  flex: 1;
  text-align: center;
  color: var(--color-lite-gray);
  font-size: 14px;
  padding: 4px 0;
  cursor: pointer;
}
.chart-tab.active { color: var(--color-selected); font-weight: bold; }
.chart-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 0 15px 10px; }
.cadence-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
}
.cadence-bar .pm-btn { width: 30px; height: 30px; }
.cadence-slider { flex: 1; -webkit-appearance: none; height: 8px; background: rgba(0,0,0,0.35); border-radius: 4px; }
.cadence-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  background: url('../assets/seekbarl_button.png') no-repeat center;
  background-size: contain;
}
.cadence-slider::-moz-range-thumb {
  width: 26px; height: 26px;
  background: url('../assets/seekbarl_button.png') no-repeat center;
  background-size: contain;
  border: none;
}
.cadence-text { color: var(--color-lite-gray); font-size: 13px; white-space: nowrap; }
.chart-scroll { flex: 1; overflow-y: auto; }
.chart-row {
  display: flex;
  border-bottom: 1px solid var(--color-divider);
  padding: 5px 0;
}
.chart-row .cell {
  flex: 1;
  text-align: center;
  font-size: 22px;
  color: var(--color-lite-gray);
}
.chart-row .cell:first-child { color: var(--color-dark-gray); }
.chart-row.head .cell { color: var(--color-dark-gray); }

/* ========== 设置页 ========== */
.settings-scroll { flex: 1; overflow-y: auto; }

/* ========== Toast ========== */
#toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 200;
  display: none;
  max-width: 80%;
  text-align: center;
}

/* ========== 对话框 ========== */
.dialog-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dialog {
  width: 82%;
  max-width: 340px;
  background: #f3f3f3;
  border-radius: 8px;
  overflow: hidden;
}
.dialog-title {
  padding: 14px 16px;
  font-size: 17px;
  color: #222;
  border-bottom: 1px solid #ccc;
}
.dialog-body { max-height: 50vh; overflow-y: auto; }
.dialog-option {
  padding: 14px 16px;
  font-size: 16px;
  color: #222;
  cursor: pointer;
  border-bottom: 1px solid #e0e0e0;
}
.dialog-option:active { background: #d9edf7; }
.dialog-btns { display: flex; border-top: 1px solid #ccc; }
.dialog-btns button {
  flex: 1;
  padding: 13px;
  background: none;
  border: none;
  font-size: 16px;
  color: #33b5e5;
  cursor: pointer;
}
.dialog-btns button + button { border-left: 1px solid #ccc; }
