:root {
  color-scheme: dark;
  --bg: #121212;
  --surface: #1c1c1e;
  --surface-2: #262629;
  --border: #333336;
  --text: #f0f0f2;
  --text-dim: #9a9aa2;
  --accent: #5b8cff;
  --danger: #ff5b6a;
  --done: #4caf6a;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 1080px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px 48px;
}

.app-header {
  padding: 24px 4px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-box {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

.auth-box h1 {
  text-align: center;
  margin: 0 0 8px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#auth-form input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
}

#auth-form button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.auth-message {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  min-height: 1.2em;
  margin: 0;
}

[hidden] { display: none !important; }

.board {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 760px) {
  .board {
    grid-template-columns: 1fr;
  }
  .projects-pane { order: 1; }
  .tasks-pane { order: 2; }
}

.tasks-pane, .projects-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.placeholder {
  color: var(--text-dim);
  padding: 24px 4px;
}

.section { margin-bottom: 20px; }
.section:last-child { margin-bottom: 0; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
}

.section-head h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-toggle {
  width: 100%;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.section-toggle .chevron {
  transition: transform 0.15s ease;
  color: var(--text-dim);
}

.section-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.new-project-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 16px;
}

.project-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 12px;
}

.project-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.12s ease, box-shadow 0.12s ease;
  touch-action: pan-y;
}

.project-card:hover { background: #2c2c30; }

.project-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.project-card .drag-handle {
  flex: none;
  color: var(--text-dim);
  cursor: grab;
  padding: 4px 2px;
  touch-action: none;
  user-select: none;
  font-size: 0.9rem;
  line-height: 1;
}

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

.project-card .name {
  font-size: 0.98rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card .meta {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.project-card.status-done .name {
  color: var(--text-dim);
  text-decoration: line-through;
}

.project-card.dragging {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  opacity: 0.95;
}

.drag-placeholder {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: rgba(91,140,255,0.08);
}

.empty-hint {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 8px 4px;
}

/* Project detail */
.project-detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 16px;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  flex: none;
  font-size: 1.1rem;
  cursor: pointer;
}

.icon-btn.danger { color: var(--danger); }

.project-title-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 600;
  min-width: 0;
}

.status-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 6px;
  font: inherit;
}

.add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.add-row input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
}

.add-row button, .modal-actions button, #new-project-form button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 18px;
  font-size: 1rem;
  cursor: pointer;
}

.task-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.task-checkbox {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}

.task-item.done .task-checkbox {
  border-color: var(--done);
  background: var(--done);
  color: #fff;
}

.task-title {
  flex: 1;
  font-size: 1rem;
  min-width: 0;
  word-break: break-word;
}

.task-item.done .task-title {
  color: var(--text-dim);
  text-decoration: line-through;
}

.task-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  flex: none;
}

.task-section { margin-top: 8px; }

.done-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  color: var(--text-dim);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}

@media (min-width: 480px) {
  .modal-backdrop { align-items: center; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 480px) {
  .modal { border-radius: 16px; }
}

.modal h2 { margin: 0; font-size: 1.1rem; }

.modal input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
}

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

.modal-actions button[type="button"] {
  background: var(--surface-2);
  color: var(--text);
}
