/* ============================================
   程序员计算器 - index.css
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f0f0f0;
  color: #1a1a1a;
  min-height: 100vh;
}

main {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 16px;
  padding-bottom: 16px;
}

header, footer {
  margin: 0;
  padding: 0;
}

div#app {
  width: 100%;
  max-width: 480px;
}

#calc-container {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.10);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============================================
   显示区
   ============================================ */

#display-area {
  padding: 16px 20px 8px;
  background: #fafafa;
  border-bottom: 1px solid #e8e8e8;
}

.base-display {
  display: flex;
  align-items: center;
  padding: 4px 0;
  min-height: 32px;
}

.base-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #888;
  min-width: 36px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f0f0f0;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}

.base-label:hover {
  background: #e0e0e0;
  color: #555;
}

.base-label.active {
  background: #3b82f6;
  color: #ffffff;
  font-weight: 700;
}

.base-value {
  font-size: 18px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Menlo', monospace;
  color: #333;
  margin-left: 10px;
  letter-spacing: 0.5px;
  overflow-x: auto;
  white-space: nowrap;
}

.base-value.active {
  font-weight: 700;
  color: #1a1a1a;
  font-size: 20px;
}

.base-value.error {
  color: #e53e3e;
}

/* ============================================
   二进制逐位方块
   ============================================ */

.bin-bits-container {
  display: flex;
  gap: 4px;
  margin-left: 10px;
  flex-wrap: wrap;
}

.bin-bit-group {
  display: flex;
  gap: 2px;
}

.bin-bit-group::after {
  content: '';
  display: block;
  width: 4px;
}

.bin-bit-group:last-child::after {
  display: none;
}

.bin-bit {
  display: inline-block;
  width: 20px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 3px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  transition: background 0.12s;
  user-select: none;
}

.bin-bit-0 {
  background: #e8e8e8;
  color: #999;
}

.bin-bit-1 {
  background: #3b82f6;
  color: #ffffff;
}

/* ============================================
   控制区
   ============================================ */

#control-area {
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}

.control-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-section-label {
  font-size: 11px;
  color: #999;
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.control-buttons {
  display: flex;
  gap: 4px;
}

.bit-btn, .sign-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  cursor: pointer;
  background: #fff;
  color: #555;
  transition: all 0.12s;
  user-select: none;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.bit-btn:hover, .sign-btn:hover {
  background: #f0f0f0;
  border-color: #ccc;
}

.bit-btn.active, .sign-btn.active {
  background: #3b82f6;
  color: #ffffff;
  border-color: #3b82f6;
}

.bit-btn:active, .sign-btn:active {
  transform: scale(0.95);
}

/* ============================================
   移位与位运算区
   ============================================ */

#bit-ops-area {
  padding: 10px 20px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ops-row {
  display: flex;
  gap: 6px;
}

/* ============================================
   HEX 字母区
   ============================================ */

#hex-letters {
  padding: 6px 20px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#hex-letters.hidden {
  display: none;
}

/* ============================================
   按钮通用样式
   ============================================ */

.op-btn, .func-btn, .num-btn {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 8px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  background: #ffffff;
  color: #333;
  transition: all 0.10s;
  user-select: none;
  min-width: 0;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.op-btn:active, .func-btn:active, .num-btn:active {
  transform: scale(0.94);
}

/* 位运算按钮 */
.bit-op {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
  font-size: 12px;
  font-weight: 700;
}

.bit-op:hover {
  background: #dbeafe;
}

.bit-op:active {
  background: #bfdbfe;
}

/* 算术运算按钮 */
.arith-op {
  background: #f5f5f5;
  color: #555;
  font-size: 16px;
}

.arith-op:hover {
  background: #ebebeb;
}

.arith-op:active {
  background: #e0e0e0;
}

/* 数字按钮 */
.num-btn {
  background: #ffffff;
  color: #1a1a1a;
  font-size: 16px;
  font-weight: 500;
}

.num-btn:hover {
  background: #f5f5f5;
}

.num-btn:active {
  background: #ebebeb;
}

.num-btn.disabled {
  color: #ccc;
  pointer-events: none;
  background: #fafafa;
  border-color: #f0f0f0;
}

/* 功能按钮 */
.func-btn {
  font-size: 16px;
  font-weight: 600;
}

.clear-btn {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.clear-btn:hover {
  background: #fee2e2;
}

.clear-btn:active {
  background: #fecaca;
}

.bksp-btn {
  background: #f5f5f5;
  color: #555;
  font-size: 18px;
}

.bksp-btn:hover {
  background: #ebebeb;
}

.bksp-btn:active {
  background: #e0e0e0;
}

/* 等号按钮 */
.eq-btn {
  background: #3b82f6;
  color: #ffffff;
  border-color: #3b82f6;
  font-size: 18px;
  font-weight: 700;
}

.eq-btn:hover {
  background: #2563eb;
}

.eq-btn:active {
  background: #1d4ed8;
}

/* 宽按钮（0跨两列） */
.btn-wide {
  flex: 2.12;
}

/* ============================================
   数字键盘区
   ============================================ */

#numpad {
  padding: 10px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ============================================
   HEX 字母按钮在非 HEX 模式下的样式
   ============================================ */

#hex-letters.disabled .hex-letter-btn {
  color: #d0d0d0;
  pointer-events: none;
}

/* ============================================
   响应式
   ============================================ */

/* ============================================
   简介 & 应用场景
   ============================================ */

#info-section {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-block {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.10);
  padding: 20px 24px;
}

.info-block h2 {
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: 700;
  color: #1a1a1a;
  border-bottom: 2px solid #3b82f6;
  padding-bottom: 8px;
}

.info-block p {
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
  color: #555;
}

.info-block ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.info-block ul li {
  position: relative;
  padding: 8px 0 8px 20px;
  font-size: 14px;
  line-height: 1.6;
  color: #555;
  border-bottom: 1px solid #f5f5f5;
}

.info-block ul li:last-child {
  border-bottom: none;
}

.info-block ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
}

.info-block ul li strong {
  color: #1a1a1a;
}

@media (max-width: 480px) {
  main {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  div#app {
    max-width: 100%;
  }

  #calc-container {
    border-radius: 0;
    box-shadow: none;
  }

  #display-area {
    padding: 12px 12px 6px;
  }

  .base-value {
    font-size: 16px;
  }

  .base-value.active {
    font-size: 18px;
  }

  .bin-bit {
    width: 16px;
    height: 18px;
    line-height: 18px;
    font-size: 10px;
  }

  .op-btn, .func-btn, .num-btn {
    font-size: 13px;
    padding: 12px 4px;
    border-radius: 5px;
  }

  .bit-op {
    font-size: 11px;
  }

  #control-area {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  #bit-ops-area {
    padding: 8px 12px;
  }

  #hex-letters {
    padding: 4px 12px;
  }

  #numpad {
    padding: 8px 12px 12px;
  }

  .ops-row {
    gap: 4px;
  }

  #ext-ops .bit-op {
    flex: 0.5;
  }

  #info-section {
    margin-top: 12px;
    gap: 8px;
  }

  .info-block {
    border-radius: 0;
    box-shadow: none;
    padding: 16px 12px;
  }

  .info-block h2 {
    font-size: 16px;
  }

  .info-block p,
  .info-block ul li {
    font-size: 13px;
  }
}

@media (max-width: 360px) {
  .bin-bit {
    width: 14px;
    height: 16px;
    line-height: 16px;
    font-size: 9px;
  }

  .ops-row {
    gap: 3px;
  }

  .op-btn, .func-btn, .num-btn {
    font-size: 12px;
    padding: 10px 2px;
  }
}
