:root {
  color-scheme: light;
  --paper: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #edf3ef;
  --ink: #26352f;
  --muted: #5f7067;
  --line: #dce5df;
  --accent: #4f7866;
  --accent-dark: #365d4c;
  --accent-soft: #dcece2;
  --danger: #a45c55;
  --shadow: 0 20px 55px rgba(54, 93, 76, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at top right, #e9f1eb 0, transparent 30rem), var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(79, 120, 102, 0.28);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(100% - 32px, 720px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 0 max(32px, env(safe-area-inset-bottom));
}

.topbar,
.welcome-row,
.section-heading,
.form-footer,
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 46px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  color: white;
  background: var(--accent);
  border-radius: 9px;
  font-size: 0.8rem;
}

.text-button {
  padding: 6px 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 0.88rem;
}

.text-button:hover {
  color: var(--accent-dark);
}

.card,
.quote-card {
  border: 1px solid rgba(220, 229, 223, 0.9);
  border-radius: 25px;
  box-shadow: var(--shadow);
}

.card {
  padding: clamp(24px, 5vw, 38px);
  background: rgba(255, 255, 255, 0.86);
}

.login-card {
  max-width: 480px;
  margin: 8vh auto 0;
  text-align: center;
}

.soft-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 22px;
  place-items: center;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 20px;
  font-size: 1.7rem;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 7vw, 3.2rem);
  font-weight: 720;
  letter-spacing: -0.045em;
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  letter-spacing: -0.03em;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.stack-form {
  display: grid;
  gap: 11px;
  margin-top: 28px;
}

.provisioning-panel {
  margin-top: 24px;
  padding: 16px;
  text-align: left;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.device-id-line {
  margin-bottom: 12px;
  font-size: 0.86rem;
}

.device-id-line code {
  color: var(--accent-dark);
  word-break: break-all;
}

.provisioning-panel summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
}

.provisioning-panel pre {
  max-height: 210px;
  margin: 12px 0;
  padding: 12px;
  overflow: auto;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.7rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
}

.secondary-button {
  min-height: 40px;
  padding: 9px 14px;
  color: var(--accent-dark);
  background: white;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 0.84rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  padding: 14px 16px;
  color: var(--ink);
  background: rgba(245, 247, 244, 0.85);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 120, 102, 0.12);
}

textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.55;
}

.primary-button {
  min-height: 48px;
  padding: 12px 20px;
  color: white;
  background: var(--accent);
  border: 0;
  border-radius: 14px;
  font-weight: 750;
  transition: background 160ms ease, transform 160ms ease;
}

.primary-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.form-message {
  min-height: 1.3em;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.45;
}

.error-message {
  color: var(--danger);
}

.success-message {
  color: var(--accent-dark);
}

.welcome-row {
  align-items: end;
  margin-bottom: 26px;
}

.welcome-row > div:first-child {
  min-width: 0;
}

.welcome-row h1 {
  margin-bottom: 10px;
}

.welcome-row .muted {
  max-width: 500px;
  margin-bottom: 0;
}

.streak-badge {
  flex: 0 0 auto;
  padding: 10px 13px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.quote-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
  padding: clamp(26px, 6vw, 44px);
  color: #f5fbf6;
  background: linear-gradient(140deg, #507865, #365d4c);
}

.quote-symbol {
  position: absolute;
  top: -12px;
  right: 23px;
  color: rgba(255, 255, 255, 0.16);
  font-family: Georgia, serif;
  font-size: 9rem;
  line-height: 1;
}

blockquote {
  position: relative;
  max-width: 580px;
  margin: 0 0 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  letter-spacing: -0.025em;
  line-height: 1.22;
}

.quote-author,
.quote-caption {
  position: relative;
  margin-bottom: 0;
}

.quote-author {
  color: #d8eee0;
  font-size: 0.93rem;
}

.quote-caption {
  margin-top: 25px;
  color: rgba(245, 251, 246, 0.76);
  font-size: 0.73rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.checkin-card {
  margin-bottom: 34px;
}

.section-heading {
  align-items: flex-start;
  margin-bottom: 25px;
}

.section-heading.compact {
  align-items: end;
  margin-bottom: 14px;
}

.status-pill {
  padding: 7px 10px;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 999px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.status-pill.complete {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
  margin-bottom: 25px;
}

.mood-button {
  display: grid;
  min-height: 78px;
  place-items: center;
  gap: 5px;
  padding: 10px 4px;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid transparent;
  border-radius: 15px;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.mood-button span {
  font-size: 1.4rem;
}

.mood-button small {
  font-size: 0.72rem;
}

.mood-button.selected {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #b9d4c1;
  box-shadow: inset 0 0 0 1px rgba(79, 120, 102, 0.08);
  transform: translateY(-1px);
}

@media (hover: hover) {
  .mood-button:hover:not(.selected) {
    color: var(--accent-dark);
    background: #e7eee9;
    border-color: #cfddd3;
    transform: translateY(-1px);
  }
}

.note-label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.form-footer {
  align-items: end;
  margin-top: 13px;
}

.form-footer .primary-button {
  flex: 0 0 auto;
}

.small-text {
  font-size: 0.78rem;
}

.history-section {
  padding: 0 4px;
}

.history-list {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  border-radius: 17px;
}

.history-row {
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}

.history-row:last-child {
  border-bottom: 0;
}

.history-row.today {
  background: rgba(220, 236, 226, 0.52);
}

.history-date {
  width: 92px;
  color: var(--muted);
}

.history-mood {
  flex: 1;
}

.history-state {
  color: #66756d;
  font-size: 0.78rem;
}

.history-state.checked {
  color: var(--accent-dark);
}

.footer {
  padding: 42px 0 10px;
  color: #66756d;
  font-size: 0.78rem;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 24px, 720px);
    padding-top: max(15px, env(safe-area-inset-top));
  }

  .topbar {
    margin-bottom: 32px;
  }

  .welcome-row {
    align-items: flex-start;
  }

  .streak-badge {
    margin-top: 6px;
  }

  .card,
  .quote-card {
    border-radius: 20px;
  }

  .mood-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .mood-button {
    grid-column: span 2;
  }

  .mood-button:nth-child(4) {
    grid-column: 2 / span 2;
  }

  .form-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
  }

  .form-footer .primary-button {
    width: 100%;
  }
}

@media (max-width: 360px) {
  .checkin-card .section-heading {
    display: grid;
    gap: 12px;
  }

  .checkin-card .status-pill {
    justify-self: start;
  }
}
