:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --panel2: #243044;
  --ink: #f0f4fc;
  --muted: #8b9bb8;
  --accent: #6366f1;
  --accent-dim: #4338ca;
  --ok: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 14px;
  --font: "SF Pro Text", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(900px 500px at 0% -10%, #1e1b4b 0%, transparent 50%),
              radial-gradient(700px 400px at 100% 0%, #134e4a 0%, transparent 45%),
              var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px 12px;
  gap: 12px;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.status {
  font-size: 0.72rem;
  color: var(--muted);
}
.status.ok { color: var(--ok); }
.status.bad { color: var(--danger); }

.token-bar {
  display: none;
  gap: 8px;
  margin-bottom: 8px;
}
.token-bar.visible { display: flex; }

.token-bar input {
  flex: 1;
  border-radius: 10px;
  border: 1px solid var(--panel2);
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.chip {
  appearance: none;
  border: 1px solid var(--panel2);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#todoList {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 0 12px;
  -webkit-overflow-scrolling: touch;
}

.todo-item {
  background: var(--panel);
  border: 1px solid var(--panel2);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  transition: border-color 0.15s;
}
.todo-item.selected {
  border-color: var(--accent);
}
.todo-item.completed .todo-title {
  text-decoration: line-through;
  color: var(--muted);
}

.todo-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--panel2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  cursor: pointer;
}
.todo-item.completed .todo-check {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
  font-size: 0.75rem;
}

.todo-body { flex: 1; min-width: 0; }

.todo-title {
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.35;
  word-break: break-word;
}

.todo-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.note-count {
  color: var(--accent);
}

.detail-panel {
  display: none;
  background: var(--panel);
  border: 1px solid var(--panel2);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  max-height: 180px;
  overflow-y: auto;
}
.detail-panel.visible { display: block; }

.detail-panel h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.note-item {
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 8px 0;
  border-bottom: 1px solid var(--panel2);
}
.note-item:last-child { border-bottom: none; }

.note-time {
  font-size: 0.7rem;
  color: var(--muted);
}

.ai-reply {
  background: #1a2438;
  border: 1px solid var(--panel2);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 8px;
  white-space: pre-wrap;
  display: none;
}
.ai-reply.visible { display: block; }

.composer {
  background: var(--panel);
  border: 1px solid var(--panel2);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-tabs {
  display: flex;
  gap: 6px;
}

.tab {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
}
.tab.active {
  background: var(--panel2);
  color: var(--ink);
  font-weight: 600;
}

#input {
  width: 100%;
  min-height: 48px;
  max-height: 120px;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 4px;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button.secondary {
  background: var(--panel2);
  color: var(--ink);
}
button.mic.listening {
  background: var(--danger);
}

.hint {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0 4px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 0.9rem;
}
