/* ══ Theme tokens ═══════════════════════════════════════════════════════════
   Every color in the app comes from these variables. Light values are the
   default; dark values apply when the OS prefers dark (unless the user picked
   Light in the menu) or when the user picked Dark explicitly. The two dark
   blocks are identical — CSS can't share one rule between a media query and
   an attribute selector. */

:root {
  color-scheme: light;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --surface-hover: #f3f1ec;
  --border: #e5e2db;
  --border-strong: #d4d0c7;
  --text: #1d1c1a;
  --text-muted: #6f6b63;
  --text-faint: #9d988e;
  --accent: #1a7f55;
  --accent-hover: #156a47;
  --accent-contrast: #ffffff;
  --accent-soft: #e2f2ea;
  --accent-text: #16704b;
  --danger: #c0392b;
  --danger-soft: #fbe8e5;
  --warn: #b45309;
  --warn-soft: #fcefdc;
  --focus-ring: 0 0 0 3px rgba(26, 127, 85, 0.22);
  --shadow-sm: 0 1px 2px rgba(28, 25, 20, 0.05);
  --shadow-md: 0 4px 14px rgba(28, 25, 20, 0.08);
  --shadow-lg: 0 16px 40px rgba(28, 25, 20, 0.16);
  --overlay: rgba(28, 25, 20, 0.32);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1a1c;
    --surface: #232326;
    --surface-2: #2c2c30;
    --surface-hover: #2a2a2e;
    --border: #333338;
    --border-strong: #46464d;
    --text: #ececee;
    --text-muted: #a3a3aa;
    --text-faint: #75757c;
    --accent: #3ecf8e;
    --accent-hover: #62dba5;
    --accent-contrast: #0a2419;
    --accent-soft: rgba(62, 207, 142, 0.14);
    --accent-text: #5fd9a2;
    --danger: #f07a6d;
    --danger-soft: rgba(240, 122, 109, 0.14);
    --warn: #f2a852;
    --warn-soft: rgba(242, 168, 82, 0.14);
    --focus-ring: 0 0 0 3px rgba(62, 207, 142, 0.28);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
    --overlay: rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1a1c;
  --surface: #232326;
  --surface-2: #2c2c30;
  --surface-hover: #2a2a2e;
  --border: #333338;
  --border-strong: #46464d;
  --text: #ececee;
  --text-muted: #a3a3aa;
  --text-faint: #75757c;
  --accent: #3ecf8e;
  --accent-hover: #62dba5;
  --accent-contrast: #0a2419;
  --accent-soft: rgba(62, 207, 142, 0.14);
  --accent-text: #5fd9a2;
  --danger: #f07a6d;
  --danger-soft: rgba(240, 122, 109, 0.14);
  --warn: #f2a852;
  --warn-soft: rgba(242, 168, 82, 0.14);
  --focus-ring: 0 0 0 3px rgba(62, 207, 142, 0.28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --overlay: rgba(0, 0, 0, 0.55);
}

/* ══ Base ══════════════════════════════════════════════════════════════════ */

/* Any class that sets `display` would otherwise override the browser's
   built-in hiding for the `hidden` attribute. */
[hidden] {
  display: none !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

a {
  color: var(--accent-text);
}

button {
  font: inherit;
  color: inherit;
}

svg.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-icon] {
  display: inline-flex;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ══ Buttons ═══════════════════════════════════════════════════════════════ */

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 34px;
  padding: 0 0.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
}

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

.btn-ghost,
.btn-link {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover,
.btn-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.5;
  cursor: default;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn--sm {
  width: 28px;
  height: 28px;
}

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

.alert-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 2px var(--bg);
}

.alert-dot--inline {
  position: static;
  margin-left: auto;
  box-shadow: none;
}

/* ══ Form controls ═════════════════════════════════════════════════════════ */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  min-height: 36px;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-error {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
  min-height: 40px;
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ══ App shell ═════════════════════════════════════════════════════════════ */

.shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "topbar topbar"
    "sidebar content"
    "donkey donkey";
  height: 100vh;
  height: 100dvh;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  min-width: 0;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-date {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.done-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.8rem;
  font-weight: 500;
}

.done-pill svg.icon {
  width: 14px;
  height: 14px;
}

/* ── Hamburger menu ── */

.menu-anchor {
  position: relative;
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 230px;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.12s ease-out;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 36px;
  padding: 0 0.65rem;
  border: none;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-2);
}

.menu-item svg.icon {
  color: var(--text-muted);
}

.menu-account {
  display: flex;
  flex-direction: column;
  padding: 0.45rem 0.65rem 0.35rem;
  min-width: 0;
}

.menu-account-name {
  font-weight: 600;
}

.menu-account-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-sep {
  height: 1px;
  margin: 0.35rem 0.25rem;
  background: var(--border);
}

.menu-label {
  padding: 0.25rem 0.65rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: 0 0.35rem 0.35rem;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-2);
}

.theme-switch button {
  min-height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.theme-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ── Sidebar ── */

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem 0.75rem;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.nav-list,
.dimension-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item,
.dimension-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 36px;
  padding: 0 0.7rem;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s;
}

.nav-item svg.icon {
  color: var(--text-muted);
}

.nav-item:hover,
.dimension-link:hover {
  background: var(--surface-2);
}

.nav-item[aria-current="page"],
.dimension-link[aria-current="page"] {
  background: var(--surface);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border);
}

.nav-item[aria-current="page"] svg.icon {
  color: var(--accent-text);
}

.sidebar-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 0.7rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.sidebar-label-link {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  text-decoration: none;
}

.sidebar-label-link:hover {
  color: var(--accent-text);
  text-decoration: underline;
}

.dimension-link {
  font-weight: 500;
}

.dimension-link svg.icon {
  color: var(--dim);
}

.sidebar-empty {
  margin: 0;
  padding: 0 0.7rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Content ── */

.content {
  grid-area: content;
  overflow-y: auto;
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 3rem;
}

.view {
  max-width: 820px;
  margin: 0 auto;
  animation: fade-in 0.18s ease-out;
}

.view-header,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.view-header {
  margin-bottom: 1.25rem;
}

.view-header h1 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.4rem;
}

.view-header h1 svg.icon {
  width: 20px;
  height: 20px;
  color: var(--accent-text);
}

.section-header {
  margin-top: 2.25rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 1.5rem 0 0.75rem;
  font-size: 0.95rem;
}

.section-header .section-title {
  margin: 0;
}

.view-header + .section-title {
  margin-top: 0;
}

.section-title svg.icon {
  color: var(--text-muted);
}

.count {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-faint);
}

.card {
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.empty-state {
  margin: 0 0 0.75rem;
  padding: 1rem 1.1rem;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.empty-state--hero {
  padding: 2rem 1.5rem;
  text-align: center;
}

.empty-state--hero p {
  max-width: 420px;
  margin: 0 auto;
}

/* ══ Entity rows ═══════════════════════════════════════════════════════════ */

.entity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.section-header + .entity-form,
.section-header ~ .empty-state,
.section-header ~ .entity-list {
  margin-top: 0.75rem;
}

.entity-item {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.entity-item:hover {
  border-color: var(--border-strong);
}

.entity-item.is-nested {
  margin-left: calc(var(--depth) * 1.75rem);
}

/* Overdue: a colored left edge, present but not alarming. */
.entity-item.is-overdue::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 3px;
  border-radius: 10px 0 0 10px;
  background: var(--warn);
}

.entity-item-main {
  flex: 1;
  min-width: 0;
}

.entity-item-title {
  font-weight: 600;
  font-size: 0.925rem;
}

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

.entity-item-desc {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.entity-item-desc--empty {
  display: none;
  font-style: italic;
  color: var(--text-faint);
}

.entity-item:hover .entity-item-desc--empty {
  display: block;
}

.entity-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.entity-item-meta:empty {
  display: none;
}

.meta-text {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.meta-text svg.icon {
  width: 13px;
  height: 13px;
}

.meta-text--warn {
  color: var(--warn);
  font-weight: 500;
}

.meta-text--accent {
  color: var(--accent-text);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Dimension tags take their hue from --dim, set inline per dimension. */
.dim-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.5rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--dim) 15%, transparent);
  color: color-mix(in srgb, var(--dim) 72%, var(--text));
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.entity-item-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

/* Row icon buttons fade in on hover where there's a mouse; on touch
   screens there's no hover, so they stay visible. */
@media (hover: hover) {
  .entity-item-actions .icon-btn,
  .list-item .icon-btn {
    opacity: 0;
    transition: opacity 0.15s, background-color 0.15s, color 0.15s;
  }

  .entity-item:hover .entity-item-actions .icon-btn,
  .entity-item:focus-within .entity-item-actions .icon-btn,
  .list-item:hover .icon-btn,
  .list-item:focus-within .icon-btn {
    opacity: 1;
  }
}

/* ── Status pill select ── */

.status-select {
  min-height: 28px;
  padding: 0.15rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tone) 14%, transparent);
  color: color-mix(in srgb, var(--tone) 75%, var(--text));
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.status-select:hover {
  border-color: color-mix(in srgb, var(--tone) 35%, transparent);
}

.status-select option {
  background: var(--surface);
  color: var(--text);
}

.tone-neutral { --tone: #8b8680; }
.tone-info { --tone: #3b82f6; }
.tone-active { --tone: #16a34a; }
.tone-success { --tone: #ca8a04; }
.tone-paused { --tone: #d97706; }

/* ── Task check circle ── */

.task-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  padding: 0;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, background-color 0.15s, transform 0.1s;
}

.task-check:hover {
  border-color: var(--accent);
}

.task-check:active {
  transform: scale(0.9);
}

.task-check svg.icon {
  width: 13px;
  height: 13px;
  stroke-width: 3;
}

.task-check[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

/* ── Inline + panel editing ── */

.inline-editable {
  cursor: text;
  border-radius: 4px;
}

.inline-editable:hover {
  background: var(--surface-hover);
  box-shadow: 0 0 0 3px var(--surface-hover);
}

.inline-edit-input {
  display: block;
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 30px;
  padding: 0.2rem 0.45rem;
  font-size: inherit;
  font-weight: inherit;
}

.entity-edit-form {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.4rem;
  padding: 0.85rem;
  border-radius: 8px;
  background: var(--surface-2);
}

.entity-edit-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.6rem;
}

.entity-edit-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ── Add forms ── */

.entity-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  animation: fade-in 0.15s ease-out;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.form-row > select,
.form-row > input {
  flex: 1;
  min-width: 9rem;
}

.form-row--repeat {
  align-items: center;
}

.form-row--repeat .checkbox-label {
  min-width: 6rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ══ Today ═════════════════════════════════════════════════════════════════ */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 500;
  font-size: 0.85rem;
}

.chip svg.icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.chip-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.chip-meta svg.icon {
  color: var(--warn);
}

/* ── Habit check-ins ── */

.habit-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 38px;
  padding: 0 0.85rem 0 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.habit-chip:hover {
  border-color: var(--accent);
}

.habit-chip .task-check {
  width: 22px;
  height: 22px;
  margin: 0;
  pointer-events: none;
}

.habit-chip[aria-pressed="true"] .habit-chip-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.habit-chip-meta {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.checkin-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.checkin-list:empty {
  display: none;
}

.checkin-strip {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: 10px;
  background: var(--accent-soft);
}

.entity-item .checkin-strip {
  margin-top: 0.4rem;
}

.checkin-question {
  flex: 1;
  min-width: 12rem;
  font-weight: 500;
}

.checkin-actions {
  display: flex;
  gap: 0.4rem;
}

.checkin-note {
  flex-basis: 100%;
  resize: vertical;
}

.checkin-rating {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-width: 15rem;
}

.checkin-rating-prompt,
.checkin-rating-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.checkin-rating-prompt {
  margin-right: 0.2rem;
}

.checkin-rating-label {
  margin-left: 0.2rem;
  font-weight: 500;
  color: var(--accent-text);
}

.rating-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.rating-btn:hover {
  border-color: var(--accent);
}

.rating-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}

/* Recent ratings on a habit row: a higher rating is a deeper tint. */
.rating-trend {
  gap: 3px;
}

.rating-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) var(--fill), var(--surface-2));
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 600;
}

.habit-last-note {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
}

.habit-last-note span {
  font-style: normal;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.checkin-done {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.checkin-done .btn-link {
  min-height: 26px;
  padding: 0 0.4rem;
  font-size: 0.8rem;
}

.form-row--labeled {
  align-items: center;
}

.form-row-label {
  flex-basis: 100%;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

#habit-schedule-target {
  flex: 0 0 5rem;
  min-width: 0;
}

/* ── Feedback on Donkey's responses ── */

.feedback-thumbs {
  display: inline-flex;
  gap: 0.1rem;
  flex-shrink: 0;
}

.feedback-thumbs .icon-btn {
  width: 28px;
  height: 28px;
}

.feedback-thumbs .icon-btn svg.icon {
  width: 14px;
  height: 14px;
}

.feedback-thumbs .icon-btn[aria-pressed="true"] {
  color: var(--accent-text);
  background: var(--accent-soft);
}

.chat-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  max-width: 82%;
}

.chat-message .chat-bubble {
  max-width: 100%;
}

.chat-message .feedback-thumbs {
  padding-left: 0.25rem;
}

@media (hover: hover) {
  .chat-message .feedback-thumbs {
    opacity: 0;
    transition: opacity 0.15s;
  }

  .chat-message:hover .feedback-thumbs,
  .chat-message:focus-within .feedback-thumbs,
  .chat-message .feedback-thumbs:has([aria-pressed="true"]) {
    opacity: 1;
  }
}

.feedback-quote {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-left: 3px solid #1f9d68;
  border-radius: 0 8px 8px 0;
  background: var(--surface-2);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.feedback-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.feedback-reasons input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.feedback-reasons span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
}

.feedback-reasons input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.feedback-reasons input:focus-visible + span {
  box-shadow: var(--focus-ring);
}

/* Donkey speaking in the bottom bar (a check-in response). */
.donkey-prompt.is-speaking {
  color: var(--text);
  font-style: normal;
  white-space: normal;
  animation: fade-in 0.25s ease-out;
}

.donkey-bar:has(.is-speaking) .avatar {
  box-shadow: 0 0 0 4px color-mix(in srgb, #1f9d68 30%, transparent);
  transition: box-shadow 0.3s;
}

/* ══ Life view / dimensions ════════════════════════════════════════════════ */

.dimension-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.85rem;
}

.dimension-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem 1.05rem;
  border: 1px solid var(--border);
  border-top: 3px solid var(--dim);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}

.dimension-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.dimension-card-link {
  color: inherit;
  text-decoration: none;
}

/* Stretches the title link over the whole card, so the card is one click
   target while screen readers still get a normal link. */
.dimension-card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
}

.dimension-card-link:focus-visible {
  outline: none;
}

.dimension-card-link:focus-visible::after {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dim) 35%, transparent);
}

.dimension-card-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.dimension-card-head h3 {
  flex: 1;
  font-size: 0.975rem;
}

.dim-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--dim) 15%, transparent);
  color: var(--dim);
}

.weight-dots {
  display: inline-flex;
  gap: 3px;
}

.weight-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
}

.weight-dots span.is-on {
  background: var(--dim);
}

.dimension-summary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text);
}

.dimension-summary--empty {
  color: var(--text-faint);
  font-style: italic;
}

.dimension-goals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.dimension-goals li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* margin-top: auto pins the bar and footer to the bottom of the card, so
   they line up across a row of cards with different amounts of text. */
.dimension-progress {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--dim);
  transition: width 0.3s;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dimension-footer {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--tone) 75%, var(--text));
}

/* Dimension view */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent-text);
}

.view[data-view="dimension"] .view-header {
  margin-bottom: 0.75rem;
}

.view[data-view="dimension"] .view-header h1 svg.icon {
  color: var(--dim);
}

/* Every row here is in the same dimension, so its tag would only repeat the heading. */
.view[data-view="dimension"] .dim-tag {
  display: none;
}

.form-slot:not(:empty) {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.dimension-completed-toggle {
  margin-top: 0.5rem;
}

/* Edit dimensions panel */

.areas-edit-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.areas-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.35rem 1.25rem;
}

.area-check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 36px;
}

.area-check-row label {
  flex: 1;
  cursor: pointer;
}

.area-check-row select {
  width: 4rem;
  min-height: 30px;
  padding: 0.15rem 0.4rem;
}

.area-check-row select:disabled {
  opacity: 0.35;
}

.areas-custom-row {
  display: flex;
  gap: 0.5rem;
}

.areas-custom-row input {
  flex: 1;
}

.areas-custom-row select {
  width: 4.5rem;
}

/* ══ Calendar ══════════════════════════════════════════════════════════════ */

.view--wide {
  max-width: 1080px;
}

.calendar-header {
  flex-wrap: wrap;
}

.calendar-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

/* Same look as the menu's theme switch. */
.calendar-switch {
  display: inline-flex;
  gap: 2px;
  margin-right: 0.5rem;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-2);
}

.calendar-switch button {
  min-height: 28px;
  padding: 0 0.65rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.calendar-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.calendar {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays div {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.cal-day {
  min-height: 108px;
  padding: 0.35rem 0.4rem 0.45rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  cursor: pointer;
}

.cal-day:hover {
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}

.cal-day:nth-child(7n) {
  border-right: none;
}

.cal-day.is-outside {
  background: var(--bg);
}

.cal-day.is-outside .cal-date {
  color: var(--text-faint);
}

.cal-date {
  align-self: flex-start;
  min-width: 24px;
  height: 24px;
  padding: 0 0.3rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 24px;
  text-align: center;
  color: var(--text-muted);
}

.cal-day.is-today .cal-date,
.cal-week-day.is-today .cal-date {
  background: var(--accent);
  color: var(--accent-contrast);
}

.cal-tasks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-task {
  padding: 0.1rem 0.4rem;
  border-left: 3px solid var(--kind, var(--border-strong));
  border-radius: 4px;
  background: color-mix(in srgb, var(--kind, var(--text-faint)) 12%, transparent);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-task .icon {
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.25em;
  vertical-align: -0.1em;
  color: var(--kind);
}

.cal-task.is-done {
  text-decoration: line-through;
  color: var(--text-faint);
}

.cal-task.is-overdue {
  color: var(--warn);
}

.cal-tasks--wrap .cal-task {
  padding-block: 0.2rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.cal-more {
  padding-left: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Week: seven columns, every item in full. */
.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-week-day {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  min-height: 360px;
  padding: 0.4rem 0.4rem 0.6rem;
  border-right: 1px solid var(--border);
  cursor: pointer;
}

.cal-week-day:last-child {
  border-right: none;
}

.cal-week-day:hover {
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}

.cal-week-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.2rem 0.4rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.cal-week-name {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* 6 months: small months with a mark per item. */
.calendar-six {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.cal-mini {
  padding: 0.6rem 0.7rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.cal-mini-title {
  margin-bottom: 0.4rem;
  padding: 0.15rem 0.3rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.cal-mini-title:hover {
  background: var(--surface-2);
}

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

.cal-mini-weekday {
  padding-bottom: 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-faint);
}

.cal-mini-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  height: 34px;
  padding: 3px 0 0;
  border: 1.5px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.cal-mini-day:hover {
  background: var(--surface-2);
}

.cal-mini-day.is-today {
  border-color: var(--accent);
  font-weight: 700;
}

.cal-marks {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 6px;
}

.cal-mark {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--kind);
}

/* A square turned 45° is wider corner to corner, so it's drawn smaller. */
.cal-mark.is-milestone {
  width: 4px;
  height: 4px;
  border-radius: 0;
  transform: rotate(45deg);
}

.cal-mark.is-done {
  opacity: 0.35;
}

.cal-mark-more {
  font-size: 0.65rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  color: var(--text-muted);
}

/* Day and Agenda: the usual rows. */
.calendar-rows .entity-list + .section-title {
  margin-top: 1.5rem;
}

.cal-agenda-heading:first-child {
  margin-top: 0;
}

.cal-agenda-heading a {
  color: inherit;
  text-decoration: none;
}

.cal-agenda-heading a:hover {
  text-decoration: underline;
}

.cal-agenda-heading.is-overdue {
  color: var(--warn);
}

.kind-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 600;
}

.kind-tag svg.icon {
  width: 13px;
  height: 13px;
  color: var(--kind);
}

.cal-milestone-check {
  width: 18px;
  height: 18px;
  margin: 2px 2px 0;
  accent-color: #9c6644;
  cursor: pointer;
}

/* Milestones under a project row */
.milestone-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.milestone {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.milestone svg.icon {
  width: 0.9em;
  height: 0.9em;
  color: #9c6644;
  flex-shrink: 0;
}

.milestone-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.milestone-date {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.milestone.is-done .milestone-title {
  text-decoration: line-through;
  color: var(--text-faint);
}

/* Remove appears on hover, like row actions; always shown on touch screens. */
.milestone-remove {
  opacity: 0;
}

.milestone:hover .milestone-remove,
.milestone-remove:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .milestone-remove {
    opacity: 1;
  }
}

.milestone-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.milestone-add .milestone-new-title {
  flex: 1 1 10rem;
}

/* ══ Lists ═════════════════════════════════════════════════════════════════ */

.list-items {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 34px;
  padding: 0 0.25rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

.list-item:hover {
  background: var(--surface-hover);
}

.list-item-content {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  cursor: text;
}

.list-item--checked .list-item-content {
  text-decoration: line-through;
  color: var(--text-faint);
}

.list-item-bullet {
  width: 5px;
  height: 5px;
  margin: 0 5px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.list-item-move-btn:disabled {
  visibility: hidden;
}

.list-item-add-form {
  margin-top: 0.4rem;
}

.list-item-add-form input {
  width: 100%;
  min-height: 32px;
  border-style: dashed;
  background: transparent;
}

.list-item-add-form input:focus {
  border-style: solid;
  background: var(--surface);
}

/* ══ Donkey bar + chat ═════════════════════════════════════════════════════ */

.donkey-bar {
  grid-area: donkey;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Donkey's face. The image is already a circle on a cream background. */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.avatar--lg {
  width: 88px;
  height: 88px;
}

.donkey-prompt {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-style: italic;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 76px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: min(420px, calc(100vw - 2rem));
  height: min(620px, calc(100dvh - 160px));
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.18s ease-out;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.chat-panel-title {
  flex: 1;
}

.chat-name {
  font-weight: 600;
}

.chat-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 0.9rem;
}

.chat-empty {
  margin: auto;
  max-width: 260px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.chat-bubble {
  max-width: 82%;
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-bubble--user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--accent);
  color: var(--accent-contrast);
}

.chat-bubble--assistant {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: var(--surface-2);
}

.chat-bubble--pending {
  color: var(--text-muted);
  font-style: italic;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem 0.4rem;
  border-top: 1px solid var(--border);
}

.chat-form input {
  flex: 1;
  min-width: 0;
}

.chat-form .btn-primary {
  padding: 0 0.75rem;
}

.chat-note {
  margin: 0;
  padding: 0 0.9rem 0.7rem;
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* ══ Sign-in screen ═══════════════════════════════════════════════════════ */

.signin-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
  overflow-y: auto;
}

.signin-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: min(380px, 100%);
  padding: 2rem 1.75rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  animation: pop-in 0.18s ease-out;
}

.signin-mascot {
  align-self: center;
  height: 220px;
}

.signin-card h1 {
  font-size: 1.35rem;
  text-align: center;
}

.signin-subtitle {
  margin: -0.5rem 0 0.25rem;
  text-align: center;
  color: var(--text-muted);
}

.signin-hint {
  text-align: center;
}

/* ══ Dialogs ═══════════════════════════════════════════════════════════════ */

.modal {
  width: min(440px, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.modal[open] {
  animation: pop-in 0.16s ease-out;
}

.modal::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(2px);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.1rem 1.25rem 1.25rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -0.25rem -0.4rem 0 0;
}

.modal-header h2 {
  font-size: 1.05rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal--wide {
  width: min(600px, calc(100vw - 2rem));
}

/* Donkey's personality dialog. */
.personality-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.personality-section h3,
.personality-section summary {
  font-size: 0.9rem;
  font-weight: 600;
}

.personality-section summary {
  cursor: pointer;
}

.personality-current {
  font-weight: 400;
  color: var(--text-muted);
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.preset-option {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}

.preset-option span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.preset-option:hover {
  background: var(--surface-hover);
}

.preset-option.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

#personality-sliders h4 {
  margin: 1rem 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Label and value on one line, the slider under them, then what each end means. */
.slider-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 0.75rem;
  margin-bottom: 0.85rem;
  font-size: 0.875rem;
}

.slider-row output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.slider-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

.slider-end {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.slider-end--high {
  text-align: right;
}

.personality-notes {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.personality-notes li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.4rem 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
}

/* Two-step sign-in dialog: one form per state (off / setting up / on). */
.mfa-step {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* White behind the QR code in both themes: scanners need dark-on-light. */
.mfa-qr {
  align-self: center;
  width: 184px;
  height: 184px;
  padding: 6px;
  border-radius: 8px;
  background: #fff;
}

.mfa-codes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem 1.5rem;
  margin: 0;
  padding: 0.75rem 1rem 0.75rem 2.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
}

.mfa-codes-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mfa-codes-warn {
  color: var(--danger);
}

/* Only appears on the printout, to say what the codes are for. */
.mfa-codes-print-title {
  display: none;
}

/* Printing the backup codes prints just the code sheet, nothing else. */
@media print {
  body.printing-codes * {
    visibility: hidden;
  }
  body.printing-codes dialog::backdrop {
    background: none;
  }
  body.printing-codes #mfa-codes-sheet,
  body.printing-codes #mfa-codes-sheet * {
    visibility: visible;
  }
  body.printing-codes #mfa-codes-sheet {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    color: #000;
  }
  body.printing-codes .mfa-codes-print-title {
    display: block;
    margin: 0 0 0.75rem;
    font: 600 1rem/1.4 Inter, sans-serif;
  }
  body.printing-codes .mfa-codes {
    border-color: #000;
  }
}

.mfa-secret {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: var(--surface-muted, var(--surface));
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  word-break: break-all;
  user-select: all;
}

.status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.status-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
}

.status-list li + li {
  border-top: 1px solid var(--border);
}

.status-pill {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.status-pill--ok {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.status-pill--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-pill--error {
  background: var(--danger-soft);
  color: var(--danger);
}

.about {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: -1rem;
  text-align: center;
}

.about h2 {
  margin-top: 0.4rem;
  font-size: 1.3rem;
}

.about p {
  margin: 0;
}

.about-tagline {
  color: var(--text-muted);
}

.about-version {
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.about p:not([class]) {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.about-credits {
  margin-top: 0.5rem !important;
  font-size: 0.75rem;
  color: var(--text-faint);
}

/* ══ Animations ════════════════════════════════════════════════════════════ */

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ══ Narrow windows ════════════════════════════════════════════════════════
   The phone gets its own Flutter app; this just keeps a narrow browser window
   usable. The sidebar becomes a scrolling row of view tabs. */

@media (max-width: 860px) {
  .shell {
    /* minmax(0, …): a plain 1fr column grows to fit its widest content (the
       Donkey bar's greeting, a long row), pushing the page off the screen. */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "topbar"
      "sidebar"
      "content"
      "donkey";
  }

  .sidebar {
    flex-direction: row;
    padding: 0.5rem 0.75rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }

  .nav-list {
    flex-direction: row;
  }

  .nav-item {
    white-space: nowrap;
  }

  .sidebar-dimensions {
    display: none;
  }

  .topbar-date {
    display: none;
  }

  .cal-day {
    min-height: 72px;
  }

  .cal-task {
    font-size: 0.68rem;
  }

  /* Seven columns don't fit: the week stacks into rows, one per day. */
  .calendar-week {
    grid-template-columns: 1fr;
  }

  .cal-week-day {
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .cal-week-day:last-child {
    border-bottom: none;
  }

  .cal-week-day .cal-tasks:empty {
    display: none;
  }

  .cal-week-head {
    border-bottom: none;
    padding-bottom: 0.15rem;
  }

  .chat-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
  }
}

/* ── Projects: open link, progress, project page ── */

.project-row-title {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Always visible (not hover-only like the row actions): it's how a project's
   page is reached. */
.project-open-link {
  flex-shrink: 0;
  color: var(--text-muted);
}

.meta-link {
  color: inherit;
  text-decoration: none;
}

.meta-link:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Projects' own color (KIND_COLORS.project in main.js). */
.project-progress {
  --dim: #9c6644;
  margin-top: 0.5rem;
  max-width: 28rem;
}

.milestone-count {
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.milestone-check:disabled {
  cursor: default;
}

.project-summary {
  margin-bottom: 0.5rem;
}

.project-page-title {
  margin: 0;
  font-size: 1.35rem;
}

.project-page-title .entity-item-title {
  font-size: inherit;
}

.project-group {
  margin-bottom: 0.9rem;
}

.project-group-head {
  margin: 0 0 0.35rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 600;
}

.project-group-title {
  color: var(--text-muted);
}

.project-group-empty {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-faint);
}

.project-milestone-add {
  margin-top: 0.4rem;
}

.choice-dialog-items {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}

.choice-dialog-items:empty {
  display: none;
}
