@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --bg:           #080810;
  --bg-2:         #0e0e1a;
  --surface:      rgba(255,255,255,.04);
  --surface-hover:rgba(255,255,255,.07);
  --border:       rgba(255,255,255,.08);
  --border-hover: rgba(255,255,255,.15);
  --text:         #ededf0;
  --text-muted:   #6b6b80;
  --text-sub:     #9393a8;
  --accent-1:     #6366f1;
  --accent-2:     #a855f7;
  --accent-grad:  linear-gradient(135deg, #6366f1, #a855f7);
  --accent-glow:  rgba(99,102,241,.35);
  --success:      #22c55e;
  --success-bg:   rgba(34,197,94,.1);
  --success-border:rgba(34,197,94,.25);
  --error:        #ef4444;
  --error-bg:     rgba(239,68,68,.1);
  --warn-bg:      rgba(234,179,8,.1);
  --warn-border:  rgba(234,179,8,.3);
  --warn-text:    #ca8a04;
  --radius-sm:    8px;
  --radius:       16px;
  --radius-lg:    22px;
}

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 40px 16px 80px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(99,102,241,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.app {
  max-width: 680px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ---- Header ---- */
header {
  text-align: center;
  margin-bottom: 36px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: var(--accent-grad);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 24px var(--accent-glow);
}

.logo-text {
  font-size: 1.5rem;
  color: var(--text);
  letter-spacing: -.02em;
}

.logo-text strong {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-muted);
  font-size: .9rem;
}

/* ---- Step indicator ---- */
.steps-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all .3s;
  position: relative;
  z-index: 1;
}

.step-dot.active {
  border-color: var(--accent-1);
  background: rgba(99,102,241,.15);
  color: #a5b4fc;
  box-shadow: 0 0 12px rgba(99,102,241,.3);
}

.step-dot.done {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.step-line {
  flex: 1;
  max-width: 80px;
  height: 1.5px;
  background: var(--border);
  transition: background .3s;
}

.step-line.done { background: var(--accent-1); opacity: .5; }

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity .25s, transform .25s;
}

.card.hidden { display: none !important; }

.card-header {
  margin-bottom: 24px;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -.01em;
  margin-bottom: 4px;
}

.card-desc {
  font-size: .85rem;
  color: var(--text-muted);
}

/* ---- Compat warning ---- */
.compat-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: .875rem;
  color: var(--warn-text);
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  z-index: 1;
}

/* ---- Folder picker ---- */
.folder-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 24px;
}

.folder-pick { flex: 1; }

.folder-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 2px;
}

.folder-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: all .2s;
  text-align: left;
}

.folder-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.folder-btn.selected {
  border-color: rgba(99,102,241,.4);
  background: rgba(99,102,241,.07);
}

.folder-btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.source-icon { background: rgba(99,102,241,.15); color: #a5b4fc; }
.dest-icon   { background: rgba(168,85,247,.15);  color: #d8b4fe; }

.folder-btn-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder-btn-title {
  font-size: .9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-btn-sub {
  font-size: .75rem;
  color: var(--text-muted);
}

.folder-btn-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform .2s;
}

.folder-btn:hover .folder-btn-arrow { transform: translateX(2px); }

.folder-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  padding-top: 28px;
  gap: 4px;
}

.connector-line {
  flex: 1;
  max-height: 16px;
  width: 1px;
  background: var(--border);
}

.connector-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: .7rem;
  flex-shrink: 0;
}

/* ---- Mode toggle ---- */
.mode-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.mode-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  white-space: nowrap;
}

.mode-toggle {
  display: flex;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
}

.mode-btn.active {
  background: rgba(99,102,241,.2);
  color: #a5b4fc;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.mode-btn:not(.active):hover { color: var(--text); }

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent-grad);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(99,102,241,.3);
  letter-spacing: -.01em;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(99,102,241,.45);
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
}

/* ---- Scan progress ---- */
.scan-progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.scan-bar-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,.06);
  border-radius: 99px;
  overflow: visible;
  position: relative;
}

.scan-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent-grad);
  width: 0%;
  transition: width .4s cubic-bezier(.4,0,.2,1);
  position: relative;
}

.scan-bar-fill::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #a5b4fc;
  box-shadow: 0 0 8px #6366f1;
  opacity: 0;
  transition: opacity .3s;
}

.scan-bar-fill[style*="width: 0%"]::after { opacity: 0; }
.scan-bar-fill:not([style*="width: 0%"])::after { opacity: 1; }

.scan-bar-label {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.scan-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scan-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .85rem;
  color: var(--text-muted);
  transition: color .3s;
}

.scan-step.active { color: var(--text); }
.scan-step.done   { color: var(--success); }

.scan-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  flex-shrink: 0;
  transition: all .3s;
}

.scan-step.active .scan-step-dot {
  background: var(--accent-1);
  box-shadow: 0 0 8px var(--accent-1);
  animation: pulse 1.2s ease-in-out infinite;
}

.scan-step.done .scan-step-dot {
  background: var(--success);
  box-shadow: none;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .6; transform: scale(.8); }
}

/* ---- Preview ---- */
.preview-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .8rem;
  color: var(--text-muted);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  margin-bottom: 20px;
}

.cluster-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.year-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  padding: 10px 4px 5px;
}

.cluster-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color .15s, background .15s;
}

.cluster-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.cluster-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  filter: saturate(.8) brightness(.85);
}

.cluster-info { flex: 1; min-width: 0; }

.cluster-path {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 3px;
}

.cluster-month {
  font-size: .85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.cluster-name {
  background: transparent;
  border: none;
  border-bottom: 1px dashed rgba(99,102,241,.5);
  color: #a5b4fc;
  font-size: .875rem;
  font-weight: 600;
  cursor: text;
  padding: 0 3px 1px;
  outline: none;
  font-family: inherit;
  max-width: 240px;
  transition: border-color .15s, background .15s;
  border-radius: 3px 3px 0 0;
}

.cluster-name:focus {
  border-bottom-color: var(--accent-1);
  background: rgba(99,102,241,.1);
}

.no-event-badge {
  font-size: .73rem;
  color: var(--text-muted);
  background: rgba(255,255,255,.06);
  border-radius: 5px;
  padding: 1px 7px;
}

.existing-badge {
  font-size: .72rem;
  color: #4ade80;
  background: rgba(74,222,128,.1);
  border: 1px solid rgba(74,222,128,.2);
  border-radius: 5px;
  padding: 1px 7px;
  white-space: nowrap;
}

.cluster-meta {
  font-size: .77rem;
  color: var(--text-muted);
}

.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ---- Execute progress ---- */
.exec-progress-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.exec-bar-track {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,.06);
  border-radius: 99px;
  overflow: hidden;
}

.exec-bar-fill {
  height: 100%;
  background: var(--accent-grad);
  border-radius: 99px;
  width: 0%;
  transition: width .35s cubic-bezier(.4,0,.2,1);
}

.exec-bar-label {
  font-size: .85rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- Done ---- */
.done-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0 8px;
  text-align: center;
}

.done-ring {
  position: relative;
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
}

.done-ring svg {
  width: 80px;
  height: 80px;
}

.done-circle {
  transform-origin: center;
  transform: rotate(-90deg);
  animation: draw-circle .6s cubic-bezier(.4,0,.2,1) forwards;
  stroke-dashoffset: 176;
}

@keyframes draw-circle {
  to { stroke-dashoffset: 0; }
}

.done-check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pop-in .35s .5s cubic-bezier(.34,1.56,.64,1) both;
}

@keyframes pop-in {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.done-wrap h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.done-summary {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 24px;
}

.error-list {
  background: var(--error-bg);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: .82rem;
  color: #fca5a5;
  text-align: left;
  max-height: 180px;
  overflow-y: auto;
  width: 100%;
}

.error-list ul { padding-left: 16px; margin-top: 5px; }
.error-list li { margin-bottom: 3px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: .78rem; }
