:root {
  --bg: #f9f9f7;
  --surface: #ffffff;
  --border: #e1e0d9;
  --text: #0b0b0b;
  --text-muted: #52514e;
  --text-faint: #898781;
  --accent: #2a78d6;
  --danger: #d03b3b;
  --success: #0ca30c;
  --row-alt: #f2f1ec;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #1e1e22;
    --border: #33333a;
    --text: #ececec;
    --text-muted: #b7b6b2;
    --text-faint: #8b8a86;
    --row-alt: #26262b;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
}

.centered-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.centered-box {
  text-align: center;
  max-width: 420px;
  padding: 0 16px;
}

.button-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

button.primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
}

button:not(.primary) {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 17px;
  border-radius: 6px;
  font-size: 14px;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}

.link-button {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  border-radius: 4px;
}
.link-button:hover { background: var(--row-alt); }

.save-status {
  font-size: 12px;
  color: var(--text-faint);
  min-width: 70px;
}
.save-status[data-status="error"] { color: var(--danger); cursor: pointer; text-decoration: underline; }
.save-status[data-status="saving"] { color: var(--text-muted); }
.save-status[data-status="saved"] { color: var(--success); }

.spacer { flex: 1; }

.filter-label {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-label select {
  font: inherit;
  padding: 4px 6px;
}

.menu { position: relative; }
.menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  min-width: 200px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  z-index: 20;
}
.menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 14px;
}
.menu-dropdown button:hover { background: var(--row-alt); }
.menu-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

@media (min-width: 900px) {
  .workspace { flex-direction: row; }
  .task-list-panel { width: 360px; flex: none; border-right: 1px solid var(--border); }
  .gantt-panel { flex: 1; }
}

.task-list-panel, .gantt-panel {
  overflow: auto;
  min-height: 0;
}
@media (max-width: 899px) {
  .task-list-panel, .gantt-panel { flex: 1 1 50%; }
}

.gantt-empty {
  padding: 24px;
  color: var(--text-muted);
  text-align: center;
}

.gantt-bar {
  cursor: grab;
}
.gantt-bar:active { cursor: grabbing; }

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.task-row.completed { background: rgba(12, 163, 12, 0.10); }
.task-row.overdue { background: rgba(208, 59, 59, 0.10); }

.task-row .task-main { flex: 1; min-width: 0; }
.task-row .task-name { font-weight: 600; }
.task-row .task-meta { font-size: 12px; color: var(--text-muted); }
.task-row .task-deps { font-size: 12px; color: var(--text-muted); }
.task-row .task-violation { font-size: 12px; color: var(--danger); }

.task-row .task-actions {
  display: flex;
  gap: 2px;
  flex: none;
}
.task-row .task-actions button {
  background: none;
  border: none;
  padding: 4px 6px;
  font-size: 14px;
  border-radius: 4px;
}
.task-row .task-actions button:hover { background: var(--row-alt); }

.task-list-toolbar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

dialog {
  border: none;
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  max-width: min(90vw, 460px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dialog-body { padding: 20px; }
.dialog-body h2 { margin: 0 0 16px; font-size: 18px; }
.dialog-body label { display: block; font-size: 13px; color: var(--text-muted); margin: 12px 0 4px; }
.dialog-body input[type="text"],
.dialog-body input[type="date"],
.dialog-body input[type="number"] {
  width: 100%;
  padding: 7px 8px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}
.dialog-body .row { display: flex; gap: 12px; }
.dialog-body .row > * { flex: 1; }
.dialog-body .checkbox-list {
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
}
.dialog-body .checkbox-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
  margin: 4px 0;
}
.dialog-body .checkbox-inline { display: flex; align-items: center; gap: 6px; margin: 12px 0; }
.dialog-body .checkbox-inline label { margin: 0; font-size: 14px; color: var(--text); }
.dialog-body .error-text { color: var(--danger); font-size: 12px; margin-top: 4px; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.dialog-body .empty-message { color: var(--text-faint); font-size: 13px; }

.picker-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; }
.picker-list li button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 4px;
}
.picker-list li button:hover { background: var(--row-alt); }

.about-box { text-align: center; }
.about-box img { margin: 12px 0; }
.about-box a { color: var(--accent); }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 4px;
  color: var(--text-faint);
  font-size: 13px;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

#webdav-login-form { text-align: left; }
#webdav-login-form label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin: 10px 0 4px;
}
#webdav-login-form input {
  width: 100%;
  padding: 7px 8px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}
#webdav-login-form button[type="submit"] {
  margin-top: 14px;
  width: 100%;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}
