:root {
  --background: #14161a;
  --surface: #1c1f25;
  --surface-raised: #23272f;
  --border: #2e333c;
  --text: #e6e8ec;
  --text-muted: #8b93a1;
  --accent: #6aa9ff;
  --accent-text: #0b1220;
  --danger: #ff6b6b;
  --radius: 10px;
  --gap: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --background: #f5f6f8;
    --surface: #ffffff;
    --surface-raised: #f0f2f5;
    --border: #dfe3e8;
    --text: #1a1d23;
    --text-muted: #6b7280;
    --accent: #2563eb;
    --accent-text: #ffffff;
    --danger: #dc2626;
  }
}

* {
  box-sizing: border-box;
}

/*  the browser hides [hidden] with display: none, but any class here that sets
    display itself wins on specificity and brings the element back. that is how
    the login screen stayed on the page after logging in.  */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.view {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

h1 {
  font-size: 22px;
  margin: 0;
}

/*#region forms */
input,
textarea,
button {
  font: inherit;
  color: inherit;
}

input[type="text"],
input[type="password"],
input:not([type]),
textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

input:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 9px 14px;
}

button.primary {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

button.ghost:hover {
  color: var(--text);
}

.icon-button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 2px 8px;
  opacity: 0;
}

.task-row:hover .icon-button,
.subtask:hover .icon-button,
.icon-button:focus-visible {
  opacity: 1;
}

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

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex: none;
  cursor: pointer;
}
/*#endregion */

/*#region login */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}

.login-card {
  width: min(360px, 90vw);
  display: grid;
  gap: 8px;
}

.login-card h1 {
  margin-bottom: 12px;
}

.login-card label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.login-card button {
  margin-top: 16px;
}
/*#endregion */

/*#region app layout */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: 20px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--gap);
}

.summary {
  font-size: 13px;
  color: var(--text-muted);
}

.new-task {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

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

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 8px 0 0;
}
/*#endregion */

/*#region tasks */
.task-list,
.subtask-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 12px;
}

.task-title {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.subtask-count,
.dates {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex: none;
}

/*  the dates are secondary: they yield first when the row runs out of room */
.dates {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .dates {
    display: none;
  }
}

.task-details {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.subtask {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 4px 4px;
}

.subtask-title {
  flex: 1;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.subtask.done .subtask-title {
  color: var(--text-muted);
  text-decoration: line-through;
}

.new-subtask {
  display: flex;
  gap: 8px;
}
/*#endregion */
