:root {
  color-scheme: light;
  --bg: #f7f5f0;
  --surface: #fffdfa;
  --text: #181713;
  --muted: #777167;
  --line: #ded8cd;
  --green: #159447;
  --red: #d13737;
  --unknown: #d7d1c7;
  --shadow: 0 12px 34px rgba(42, 35, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 18px clamp(16px, 5vw, 32px) 8px;
}

.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 700;
}

.nav {
  align-items: center;
  display: flex;
  gap: 12px;
  font-size: 0.92rem;
}

.nav form {
  margin: 0;
}

.nav button,
.nav a {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 0;
}

.page {
  margin: 0 auto;
  max-width: 720px;
  padding: 18px clamp(16px, 5vw, 32px) 48px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.2rem;
  line-height: 1.02;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.dashboard-head,
.detail-head {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin-bottom: 22px;
}

.primary-link,
.secondary-link,
.primary-button {
  align-items: center;
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 7px;
  color: var(--surface);
  display: inline-flex;
  min-height: 42px;
  padding: 0 16px;
}

.secondary-link {
  background: transparent;
  color: var(--text);
}

.behaviour-list {
  display: grid;
  gap: 12px;
}

.behaviour-card,
.auth-panel,
.form-panel,
.empty-state,
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.behaviour-card {
  border-left: 5px solid var(--accent);
  padding: 14px;
}

.card-title-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title-row a,
.detail-head h1 {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.colour-dot {
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  height: 10px;
  width: 10px;
}

.streak-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  min-width: 34px;
  padding: 3px 9px;
  text-align: center;
}

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

.week-grid form,
.recent-grid form,
.history-grid form {
  margin: 0;
}

.day-dot {
  align-items: center;
  aspect-ratio: 1;
  background: #eee9df;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  position: relative;
  width: 100%;
}

.day-dot span {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1;
}

.day-dot strong {
  font-size: 0.9rem;
  line-height: 1.1;
}

.day-dot b {
  bottom: -3px;
  font-size: 0.78rem;
  line-height: 1;
  position: absolute;
  right: -2px;
}

.day-dot:disabled {
  cursor: default;
  opacity: 0.42;
}

.state-success {
  background: rgba(21, 148, 71, 0.14);
  border-color: rgba(21, 148, 71, 0.35);
}

.state-failure {
  background: rgba(209, 55, 55, 0.14);
  border-color: rgba(209, 55, 55, 0.35);
}

.is-tapped.state-success {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.is-tapped.state-failure {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

.is-tapped span,
.is-tapped strong {
  color: inherit;
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 26px;
}

.stat {
  padding: 16px;
}

.stat span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.stat strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.4rem;
  line-height: 1;
}

.section-block {
  margin-top: 28px;
}

.section-block h2 {
  margin-bottom: 12px;
}

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

.history-grid {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(auto-fill, minmax(12px, 1fr));
}

.history-box {
  aspect-ratio: 1;
  background: var(--unknown);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  display: block;
  min-width: 0;
  padding: 0;
  width: 100%;
}

.history-box.large {
  align-items: center;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.history-box.large span {
  color: var(--muted);
  font-size: 0.68rem;
}

.history-box.large strong {
  font-size: 0.9rem;
}

.history-box.state-success {
  background: color-mix(in srgb, var(--accent) 72%, white);
}

.history-box.state-failure {
  background: var(--red);
}

.history-box.state-unknown {
  background: var(--unknown);
}

.auth-panel,
.form-panel,
.empty-state {
  padding: 22px;
}

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.form-stack label,
.form-stack fieldset {
  border: 0;
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
}

.form-stack span,
.form-stack legend {
  color: var(--muted);
  font-size: 0.84rem;
}

.form-stack input[type="text"],
.form-stack input[type="email"],
.form-stack input[type="password"],
.form-stack input[type="number"] {
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 44px;
  padding: 0 12px;
  width: 100%;
}

.form-stack input[type="color"] {
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  height: 44px;
  padding: 4px;
  width: 72px;
}

.form-stack ul {
  color: var(--red);
  list-style: none;
  margin: 0;
  padding: 0;
}

.form-stack #id_kind {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.form-stack #id_kind label {
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
}

.archive-form {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 18px;
}

.archive-form button {
  background: transparent;
  border: 0;
  color: var(--red);
  cursor: pointer;
  padding: 0;
}

@media (max-width: 430px) {
  .topbar {
    align-items: flex-start;
  }

  .nav {
    gap: 9px;
  }

  h1 {
    font-size: 1.95rem;
  }

  .behaviour-card {
    padding: 12px;
  }
}

