/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0e0e10;
  --bg2: #161618;
  --bg3: #1e1e22;
  --bg4: #26262c;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.13);
  --border3: rgba(255,255,255,0.2);
  --text: #f2efe9;
  --text2: #9e9890;
  --text3: #5a5650;
  --accent: #6c63ff;
  --accent2: #a78bfa;
  --accent-bg: rgba(108,99,255,0.12);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.1);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.1);
  --amber: #f59e0b;
  --amber-bg: rgba(245,158,11,0.1);
  --radius: 10px;
  --radius-lg: 14px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 40% at 15% 0%, rgba(108,99,255,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 50% 30% at 85% 100%, rgba(167,139,250,0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo { padding: 28px 20px 20px; border-bottom: 0.5px solid var(--border); }
.logo-text { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.logo-text span { color: var(--accent2); }
.logo-sub { font-size: 12px; color: var(--text3); margin-top: 3px; }

.sidebar-section {
  padding: 16px 12px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-list { list-style: none; padding: 0 8px; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  border: 0.5px solid transparent;
  margin-bottom: 2px;
}
.sidebar-item:hover { background: var(--bg3); border-color: var(--border); }
.sidebar-item.active { background: var(--accent-bg); border-color: rgba(108,99,255,0.25); }
.sidebar-item .list-icon { font-size: 16px; flex-shrink: 0; }
.sidebar-item .list-name { flex: 1; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item.active .list-name { color: var(--accent2); }
.sidebar-item .list-pct { font-size: 11px; color: var(--text3); flex-shrink: 0; }
.sidebar-item.active .list-pct { color: var(--accent2); }

.sidebar-footer { margin-top: auto; padding: 12px 8px; border-top: 0.5px solid var(--border); display: flex; flex-direction: column; gap: 6px; }

.btn-new-list {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent-bg);
  border: 0.5px solid rgba(108,99,255,0.3);
  color: var(--accent2);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-new-list:hover { background: rgba(108,99,255,0.2); border-color: rgba(108,99,255,0.5); }

.btn-import-global {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 8px;
  background: transparent;
  border: 0.5px solid var(--border);
  color: var(--text3);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-import-global:hover { border-color: var(--border2); color: var(--text2); }

/* ── Main ── */
.main { flex: 1; overflow-y: auto; min-width: 0; }
.main-inner { max-width: 720px; margin: 0 auto; padding: 40px 32px 80px; }

/* ── List header ── */
.list-header { margin-bottom: 32px; }
.list-header-top { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.list-emoji { font-size: 40px; line-height: 1; }
.list-title-wrap { flex: 1; }
.list-title { font-family: 'Syne', sans-serif; font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.list-desc { font-size: 14px; color: var(--text2); margin-top: 5px; }
.list-header-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; align-items: center; }

/* ── Buttons ── */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  border: 0.5px solid var(--border2);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.btn:hover { border-color: var(--border3); color: var(--text); background: var(--bg4); }
.btn.danger:hover { border-color: rgba(239,68,68,0.4); color: var(--red); background: var(--red-bg); }
.btn.success { border-color: rgba(34,197,94,0.3); color: var(--green); background: var(--green-bg); }
.btn.success:hover { border-color: rgba(34,197,94,0.5); background: rgba(34,197,94,0.15); }

.btn-icon {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text3);
  transition: all 0.15s;
  font-size: 14px;
}
.btn-icon:hover { background: var(--bg3); color: var(--text); }

/* ── Stats ── */
.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 28px; }
.stat { background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 6px; font-weight: 500; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 700; color: var(--text); }
.stat-value.accent { color: var(--accent2); }

/* ── Progress ── */
.progress-wrap { margin-bottom: 28px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text3); margin-bottom: 8px; }
.progress-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 2px; transition: width 0.5s cubic-bezier(0.4,0,0.2,1); }

/* ── Controls ── */
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 24px; }
.search-wrap { flex: 1; min-width: 160px; }
.search-wrap input {
  width: 100%;
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 8px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.search-wrap input::placeholder { color: var(--text3); }
.search-wrap input:focus { border-color: var(--border2); }

.filter-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  border: 0.5px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--border2); color: var(--text); }
.filter-btn.active { background: var(--accent-bg); border-color: rgba(108,99,255,0.35); color: var(--accent2); }

/* ── Category sections ── */
.cat-section { margin-bottom: 32px; }
.cat-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cat-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.09em; }
.cat-line { flex: 1; height: 0.5px; background: var(--border); }
.cat-count { font-size: 11px; color: var(--text3); }
.cat-mark-all { font-size: 11px; color: var(--text3); cursor: pointer; background: none; border: none; font-family: 'DM Sans', sans-serif; transition: color 0.15s; padding: 0; }
.cat-mark-all:hover { color: var(--text2); }

/* ── Items ── */
.item-list { display: flex; flex-direction: column; gap: 3px; }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 9px;
  border: 0.5px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.item:hover { background: var(--bg2); border-color: var(--border); }
.item.done { background: rgba(108,99,255,0.05); border-color: rgba(108,99,255,0.15); }
.item.done:hover { background: rgba(108,99,255,0.08); }

.check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  font-size: 11px;
  color: transparent;
}
.item.done .check { background: var(--accent); border-color: var(--accent); color: #fff; }

.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color 0.15s; }
.item.done .item-name { color: var(--text2); }
.item-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }

.item-tag { font-size: 10px; font-weight: 500; padding: 3px 9px; border-radius: 20px; flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.04em; }

.item-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.item:hover .item-actions { opacity: 1; }

/* ── Add item ── */
.add-item-wrap { margin-top: 12px; }
.add-item-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 20px;
}
.add-item-form input, .add-item-form select {
  background: var(--bg3);
  border: 0.5px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
}
.add-item-form input::placeholder { color: var(--text3); }
.add-item-form input:focus, .add-item-form select:focus { border-color: var(--border2); }
.add-item-form input.name-input { flex: 2; min-width: 140px; }
.add-item-form input.sub-input { flex: 1; min-width: 100px; }
.add-item-form select { flex: 1; min-width: 100px; }
.add-item-form select option { background: var(--bg3); }

.btn-add {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 7px;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-add:hover { background: var(--accent2); }

/* ── Modals ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg2);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  transform: translateY(10px);
  transition: transform 0.2s;
}
.overlay.open .modal { transform: translateY(0); }
.modal-title { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 700; margin-bottom: 20px; }

.form-group { margin-bottom: 16px; }
.form-label { font-size: 12px; color: var(--text2); margin-bottom: 6px; display: block; font-weight: 500; }
.form-input {
  width: 100%;
  background: var(--bg3);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.form-input::placeholder { color: var(--text3); }
.form-input:focus { border-color: var(--accent); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

.btn-primary {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 20px;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary:hover { background: var(--accent2); }

.btn-cancel {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 20px;
  border-radius: 8px;
  background: none;
  border: 0.5px solid var(--border2);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-cancel:hover { border-color: var(--border3); color: var(--text); }

/* ── Emoji picker ── */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}
.emoji-opt {
  font-size: 22px;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: background 0.1s;
  border: none;
  background: none;
}
.emoji-opt:hover { background: var(--bg3); }
.emoji-opt.selected { background: var(--accent-bg); }

/* ── Import/Export ── */
.import-drop-zone {
  border: 1.5px dashed var(--border2);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}
.import-drop-zone:hover, .import-drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.import-drop-zone .drop-icon { font-size: 32px; margin-bottom: 10px; }
.import-drop-zone p { font-size: 14px; color: var(--text2); }
.import-drop-zone span { font-size: 12px; color: var(--text3); display: block; margin-top: 4px; }

.import-preview {
  background: var(--bg3);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  display: none;
}
.import-preview.visible { display: block; }
.import-preview-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.import-preview-meta { font-size: 12px; color: var(--text3); }

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text);
  z-index: 200;
  opacity: 0;
  transition: all 0.25s;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(34,197,94,0.3); color: var(--green); }
.toast.error { border-color: rgba(239,68,68,0.3); color: var(--red); }

/* ── Empty / Welcome ── */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text3); }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-title { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.empty-desc { font-size: 14px; line-height: 1.6; }

.welcome { text-align: center; padding: 80px 20px; }
.welcome-icon { font-size: 56px; margin-bottom: 20px; }
.welcome-title { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 800; margin-bottom: 10px; }
.welcome-desc { font-size: 15px; color: var(--text2); max-width: 360px; margin: 0 auto 28px; line-height: 1.6; }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.cat-section { animation: fadeIn 0.25s ease both; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .sidebar { display: none; }
  .main-inner { padding: 24px 16px 60px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .list-title { font-size: 24px; }
}
