:root {
  --bg-0: #3a3c46;
  --card: #ffffff;
  --text: #1a1b1f;
  --text-soft: #5a5c66;
  --text-mute: #8a8c96;
  --border: rgba(0,0,0,0.08);
  --accent: #5b7fff;
  --danger: #e04b4b;
  --success: #3fbf7f;
  --p1: #e04b4b;
  --p2: #f0a040;
  --p3: #5b7fff;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.15);
  --shadow: 0 4px 12px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.18);
  --shadow-md: 0 10px 24px rgba(0,0,0,0.2), 0 3px 6px rgba(0,0,0,0.15);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.3), 0 6px 12px rgba(0,0,0,0.2);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(1400px 800px at 8% -10%, rgba(99,160,255,0.14), transparent 60%),
    radial-gradient(1200px 700px at 100% 0%, rgba(192,132,252,0.11), transparent 60%),
    radial-gradient(1000px 600px at 50% 110%, rgba(244,114,182,0.07), transparent 60%),
    var(--bg-0);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 1400px; margin: 0 auto; padding: 16px 20px 40px; }

/* ===== topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 8px 14px;
  box-shadow: var(--shadow);
}
.tabs { display: flex; gap: 4px; position: relative; }
.tab {
  background: transparent;
  border: none;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.tab.active { background: var(--bg-0); color: #fff; }
.tab:hover:not(.active) { background: rgba(0,0,0,0.04); }
.status { font-size: 11px; color: var(--text-mute); }
.status.synced::before { content: "●"; color: var(--success); margin-right: 4px; }
.status.syncing::before { content: "●"; color: #f0a040; margin-right: 4px; }
.status.error::before { content: "●"; color: var(--danger); margin-right: 4px; }

/* ===== stats ===== */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow-sm); }
.stat-num { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-mute); margin-top: 4px; }

/* ===== adder ===== */
.adder { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.adder input[type="text"], .adder input[type="url"] {
  border: none; background: transparent; padding: 6px 2px; font-size: 15px;
  color: var(--text); outline: none; border-bottom: 1px solid transparent;
}
.adder input[type="text"]:focus, .adder input[type="url"]:focus { border-bottom-color: var(--accent); }
#input-title { font-size: 17px; font-weight: 600; }
.rich-input { min-height: 40px; padding: 6px 2px; font-size: 14px; color: var(--text); outline: none; line-height: 1.5; }
.rich-input:empty:before { content: attr(data-placeholder); color: var(--text-mute); }
.rich-input ul { margin: 6px 0; padding-left: 20px; }
.rich-input b, .rich-input strong { font-weight: 700; }
.rich-tools { display: flex; gap: 4px; }
.btn-rich {
  background: rgba(0,0,0,0.04); border: none; width: 30px; height: 28px; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: var(--text-soft);
}
.btn-rich:hover { background: rgba(0,0,0,0.08); }
.adder-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters select {
  background: rgba(0,0,0,0.04); border: none; padding: 6px 10px; border-radius: 6px;
  font-size: 13px; color: var(--text-soft); outline: none; cursor: pointer;
}
.btn-primary {
  background: var(--accent); color: #fff; border: none; padding: 9px 18px;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.15s;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; }

/* ===== tag filter ===== */
.tag-filter { display: flex; gap: 6px; margin-bottom: 16px; }
.pill {
  background: rgba(255,255,255,0.85); border: none; padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--text-soft); cursor: pointer; box-shadow: var(--shadow-sm);
}
.pill.active { background: var(--text); color: #fff; }

/* ===== columns ===== */
.columns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; align-items: start; }
.col {
  background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm);
  min-height: 60px;
}
.col h3 { font-size: 13px; font-weight: 700; margin: 0 0 10px 0; color: var(--text); text-transform: uppercase; letter-spacing: 0.5px; }
.col-sub { font-size: 10px; color: var(--text-mute); font-weight: 500; text-transform: none; letter-spacing: 0; margin-left: 4px; }
.col-body { display: flex; flex-direction: column; gap: 6px; min-height: 20px; }
.col.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }

.task {
  background: rgba(0,0,0,0.02); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 13px; cursor: pointer; display: flex; align-items: flex-start; gap: 8px;
  transition: all 0.15s; position: relative;
}
.task:hover { background: rgba(0,0,0,0.04); }
.task.dragging { opacity: 0.4; }
.task.done { opacity: 0.5; }
.task.done .task-title { text-decoration: line-through; }
.task-check {
  width: 16px; height: 16px; border: 1.5px solid var(--text-mute); border-radius: 4px;
  flex-shrink: 0; margin-top: 1px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.task-check.checked { background: var(--success); border-color: var(--success); color: #fff; font-size: 11px; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 500; color: var(--text); line-height: 1.3; word-break: break-word; }
.task-meta { display: flex; gap: 4px; margin-top: 3px; align-items: center; }
.chip {
  display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.chip.p1 { background: rgba(224,75,75,0.12); color: var(--p1); }
.chip.p2 { background: rgba(240,160,64,0.12); color: var(--p2); }
.chip.p3 { background: rgba(91,127,255,0.12); color: var(--p3); }
.chip.pro { background: rgba(91,127,255,0.12); color: var(--p3); }
.chip.perso { background: rgba(192,132,252,0.15); color: #a855f7; }
.task-has-desc { width: 5px; height: 5px; border-radius: 50%; background: var(--text-mute); flex-shrink: 0; margin-top: 7px; }

/* ===== learnings ===== */
.learnings-section { margin-top: 20px; background: var(--card); padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.learnings-section h3 { margin: 0 0 12px 0; font-size: 14px; }
.learning-list { display: flex; flex-direction: column; gap: 8px; }
.learning-item { padding: 10px 12px; background: rgba(0,0,0,0.02); border-radius: 8px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.learning-item a { color: var(--accent); text-decoration: none; font-weight: 500; }
.learning-item a:hover { text-decoration: underline; }
.learning-del { background: transparent; border: none; color: var(--text-mute); cursor: pointer; font-size: 16px; }

/* ===== habits ===== */
.habits-list { display: flex; flex-direction: column; gap: 8px; }
.habit {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 14px; cursor: pointer;
}
.habit-check {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--text-mute);
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
  background: transparent; color: transparent; font-size: 16px; transition: all 0.15s;
}
.habit-check.done { background: var(--success); border-color: var(--success); color: #fff; }
.habit-main { flex: 1; min-width: 0; }
.habit-name { font-weight: 600; font-size: 15px; color: var(--text); }
.habit-desc { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.habit-stats { display: flex; gap: 14px; font-size: 12px; color: var(--text-soft); margin-top: 6px; }
.habit-stats b { color: var(--text); font-weight: 600; }
.habit-del { background: transparent; border: none; color: var(--text-mute); cursor: pointer; font-size: 18px; }

/* ===== modal ===== */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-body {
  position: relative; background: var(--card); border-radius: var(--radius); padding: 24px 28px;
  max-width: 540px; width: calc(100% - 40px); box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
}
.modal-close { position: absolute; top: 10px; right: 14px; background: transparent; border: none; font-size: 24px; cursor: pointer; color: var(--text-soft); }
.modal-body h2 { margin: 0 0 12px 0; font-size: 22px; color: var(--text); outline: none; }
.modal-meta { display: flex; gap: 6px; margin-bottom: 14px; }
.modal-desc { min-height: 80px; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; }
.modal-tools { margin-bottom: 14px; }

#setup-modal input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; margin: 10px 0; }

/* ===== responsive ===== */
@media (max-width: 920px) {
  .columns { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  #app { padding: 12px 10px 30px; }
  .columns { grid-template-columns: 1fr; }
  .adder-row { flex-direction: column; align-items: stretch; }
  .btn-primary { width: 100%; }
}
