:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
  color: #17211c;
  background: #f3f6f1;

  --green: #17683d;
  --green-soft: #dce8df;
  --ink: #17211c;
  --muted: #637167;
  --border: #dce7df;
  --surface: #ffffff;
  --radius: 1.25rem;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.7rem 1rem;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 104, 61, 0.12);
}

button {
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0.7rem 1.15rem;
  transition: filter 0.15s ease, background 0.15s ease;
}

button:hover {
  filter: brightness(1.05);
}

button:active {
  filter: brightness(0.95);
}

button.secondary {
  background: var(--green-soft);
  color: var(--green);
}

button.danger {
  background: #f1d8d4;
  color: #8f271b;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: #fff;
  padding: 0.7rem 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 104, 61, 0.12);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23637167' d='M1.4 0L6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.shell {
  margin: 0 auto;
  max-width: 880px;
  padding: 3rem 1.25rem 2.5rem;
}

.site-footer {
  margin: 0 auto;
  max-width: 880px;
  padding: 0 1.25rem 3rem;
}

.site-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
  text-align: center;
}

.site-footer > p:first-of-type {
  border-top: 1px solid var(--border);
  padding-top: 2rem;
  max-width: 64ch;
  margin: 0 auto;
}

.site-footer a {
  color: var(--green);
  font-weight: 600;
}

.footer-support {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem !important;
}

.coffee-link {
  display: inline-block;
  background: #ffdd00;
  color: #1a1a1a !important;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
}

.coffee-link:hover {
  filter: brightness(0.96);
}

.footer-links {
  margin-top: 1rem;
}

.back-link {
  color: var(--green);
  text-decoration: none;
}

.legal h2 {
  font-size: 1.05rem;
  margin: 0.75rem 0 0;
}

.legal p,
.legal li {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.65;
}

.legal ul {
  margin: 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.legal a {
  color: var(--green);
  font-weight: 600;
}

/* Hero */
.hero {
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: clamp(2rem, 6vw, 3.25rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 0.5rem 0 0.75rem;
  max-width: 22ch;
}

.hero p {
  color: var(--muted);
  font-size: 1.1rem;
  margin: 0;
  max-width: 60ch;
}

.eyebrow {
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  margin: 0;
  text-transform: uppercase;
}

.hero-cta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}

.btn-primary {
  background: var(--green);
  border-radius: var(--radius-pill);
  color: #fff;
  display: inline-block;
  font-weight: 700;
  padding: 0.8rem 1.5rem;
  text-decoration: none;
  transition: filter 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.hero-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.ciq-badge {
  display: inline-flex;
  line-height: 0;
  transition: filter 0.15s ease;
}

.ciq-badge:hover {
  filter: brightness(1.05);
}

.ciq-badge img {
  height: 52px;
  width: auto;
}

/* Watch showcase */
.showcase {
  margin: 3.5rem 0 1rem;
}

.showcase-intro {
  margin-bottom: 1.5rem;
  max-width: 60ch;
}

.showcase-intro h2 {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.showcase-intro p {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0;
}

.showcase-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(2, 1fr);
}

.watch-shot {
  margin: 0;
}

.watch-shot img {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(31, 70, 46, 0.12);
  display: block;
  height: auto;
  width: 100%;
}

.watch-shot figcaption {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.75rem;
  text-align: center;
}

/* How it works */
.steps {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, 1fr);
  margin: 3rem 0 1rem;
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.step-num {
  align-items: center;
  background: var(--green-soft);
  border-radius: var(--radius-pill);
  color: var(--green);
  display: inline-flex;
  font-weight: 800;
  height: 2rem;
  justify-content: center;
  margin-bottom: 0.75rem;
  width: 2rem;
}

.step h3 {
  font-size: 1.1rem;
  margin: 0 0 0.35rem;
}

.step p {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(31, 70, 46, 0.06);
  padding: 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card h2 {
  font-size: 1.15rem;
  margin: 0;
}

.card-intro {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.card-intro p {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

/* Account card */
.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#auth-status {
  color: var(--muted);
  margin: 0;
}

#auth-status.auth-status--cta {
  color: var(--ink);
  font-weight: 600;
  background: #fff6e6;
  border: 1px solid #f2c879;
  border-left: 4px solid #e0991f;
  border-radius: 0.65rem;
  padding: 0.6rem 0.8rem;
}

.email-auth {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.email-auth input {
  border-radius: 0.65rem;
  padding: 0.55rem 0.8rem;
  font-size: 0.92rem;
}

.email-auth button[type="submit"] {
  border-radius: 0.65rem;
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
}

.auth-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  margin-top: 0.1rem;
}

.auth-toggle-line {
  color: var(--muted);
  font-size: 0.82rem;
}

.linklike {
  background: none;
  border: 0;
  color: var(--green);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0;
  width: auto;
}

.linklike:hover {
  text-decoration: underline;
  filter: none;
}

#auth-card .actions button {
  border-radius: 0.65rem;
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
}

/* Compact account bar once signed in */
.card.signed-in {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
}

.card.signed-in h2 {
  display: none;
}

.card.signed-in #auth-status {
  color: var(--ink);
  font-weight: 600;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Habits card */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.card-header > div {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.card-header h2 {
  margin: 0;
}

.card-header p {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

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

.habit-form input {
  width: 16rem;
  max-width: 100%;
}

.habit-form button {
  flex-shrink: 0;
}

.habit-list {
  display: grid;
  gap: 0.6rem;
}

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

.habit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #f7faf7;
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.85rem 1.1rem;
}

.habit-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}

.habit-reorder {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex-shrink: 0;
}

.reorder-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
}

.reorder-btn:hover:not(:disabled) {
  filter: none;
  border-color: var(--green);
  color: var(--green);
}

.reorder-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.habit-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-status {
  color: var(--muted);
  font-size: 0.85rem;
}

.habit-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.habit-actions button {
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
}

.habit-edit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  flex-wrap: wrap;
}

.habit-edit-input {
  flex: 1;
  min-width: 8rem;
  border-radius: 0.65rem;
  padding: 0.5rem 0.8rem;
}

.empty-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
  padding: 0.4rem 0;
}

/* Grid of settings/pairing/today */
.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 1rem;
  align-items: start;
}

.grid .card {
  margin-bottom: 0;
}

/* Field pattern: label stacked above its control */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.field-row input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.field-row button {
  flex-shrink: 0;
}

.status {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
  min-height: 1.1rem;
}

.status:empty {
  min-height: 0;
}

/* Paired devices */
.paired-devices {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #f7faf7;
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.75rem 0.9rem;
}

.device-copy {
  min-width: 0;
}

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

.device-meta {
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.78rem;
  line-height: 1.4;
  margin-top: 0.2rem;
}

.device-item .danger {
  flex-shrink: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

.device-empty {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

/* Today card */
.today-summary {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}

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

.known-issues {
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
  padding-left: 1.1rem;
}

.known-issues li {
  font-size: 0.92rem;
  line-height: 1.55;
}

.known-issues strong {
  color: var(--ink);
}

.today-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
}

.today-mark {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid #c2d2c6;
}

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

.today-streak {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: #b4540a;
  background: #fff1e2;
  border: 1px solid #f3cda0;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.today-item.done {
  color: var(--ink);
}

.today-item.done .today-mark {
  border-color: var(--green);
  background:
    var(--green)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6.3l2.4 2.4 4.6-5'/%3E%3C/svg%3E")
    center / 0.72rem no-repeat;
}

/* Completion history */
.history-scroll {
  overflow-x: auto;
  padding-bottom: 0.3rem;
}

.history-table {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) repeat(var(--history-days), 2.4rem);
  min-width: max-content;
  align-items: center;
}

.history-row {
  display: contents;
}

.history-habit-heading,
.history-date {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  min-height: 2.4rem;
  padding: 0.3rem;
}

.history-date {
  align-content: end;
  text-align: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.history-habit-name,
.history-cell {
  border-top: 1px solid var(--border);
  min-height: 2.6rem;
}

.history-habit-name {
  align-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  padding-right: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-cell {
  margin: 0.45rem;
  min-height: 1.7rem;
  border: 1px solid #d7e1d9;
  border-radius: 0.45rem;
  background: #f3f6f1;
}

.history-cell.done {
  border-color: var(--green);
  background: var(--green);
}

.skeleton-history {
  height: 2.6rem;
  margin-top: 0.45rem;
}

.skeleton {
  background: linear-gradient(90deg, #eef2ee 25%, #e3eae4 37%, #eef2ee 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 0.5rem;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

.skeleton-row {
  height: 3.6rem;
  border-radius: 1rem;
}

.skeleton-line {
  height: 1.05rem;
  width: 70%;
  list-style: none;
}

.skeleton-pill {
  display: inline-block;
  width: 4rem;
  height: 1.75rem;
  border-radius: 0.5rem;
}

.hidden {
  display: none;
}

.sr-only {
  height: 1px;
  margin: -1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

@media (max-width: 640px) {
  .shell {
    padding: 2rem 1rem 3rem;
  }

  .steps {
    grid-template-columns: 1fr;
  }

  .showcase-grid {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .watch-shot {
    max-width: 340px;
  }

  .card-header {
    flex-direction: column;
  }

  .habit-form {
    width: 100%;
  }

  .habit-form input {
    width: 100%;
  }

  .habit-item {
    flex-direction: column;
    align-items: stretch;
  }

  .habit-reorder {
    flex-direction: row;
    order: 1;
  }

  .reorder-btn {
    flex: 1;
    padding: 0.4rem 0.45rem;
  }

  .habit-actions {
    width: 100%;
  }

  .habit-actions button {
    flex: 1;
  }
}
