: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;
  --checkbox-size: 17px;
  --row-gap: 10px;
  /*  width of the checkbox plus the gap after it: what text under the title
      indents by to line up with it */
  --row-indent: calc(var(--checkbox-size) + var(--row-gap));
}

@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-row:hover .icon-button,
.icon-button:focus-visible {
  opacity: 1;
}

/*  without a pointer there is no hover to reveal them, so they stay visible */
@media (hover: none) {
  .icon-button {
    opacity: 1;
  }
}

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

/*  the notes toggle is not destructive, so no red; and a subtask that has
    notes shows its button all the time, so you know there is something in it */
.subtask-toggle {
  font-size: 14px;
}

.subtask-toggle:hover {
  color: var(--text);
}

.subtask-toggle.has-notes {
  opacity: 1;
  color: var(--accent);
}

input[type="checkbox"] {
  width: var(--checkbox-size);
  height: var(--checkbox-size);
  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 help */
.version {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: normal;
}

.login-card .version {
  margin: 12px 0 0;
  text-align: center;
}

.round {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-weight: 600;
}

.help {
  width: min(520px, 92vw);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
}

.help::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.help-header h2 {
  margin: 0;
  font-size: 18px;
}

.help-header .icon-button {
  opacity: 1;
}

.help-body {
  margin: 0;
}

.help-body dt {
  font-weight: 600;
  margin-top: 12px;
}

.help-body dd {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.help-footer {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.help-footer a {
  color: var(--accent);
}
/*#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: var(--row-gap);
  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;
}

.dates {
  white-space: nowrap;
}

/*  on a phone the row has no room next to the title: the dates move to their
    own line underneath, indented to line up with the title */
@media (max-width: 480px) {
  .task-row,
  .subtask-row {
    flex-wrap: wrap;
  }

  .dates {
    flex-basis: 100%;
    order: 1;
    padding-left: var(--row-indent);
    margin-top: -4px;
  }
}

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

.subtask-row {
  display: flex;
  align-items: center;
  gap: var(--row-gap);
  padding: 4px 0 4px 4px;
}

.subtask-details {
  padding: 2px 0 8px calc(var(--row-indent) + 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 */
