/* Reset & base */
*{box-sizing:border-box}
body{background:#282A36;color:#F8F8F2;font-family:'Segoe UI',system-ui,sans-serif;padding:1rem;margin:0;padding-bottom:2rem}

/* Header */
.app-header{text-align:center;margin:1rem 0 2rem 0}
.logo{font-size:3.5rem;font-weight:900;color:#8BE9FD;letter-spacing:4px;text-shadow:0 0 20px rgba(139,233,253,.2)}
.subtitle{font-size:.85rem;color:#6272A4;letter-spacing:2px;margin-top:-.2rem}
.subtitle a.pantsu-link{color:#FF79C6;text-decoration:none;font-weight:bold}
.subtitle a.pantsu-link:hover{text-decoration:underline}

/* Main container */
.app-container{max-width:800px;margin:0 auto;padding:0 .5rem}

/* Control boxes – equal height when collapsed */
.controls{background:#44475A;padding:.8rem 1rem;border-radius:12px;margin-bottom:1rem;border:1px solid #6272A4;min-height:60px;display:flex;flex-direction:column;justify-content:center}
details.controls{padding:.8rem 1rem}
details.controls summary{cursor:pointer;font-weight:bold;color:#8BE9FD;list-style:none;display:flex;align-items:center}
details.controls summary::-webkit-details-marker{display:none}
details.controls summary:hover{color:#50FA7B}
details.controls[open] summary{margin-bottom:.5rem}
#presetControls{justify-content:center}

/* MD5 row */
.md5-row{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}
.md5-row input{flex:1;min-width:200px;background:#282A36;color:#F8F8F2;border:1px solid #6272A4;padding:.4rem;border-radius:4px}
.load-btn{background:#8BE9FD;color:#282A36;border:none;padding:.4rem 1.2rem;border-radius:4px;font-weight:bold;cursor:pointer}
.load-btn:disabled{opacity:.5;cursor:not-allowed}

/* Slider rows */
.slider-row{display:flex;align-items:center;gap:1rem;margin-bottom:.5rem}
.slider-row label{width:80px;font-weight:bold;font-size:.9rem;flex-shrink:0}
.slider-wrapper{flex:1;position:relative;height:28px}
.slider-wrapper input[type=range]{width:100%;height:6px;background:#6272A4;border-radius:4px;-webkit-appearance:none;appearance:none;position:absolute;top:50%;transform:translateY(-50%);margin:0}
.slider-wrapper input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:18px;height:18px;border-radius:50%;background:#8BE9FD;cursor:pointer;transition:background .2s}
.slider-wrapper input[type=range]::-moz-range-thumb{width:18px;height:18px;border-radius:50%;background:#8BE9FD;cursor:pointer;border:none}
.slider-wrapper.bypassed input[type=range]{opacity:.3}
.slider-wrapper.bypassed input[type=range]::-webkit-slider-thumb{background:#6272A4;cursor:not-allowed}
.slider-wrapper.bypassed input[type=range]::-moz-range-thumb{background:#6272A4;cursor:not-allowed}
.bypass-label{display:none;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.7rem;font-weight:bold;color:#6272A4;pointer-events:none;background:#44475A;padding:0 6px;border-radius:4px;white-space:nowrap}
.slider-wrapper.bypassed .bypass-label{display:block}
.slider-row input[type=number]{width:70px;background:#282A36;color:#F8F8F2;border:1px solid #6272A4;padding:.3rem;border-radius:4px;font-size:.9rem;text-align:center}

/* Buttons */
.preset-btn{background:#44475A;border:1px solid #6272A4;color:#F8F8F2;padding:.3rem 1rem;border-radius:30px;cursor:pointer;font-size:.8rem;font-weight:bold;transition:.15s}
.preset-btn:hover{background:#6272A4}
.preset-btn.active{background:#8BE9FD;color:#282A36;border-color:#8BE9FD}
.btn{background:#44475A;border:1px solid #6272A4;color:#F8F8F2;padding:.3rem 1rem;border-radius:30px;cursor:pointer;font-size:.8rem;font-weight:bold;transition:.15s}
.btn:hover{background:#6272A4}

/* Trill grid */
.pair-factors{display:flex;flex-wrap:wrap;gap:1.5rem;align-items:flex-start;margin-top:.5rem}
.pair-grid{flex:2;min-width:300px}
.factor-group{flex:1;min-width:150px;display:flex;flex-direction:column;gap:.8rem}
.factor-group label{display:flex;justify-content:space-between;font-size:.9rem;align-items:center}
.factor-group input[type=number]{width:100px;background:#282A36;color:#F8F8F2;border:1px solid #6272A4;padding:.3rem;border-radius:4px;text-align:center}
.pair-container{display:flex;flex-direction:column;gap:.3rem;width:100%}
.pair-row{display:flex;align-items:center;gap:.2rem}
.pair-row .label{width:2.2rem;font-weight:bold;color:#6272A4;text-align:right;padding-right:.5rem;font-size:.8rem;flex-shrink:0}
.pair-row .buttons{display:flex;gap:.2rem;flex-wrap:wrap}
.trill-btn{background:#282A36;border:1px solid #6272A4;border-radius:20px;padding:.15rem .4rem;font-size:.6rem;cursor:pointer;text-align:center;color:#F8F8F2;transition:.15s;touch-action:manipulation;white-space:nowrap;display:flex;flex-direction:column;align-items:center;justify-content:center;min-width:50px;line-height:1.2}
.trill-btn:hover{background:#44475A}
.trill-btn.reward{background:#50FA7B;color:#282A36;border-color:#50FA7B}
.trill-btn.penalty{background:#FF5555;color:#F8F8F2;border-color:#FF5555}
.trill-btn .count{font-size:.5rem;color:#6272A4;margin-top:1px}
.trill-btn.reward .count,.trill-btn.penalty .count{color:rgba(255,255,255,.7)}

/* Search */
.search-area{display:flex;gap:.5rem;align-items:center;margin:.5rem 0 1rem 0;flex-wrap:wrap}
.search-area input{flex:1;min-width:160px;background:#282A36;color:#F8F8F2;border:1px solid #6272A4;padding:.4rem .6rem;border-radius:4px;font-size:.9rem}
.search-area .btn{padding:.4rem 1rem}
.search-area select{background:#282A36;color:#F8F8F2;border:1px solid #6272A4;padding:.2rem;border-radius:4px}

/* Stats */
.stat-box{background:#44475A;padding:.6rem 1rem;border-radius:8px;margin-bottom:1rem;border-left:4px solid #8BE9FD;font-size:.9rem}
.stat-box span{font-weight:bold;color:#8BE9FD}

/* Table */
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
table{width:100%;border-collapse:collapse;font-size:.8rem;min-width:700px}
th,td{border:1px solid #44475A;padding:.3rem .5rem;text-align:left;white-space:nowrap}
th{background:#44475A;position:sticky;top:0;z-index:10;cursor:pointer;user-select:none}
th:hover{background:#6272A4}
th:first-child,td:first-child{position:sticky;left:0;z-index:5;background:#282A36}
th:first-child{z-index:11;background:#44475A}
th:nth-child(2),td:nth-child(2){position:sticky;left:3.5rem;z-index:5;background:#282A36}
th:nth-child(2){z-index:11;background:#44475A}
.rank-1{background:rgba(139,233,253,.15)}
.rank-move.up{color:#50FA7B}
.rank-move.down{color:#FF5555}
.rank-move.same{color:#6272A4}
.loading{color:#6272A4;text-align:center;padding:2rem}

/* Spinner */
.spinner{border:4px solid #6272A4;border-top:4px solid #8BE9FD;border-radius:50%;width:30px;height:30px;animation:spin 1s linear infinite;margin:1rem auto}
@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}

/* Toast */
.toast{position:fixed;bottom:2rem;right:2rem;background:#44475A;border-left:4px solid #8BE9FD;padding:.6rem 1.2rem;border-radius:8px;box-shadow:0 4px 20px rgba(0,0,0,.5);z-index:1000;animation:fadeIn .3s ease}
@keyframes fadeIn{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}

/* Responsive */
@media(max-width:700px){
    .logo{font-size:2.8rem}
    .app-container{padding:0 .2rem}
    .slider-row label{width:60px;font-size:.8rem}
    .slider-row input[type=number]{width:60px}
    .trill-btn{min-width:40px;font-size:.5rem;padding:.1rem .2rem}
    .pair-row .label{width:1.8rem;font-size:.7rem}
    .controls{padding:.6rem;min-height:50px}
    .factor-group label{font-size:.8rem}
    .factor-group input[type=number]{width:80px}
    .search-area input{min-width:120px}
    table{font-size:.7rem;min-width:600px}
    th,td{padding:.2rem .3rem}
}
