/* ============================================
   音声正規化ツール - Style
   SiteTop design system + CcfoliaAudioTool theme
   ============================================ */

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

:root {
  /* SiteTop base */
  --bg: #0c0f16;
  --card: rgba(16, 20, 30, 0.82);
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --muted: #64748b;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --input-bg: rgba(0, 0, 0, 0.30);
  --input-border: rgba(255, 255, 255, 0.08);
  --danger: #ef4444;
  --radius: 14px;
  --radius-lg: 20px;
  --tr: 0.18s ease;

  /* Audio tool specific */
  --accent-bgm: #7c6cff;
  --accent-bgm-light: #9d90ff;
  --accent-bgm-glow: rgba(124, 108, 255, 0.25);
  --accent-bgm-gradient: linear-gradient(135deg, #6c5ce7, #7c6cff, #a29bfe);
  --accent-se: #f0923b;
  --accent-se-light: #f5ad6e;
  --accent-se-glow: rgba(240, 146, 59, 0.25);
  --accent-se-gradient: linear-gradient(135deg, #e17055, #f0923b, #fdcb6e);
  --accent-balanced: #00cec9;

  --bg-card: #1a1e28;
  --bg-card-hover: #1f2432;
  --bg-elevated: #232838;
  --bg-input: #12151c;

  --font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html { scrollbar-gutter: stable; overflow-y: scroll; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(124, 108, 255, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(240, 146, 59, 0.04) 0%, transparent 60%);
}

input[type="radio"],
input[type="checkbox"] { accent-color: var(--accent-bgm); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ── Site Bar ── */
.site-bar {
  background: rgba(8, 10, 16, 0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100;
  font-size: 14px; line-height: 1.4;
  /* 他ページとブランド文字幅を揃えるため font-family を明示（body の Noto Sans JP を継承させない） */
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.site-bar__inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.site-bar__brand {
  font-weight: 800; font-size: 16px; color: var(--text); text-decoration: none;
  letter-spacing: 0.04em;
}
.site-bar__right { display: flex; align-items: center; gap: 14px; }
.site-bar__user {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary);
}
.site-bar__avatar { border-radius: 50%; vertical-align: middle; }
.site-bar__link {
  font-size: 13px; color: var(--muted); text-decoration: none; transition: color 0.15s;
}
.site-bar__link:hover { color: var(--text); }
.site-bar__login {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; background: #5865F2; color: #fff; border-radius: 8px;
  font-size: 13px; font-weight: 600; text-decoration: none; transition: background 0.15s;
}
.site-bar__login:hover { background: #4752c4; }

/* ── Range (global) ── */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 4px; background: rgba(255,255,255,0.08);
  border: none; border-radius: 2px; outline: none; padding: 0; vertical-align: middle;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-bgm); border: 2px solid rgba(255,255,255,0.2); cursor: pointer;
}
input[type="range"]::-moz-range-track {
  height: 4px; background: rgba(255,255,255,0.08); border: none; border-radius: 2px;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-bgm); border: 2px solid rgba(255,255,255,0.2); cursor: pointer;
}

/* ── Layout ── */
.tool-page { max-width: 1100px; margin: 0 auto; padding: 32px 16px 80px; }

.tool-header { margin-bottom: 24px; }
.tool-header__row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tool-header h1 {
  margin: 0 0 8px; font-size: 32px; font-weight: 800; letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent-bgm-light), var(--text));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.tool-header__row .api-status { margin-bottom: 8px; }
.tool-header p { margin: 0; color: var(--muted); font-size: 15px; }

/* ── Cards ── */
.tool-card {
  background: var(--card); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; margin-bottom: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25); transition: border-color var(--tr);
}
.tool-card:hover { border-color: var(--border-hover); }
.tool-card h2 { margin: 0 0 16px; font-size: 17px; font-weight: 700; color: var(--text-secondary); }

/* ── Help Section ── */
.help-section { cursor: default; }
.help-toggle {
  cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--text-secondary);
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.help-toggle::-webkit-details-marker { display: none; }
.help-toggle::before { content: '▶'; font-size: 0.7rem; transition: transform 0.2s; }
details[open] .help-toggle::before { transform: rotate(90deg); }
.help-body { margin-top: 16px; font-size: 0.85rem; line-height: 1.7; color: var(--text-secondary); }
.help-body h3 {
  font-size: 0.9rem; font-weight: 600; color: var(--text); margin: 20px 0 8px;
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.help-body h3:first-child { margin-top: 0; }
.help-body ol { padding-left: 20px; margin: 0 0 8px; }
.help-body ol li { margin-bottom: 4px; }
.help-body p { margin: 0 0 8px; }
.help-terms { margin: 0 0 8px; }
.help-terms dt {
  font-weight: 600; color: var(--accent-bgm-light); font-size: 0.85rem; margin-top: 8px;
}
.help-terms dd { margin: 2px 0 0 16px; color: var(--text-secondary); }
.help-note {
  margin-top: 12px; padding: 8px 12px; border-radius: 6px;
  background: rgba(240, 146, 59, 0.08); border: 1px solid rgba(240, 146, 59, 0.2);
  color: var(--accent-se-light); font-size: 0.8rem;
}

/* ── API Status ── */
.api-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; color: var(--muted);
  padding: 4px 12px; margin-bottom: 16px;
  background: var(--bg-card); border-radius: 6px; border: 1px solid var(--border);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #f39c12; transition: background 0.25s; box-shadow: 0 0 6px currentColor;
}
.api-status.ok .status-dot { background: #2ecc71; }
.api-status.error .status-dot { background: #e74c3c; }

/* ── Guest Banner ── */
.guest-banner {
  background: rgba(240, 146, 59, 0.08); border: 1px solid rgba(240, 146, 59, 0.2);
  border-radius: 10px; padding: 12px 18px; margin-bottom: 16px;
  font-size: 0.85rem; color: var(--accent-se-light);
}
.guest-banner a { color: var(--accent-bgm-light); font-weight: 600; }

/* ── Global Standard Bar ── */
.global-standard-bar {
  display: flex; gap: 24px; padding: 8px 24px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 14px; flex-wrap: wrap; align-items: center;
}
.standard-item { display: flex; align-items: center; gap: 6px; }
.standard-label {
  font-size: 0.7rem; color: var(--muted); text-transform: uppercase;
  font-weight: 600; letter-spacing: 0.5px;
}
.standard-value {
  font-size: 0.85rem; font-weight: 700; font-family: var(--font-mono);
  color: var(--accent-bgm-light);
}
.standard-playback .standard-value { color: var(--text-secondary); font-weight: 500; }

/* ── Drop Zone ── */
.dropzone {
  border: 2px dashed var(--border-hover); border-radius: var(--radius-lg);
  padding: 48px 32px; text-align: center; cursor: pointer;
  transition: all 0.25s; position: relative; overflow: hidden;
  background: rgba(21, 24, 32, 0.5);
}
.dropzone::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(124, 108, 255, 0.05) 0%, transparent 70%);
  opacity: 0; transition: opacity 0.25s;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--accent-bgm); background: var(--bg-card); }
.dropzone:hover::before, .dropzone.drag-over::before { opacity: 1; }
.dropzone.drag-over { box-shadow: 0 0 20px rgba(124, 108, 255, 0.15), inset 0 0 40px rgba(124, 108, 255, 0.05); }
.dropzone__icon { color: var(--muted); margin-bottom: 16px; transition: color 0.25s, transform 0.25s; }
.dropzone:hover .dropzone__icon, .dropzone.drag-over .dropzone__icon { color: var(--accent-bgm); transform: translateY(-4px); }
.dropzone__title { font-size: 1.15rem; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.dropzone__sub { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.dropzone__hint { font-size: 0.75rem; color: var(--muted); margin-top: 8px; }

/* ── Section Header ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.section-header h2 { margin: 0; font-size: 1.1rem; font-weight: 600; color: var(--text-secondary); }
.section-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 6px; font-size: 0.85rem;
  font-weight: 500; font-family: var(--font-family); cursor: pointer;
  transition: all 0.15s; border: none; white-space: nowrap;
}
.btn-primary { background: var(--accent-bgm-gradient); color: white; }
.btn-primary:hover { box-shadow: 0 0 20px rgba(124, 108, 255, 0.15); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hover); background: var(--bg-elevated); }
.btn-xs { padding: 2px 8px; font-size: 0.7rem; }

/* ── Track List ── */
.track-list { display: flex; flex-direction: column; gap: 12px; }

/* ── Track Card ── */
.track-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; transition: all 0.25s; position: relative;
}
.track-card:hover { border-color: var(--border-hover); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.track-card[data-type="bgm"] { border-left: 3px solid var(--accent-bgm); }
.track-card[data-type="se"]  { border-left: 3px solid var(--accent-se); }

.track-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 8px; gap: 12px;
}
.track-info { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; }
.track-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-duration { font-size: 0.75rem; color: var(--muted); font-family: var(--font-mono); flex-shrink: 0; }
.track-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Type Toggle */
.type-toggle {
  display: flex; background: var(--bg-input); border-radius: 6px;
  overflow: hidden; border: 1px solid var(--border);
}
.type-btn {
  padding: 3px 12px; font-size: 0.75rem; font-weight: 600; font-family: var(--font-family);
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  transition: all 0.15s;
}
.type-btn.active[data-type="bgm"] { background: var(--accent-bgm); color: white; }
.type-btn.active[data-type="se"]  { background: var(--accent-se); color: white; }

.btn-play, .btn-remove {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-secondary);
  border-radius: 6px; cursor: pointer; transition: all 0.15s;
}
.btn-play:hover { color: var(--accent-bgm-light); background: var(--bg-elevated); }
.btn-play.playing { color: var(--accent-se); }
.btn-play.playing svg { display: none; }
.btn-play.playing::after { content: '\u23F8'; font-size: 14px; }
.btn-remove:hover { color: #e74c3c; background: rgba(231, 76, 60, 0.1); }

/* Track Body */
.track-card-body { padding: 0 16px 12px; display: flex; align-items: center; gap: 16px; }
.waveform-canvas { flex: 1; height: 60px; border-radius: 6px; background: var(--bg-input); }
.track-metrics { display: flex; gap: 16px; flex-shrink: 0; }
.metric { display: flex; flex-direction: column; align-items: center; min-width: 65px; }
.metric-label {
  font-size: 0.65rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: 500;
}
.metric-value { font-size: 1.15rem; font-weight: 700; font-family: var(--font-mono); line-height: 1.3; }
.metric-unit { font-size: 0.65rem; color: var(--muted); }
.metric-highlight { background: rgba(124, 108, 255, 0.08); border-radius: 6px; padding: 2px 6px; }

/* ── Shaping Section ── */
.shaping-section { padding: 4px 16px 8px; border-top: 1px solid var(--border); }
.shaping-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shaping-radios { display: flex; gap: 2px; background: var(--bg-input); border-radius: 6px; padding: 2px; }
.shaping-radio {
  display: flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 4px;
  cursor: pointer; font-size: 0.75rem; font-weight: 500; color: var(--muted);
  transition: all 0.15s; user-select: none;
}
.shaping-radio:hover { color: var(--text); }
.shaping-radio input[type="radio"] { display: none; }
.shaping-radio:has(input:checked) { background: var(--accent-bgm); color: #fff; font-weight: 600; }

.recommended-badge {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 4px;
  background: rgba(0, 206, 201, 0.12); color: var(--accent-balanced);
  font-weight: 600; border: 1px solid rgba(0, 206, 201, 0.2);
}

/* Detail Panel */
.shaping-detail {
  margin-top: 8px; padding: 8px; background: var(--bg-input); border-radius: 6px;
}
.detail-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.detail-row label {
  width: 40px; font-size: 0.7rem; font-weight: 600; color: var(--muted);
  font-family: var(--font-mono);
}
.detail-slider { flex: 1; }
.detail-value {
  width: 30px; text-align: right; font-size: 0.75rem;
  font-family: var(--font-mono); font-weight: 600; color: var(--accent-bgm-light);
}

/* ── Warning Badges ── */
.track-warnings { padding: 4px 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.warning-badge {
  display: inline-block; font-size: 0.7rem; font-weight: 600;
  padding: 3px 8px; border-radius: 4px; line-height: 1.4;
}
.warning-badge.warning { background: rgba(241, 196, 15, 0.12); color: #f1c40f; border: 1px solid rgba(241, 196, 15, 0.2); }
.warning-badge.danger { background: rgba(231, 76, 60, 0.12); color: #e74c3c; border: 1px solid rgba(231, 76, 60, 0.2); }
.warning-badge.info { background: rgba(52, 152, 219, 0.12); color: #3498db; border: 1px solid rgba(52, 152, 219, 0.2); }

/* ── Loading ── */
.track-loading {
  position: absolute; inset: 0; background: rgba(13, 15, 20, 0.85);
  align-items: center; justify-content: center; gap: 8px;
  color: var(--text-secondary); font-size: 0.85rem; backdrop-filter: blur(4px); z-index: 10;
  display: none;
}
.track-loading:not([hidden]) {
  display: flex;
}
.loading-spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--accent-bgm); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Track Normalize Progress ── */
.track-normalize-progress { padding: 4px 16px 8px; }
.track-progress-text { font-size: 0.7rem; color: var(--muted); font-family: var(--font-mono); }

/* ── Download Link ── */
.track-download-link {
  display: block; padding: 6px 16px; font-size: 0.8rem;
  color: var(--accent-bgm-light); text-decoration: none; font-weight: 500;
}
.track-download-link:hover { text-decoration: underline; }

/* ── Balance Chart ── */
.balance-chart-container {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px;
}
.chart-header { display: flex; gap: 24px; margin-bottom: 12px; font-size: 0.8rem; font-weight: 500; }
.chart-label-bgm { color: var(--accent-bgm-light); }
.chart-label-se { color: var(--accent-se-light); }
.balance-chart { display: flex; flex-direction: column; gap: 8px; }

.chart-row { display: grid; grid-template-columns: 180px 1fr 60px 50px; gap: 12px; align-items: center; padding: 4px 0; }
.chart-track-name { font-size: 0.8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-bar-container {
  position: relative; height: 24px; background: var(--bg-input);
  border-radius: 6px; overflow: hidden;
}
.chart-bar { height: 100%; border-radius: 6px; transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.chart-bar.bgm { background: var(--accent-bgm-gradient); box-shadow: 0 0 20px rgba(124, 108, 255, 0.15); }
.chart-bar.se { background: var(--accent-se-gradient); box-shadow: 0 0 20px rgba(240, 146, 59, 0.15); }
.chart-vol { font-size: 0.9rem; font-weight: 700; font-family: var(--font-mono); text-align: right; }
.chart-vol.bgm { color: var(--accent-bgm-light); }
.chart-vol.se { color: var(--accent-se-light); }
.chart-type-badge { font-size: 0.65rem; font-weight: 600; padding: 1px 6px; border-radius: 6px; text-align: center; }
.chart-type-badge.bgm { background: rgba(124, 108, 255, 0.15); color: var(--accent-bgm-light); }
.chart-type-badge.se { background: rgba(240, 146, 59, 0.15); color: var(--accent-se-light); }

/* ── Normalize Section ── */
.normalize-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 20px; margin-top: 14px;
}
.normalize-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.normalize-actions { display: flex; gap: 8px; align-items: center; }

.bitrate-selector { display: flex; align-items: center; gap: 4px; }
.bitrate-option {
  display: flex; align-items: center; gap: 3px; padding: 4px 10px; border-radius: 4px;
  cursor: pointer; font-size: 0.75rem; font-weight: 500; color: var(--muted);
  background: var(--bg-input); transition: all 0.15s; user-select: none;
}
.bitrate-option input[type="radio"] { display: none; }
.bitrate-option:has(input:checked) { background: var(--accent-bgm); color: #fff; font-weight: 600; }
.bitrate-hint { font-size: 0.65rem; color: var(--muted); margin-left: 4px; }

/* ── Progress Bar ── */
.normalize-progress-section { margin-top: 8px; }
.progress-bar-container {
  width: 100%; height: 6px; background: var(--bg-input);
  border-radius: 3px; overflow: hidden; margin-bottom: 4px;
}
.progress-bar {
  height: 100%; background: var(--accent-bgm-gradient);
  border-radius: 3px; transition: width 0.25s; width: 0%;
}
.progress-text { font-size: 0.75rem; color: var(--muted); font-family: var(--font-mono); }

/* ── Copy Feedback ── */
.copy-feedback {
  font-size: 0.8rem; color: var(--accent-balanced); margin-top: 4px;
  min-height: 0;
}
.copy-feedback:not(:empty) { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

/* ── Normalize File List ── */
.normalize-file-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.normalize-file-row {
  display: grid; grid-template-columns: 1fr 120px 100px; gap: 10px;
  align-items: center; font-size: 0.8rem; padding: 4px 0;
}
.nf-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.nf-progress { min-width: 0; }
.nf-status { text-align: right; color: var(--muted); font-size: 0.75rem; }
.nf-download { color: var(--accent-bgm-light); text-decoration: none; font-weight: 500; cursor: pointer; }
.nf-download:hover { text-decoration: underline; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated); color: var(--text);
  padding: 8px 24px; border-radius: 10px; font-size: 0.85rem;
  border: 1px solid var(--border); box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  opacity: 0; transition: all 0.25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .tool-page { padding: 16px; }
  .track-card-body { flex-direction: column; }
  .waveform-canvas { width: 100%; }
  .track-metrics { width: 100%; justify-content: space-around; }
  .chart-row { grid-template-columns: 120px 1fr 50px 40px; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .normalize-controls { flex-direction: column; align-items: flex-start; }
  .global-standard-bar { gap: 12px; padding: 8px 16px; }
}
