:root {
  --bg: #15101f;
  --bg-2: #231836;
  --accent: #ff5fa2;
  --accent-2: #ff9a5f;
  --accent-3: #7c5cff;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.12);
  --text: #ffffff;
  --muted: #c1b5d8;
  --radius: 24px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --glow: 0 0 30px rgba(255, 95, 162, 0.2);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 80% 0%, rgba(255, 95, 162, 0.18), transparent 45%),
    radial-gradient(circle at 10% 60%, rgba(124, 92, 255, 0.14), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(255, 154, 95, 0.12), transparent 45%),
    linear-gradient(180deg, #15101f 0%, #1e1430 100%);
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 18px 130px;
}

.header {
  text-align: center;
  margin-bottom: 32px;
}

.badge {
  display: inline-block;
  background: var(--surface-2);
  color: var(--accent-2);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 50px;
  margin-bottom: 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.header h1 {
  font-size: 40px;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.03em;
  text-shadow: 0 4px 20px rgba(255, 95, 162, 0.25);
}

.sub {
  color: var(--muted);
  font-size: 16px;
  margin: 0;
}

.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline-line {
  position: absolute;
  left: 12px;
  top: 20px;
  bottom: 20px;
  width: 5px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--accent-3), var(--accent), var(--accent-2));
  opacity: 0.7;
}

.timeline-item {
  position: relative;
  margin-bottom: 14px;
}

.timeline-dot {
  position: absolute;
  left: -25px;
  top: 20px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.25);
  transition: all 0.2s ease;
  z-index: 2;
}

.timeline-dot.active {
  background: var(--accent);
  border-color: #fff;
  box-shadow: 0 0 14px var(--accent);
  transform: scale(1.15);
}

.timeline-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 15px 17px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.timeline-card:hover {
  transform: translateX(3px);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: var(--shadow);
}

.timeline-card.open {
  border-color: rgba(255, 95, 162, 0.45);
  box-shadow: var(--glow);
}

.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.timeline-time {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

.timeline-bar-wrap {
  flex: 1;
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  max-width: 180px;
}

.timeline-bar {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent-3), var(--accent), var(--accent-2));
  transition: width 0.4s ease;
  box-shadow: 0 0 8px rgba(255, 95, 162, 0.25);
}

.timeline-count {
  font-size: 13px;
  color: var(--muted);
  min-width: 70px;
  text-align: right;
}

.timeline-names {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.timeline-card.open .timeline-names {
  display: block;
}

.timeline-names ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-names li {
  font-size: 14px;
  padding: 4px 0;
  color: #ede6ff;
}

.timeline-names li span {
  color: var(--accent-2);
  font-weight: 600;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

.loading,
.error-main {
  text-align: center;
  color: var(--muted);
  padding: 50px 0;
  font-size: 16px;
}

.fab {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 10;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 18px 36px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow), 0 0 24px rgba(255, 95, 162, 0.35);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.fab:hover {
  box-shadow: var(--shadow), 0 0 36px rgba(255, 95, 162, 0.55);
}

.fab:active {
  transform: translateX(-50%) scale(0.96);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #25163d, #15101f);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px 28px 0 0;
  padding: 26px 22px 32px;
  transform: translateY(30px);
  transition: transform 0.25s ease;
  box-shadow: 0 -10px 60px rgba(0, 0, 0, 0.5);
}

.modal[aria-hidden="false"] .modal-card {
  transform: translateY(0);
}

@media (min-width: 560px) {
  .modal { align-items: center; }
  .modal-card {
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.12);
  }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.steps {
  display: flex;
  gap: 8px;
}

.step {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
}

.step.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 0 12px rgba(255, 95, 162, 0.35);
}

.step-content {
  transition: opacity 0.2s ease;
}

.step-content.hidden {
  display: none;
}

.modal-hint {
  color: var(--muted);
  font-size: 15px;
  margin: 0 0 22px;
}

.quick-range {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.quick-range button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.quick-range button:hover,
.quick-range button.active {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-color: transparent;
  box-shadow: 0 0 16px rgba(255, 95, 162, 0.3);
}

.range-pick {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.range-pick label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
}

.range-pick select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  padding: 15px 14px;
  outline: none;
  width: 100%;
}

.range-pick select:focus {
  border-color: var(--accent);
}

.range-arrow {
  font-size: 22px;
  color: var(--accent-2);
  padding-bottom: 14px;
  font-weight: 700;
}

.preview-label {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
}

.preview-timeline {
  display: flex;
  height: 28px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.preview-segment {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
}

.preview-segment:last-child { border-right: none; }
.preview-segment.selected {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.15);
}

.step-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.step-actions .next-btn,
.step-actions .submit {
  flex: 1;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: 0 0 20px rgba(255, 95, 162, 0.25);
}

.step-actions .next-btn:hover,
.step-actions .submit:hover {
  box-shadow: 0 0 30px rgba(255, 95, 162, 0.45);
}

.step-actions .next-btn:active,
.step-actions .submit:active {
  transform: scale(0.98);
}

.step-actions .submit:disabled {
  filter: grayscale(0.6);
  cursor: wait;
  box-shadow: none;
}

.step-actions .back-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.step-actions .back-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.peak-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 26px 20px;
  text-align: center;
  margin-bottom: 18px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.peak-time {
  font-size: 15px;
  color: var(--accent-2);
  font-weight: 700;
  margin-bottom: 8px;
}

.peak-count {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.peak-label {
  font-size: 14px;
  color: var(--muted);
}

.peak-empty {
  font-size: 16px;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 6px;
}

.peak-empty-sub {
  font-size: 14px;
  color: var(--accent-2);
}

.peak-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.peak-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
}

.peak-row-count {
  color: var(--muted);
  font-weight: 600;
}

.fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.fields input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  padding: 16px;
  outline: none;
  transition: border-color 0.15s ease;
}

.fields input:focus {
  border-color: var(--accent);
}

.fields input::placeholder {
  color: #9d8bb8;
}

.error {
  color: #ff8a8a;
  font-size: 14px;
  margin-top: 14px;
  text-align: center;
  min-height: 20px;
}

@media (max-width: 480px) {
  .wrap { padding: 22px 14px 120px; }
  .header h1 { font-size: 32px; }
  .timeline { padding-left: 26px; }
  .timeline-line { left: 8px; }
  .timeline-dot { left: -21px; }
  .timeline-head { flex-wrap: wrap; }
  .timeline-bar-wrap { order: 3; width: 100%; max-width: none; margin-top: 8px; }
  .timeline-count { order: 2; }
  .timeline-time { order: 1; }
  .fab { width: calc(100% - 36px); padding: 16px; font-size: 16px; }
  .range-pick { flex-direction: column; align-items: stretch; }
  .range-arrow { display: none; }
  .range-pick label { width: 100%; }
  .modal-header h2 { font-size: 20px; }
  .peak-count { font-size: 44px; }
  .step-actions { flex-direction: column; }
  .step-actions .back-btn { order: 2; }
}

.chart-label {
  font-size: 13px;
  color: var(--muted);
  margin: 22px 0 10px;
}

.chart-wrap {
  position: relative;
  margin-bottom: 24px;
}

.mini-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 90px;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  overflow-x: auto;
  overflow-y: hidden;
}

.chart-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}

.chart-bar {
  flex: 1 0 20px;
  min-width: 20px;
  border-radius: 8px 8px 4px 4px;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  align-self: flex-end;
}

.chart-bar:hover,
.chart-bar.active {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 16px rgba(255, 95, 162, 0.35);
  transform: translateY(-2px);
}

.chart-bar.peak {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 20px rgba(255, 95, 162, 0.45);
}

.chart-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: rgba(30, 20, 48, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
  z-index: 5;
  box-shadow: var(--shadow);
}

.chart-tooltip.visible {
  opacity: 1;
}

.summary {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

.summary strong {
  color: var(--text);
  font-weight: 600;
}

.controls {
  margin-top: 18px;
  text-align: center;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}
