:root {
  color-scheme: light;
  --bg: #f7f6fb;
  --surface: #ffffff;
  --surface-soft: #faf9fd;
  --text: #17151f;
  --muted: #6f6b7c;
  --border: #e7e3ee;
  --purple: #6d4aff;
  --purple-dark: #5636e6;
  --purple-soft: #f0ecff;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --success: #168254;
  --warning: #a15c00;
  --shadow: 0 14px 36px rgba(30, 24, 50, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 10% 0%, rgba(109, 74, 255, 0.08), transparent 26rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(109, 74, 255, 0.22);
  outline-offset: 2px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--purple);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.subtitle, .footer-note { color: var(--muted); }
.subtitle { margin-bottom: 0; }

.topbar-actions,
.toolbar-controls,
.dialog-actions,
.task-card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.button,
.icon-button,
.view-button,
.text-button {
  border: 0;
  border-radius: 12px;
  transition: 160ms ease;
}

.button {
  min-height: 44px;
  padding: 0 16px;
  font-weight: 700;
}

.button-primary {
  background: var(--purple);
  color: #fff;
}

.button-primary:hover { background: var(--purple-dark); }

.button-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.button-secondary:hover { background: var(--surface-soft); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
}

.stat-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-value {
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
}

.search-wrap { flex: 1 1 340px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
}

input, select { min-height: 44px; padding: 0 12px; }
textarea { padding: 11px 12px; resize: vertical; }

.toolbar-controls { flex-wrap: wrap; justify-content: flex-end; }
.toolbar-controls label { min-width: 132px; }
.toolbar-controls label > span {
  display: block;
  margin: 0 0 5px 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.view-toggle {
  display: inline-flex;
  align-self: flex-end;
  min-height: 44px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.view-button {
  padding: 0 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.view-button.is-active {
  background: var(--surface);
  color: var(--purple);
  box-shadow: 0 2px 8px rgba(33, 27, 53, 0.08);
}

.notice {
  min-height: 0;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.notice:not(:empty) {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--purple-soft);
  color: #4932a9;
}

.notice.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.task-list { display: grid; gap: 10px; }

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 7px 22px rgba(30, 24, 50, 0.035);
}

.task-card.is-overdue { border-color: #f0b8b2; }
.task-card-main { min-width: 0; }

.task-card-topline {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #aaa;
}

.status-dot[data-status="todo"] { background: #8b8796; }
.status-dot[data-status="in_progress"] { background: #5c6ac4; }
.status-dot[data-status="review"] { background: #b26a00; }
.status-dot[data-status="done"] { background: #168254; }

.project-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-title {
  margin-bottom: 7px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.task-description {
  max-width: 800px;
  margin-bottom: 12px;
  color: var(--muted);
  white-space: pre-wrap;
}

.task-description:empty { display: none; }

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.meta-pill.priority-urgent { background: #ffe9e7; color: #a52a20; }
.meta-pill.priority-high { background: #fff1df; color: #995007; }
.meta-pill.priority-medium { background: #edf0ff; color: #4f5ca0; }
.meta-pill.priority-low { background: #edf7f2; color: #36735a; }
.meta-pill.overdue { background: #ffe9e7; color: var(--danger); }
.meta-pill.today { background: #fff1df; color: var(--warning); }

.task-card-actions {
  align-self: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.compact-select-label { min-width: 132px; }
.compact-select-label select { min-height: 38px; font-size: 0.86rem; }

.text-button {
  min-height: 38px;
  padding: 0 10px;
  background: transparent;
  color: var(--purple);
  font-weight: 800;
}

.text-button:hover { background: var(--purple-soft); }
.text-button.danger { color: var(--danger); }
.text-button.danger:hover { background: var(--danger-soft); }

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(235px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.board-column {
  min-width: 235px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.board-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.board-column-title {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.board-count {
  min-width: 26px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

.board-stack { display: grid; gap: 9px; }
.board .task-card {
  grid-template-columns: 1fr;
  padding: 14px;
}
.board .task-card-actions { justify-content: flex-start; }
.board .task-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.empty-state {
  padding: 56px 18px;
  border: 1px dashed #d7d1e5;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.58);
  text-align: center;
}

.empty-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 1.35rem;
  font-weight: 900;
}

.empty-state h2 { margin-bottom: 6px; }
.empty-state p { margin-bottom: 18px; color: var(--muted); }
.footer-note { margin-top: 22px; font-size: 0.82rem; text-align: center; }

.task-dialog {
  width: min(680px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.task-dialog::backdrop { background: rgba(20, 17, 31, 0.48); }
.task-dialog form { padding: 22px; }

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.dialog-header h2 { margin-bottom: 0; font-size: 1.5rem; }

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1.5rem;
}
.icon-button:hover { background: var(--purple-soft); color: var(--purple); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-field { min-width: 0; }
.form-field-wide { grid-column: 1 / -1; }
.form-field > span {
  display: block;
  margin: 0 0 6px 2px;
  font-size: 0.82rem;
  font-weight: 800;
}

.form-error { min-height: 21px; margin: 12px 0 0; color: var(--danger); font-size: 0.86rem; }
.dialog-actions { justify-content: flex-end; margin-top: 16px; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 800px) {
  .topbar, .toolbar { flex-direction: column; }
  .topbar-actions { width: 100%; }
  .topbar-actions .button { flex: 1; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar-controls { width: 100%; justify-content: flex-start; }
  .toolbar-controls label { flex: 1 1 140px; }
  .view-toggle { align-self: stretch; }
  .view-button { flex: 1; }
  .task-card { grid-template-columns: 1fr; }
  .task-card-actions { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 24px; }
  .stats-grid { gap: 8px; }
  .stat-card { padding: 14px; }
  .toolbar { padding: 10px; }
  .toolbar-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar-controls label { min-width: 0; }
  .view-toggle { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field-wide { grid-column: auto; }
  .task-dialog form { padding: 18px; }
}
