/* Header */
.header{
  position:sticky; top:0; z-index:30;
  backdrop-filter: blur(12px);
  background: rgba(11,18,32,.7);
  border-bottom:1px solid var(--border);
}
.header-inner{
  max-width:1100px; margin:0 auto;
  padding:14px 16px;
  display:flex; align-items:center; justify-content:space-between; gap:12px;
}
.brand{
  display:flex; align-items:center; gap:12px;
}
.brand-icon{
  width:38px; height:38px; border-radius:11px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display:grid; place-items:center; font-size:18px; box-shadow: var(--shadow-soft);
}
.brand h1{font-size:18px; margin:0; font-weight:700; letter-spacing:-.02em}
.brand p{margin:0; font-size:12px; color:var(--text-muted)}
.header-actions{display:flex; gap:8px; align-items:center; flex-shrink:0}
.icon-btn{
  width:42px; height:42px; border-radius:12px;
  background: var(--bg-soft); border:1px solid var(--border);
  display:grid; place-items:center; cursor:pointer; color:var(--text);
  transition:.2s; font-size:18px; flex-shrink:0;
}
.icon-btn:hover{transform:translateY(-1px); background:var(--bg-elev); border-color:#2f4a8a}
.badge{
  display:inline-flex; align-items:center; gap:6px;
  font-size:11px; font-weight:600; letter-spacing:.01em;
  padding:6px 10px; border-radius:999px; white-space:nowrap; line-height:1;
  background: rgba(0,229,204,.12); color: var(--accent); border:1px solid rgba(0,229,204,.25);
  transition: all .25s ease;
}
.badge-dot{
  width:7px; height:7px; border-radius:50%; background: currentColor; flex-shrink:0;
  box-shadow: 0 0 0 0 currentColor; animation: badgePulse 2s infinite;
}
@keyframes badgePulse{
  0%{ box-shadow: 0 0 0 0 currentColor; opacity:1}
  70%{ box-shadow: 0 0 0 6px transparent; opacity:.9}
  100%{ box-shadow: 0 0 0 0 transparent; opacity:1}
}
.badge--loading{ background: rgba(91,124,255,.14); color:#8ea6ff; border-color: rgba(91,124,255,.28)}
.badge--ready{ background: rgba(0,211,138,.15); color:#00e5a0; border-color: rgba(0,211,138,.32)}
.badge--error{ background: rgba(255,84,112,.14); color:#ff8da3; border-color: rgba(255,84,112,.32)}
.badge--warn{ background: rgba(255,176,46,.14); color:#ffcc6b; border-color: rgba(255,176,46,.32)}

/* — Smart mobile header: badge wraps to new line and stays fully visible — */
@media (max-width: 560px){
  .header-inner{
    flex-wrap:wrap; padding:10px 12px; gap:10px;
  }
  .brand{ flex:1 1 auto; min-width:0 }
  .brand h1{ font-size:15px }
  .brand p{ font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
  .brand-icon{ width:32px; height:32px; font-size:16px; border-radius:9px }
  .header-actions{
    flex:1 1 100%; order:3; justify-content:space-between; gap:8px;
    padding-top:6px; border-top:1px solid rgba(36,54,95,.5);
  }
  .badge{
    flex:1; justify-content:center; text-align:center;
    font-size:12px; padding:8px 12px; font-weight:700;
  }
  .badge-text{ white-space:nowrap }
  .icon-btn{ width:38px; height:38px; font-size:16px }
}
@media (max-width: 360px){
  .badge{ font-size:11px; padding:7px 10px }
  .brand h1{ font-size:14px }
}

/* Main */
.main{
  max-width:1100px; margin:0 auto; padding:20px 16px 60px;
  display:grid; gap:18px;
}
.card{
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)), var(--bg-card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding:18px;
}
.card-header{
  display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px;
}
.card-title{
  font-size:14px; font-weight:700; letter-spacing:-.01em; display:flex; align-items:center; gap:8px;
}
.card-title span{opacity:.9}
.step-num{
  width:26px; height:26px; border-radius:999px; background: var(--bg-soft); border:1px solid var(--border);
  display:grid; place-items:center; font-size:12px; font-weight:700; color:var(--text-muted);
}
.muted{color:var(--text-muted); font-size:13px}
.grid-2{ display:grid; gap:14px; }
@media(min-width:860px){ .grid-2{grid-template-columns: 1.1fr .9fr} }

/* Dropzone */
.dropzone{
  border:2px dashed #2a3f78; border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(91,124,255,.06), transparent);
  padding:28px 18px; text-align:center; cursor:pointer;
  transition:.2s; position:relative; overflow:hidden;
}
.dropzone:hover{border-color: var(--primary); background: rgba(91,124,255,.08); transform: translateY(-1px)}
.dropzone.dragover{border-color: var(--accent); background: rgba(0,229,204,.08); box-shadow: 0 0 0 4px rgba(0,229,204,.15)}
.drop-icon{width:54px; height:54px; margin:0 auto 10px; border-radius:16px; background: var(--bg-soft); border:1px solid var(--border); display:grid; place-items:center; font-size:24px}
.dropzone h3{margin:6px 0 4px; font-size:16px}
.dropzone p{margin:0; color:var(--text-muted); font-size:13px}
.file-meta{
  margin-top:12px; display:flex; flex-wrap:wrap; gap:8px; justify-content:center;
}
.pill{
  font-size:12px; padding:6px 10px; border-radius:999px; background: var(--bg-soft); border:1px solid var(--border); color:var(--text-muted);
}
.btn{
  appearance:none; border:0; cursor:pointer; font-weight:600;
  padding:10px 16px; border-radius:12px; font-size:14px;
  transition:.2s; display:inline-flex; align-items:center; gap:8px; justify-content:center;
}
.btn-primary{
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color:white; box-shadow: 0 6px 18px rgba(91,124,255,.35);
}
.btn-primary:hover{transform:translateY(-1px); filter:brightness(1.05)}
.btn-primary:disabled{opacity:.5; cursor:not-allowed; transform:none}
.btn-ghost{
  background: var(--bg-soft); border:1px solid var(--border); color:var(--text);
}
.btn-ghost:hover{background:var(--bg-elev)}
.btn-small{padding:7px 12px; font-size:12px; border-radius:10px}
.btn-wide{width:100%}

/* Task selector */
.task-grid{ display:grid; grid-template-columns: repeat(3,1fr); gap:10px; }
.task-card{
  padding:14px 10px; border-radius:14px; background: var(--bg-soft); border:1px solid var(--border);
  cursor:pointer; text-align:center; transition:.2s;
}
.task-card:hover{border-color:#2f4a8a; transform: translateY(-1px)}
.task-card.active{border-color: var(--primary); background: linear-gradient(180deg, rgba(91,124,255,.18), rgba(91,124,255,.06)); box-shadow: 0 6px 18px rgba(91,124,255,.18)}
.task-card .emoji{font-size:20px}
.task-card b{display:block; font-size:13px; margin:4px 0 2px}
.task-card span{font-size:11px; color:var(--text-muted); line-height:1.3; display:block}

/* Progress */
.progress-wrap{ display:grid; gap:10px }
.progress-item{ display:flex; justify-content:space-between; align-items:center; padding:10px 12px; background: var(--bg-soft); border:1px solid var(--border); border-radius:12px; font-size:13px }
.progress-bar{height:6px; background: #0f1c3a; border-radius:999px; overflow:hidden; flex:1; margin:0 12px}
.progress-fill{height:100%; background: linear-gradient(90deg, var(--primary), var(--accent)); width:0%; transition:.3s}

/* Chunk list */
.chunk-list{ display:grid; gap:10px; max-height:420px; overflow:auto; padding-right:4px }
.chunk-item{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:12px 14px; border-radius:14px; background: var(--bg-soft); border:1px solid var(--border);
  transition:.2s; font-size:13px;
}
.chunk-item.done{border-color: rgba(0,211,138,.35); background: linear-gradient(90deg, rgba(0,211,138,.12), rgba(0,211,138,.02))}
.chunk-item.processing{border-color: rgba(91,124,255,.45); background: linear-gradient(90deg, rgba(91,124,255,.12), transparent)}
.chunk-item.retrying{border-color: rgba(255,176,46,.4); background: rgba(255,176,46,.06)}
.chunk-item.error{border-color: rgba(255,84,112,.5); background: rgba(255,84,112,.07)}
.chunk-badge{font-weight:700; font-size:12px; background: #0f1c3a; border:1px solid var(--border); padding:4px 8px; border-radius:999px}
.chunk-time{color:var(--text-muted); font-size:12px; margin-top:2px}
.chunk-dur{opacity:.8}
.chunk-status{font-weight:600; display:flex; align-items:center; gap:6px}
.spinner{
  width:14px; height:14px; border:2px solid rgba(255,255,255,.2); border-top-color: var(--primary);
  border-radius:999px; animation: spin .8s linear infinite; display:inline-block;
}
@keyframes spin{to{transform:rotate(360deg)}}
.empty{padding:22px; text-align:center; color:var(--text-muted); background: var(--bg-soft); border:1px dashed var(--border); border-radius:14px}

/* Result */
.result-actions{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px }
.result-box{
  background: #0a1020; border:1px solid var(--border); border-radius:14px; padding:16px;
  min-height:160px; max-height:520px; overflow:auto; font-size:14px; line-height:1.7;
}
.result-box h1,.result-box h2,.result-box h3{margin:14px 0 6px; line-height:1.2}
.result-box h1{font-size:20px} .result-box h2{font-size:16px} .result-box h3{font-size:14px}
.result-box ul{padding-left:18px} .result-box li{margin:4px 0}
.result-box strong{color:#fff; background: rgba(91,124,255,.15); padding:0 3px; border-radius:4px}
.result-box hr{border:0; border-top:1px solid var(--border); margin:14px 0}
.result-placeholder{color:var(--text-muted); text-align:center; padding:40px 10px}
.result-placeholder .big{font-size:28px; margin-bottom:8px}

/* Footer */
.footer{max-width:1100px; margin:0 auto; padding:18px 16px 30px; color:var(--text-muted); font-size:12px; text-align:center; border-top:1px solid rgba(36,54,95,.5)}


/* Scrollbar */
::-webkit-scrollbar{width:8px; height:8px}
::-webkit-scrollbar-thumb{background:#223562; border-radius:999px}
::-webkit-scrollbar-track{background:transparent}
