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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --text: #eee;
  --text2: #aaa;
  --ok: #4ecca3;
  --warn: #f0a500;
  --err: #e94560;
  --radius: 8px;
}

body {
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

header {
  text-align: center;
  padding: 16px 0 8px;
}
header h1 {
  font-size: 1.4em;
  font-weight: 700;
}

section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
section h2 {
  font-size: 1em;
  color: var(--text2);
  margin-bottom: 10px;
  border-bottom: 1px solid var(--surface2);
  padding-bottom: 6px;
}

/* 入力 */
.input-row {
  display: flex;
  gap: 8px;
}
.input-row input[type="text"],
.input-row input[type="number"] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.input-row input:focus {
  border-color: var(--accent);
}
.input-row button {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.input-row button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.input-row button:active:not(:disabled) {
  transform: scale(0.97);
}

.options-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 10px;
  font-size: 0.9em;
  color: var(--text2);
}
.options-row label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.options-row input[type="number"] {
  width: 56px;
  padding: 4px 8px;
  border: 1px solid var(--surface2);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  text-align: center;
}
.options-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
}

/* ログエリア */
#log-area, #mix-log-area {
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.82em;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text2);
  line-height: 1.5;
  padding: 4px 0;
}
.log-line {
  padding: 1px 0;
  word-break: break-all;
}

/* プログレスバー */
#progress-bar-wrap, #mix-progress-wrap {
  position: relative;
  height: 24px;
  background: var(--bg);
  border-radius: 12px;
  margin-top: 10px;
  overflow: hidden;
}
#progress-bar, #mix-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  border-radius: 12px;
  width: 0%;
  transition: width 0.3s ease;
}
#progress-text, #mix-progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75em;
  font-weight: 600;
  color: var(--text);
}

/* 検索結果リスト */
#results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.88em;
}
.result-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border-radius: 50%;
  font-size: 0.75em;
  font-weight: 700;
  color: var(--text2);
}
.result-body {
  flex: 1;
  min-width: 0;
}
.result-title {
  line-height: 1.4;
  word-break: break-word;
}
.result-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-ok { background: var(--ok); color: var(--bg); }
.badge-warn { background: var(--warn); color: var(--bg); }
.badge-err { background: var(--err); color: #fff; }
.result-doi {
  font-size: 0.72em;
  color: var(--text2);
  text-decoration: none;
  border-bottom: 1px dashed var(--text2);
}
.result-doi:hover { color: var(--text); }
.result-action {
  flex-shrink: 0;
  align-self: center;
}
.btn-dl {
  display: inline-block;
  padding: 6px 14px;
  background: var(--ok);
  color: var(--bg);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.8em;
  white-space: nowrap;
}
.btn-dl:active { transform: scale(0.95); }
.result-note {
  font-size: 0.75em;
  color: var(--text2);
}

/* EPUB DL */
#epub-download {
  text-align: center;
  margin-top: 12px;
}
.btn-download {
  display: inline-block;
  padding: 12px 28px;
  background: var(--ok);
  color: var(--bg);
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 700;
  font-size: 1em;
}

/* ユーティリティ */
.hidden { display: none !important; }

/* スクロールバー */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 2px; }
