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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f0f;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
}

/* ── Main area ── */
.main {
  flex: 1;
  padding: 2rem 2.5rem;
  overflow-y: auto;
  min-width: 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  max-width: 640px;
}

h1 { font-size: 1.8rem; font-weight: 600; color: #fff; }

.top-bar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.add-project-btn,
.logout-btn {
  padding: 0.45rem 0.9rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: transparent;
  color: #999;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.add-project-btn:hover { border-color: #5b8def; color: #5b8def; }
.logout-btn:hover { border-color: #f87171; color: #f87171; }

/* ── Add form ── */
.add-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  max-width: 640px;
}

.add-form input[type="text"] {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.add-form input[type="text"]:focus { border-color: #5b8def; }

.add-form select {
  padding: 0.7rem 0.8rem;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
}

.add-form .project-select {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.add-form button {
  padding: 0.7rem 1.2rem;
  border: none;
  border-radius: 8px;
  background: #5b8def;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.add-form button:hover { background: #4a7de0; }

/* ── Filters ── */
.filters { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; max-width: 640px; }

.filters button {
  padding: 0.4rem 0.9rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: transparent;
  color: #999;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.filters button.active { background: #5b8def; border-color: #5b8def; color: #fff; }
.filters button:hover:not(.active) { border-color: #555; color: #ccc; }

/* ── Project sections ── */
.projects-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 640px;
}

.project-section {
  border: 1px solid #222;
  border-radius: 10px;
  background: #141414;
  overflow: hidden;
  transition: border-color 0.2s;
}
.project-section.drag-over { border-color: #5b8def; }
.project-section.focused { border-color: #5b8def; }

.project-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #181818;
  border-bottom: 1px solid #222;
  cursor: pointer;
  user-select: none;
}

.project-header .collapse-icon {
  font-size: 0.7rem;
  color: #555;
  transition: transform 0.2s;
  width: 12px;
  text-align: center;
}
.project-section.collapsed .collapse-icon { transform: rotate(-90deg); }

.project-header .project-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  color: #ccc;
}
.project-header .project-name.editing {
  background: #111;
  border: 1px solid #444;
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  outline: none;
  color: #e0e0e0;
  cursor: text;
  font-weight: 400;
}

.project-header .project-stats {
  font-size: 0.75rem;
  color: #555;
}

.project-header .project-delete {
  background: none;
  border: none;
  color: transparent;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
  transition: color 0.2s;
}
.project-header:hover .project-delete { color: #555; }
.project-header .project-delete:hover { color: #f87171; }

.project-body {
  padding: 0.5rem;
  min-height: 40px;
}
.project-section.collapsed .project-body { display: none; }

.project-body .task-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.project-body .empty-drop {
  text-align: center;
  color: #444;
  padding: 1rem;
  font-size: 0.85rem;
  border: 1px dashed #2a2a2a;
  border-radius: 6px;
}

/* ── Tasks ── */
.task {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  background: #1a1a1a;
  border: 1px solid #262626;
  border-radius: 8px;
  transition: all 0.15s;
  cursor: grab;
}
.task:active { cursor: grabbing; }
.task:hover { border-color: #333; }
.task.selected { border-color: #5b8def; background: #1c2333; }
.task.dragging { opacity: 0.4; }
.task.done .task-title { text-decoration: line-through; color: #555; }

.task input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: #5b8def;
  cursor: pointer;
  flex-shrink: 0;
}

.task-title {
  flex: 1; font-size: 0.9rem; cursor: default;
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.task-title.editing {
  background: #111;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  outline: none;
  color: #e0e0e0;
  cursor: text;
  overflow: visible;
}

.priority {
  font-size: 0.65rem; font-weight: 600;
  padding: 0.15rem 0.4rem; border-radius: 4px;
  text-transform: uppercase; flex-shrink: 0;
}
.priority.low { background: #1a2e1a; color: #4ade80; }
.priority.medium { background: #2e2a1a; color: #fbbf24; }
.priority.high { background: #2e1a1a; color: #f87171; }

.task-date { font-size: 0.7rem; color: #555; flex-shrink: 0; }

.task-actions {
  display: flex;
  gap: 0.15rem;
  flex-shrink: 0;
}

.edit-btn, .delete-btn {
  background: none; border: none; color: #444;
  font-size: 0.95rem; cursor: pointer; padding: 0.15rem;
  line-height: 1; transition: color 0.2s; flex-shrink: 0;
}
.edit-btn:hover { color: #5b8def; }
.delete-btn:hover { color: #f87171; }

/* ── Right panel ── */
.right-panel {
  width: 340px;
  background: #141414;
  border-left: 1px solid #222;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
}

/* ── Hotkey panel (collapsible) ── */
.hotkey-panel {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  border-bottom: 1px solid #222;
}
.hotkey-panel.collapsed .hotkey-content { display: none; }

.hotkey-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0.5rem;
}
.hotkey-panel.collapsed .hotkey-toggle { margin-bottom: 0; }

.hotkey-toggle h2 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555;
  margin: 0;
}

.hotkey-toggle .toggle-icon {
  font-size: 0.6rem;
  color: #555;
  transition: transform 0.2s;
}
.hotkey-panel.collapsed .toggle-icon { transform: rotate(-90deg); }

.hotkey-section { margin-bottom: 0.75rem; }

.hotkey-section h3 {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #444;
  margin-bottom: 0.3rem;
}

.hotkey-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0;
  font-size: 0.78rem;
}

.hotkey-row .label { color: #777; }

.hotkey-row kbd {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  font-family: inherit;
  font-size: 0.68rem;
  color: #999;
  min-width: 20px;
  text-align: center;
}

/* ── Chat panel ── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #222;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555;
}

.chat-header .model-label {
  font-size: 0.65rem;
  color: #444;
}

.chat-api-key {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #222;
}

.chat-api-key input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 0.8rem;
  outline: none;
}
.chat-api-key input:focus { border-color: #5b8def; }
.chat-api-key input::placeholder { color: #555; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chat-msg {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.45;
  max-width: 95%;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-msg.user {
  background: #1c2a44;
  color: #b8d4ff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.chat-msg.assistant {
  background: #1e1e1e;
  color: #ccc;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.chat-msg.error {
  background: #2e1a1a;
  color: #f87171;
  align-self: center;
  font-size: 0.8rem;
}

.chat-msg.thinking {
  background: #1e1e1e;
  color: #666;
  align-self: flex-start;
  font-style: italic;
}

.chat-input-area {
  padding: 0.75rem;
  border-top: 1px solid #222;
  display: flex;
  gap: 0.4rem;
}

.chat-input-area textarea {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 38px;
  max-height: 120px;
}
.chat-input-area textarea:focus { border-color: #5b8def; }

.chat-input-area button {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: #5b8def;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  align-self: flex-end;
}
.chat-input-area button:hover { background: #4a7de0; }
.chat-input-area button:disabled { background: #333; color: #666; cursor: default; }

/* ── Drag placeholder ── */
.drop-indicator {
  height: 3px;
  background: #5b8def;
  border-radius: 2px;
  margin: 0.15rem 0;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .right-panel { width: 280px; }
}
@media (max-width: 900px) {
  .right-panel { display: none; }
  .main { padding: 1.5rem 1rem; }
}
