:root {
  --bg: #0a0a0a;
  --panel: #121212;
  --panel2: #1a1a1a;
  --border: #262626;
  --text: #e6e6e6;
  --dim: #8a8a8a;
  --accent: #f0f0f0;
  --green: #6fae7f;
  --red: #c05757;
  --amber: #b8915a;
}

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

body {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- sidebar ---------- */
#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: width 0.18s ease;
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px;
}

.brand { font-weight: 700; font-size: 15px; letter-spacing: -0.5px; white-space: nowrap; }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--dim);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font: inherit;
  line-height: 1;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--dim); }

#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a {
  color: var(--dim);
  text-decoration: none;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
#nav a svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
#nav a:hover { background: var(--panel2); color: var(--text); }
#nav a.active { background: var(--panel2); color: var(--accent); font-weight: 600; }

#sidebar.collapsed { width: 56px; }
#sidebar.collapsed .label,
#sidebar.collapsed .brand span,
#sidebar.collapsed .mode-card *:not(.badge) { display: none; }
#sidebar.collapsed #nav a { justify-content: center; padding: 8px 0; }
#sidebar.collapsed .mode-card { padding: 8px; align-items: center; }
#sidebar.collapsed .mode-card .badge { font-size: 10px; padding: 4px; }
#sidebar.collapsed .sidebar-head { justify-content: center; }

.mode-card {
  margin-top: auto;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mode-card .badge {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  text-align: center;
}
.mode-card .badge.work { background: rgba(240, 240, 240, 0.08); color: var(--accent); }
.mode-card .badge.play { background: rgba(184, 145, 90, 0.12); color: var(--amber); }
.mode-card .quiet { color: var(--amber); font-size: 12px; }

/* ---------- layout ---------- */
#view { padding: 24px; overflow-y: auto; max-height: 100vh; }

h1 { font-size: 20px; margin-bottom: 16px; letter-spacing: -0.5px; }
h2 { font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.page-head h1 { margin-bottom: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card .card-title { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }

ul.list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
li.item {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
li.item .title { flex: 1; }
li.item .meta { color: var(--dim); font-size: 12px; white-space: nowrap; }
li.item.done .title { text-decoration: line-through; color: var(--dim); }

/* ---------- kanban ---------- */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  align-items: start;
}
.kanban-col {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  transition: border-color 0.15s;
}
.kanban-col.drag-over { border-color: var(--dim); }
.kanban-col h2 { margin: 0; display: flex; justify-content: space-between; align-items: center; }
.kanban-col h2 .count { color: var(--dim); font-size: 12px; }

.todo-item {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 11px;
  cursor: grab;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.todo-item:active { cursor: grabbing; }
.todo-item.dragging { opacity: 0.4; border-style: dashed; }
.todo-item.done .title { text-decoration: line-through; color: var(--dim); }
.todo-item .title { flex: 1; word-break: break-word; }
.todo-item .meta { color: var(--dim); font-size: 12px; white-space: nowrap; }
.todo-item button { padding: 2px 8px; font-size: 12px; }

/* ---------- controls ---------- */
button {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}
button:hover { border-color: var(--dim); }
button.primary { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
button.primary:hover { background: var(--accent); }
button.danger:hover { border-color: var(--red); color: var(--red); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

input, select, textarea {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font: inherit;
  width: 100%;
}
textarea { resize: vertical; min-height: 80px; }
form.row { display: flex; gap: 8px; }
form.row input { flex: 1; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: min(480px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.modal-box h3 { font-size: 15px; }
.modal-box label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--dim);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- misc ---------- */
#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  max-width: 340px;
}
.toast {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--dim);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  animation: slide 0.2s ease;
}
.toast.drift { border-left-color: var(--red); }
.toast.overstay { border-left-color: var(--amber); }
.toast.mode_work, .toast.mode_play { border-left-color: var(--green); }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } }

.timer-display {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  padding: 12px 0;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--dim); text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }

pre.raw {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: var(--dim);
  max-height: 240px;
  overflow-y: auto;
  background: var(--panel2);
  border-radius: 6px;
  padding: 10px;
}

.bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.bar-track { flex: 1; height: 10px; background: var(--panel2); border-radius: 5px; overflow: hidden; display: flex; }
.bar-work { background: var(--green); height: 100%; }
.bar-play { background: var(--amber); height: 100%; }

.empty { color: var(--dim); font-style: italic; padding: 8px 0; }

/* floating add button */
.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  z-index: 50;
}
.fab.primary { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }