:root {
    --bg-color: #121212;
    --surface-color: #1a1a1a;
    --primary-color: #00e5ff;
    --primary-variant: #00b8d4;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --divider: #333333;
    --btn-bg: #2a2a2a;
    --btn-active: #404040;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
}

/* Sticky Header & Result Card */
.sticky-header-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--divider);
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    padding: 0.8rem 1rem;
}

header {
    text-align: center;
}

header h1 {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(90deg, var(--primary-color), #b2ff59);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.result-card {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 1rem 1.2rem 0.8rem;
    max-width: 600px;
    margin: 0 auto;
    border: 1px solid var(--divider);
    position: relative;
    overflow: hidden;
}

#bike-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1280px;
    height: 1280px;
    transform: translate(-50%, -50%) scale(0.20);
    transform-origin: center center;
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

.result-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.8rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--divider);
    position: relative; z-index: 10;
}
.result-row.primary .label { font-size: 1.2rem; color: var(--text-secondary); }
.result-row.primary .value { font-size: 3.5rem; font-weight: 800; color: var(--primary-color); line-height: 1; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; text-align: center; position: relative; z-index: 10; }
.result-grid.two-cols { grid-template-columns: repeat(2, 1fr); }
.result-item .label { display: block; font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 0.2rem; }
.result-item .value { display: block; font-size: 1.25rem; font-weight: 600; }
#res-speed { color: var(--primary-color); }

/* Cadence Slider in Result Card */
.cadence-slider-area {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px dashed var(--divider);
    position: relative;
    z-index: 10;
}
.cadence-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}
.cadence-val-display b { color: var(--primary-color); font-size: 1.1rem; }
.styled-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--divider);
    border-radius: 5px;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
}
.styled-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}

/* Main Content area */
main { padding: 1rem 1rem 2rem; max-width: 600px; margin: 0 auto; }

.mode-tabs {
    display: flex; justify-content: center; gap: 0.5rem;
    background: var(--surface-color); padding: 0.25rem;
    border-radius: 12px; border: 1px solid var(--divider);
    margin: 0 auto 1rem;
}
.mode-btn {
    flex: 1; padding: 0.5rem 0; font-size: 0.95rem;
    font-weight: 600; color: var(--text-secondary);
    background: transparent; border: none; border-radius: 8px;
    cursor: pointer; transition: all 0.2s;
}
.mode-btn.active {
    background: var(--btn-active); color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Inputs & Controls */
.controls { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
.control-group label { display: block; font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 0.3rem; }
.control-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.control-header label { margin-bottom: 0; }
.btn-manual {
    background: transparent; border: 1px solid var(--primary-color); color: var(--primary-color);
    padding: 0.2rem 0.6rem; font-size: 0.8rem; border-radius: 6px; cursor: pointer; transition: all 0.2s;
}
.btn-manual.active {
    background: var(--primary-color); color: var(--bg-color); font-weight: bold;
}
.input-stepper { display: flex; background: var(--surface-color); border-radius: 12px; overflow: hidden; height: 48px; border: 1px solid var(--divider); }
.input-stepper.compact { height: 40px; border-radius: 8px; }
.input-stepper.compact .btn-step { font-size: 1.4rem; }
.input-stepper.compact input { font-size: 1.1rem; }
.btn-step {
    flex: 1; background: var(--btn-bg); border: none; color: var(--primary-color);
    font-size: 1.8rem; font-weight: bold; cursor: pointer; transition: background 0.2s;
}
.btn-step:active { background: var(--btn-active); }
.input-stepper input {
    flex: 2; background: transparent; border: none; color: var(--text-primary);
    font-size: 1.5rem; font-weight: 600; text-align: center; width: 100%;
}
.input-stepper input:focus { outline: none; }
select {
    width: 100%; height: 48px; background: var(--surface-color); border: 1px solid var(--divider);
    border-radius: 12px; color: var(--text-primary); font-size: 1rem; padding: 0 1rem;
    appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 1rem center; background-size: 1em;
}
select:disabled { opacity: 0.3; }
.toggle-group { flex-direction: row; justify-content: space-between; align-items: center; display: flex; }
.toggle-group label:first-child { margin-bottom: 0; }
.switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--btn-bg); transition: .4s; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(26px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Virtual Shifter */
.shifter-widget { background: var(--surface-color); border: 1px solid var(--primary-variant); border-radius: 12px; padding: 1rem; margin-bottom: 0.5rem; }
.shifter-title { font-size: 1rem; font-weight: 800; color: var(--text-primary); margin-bottom: 0.8rem; text-align: center; letter-spacing: 1px; }
.shifter-row { margin-bottom: 1rem; }
.shifter-row:last-child { margin-bottom: 0; }
.shifter-label { display: flex; justify-content: space-between; align-items: center; font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 0.4rem; }
.gear-badge { background: var(--primary-color); color: var(--bg-color); padding: 0.15rem 0.6rem; border-radius: 12px; font-size: 0.8rem; font-weight: 800; }
.shifter-controls { display: flex; align-items: stretch; background: var(--bg-color); border-radius: 12px; height: 50px; overflow: hidden; border: 1px solid var(--divider); }
.btn-shift { flex: 1; background: var(--btn-bg); border: none; color: var(--text-primary); font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: background 0.1s; }
.btn-shift:active { background: var(--primary-variant); color: #121212; }
.btn-shift:disabled { opacity: 0.3 !important; cursor: default; background: var(--btn-bg) !important; color: var(--text-primary) !important; }
.shifter-display { flex: 1.2; display: flex; justify-content: center; align-items: center; background: transparent; border-left: 1px solid var(--divider); border-right: 1px solid var(--divider); }
.shifter-display .gear-teeth { font-size: 2rem; font-weight: 800; color: var(--primary-color); }
.shifter-display .t-label { font-size: 1rem; color: var(--text-secondary); margin-top: 0.5rem; margin-left: 0.1rem; }

/* Setup Accordion */
.setup-accordion details { background: rgba(255,255,255,0.02); border: 1px solid var(--divider); border-radius: 12px; }
.setup-accordion summary { padding: 1rem; cursor: pointer; font-size: 0.95rem; font-weight: 600; color: var(--primary-color); outline: none; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.setup-accordion summary::-webkit-details-marker { display: none; }
.setup-accordion summary::after { content: '+'; font-size: 1.5rem; font-weight: 400; }
.setup-accordion details[open] summary::after { content: '-'; }
.setup-accordion details[open] summary { border-bottom: 1px solid var(--divider); }
.accordion-content { padding: 1rem; background: transparent; }
.manual-setup-container { background: rgba(0,0,0,0.2); padding: 1rem; border-radius: 8px; margin-top: 0.5rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.manual-setup-container.full-width { grid-template-columns: 1fr; }

/* Affiliate Area */
.affiliate-placeholder { padding: 2rem 1rem; background: rgba(0, 229, 255, 0.05); border: 1px dashed var(--primary-color); border-radius: 12px; text-align: center; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.6; }
.ad-container-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 0.6rem; 
    margin-top: 1rem; 
}
.btn-amazon-search-mini { 
    display: flex; 
    flex-direction: column;
    align-items: center; 
    justify-content: center;
    background: linear-gradient(135deg, #2d2d2d, #1a1a1a);
    border: 1px solid #ff9900;
    color: var(--text-primary); 
    text-decoration: none; 
    padding: 0.6rem 0.4rem; 
    border-radius: 10px; 
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.btn-amazon-search-mini:hover { 
    transform: translateY(-2px); 
    border-color: #ffb84d;
    box-shadow: 0 6px 12px rgba(255, 153, 0, 0.2);
    background: linear-gradient(135deg, #3d3d3d, #2a2a2a);
}
.cat-label { 
    font-size: 0.7rem; 
    color: #ff9900; 
    font-weight: 800; 
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}
.cat-keyword { 
    font-size: 0.85rem; 
    font-weight: 600; 
    text-align: center;
}
.icon-search { width: 16px; height: 16px; }

/* Guide Link Button */
.guide-link-area {
    margin-top: 2rem;
    text-align: center;
}
.btn-guide {
    display: inline-block;
    padding: 0.8rem 2rem;
    background: var(--surface-color);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-guide:hover {
    background: var(--primary-color);
    color: var(--bg-color);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}
