* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: "Microsoft JhengHei","PingFang TC","Noto Sans TC",sans-serif; background:#f5f5f5; color:#333; }
#app { max-width:480px; margin:0 auto; padding:8px; }
header { text-align:center; padding:12px 0; }
header h1 { font-size:20px; margin-bottom:8px; }
.tier-switch { display:flex; align-items:center; justify-content:center; gap:8px; }
.tier-switch select { padding:6px 12px; border-radius:6px; border:1px solid #ccc; font-size:14px; }

.card { background:#fff; border-radius:10px; padding:14px; margin-bottom:10px; box-shadow:0 1px 3px rgba(0,0,0,0.1); }
.card h2 { font-size:16px; margin-bottom:10px; color:#2c5282; border-bottom:2px solid #e2e8f0; padding-bottom:6px; }
.hint { font-size:12px; color:#718096; margin-bottom:10px; }

/* Tap Button */
.rate-row { display:flex; flex-direction:column; gap:10px; }
.tap-area { display:flex; gap:8px; }
#tapBtn { flex:1; padding:20px; font-size:18px; background:#2c5282; color:#fff; border:none; border-radius:10px; cursor:pointer; user-select:none; -webkit-user-select:none; display:flex; flex-direction:column; align-items:center; gap:4px; }
#tapBtn:active { background:#1a365d; transform:scale(0.97); }
#tapCount { font-size:24px; font-weight:bold; }
#tapReset { padding:10px 16px; background:#e2e8f0; border:none; border-radius:8px; font-size:14px; cursor:pointer; }
.rate-manual { display:flex; align-items:center; gap:6px; font-size:14px; }
.rate-manual input { width:60px; padding:6px; border:1px solid #ccc; border-radius:6px; text-align:center; font-size:16px; }
.rate-result { font-size:15px; font-weight:bold; padding:6px; text-align:center; border-radius:6px; }
.rate-result.normal { background:#c6f6d5; color:#22543d; }
.rate-result.fast { background:#fed7d7; color:#9b2c2c; }
.rate-result.slow { background:#bee3f8; color:#2a4365; }

/* Brush control */
.brush-control { display:flex; align-items:center; gap:8px; margin-bottom:12px; font-size:14px; }
.brush-control input[type=range] { flex:1; }
#brushSizeLabel { width:24px; text-align:right; font-weight:bold; color:#2c5282; }

/* Chart layout */
.chart-wrap { display:flex; align-items:flex-start; justify-content:center; gap:0; }
.hand-block { display:flex; flex-direction:column; align-items:center; }
.hand-title { font-weight:bold; color:#2c5282; font-size:14px; }

.code-row { display:flex; align-items:center; gap:4px; margin-bottom:6px; flex-wrap:wrap; justify-content:center; }
.code-row select { padding:4px; border:1px solid #ccc; border-radius:4px; font-size:12px; background:#fff; }
.code-badge {
  display:inline-block; min-width:30px; text-align:center;
  font-size:16px; font-weight:bold; color:#1a365d;
  background:#e2e8f0; border-radius:4px; padding:2px 8px;
}

.canvas-row { display:flex; align-items:stretch; gap:4px; }
.canvas-stack { position:relative; width:150px; height:330px; }
.canvas-stack canvas { position:absolute; top:0; left:0; width:150px; height:330px; }
#left_ink, #right_ink { cursor:crosshair; }

.row-labels { display:flex; flex-direction:column; justify-content:space-around; align-items:center; width:56px; }
.row-labels.right { align-items:center; }
.row-label-item { display:flex; flex-direction:column; align-items:center; gap:2px; height:110px; justify-content:center; }
.pos-name { font-size:13px; font-weight:bold; color:#2c5282; text-align:center; line-height:1.3; }
.pos-name small { font-weight:normal; color:#718096; font-size:10px; }

.distinct-ctl { display:none; flex-direction:column; gap:2px; margin-top:2px; }
.distinct-ctl select { font-size:10px; padding:1px; width:52px; }
.tier2-active .distinct-ctl { display:flex; }

.clear-btn { margin-top:8px; padding:6px 14px; background:#e2e8f0; border:none; border-radius:6px; font-size:13px; cursor:pointer; }

.side-labels { display:flex; flex-direction:column; justify-content:flex-end; align-items:center; width:34px; padding-bottom:36px; }
.side-labels span { writing-mode: vertical-rl; font-size:12px; color:#666; letter-spacing:2px; }
.side-labels span:nth-child(1) { align-self:flex-end; }
.side-labels span:nth-child(2) { margin:8px 0; }
.side-labels span:nth-child(3) { align-self:flex-start; }

/* Tier 2 extra fields */
.tier2-section .extra-field { margin-bottom:10px; }
.tier2-section label { font-size:14px; display:block; margin-bottom:4px; }
.tier2-section select, .tier2-section textarea { width:100%; padding:8px; border:1px solid #ccc; border-radius:6px; font-size:14px; }
.touch-checks { display:flex; gap:12px; flex-wrap:wrap; }
.touch-checks label { display:flex; align-items:center; gap:4px; font-size:15px; }
.touch-checks input { width:18px; height:18px; }

/* Submit */
.submit-btn { width:100%; padding:14px; font-size:18px; font-weight:bold; background:#2c5282; color:#fff; border:none; border-radius:10px; cursor:pointer; }
.submit-btn:active { background:#1a365d; }
.submit-btn:disabled { background:#a0aec0; cursor:not-allowed; }
.status-msg { text-align:center; margin-bottom:8px; font-size:14px; }
.status-msg.ready { color:#22543d; }
.status-msg.incomplete { color:#9b2c2c; }

/* Results */
#resultContent { font-size:14px; line-height:1.6; }
.result-section { margin-bottom:12px; padding:10px; background:#f7fafc; border-radius:6px; border-left:3px solid #2c5282; }
.result-section h3 { font-size:14px; color:#2c5282; margin-bottom:6px; }
.result-section p, .result-section li { font-size:13px; }
.result-section ul { padding-left:16px; }

/* Radar Chart */
.radar-container { text-align:center; margin:10px 0; }
.radar-container canvas { max-width:280px; }

/* Prescription Card */
.rx-card { background:#fffff0; border:1px solid #ecc94b; border-radius:8px; padding:10px; margin-top:8px; }
.rx-card h4 { color:#975a16; margin-bottom:6px; }
.rx-card .rx-main { font-size:15px; font-weight:bold; color:#744210; }
.rx-card .rx-food { font-size:13px; color:#666; margin-top:4px; }

@media(max-width:480px) {
  .canvas-stack { width:120px; height:264px; }
  .canvas-stack canvas { width:120px; height:264px; }
  .row-label-item { height:88px; }
  .row-labels { width:48px; }
}
