/* ══ 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 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"] {
  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-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 {
  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);
  scroll-margin-top: 1rem;
  transition: box-shadow 0.3s;
}

.dimension-card.is-highlighted {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dim) 35%, transparent), var(--shadow-md);
}

.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;
}

.dimension-footer {
  margin-top: auto;
  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));
}

/* 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-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.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;
}

.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-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 24px;
  text-align: center;
  color: var(--text-muted);
}

.cal-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(--dim, var(--border-strong));
  border-radius: 4px;
  background: color-mix(in srgb, var(--dim, var(--text-faint)) 12%, transparent);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

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

.calendar-hint {
  margin-top: 0.75rem;
}

/* ══ 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);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1f9d68;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.avatar--lg {
  width: 64px;
  height: 64px;
  font-size: 1.75rem;
}

.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-card .avatar {
  align-self: center;
}

.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;
}

.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 {
    grid-template-columns: 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;
  }

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