@import url("/fonts/google-fonts.css");

:root {
  color-scheme: light;
  --bg: #f5f1ea;
  --bg-accent: #f0dfc8;
  --ink: #1c1c1c;
  --muted: #5f584f;
  --panel: #fffaf2;
  --accent: #f4a261;
  --accent-dark: #d9773c;
  --green: #2a9d8f;
  --shadow: 0 22px 45px rgba(46, 35, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at top, #fff9f0 0%, var(--bg) 55%, #f0e0cb 100%);
  color: var(--ink);
  min-height: 100vh;
}

body.auth-pending .page {
  opacity: 0;
  pointer-events: none;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 28px 64px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  background: linear-gradient(120deg, #ffe7c7 0%, #f2d3a8 50%, #f3bd84 100%);
  padding: 28px 32px;
  border-radius: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 32px;
  animation: float-in 0.7s ease forwards;
  position: relative;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.7rem;
  color: rgba(0, 0, 0, 0.6);
  margin-bottom: 8px;
}

.hero h1 {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: clamp(2rem, 2.6vw, 3rem);
  margin: 0;
}

.subtitle {
  margin: 8px 0 0;
  color: rgba(0, 0, 0, 0.65);
  max-width: 480px;
}

.subtitle.justify {
  text-align: justify;
}

.year-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.year-controls.footer-year {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 2;
}

.hero-side {
  display: grid;
  gap: 16px;
  justify-items: end;
  align-self: stretch;
}

.menu-wrap {
  position: relative;
  display: grid;
  gap: 8px;
  justify-items: end;
  align-self: start;
}

.greeting {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  width: 100%;
}

.greeting-name {
  font-weight: 600;
  color: #1c1c1c;
}

.menu-button {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: transparent;
  display: grid;
  gap: 4px;
  place-content: center;
  cursor: pointer;
}

.menu-button span {
  width: 18px;
  height: 2px;
  background: #1c1c1c;
  display: block;
}

.menu-button span {
  transition:
    transform .18s ease,
    opacity .18s ease;
  transform-origin: center;
}

.menu-button.menu-open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.menu-button.menu-open span:nth-child(2) {
  opacity: 0;
}

.menu-button.menu-open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.menu-panel a,
.menu-panel button {
  -webkit-tap-highlight-color: transparent;
}

.menu-panel {
  position: absolute;
  top: 0;
  right: 50px;
  background: #fffaf2;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  padding: 12px;
  min-width: 220px;
  box-shadow: var(--shadow);
  z-index: 50;
  display: grid;
  justify-items: start;
  text-align: left;
  transition:
    opacity .18s ease,
    transform .18s ease;
}

.menu-panel.menu-closed {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.menu-panel .greeting {
  margin-bottom: 8px;
}

.menu-panel ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: left;
}

.menu-panel li {
  display: block;
}

.menu-panel .ghost {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  color: #1c1c1c;
}

.menu-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.menu-link:hover {
  text-decoration: underline;
}

.year-label {
  font-size: 1.6rem;
  font-weight: 600;
}

.icon-button {
  border: none;
  background: transparent;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.icon-button:hover {
  transform: translateY(-2px);
  box-shadow: none;
}

.habit-fab {
  position: fixed;
  right: 1px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: none;
  cursor: pointer;
  z-index: 95;
  display: none;
  touch-action: none;
  user-select: none;
  gap: 6px;
  align-items: center;
  justify-content: center;
  transition: left 0.18s ease, top 0.18s ease;
}

.habit-fab.is-dragging {
  transition: none;
}

.habit-fab::before {
  content: "↑";
  white-space: pre;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 0.8;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  -webkit-text-stroke: 1px var(--accent-dark);
  text-shadow: 0 0 1px var(--accent-dark);
  transform: none;
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-form input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-family: inherit;
  font-size: 0.85rem;
}

.auth-form textarea {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-family: inherit;
  font-size: 0.85rem;
  min-height: 120px;
  resize: vertical;
}

.auth-actions {
  display: flex;
  gap: 8px;
}

.auth-actions.spaced {
  margin-top: 16px;
}

.auth-actions button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: none;
  background: var(--accent-dark);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.auth-actions.message-actions button {
  padding: 12px 14px;
  font-size: 0.95rem;
}

.auth-actions + .login-links {
  margin-top: 12px;
}

.auth-actions .ghost {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.login-actions {
  display: flex;
  gap: 10px;
  margin: 12px 0 16px;
}

.login-actions button {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent-dark);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.login-actions a {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent-dark);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.login-actions.back-actions a {
  flex: 1;
  padding: 10px 12px;
  font-size: 1rem;
}

.login-actions .ghost {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.login-actions.hidden {
  display: none;
}

.login-links.hidden {
  display: none;
}

.auth-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.login-page {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 80px);
}

.login-card {
  width: min(420px, 92vw);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.policy-card {
  width: min(860px, 92vw);
}

.login-card h1 {
  font-family: "Fraunces", "Times New Roman", serif;
  margin: 0 0 6px;
}

.login-title-center {
  text-align: center;
}

.login-eyebrow-center {
  text-align: center;
}

.login-subtitle-justify {
  text-align: justify;
}

.login-card .subtitle {
  margin-top: 0;
}

.login-logo {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 12px;
  margin-bottom: 10px;
  margin-left: auto;
  margin-right: auto;
  display: block;
}

.login-links {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}

.login-links a {
  color: var(--accent-dark);
  text-decoration: none;
}

.login-links a:hover {
  text-decoration: underline;
}

.policy-meta {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.policy-content {
  display: grid;
  gap: 16px;
  margin: 16px 0 8px;
  text-align: left;
}

.policy-section h2 {
  margin: 0 0 6px;
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 1.05rem;
}

.policy-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
  text-align: justify;
}

.policy-list {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.policy-content a {
  color: var(--accent-dark);
  text-decoration: none;
}

.policy-content a:hover {
  text-decoration: underline;
}

.site-footer {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.faq-list {
  display: grid;
  gap: 12px;
  margin: 16px 0 8px;
}

.faq-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 12px 0 6px;
}

.faq-search input {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-family: inherit;
  font-size: 0.9rem;
}

.faq-search .ghost {
  padding: 10px 14px;
  border-radius: 10px;
}

.faq-item {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  float: right;
  font-weight: 600;
  color: var(--accent-dark);
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.faq-mark {
  background: #ffe0b8;
  color: inherit;
  padding: 0 2px;
  border-radius: 4px;
}

.auth-note {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}


.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 28px;
}

.layout.no-habits {
  grid-template-columns: 1fr;
}

.layout.no-habits .habits {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  box-sizing: border-box;
}

.panel {
  background: var(--panel);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.6s ease forwards;
}

.floating-calendar {
  width: min(860px, 92vw);
  margin: -12px auto 28px;
  position: relative;
  z-index: 1;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-header h2 {
  margin: 0;
  font-family: "Fraunces", "Times New Roman", serif;
}

.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.habits-list {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}

.habits-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.habits-empty {
  margin: -10px 0 20px;
  color: var(--muted);
  font-weight: 400;
}

.habit-card {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease;
}

.habit-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 0, 0, 0.2);
}

.habit-card.active {
  border-color: var(--accent-dark);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.habit-card .habit-info {
  display: grid;
  gap: 4px;
}

.habit-card span {
  font-weight: 600;
}

.habit-card small {
  color: var(--muted);
}

.habit-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.habit-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-dark);
  cursor: pointer;
}

.habit-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.habit-form {
  display: grid;
  gap: 12px;
}

.habit-details .habit-form {
  margin-top: 12px;
}

.habit-summary.login-button {
  width: 100%;
  border: none;
}

.habit-summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
}

.habit-summary.login-button {
  background: var(--accent-dark);
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  justify-content: center;
  text-align: center;
}

.habit-details[open] > .habit-summary.login-button {
  display: none;
}

.habit-details[open] .habit-summary.login-button {
  border-radius: 12px;
}

.habit-summary::-webkit-details-marker {
  display: none;
}

.habit-summary::after {
  content: "+";
  font-size: 1.1rem;
  color: var(--muted);
}

.habit-summary.login-button::after {
  content: "";
}

.habit-details[open] .habit-summary::after {
  content: "-";
}

.habit-form label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.habit-form input:not([type="color"]) {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-family: inherit;
}

.habit-form input[type="color"] {
  padding: 0 !important;
  width: 44px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: transparent;
  cursor: pointer;
}

.habit-form input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.habit-form input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 10px;
}

.habit-form button {
  padding: 12px;
  border-radius: 14px;
  border: none;
  background: var(--accent-dark);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.habit-form button:hover {
  transform: translateY(-2px);
}

.habit-actions {
  display: flex;
  gap: 10px;
}

.habit-actions .ghost {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.details {
  display: grid;
  gap: 22px;
}

.details-placeholder {
  display: none;
  text-align: center;
}

.details-placeholder h3 {
  margin: 0 0 6px;
  font-family: "Fraunces", "Times New Roman", serif;
}

.details-placeholder p {
  margin: 0;
  color: var(--muted);
}

.details-body {
  display: grid;
  gap: 22px;
}

.details-toggle {
  display: none;
  justify-self: start;
}

.hidden {
  display: none;
}

.edit-panel {
  display: grid;
  gap: 12px;
  background: #fff;
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.edit-panel.hidden {
  display: none;
}

.edit-panel label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.edit-panel input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-family: inherit;
}

.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.edit-actions .primary {
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  background: var(--accent-dark);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.details.empty .stats-grid,
.details.empty .progress-wrap,
.details.empty .panel-inner {
  opacity: 0.5;
  pointer-events: none;
}

.details.no-habits .stats-grid,
.details.no-habits .progress-wrap,
.details.no-habits #weekly-summary,
.details.no-habits .year-bars {
  display: none;
}

.details.no-habits .panel-header,
.details.no-habits .stats-grid,
.details.no-habits .progress-wrap,
.details.no-habits .panel-inner {
  display: none;
}

.details.no-habits {
  padding: 0;
  background: transparent;
  box-shadow: none;
  border: none;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

button.ghost {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: transparent;
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
}

button.ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ghost.is-active {
  border-color: var(--accent-dark);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.note-dialog {
  border: none;
  border-radius: 20px;
  padding: 0;
  width: min(520px, 92vw);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.25);
}

.note-dialog::backdrop {
  background: rgba(25, 20, 14, 0.55);
}

.note-form {
  display: grid;
  gap: 16px;
  padding: 22px;
  background: #fffaf2;
}

.note-form header h3 {
  margin: 0 0 4px;
  font-family: "Fraunces", "Times New Roman", serif;
}

.note-form header p {
  margin: 0;
  color: var(--muted);
}

.note-form label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.note-form textarea {
  resize: vertical;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-family: inherit;
}

.note-fields {
  display: grid;
  gap: 12px;
}

.note-field label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.selected-notes ul {
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
}

.selected-notes li {
  margin: 4px 0;
}

.note-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.note-actions button[type="submit"] {
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  background: var(--green);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.stat {
  background: #fff;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.stat h4 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.stat span {
  font-size: 1.6rem;
  font-weight: 600;
}

.progress-wrap {
  background: #fff;
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.progress-bar {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #f0e0cb;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 0.3s ease;
}

.panel-inner {
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.section-header h3 {
  margin: 0;
  font-family: "Fraunces", "Times New Roman", serif;
}

.section-header p {
  margin: 6px 0 16px;
  color: var(--muted);
}

.weekly-summary {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  align-items: end;
}

.weekly-day {
  display: grid;
  gap: 6px;
  justify-items: center;
  font-size: 0.7rem;
  color: var(--muted);
}

.weekly-day-label {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.weekly-bar {
  width: 100%;
  height: 70px;
  border-radius: 12px;
  background: #f3e2cf;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  position: relative;
}

.weekly-state,
.bar-state { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 0.65rem; font-weight: 700; }
.weekly-day.state-not-applicable .weekly-fill,
.weekly-day.state-future .weekly-fill,
.month-bar.state-not-applicable .fill,
.month-bar.state-future .fill { height: 0 !important; }
.weekly-day.state-not-applicable .weekly-bar,
.month-bar.state-not-applicable .bar { background: color-mix(in srgb, var(--muted) 12%, transparent); }
.weekly-day.state-future .weekly-bar,
.month-bar.state-future .bar { background: color-mix(in srgb, var(--muted) 7%, transparent); }

.weekly-fill {
  width: 100%;
  background: var(--accent);
  transition: height 0.3s ease;
}

.year-bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(24px, 1fr));
  gap: 8px;
}

.month-bar {
  display: grid;
  align-items: end;
  gap: 6px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
}

.month-bar span {
  display: block;
}

.month-bar .bar {
  width: 100%;
  height: 90px;
  border-radius: 12px;
  background: #f3e2cf;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  position: relative;
}

.month-bar .fill {
  width: 100%;
  background: var(--accent);
  transition: height 0.3s ease;
}

.calendar {
  display: grid;
  gap: 18px;
}

.day-notes {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: -10px;
  margin-bottom: 8px;
}

.day-notes h4 {
  margin: 0 0 4px;
  font-size: 0.9rem;
}

.day-notes p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

#edit-notes {
  padding: 6px 24px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  margin-left: auto;
  margin-right: auto;
}

.selected-notes {
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed rgba(0, 0, 0, 0.15);
  background: #fdf8f1;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 14px;
  min-height: 44px;
}

.month {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  padding: 12px;
}

.current-month {
  border-color: var(--accent-dark);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
  background: #fff5e8;
}

.month-details {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  background: #fdf8f1;
  overflow: hidden;
}

.month-summary {
  list-style: none;
  padding: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.month-summary::-webkit-details-marker {
  display: none;
}

.month-summary::after {
  content: "+";
  font-size: 1.1rem;
  color: var(--muted);
}

.month-details[open] .month-summary::after {
  content: "-";
}

.month-body {
  padding: 0 12px 12px;
}

.month h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: pointer;
  background: #fdf8f1;
  transition: transform 0.2s ease, background 0.2s ease;
  position: relative;
}

.day.selected {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

.day .done-check {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
  line-height: 1;
}

.day-checks {
  position: absolute;
  bottom: 4px;
  left: 4px;
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  max-width: calc(100% - 28px);
}

.day-check {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.6rem;
  display: grid;
  place-items: center;
  line-height: 1;
}

.day:hover {
  transform: translateY(-2px);
}

.day.done {
  background: #fdf8f1;
  color: inherit;
  border-color: rgba(0, 0, 0, 0.1);
}

.day.placeholder {
  border: none;
  background: transparent;
  cursor: default;
}


@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 981px) {
  .page {
    max-width: 1280px;
  }

  body[data-page="main"] .page {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 28px;
  }

  body[data-page="main"] .hero {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  body[data-page="main"] #flash-message,
  body[data-page="main"] #floating-calendar,
  body[data-page="main"] #ai-actions-area,
  body[data-page="main"] #main-layout,
  body[data-page="main"] .site-footer {
    grid-column: 1 / -1;
  }

  body[data-page="main"] .layout {
    display: grid;
    width: 100%;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 28px;
  }

  body[data-page="main"] #main-layout:not(.no-habits) .habits {
    grid-column: 1 / 2;
    grid-row: 1;
  }

  body[data-page="main"] #main-layout.no-habits .habits {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 560px;
    width: 100%;
  }

  body[data-page="main"] #floating-calendar {
    width: 100%;
    margin: 0;
    align-self: start;
  }

  body[data-page="main"] #ai-actions-area {
    width: 100%;
    margin: 0;
  }

  body[data-page="main"] #main-layout:not(.no-habits) .details,
  body[data-page="main"] #main-layout:not(.no-habits) .details-placeholder {
    grid-column: 2 / 3;
    grid-row: 1;
    align-self: start;
  }

  body[data-page="main"].no-current-calendar #floating-calendar {
    display: none !important;
  }

  body[data-page="main"].no-current-calendar .details {
    grid-row: 1 !important;
  }

  .layout {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .floating-calendar {
    width: 100%;
    margin: 0;
  }

  .hero {
    flex-wrap: wrap;
  }

  .hero h1 {
    font-size: clamp(2.2rem, 2.9vw, 3.4rem);
  }

  .year-controls.footer-year {
    position: static;
    transform: none;
    width: 100%;
    justify-content: center;
    margin-top: 12px;
  }

  .habits {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 160px);
    overflow: auto;
    align-self: start;
  }

  .menu-panel {
    right: 50px;
    top: 0;
    min-width: 240px;
    padding: 14px 16px;
  }

  .menu-panel .greeting,
  .menu-panel ol {
    color: rgba(0, 0, 0, 0.7);
  }

  .menu-panel ol {
    gap: 10px;
    font-size: 0.9rem;
  }

  .menu-panel li {
    padding: 2px 0;
  }

  .subtitle {
    line-height: 1.6;
    max-width: 520px;
    color: rgba(0, 0, 0, 0.72);
  }

  .hero .subtitle {
    max-width: 460px;
  }

  .panel-header p {
    line-height: 1.6;
    max-width: 560px;
    color: rgba(0, 0, 0, 0.72);
  }

  .details-body {
    gap: 28px;
  }

  .stat {
    background: #fffef9;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 10px 18px rgba(46, 35, 24, 0.06);
    display: grid;
    gap: 6px;
  }

  .panel-inner,
  .stat,
  .progress-wrap {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .panel-inner:hover,
  .stat:hover,
  .progress-wrap:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 26px rgba(46, 35, 24, 0.12);
  }

  .habit-card.active {
    position: relative;
    background: #fff2e4;
    border-color: var(--accent-dark);
    box-shadow: 0 8px 16px rgba(217, 119, 60, 0.18);
  }

  .habit-card.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 999px;
    background: var(--accent-dark);
  }

  .month h4 {
    font-size: 1rem;
  }

  .day {
    font-size: 0.75rem;
  }

  .stat span {
    line-height: 1;
  }

  button:focus-visible,
  a:focus-visible,
  input:focus-visible,
  .menu-button:focus-visible {
    outline: 2px solid var(--accent-dark);
    outline-offset: 3px;
    box-shadow: 0 0 0 4px rgba(217, 119, 60, 0.2);
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  body[data-page="main"].no-current-calendar .layout .details {
    grid-row: 1;
  }

  body[data-page="main"].no-current-calendar .layout .habits {
    grid-row: 2;
  }

  body[data-page="main"].no-current-calendar .layout {
    gap: 16px;
  }

  body[data-page="main"] .details.empty {
    display: none;
  }

  body[data-page="main"] .details.empty + .details-placeholder {
    display: grid;
    gap: 6px;
  }

  body[data-page="main"].no-current-calendar .layout .details.empty + .details-placeholder {
    grid-row: 1;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    padding-top: 32px;
  }

  .hero-side {
    position: absolute;
    top: 20px;
    right: 20px;
    justify-items: end;
  }

  .year-controls.footer-year {
    position: static;
    transform: none;
    margin-top: 5px;
    align-self: center;
  }

  .floating-calendar {
    margin-top: 12px;
  }
}

@media (max-width: 720px) {
  .year-bars {
    grid-template-columns: repeat(6, 1fr);
  }

  .calendar {
    gap: 14px;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 24px 18px 48px;
  }

  .hero {
    padding: var(--hero-menu-offset, 56px) 20px 28px;
    border-radius: 22px;
    gap: 16px;
    transition: padding 0.25s ease;
  }

  .hero h1 {
    font-size: clamp(1.7rem, 6vw, 2.3rem);
  }

  .subtitle {
    max-width: 100%;
  }

  .hero-side {
    position: absolute;
    top: 14px;
    right: 14px;
    justify-items: end;
  }

  .menu-wrap {
    justify-items: end;
  }

  .menu-panel {
    top: 44px;
    right: 0;
    width: min(260px, calc(100vw - 32px));
  }

  .year-controls.footer-year {
    width: 100%;
    justify-content: center;
  }

  .layout {
    gap: 20px;
  }

  .panel {
    padding: 18px;
    border-radius: 20px;
  }

  .panel-inner {
    padding: 14px;
    border-radius: 16px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .detail-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .details-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
  }

  .details-toggle.has-notes {
    padding-right: 42px;
  }

  .details-toggle.has-notes::after {
    content: attr(data-note-count);
    position: absolute;
    right: 12px;
    top: 50%;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--green);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    display: grid;
    place-items: center;
    box-shadow: 0 6px 14px rgba(42, 157, 143, 0.25);
    transform: translateY(-50%);
  }

  .details-toggle.notes-mid::after {
    background: var(--accent);
    box-shadow: 0 6px 14px rgba(244, 162, 97, 0.3);
  }

  .details-toggle.notes-many::after {
    background: var(--accent-dark);
    box-shadow: 0 6px 14px rgba(217, 119, 60, 0.35);
  }

  .details-body {
    overflow: hidden;
    max-height: 2200px;
    opacity: 1;
    transform: translateY(0);
    transition: max-height 0.35s ease, opacity 0.25s ease, transform 0.25s ease;
    will-change: max-height, opacity, transform;
  }

  .details.is-collapsed .details-body {
    max-height: 0;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .progress-labels {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }

  .weekly-summary {
    gap: 8px;
  }

  .weekly-day-label {
    flex-direction: column;
    gap: 2px;
    line-height: 1.1;
  }

  .year-bars {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  .calendar {
    gap: 12px;
  }

  .month,
  .month-details {
    border-radius: 14px;
  }

  .month {
    padding: 8px;
  }

  .month-summary {
    padding: 8px;
    font-size: 0.85rem;
  }

  .month-body {
    padding: 0 8px 8px;
  }

  .month h4 {
    font-size: 0.85rem;
    margin-bottom: 8px;
  }

  .weekdays {
    font-size: 0.65rem;
  }

  .day-notes {
    flex-direction: column;
    align-items: flex-start;
  }

  .login-page {
    min-height: auto;
  }

  .login-card {
    width: 100%;
    padding: 22px;
  }

  body[data-page="thanks"] .login-card h1,
  body[data-page="unconfirmed"] .login-card h1 {
    font-size: 1.5rem;
    line-height: 1.2;
  }

  body[data-page="thanks"] .login-card .subtitle,
  body[data-page="unconfirmed"] .login-card .subtitle {
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: left;
  }

  .login-logo {
    width: 96px;
    height: 96px;
  }

  .login-actions,
  .auth-actions,
  .login-links {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-status {
    flex-direction: column;
    align-items: flex-start;
  }

  .menu-button,
  .icon-button {
    width: 44px;
    height: 44px;
  }

  .habit-fab.is-visible {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .note-dialog {
    width: calc(100vw - 24px);
    max-width: none;
    border-radius: 18px;
  }

  .note-form {
    padding: 18px;
    max-height: 78vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .note-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .month-grid,
  .weekdays {
    gap: 4px;
  }

  .day {
    font-size: 0.65rem;
    border-radius: 8px;
  }

  .day.has-unread-notes::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 0 0 2px rgba(42, 157, 143, 0.2), 0 4px 10px rgba(42, 157, 143, 0.25);
  }

  .day.has-unread-notes.notes-mid::after {
    background: var(--accent);
    box-shadow: 0 0 0 2px rgba(244, 162, 97, 0.2), 0 4px 10px rgba(244, 162, 97, 0.3);
  }

  .day.has-unread-notes.notes-many::after {
    background: var(--accent-dark);
    box-shadow: 0 0 0 2px rgba(217, 119, 60, 0.2), 0 4px 10px rgba(217, 119, 60, 0.35);
  }

  .day .done-check {
    width: 16px;
    height: 16px;
    font-size: 0.6rem;
    bottom: 3px;
    right: 3px;
  }

  .day-checks {
    bottom: 3px;
    left: 3px;
    gap: 1px;
    max-width: calc(100% - 22px);
  }

  .day-check {
    width: 12px;
    height: 12px;
    font-size: 0.55rem;
  }

  .habits-list {
    gap: 8px;
    margin-bottom: 16px;
    max-height: 44vh;
    overflow-y: auto;
    padding-right: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .habit-card {
    padding: 10px 12px;
    position: relative;
  }

  .habit-card span {
    font-size: 0.9rem;
  }

  .habit-card small {
    font-size: 0.75rem;
  }

  .habit-check {
    font-size: 0.7rem;
  }

  body[data-page="main"] #add-habit-button {
    position: static;
    display: block;
    width: min(260px, 100%);
    margin: 14px auto 0;
    padding: 12px 18px;
    border-radius: 999px;
    font-size: 0.85rem;
    text-align: center;
  }

  .habit-card.active {
    background: #fff2e4;
    border-color: var(--accent-dark);
    box-shadow: 0 8px 16px rgba(217, 119, 60, 0.18);
  }

  .habit-card.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 999px;
    background: var(--accent-dark);
  }
}

/* Accessibility hardening */
.link-button {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.habit-card:focus-visible,
.day:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(217, 119, 60, 0.2);
}

/* =========================================================
   POWER HABITS - PERFIL V3
   ========================================================= */


/* ---------- Base compartilhada ---------- */

.profile-card {
  width: min(100%, 430px);
}

.profile-section {
  margin-top: 20px;
  padding: 18px;
  background: rgba(255,255,255,.72);
  border-radius: 18px;
  text-align: left;
}

.profile-section h2 {
  margin: 0 0 18px;
  font-size: 19px;
  line-height: 1.25;
}

.profile-field {
  margin-bottom: 18px;
}

.profile-field:last-child {
  margin-bottom: 0;
}

.profile-field > label,
.profile-section > label {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.35;
}


/* ---------- Avatar ---------- */

.profile-avatar-centered {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 18px 0 24px;
}

.profile-avatar-centered img,
.profile-avatar-large {
  display: block;
  width: 112px;
  height: 112px;
  margin: 0 auto;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 8px 20px rgba(0,0,0,.10);
}

.profile-photo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 12px auto 0;
  padding: 10px 20px;
  border-radius: 999px;
  background: #dd7a35;
  color: #fff;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.profile-photo-button input[type="file"] {
  display: none;
}


/* ---------- Botões / navegação ---------- */

.profile-save,
.profile-back {
  box-sizing: border-box;
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
}

.profile-save {
  margin-top: 20px;
  padding: 13px 16px;
  border: 1px solid #dd7a35;
  background: #dd7a35;
  color: #fff;
  cursor: pointer;
}

.profile-save:disabled {
  opacity: .65;
  cursor: wait;
}

.profile-back {
  margin-top: 12px;
  padding: 12px 16px;
  border: 1px solid #dd7a35;
  background: #fff;
  color: #dd7a35;
}


/* =========================================================
   PERFIL - VISUALIZAÇÃO
   ========================================================= */

body[data-page="perfil"] #profile_name {
  width: 100%;
  margin: 20px auto 28px;
  text-align: center;
}

.profile-summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 18px;
}

.profile-summary-item:last-child {
  margin-bottom: 0;
}

.profile-summary-item strong {
  color: #666;
  font-size: 14px;
  line-height: 1.3;
}

.profile-summary-item span {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
}

.profile-summary-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.profile-summary-pair .profile-summary-item {
  margin-bottom: 0;
}


/* =========================================================
   EDITAR PERFIL
   ========================================================= */

body[data-page="editar-perfil"] {
  overflow-y: auto;
}

body[data-page="editar-perfil"] .page {
  width: 100%;
  min-height: 100vh;
}

body[data-page="editar-perfil"] .login-page {
  height: auto;
  min-height: 100vh;
  padding: 20px;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body[data-page="editar-perfil"] .login-card {
  width: min(100%, 430px);
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  flex: none;
  margin: 0 auto;
  padding: 28px;
  box-sizing: border-box;
}

body[data-page="editar-perfil"] .login-logo {
  display: block;
  width: 80px;
  height: 80px;
  margin: 0 auto 18px;
  object-fit: contain;
}

body[data-page="editar-perfil"] input:not([type="checkbox"]):not([type="file"]),
body[data-page="editar-perfil"] select {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #fff;
  font-size: 15px;
}

body[data-page="editar-perfil"] #birth_date[readonly] {
  background: rgba(0,0,0,.035);
  color: #555;
  cursor: default;
}

body[data-page="editar-perfil"] #primary_goal,
body[data-page="editar-perfil"] #habit_experience {
  display: block;
  width: 100%;
  margin: 0 0 20px;
}


/* ---------- Interesses ---------- */

body[data-page="editar-perfil"] .interest-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 18px;
  row-gap: 14px;
  margin-top: 10px;
}

body[data-page="editar-perfil"] .interest-grid label {
  min-height: 32px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 0;
  background: transparent;
  font-size: 15px;
  line-height: 1.25;
}

body[data-page="editar-perfil"] .interest-grid input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
}

body[data-page="editar-perfil"] #interest_other_text {
  width: 100%;
  margin-top: 16px;
}


/* ---------- Comunicação ---------- */

body[data-page="editar-perfil"] #marketing_consent {
  width: 16px;
  height: 16px;
  margin: 1px 8px 0 0;
}


/* ---------- Footer ---------- */

body[data-page="editar-perfil"] .site-footer {
  position: static;
  inset: auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 22px auto 8px;
  padding: 0;
  text-align: center;
}

body[data-page="editar-perfil"] .site-footer a {
  display: inline-block;
  color: #625b54;
  font-size: 14px;
  line-height: 1.4;
  text-decoration: none;
}

body[data-page="editar-perfil"] .site-footer a:hover {
  text-decoration: underline;
}


/* ---------- Mobile ---------- */

@media (max-width: 420px) {
  body[data-page="editar-perfil"] .profile-section {
    padding: 20px 18px;
  }

  body[data-page="editar-perfil"] .interest-grid {
    column-gap: 14px;
  }
}

@media (max-width: 340px) {
  .profile-summary-pair {
    gap: 12px;
  }
}


/* =========================================================
   POWER HABITS - PREFERÊNCIAS V1
   ========================================================= */

.preferences-card {
  width: min(100%, 430px);
}

.preferences-section {
  margin-top: 20px;
  padding: 18px;
  background: rgba(255,255,255,.72);
  border-radius: 18px;
  text-align: left;
}

.preferences-section h2 {
  margin: 0 0 18px;
  font-size: 19px;
  line-height: 1.25;
}

.preferences-field {
  margin-bottom: 18px;
}

.preferences-field:last-child {
  margin-bottom: 0;
}

.preferences-field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.35;
}

.preferences-field input,
.preferences-field select {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #fff;
  font: inherit;
}

.preferences-field select:disabled {
  background: rgba(0,0,0,.035);
  color: #666;
}

.preferences-toggle-row {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;

  margin-bottom: 18px;
}

.preferences-toggle-row:last-child {
  margin-bottom: 0;
}

.preferences-toggle-row span {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preferences-toggle-row strong {
  font-size: 15px;
  line-height: 1.3;
}

.preferences-toggle-row small {
  color: #6a625b;
  font-size: 13px;
  line-height: 1.35;
}

.preferences-toggle-row
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.preferences-message {
  min-height: 22px;
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
}

body[data-page="preferencias"]
.site-footer {
  position: static;
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 22px auto 8px;
  text-align: center;
}

body[data-page="preferencias"]
.site-footer a {
  color: #625b54;
  text-decoration: none;
  font-size: 14px;
}


/* =========================================================
   POWER HABITS - TEMA V2
   ========================================================= */

:root {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --dark-bg: #171614;
  --dark-surface-1: #24221f;
  --dark-surface-2: #2c2925;
  --dark-surface-3: #332f2a;

  --dark-border: #4a443d;
  --dark-border-soft: #3d3934;

  --dark-text: #f5f0e9;
  --dark-text-secondary: #bdb4aa;
  --dark-text-muted: #918980;

  --dark-accent: #e37b32;
  --dark-accent-soft: rgba(227, 123, 50, .16);
}


/* =========================================================
   BASE
   ========================================================= */

html[data-theme="dark"] body {
  background:
    radial-gradient(
      circle at top,
      #211e1a 0,
      #171614 48%,
      #131210 100%
    );

  color: var(--dark-text);
}

html[data-theme="dark"] .page,
html[data-theme="dark"] .login-page {
  color: var(--dark-text);
}


/* =========================================================
   TIPOGRAFIA
   ========================================================= */

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] strong {
  color: var(--dark-text);
}

html[data-theme="dark"] p,
html[data-theme="dark"] label,
html[data-theme="dark"] span {
  color: inherit;
}

html[data-theme="dark"] .eyebrow,
html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .panel-header p,
html[data-theme="dark"] .details-placeholder p,
html[data-theme="dark"] .preferences-toggle-row small,
html[data-theme="dark"] .profile-summary-item strong {
  color: var(--dark-text-secondary);
}


/* =========================================================
   HERO
   ========================================================= */

html[data-theme="dark"] .hero {
  background:
    linear-gradient(
      145deg,
      #2d2924 0%,
      #24211e 100%
    );

  color: var(--dark-text);

  border-color: var(--dark-border-soft);

  box-shadow:
    0 18px 45px rgba(0,0,0,.25);
}

html[data-theme="dark"] .hero .subtitle {
  color: var(--dark-text-secondary);
}


/* =========================================================
   MENU
   ========================================================= */

html[data-theme="dark"] .menu-panel {
  background: var(--dark-surface-2);
  color: var(--dark-text);
  border-color: var(--dark-border);
  box-shadow:
    0 20px 45px rgba(0,0,0,.35);
}

html[data-theme="dark"] .menu-panel a,
html[data-theme="dark"] .menu-panel button,
html[data-theme="dark"] .menu-panel .greeting {
  color: var(--dark-text);
}

html[data-theme="dark"] .menu-panel .ghost {
  color: var(--dark-accent);
}


/* =========================================================
   PAINÉIS / CARDS
   ========================================================= */

html[data-theme="dark"] .panel,
html[data-theme="dark"] .details,
html[data-theme="dark"] .details-placeholder,
html[data-theme="dark"] .panel-inner,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .profile-section,
html[data-theme="dark"] .preferences-section {
  background: var(--dark-surface-1);
  color: var(--dark-text);

  border-color: var(--dark-border-soft);

  box-shadow:
    0 14px 34px rgba(0,0,0,.22);
}

html[data-theme="dark"] .panel-inner {
  background: var(--dark-surface-2);
}


/* =========================================================
   LISTA DE HÁBITOS
   ========================================================= */

html[data-theme="dark"] .habit-card {
  background: var(--dark-surface-2);
  color: var(--dark-text);

  border-color: var(--dark-border);

  box-shadow: none;
}

html[data-theme="dark"] .habit-card:hover {
  background: var(--dark-surface-3);
}

html[data-theme="dark"] .habit-card.active {
  background:
    linear-gradient(
      135deg,
      #34302b,
      #2c2925
    );

  border-color: var(--dark-accent);

  box-shadow:
    inset 0 0 0 1px rgba(227,123,50,.12);
}

html[data-theme="dark"] .habit-card span {
  color: var(--dark-text);
}

html[data-theme="dark"] .habit-card small {
  color: var(--dark-text-secondary);
}

html[data-theme="dark"] .habits-empty {
  color: var(--dark-text-secondary);
}


/* =========================================================
   CALENDÁRIO
   ========================================================= */

html[data-theme="dark"] .floating-calendar,
html[data-theme="dark"] .calendar,
html[data-theme="dark"] .month,
html[data-theme="dark"] .month-details,
html[data-theme="dark"] .month-body {
  background: var(--dark-surface-1);
  color: var(--dark-text);

  border-color: var(--dark-border);
}

html[data-theme="dark"] .floating-calendar {
  box-shadow:
    0 18px 42px rgba(0,0,0,.28);
}


/* título do mês */

html[data-theme="dark"] .month h4,
html[data-theme="dark"] .month-summary {
  color: var(--dark-text);
}


/* dias da semana */

html[data-theme="dark"] .weekdays {
  color: var(--dark-text-secondary);
}

html[data-theme="dark"] .weekdays span {
  color: var(--dark-text-secondary);
}


/* células */

html[data-theme="dark"] .day {
  background: var(--dark-surface-2);

  color: var(--dark-text);

  border-color: var(--dark-border);

  box-shadow: none;
}

html[data-theme="dark"] .day:hover {
  background: var(--dark-surface-3);
  border-color: #62594f;
}

html[data-theme="dark"] .day.selected {
  background: var(--dark-accent-soft);
  color: var(--dark-text);

  border-color: var(--dark-accent);

  box-shadow:
    inset 0 0 0 1px rgba(227,123,50,.18);
}

html[data-theme="dark"] .day.done {
  background:
    linear-gradient(
      145deg,
      #34413a,
      #29332e
    );

  border-color: #526d5e;

  color: #eef8f1;
}

html[data-theme="dark"] .day.placeholder {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}


/* checks */

html[data-theme="dark"] .day-check,
html[data-theme="dark"] .day .done-check {
  border-color: #777068;
}


/* =========================================================
   DETALHES / ESTATÍSTICAS
   ========================================================= */

html[data-theme="dark"] .details-placeholder h3 {
  color: var(--dark-text);
}

html[data-theme="dark"] .details-placeholder p {
  color: var(--dark-text-secondary);
}

html[data-theme="dark"] .details-toggle {
  color: var(--dark-text);
}

html[data-theme="dark"] .edit-panel {
  background: var(--dark-surface-2);
  border-color: var(--dark-border);
}


/* =========================================================
   RESUMOS E BARRAS
   ========================================================= */

html[data-theme="dark"] .weekly-day {
  background: var(--dark-surface-2);
  border-color: var(--dark-border);
}

html[data-theme="dark"] .weekly-day-label {
  color: var(--dark-text-secondary);
}

html[data-theme="dark"] .month-bar .bar {
  background: #403b35;
}

html[data-theme="dark"] .month-bar .fill {
  background: var(--dark-accent);
}


/* =========================================================
   INPUTS / SELECTS
   ========================================================= */

html[data-theme="dark"]
input:not([type="checkbox"]):not([type="radio"]),

html[data-theme="dark"] select,

html[data-theme="dark"] textarea {
  background: #1c1b19 !important;

  color: var(--dark-text) !important;

  border-color: var(--dark-border) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--dark-text-muted);
}

html[data-theme="dark"] select:disabled,
html[data-theme="dark"] input:disabled,
html[data-theme="dark"] input[readonly] {
  background: #24221f !important;
  color: #999187 !important;
}


/* =========================================================
   CHECKBOX
   ========================================================= */

html[data-theme="dark"] input[type="checkbox"] {
  accent-color: var(--dark-accent);
}


/* =========================================================
   PERFIL
   ========================================================= */

html[data-theme="dark"] .profile-summary-item span {
  color: var(--dark-text);
}

html[data-theme="dark"] .profile-back {
  background: transparent;
  color: var(--dark-accent);
  border-color: var(--dark-accent);
}


/* =========================================================
   PREFERÊNCIAS
   ========================================================= */

html[data-theme="dark"] .preferences-field input,
html[data-theme="dark"] .preferences-field select {
  background: #1c1b19 !important;
}

html[data-theme="dark"] .preferences-toggle-row {
  color: var(--dark-text);
}


/* =========================================================
   FOOTER
   ========================================================= */

html[data-theme="dark"] .site-footer,
html[data-theme="dark"] .site-footer a {
  color: #9f978e !important;
}


/* =========================================================
   FOCO / ACESSIBILIDADE
   ========================================================= */

html[data-theme="dark"] .habit-card:focus-visible,
html[data-theme="dark"] .day:focus-visible,
html[data-theme="dark"] button:focus-visible,
html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] input:focus-visible,
html[data-theme="dark"] select:focus-visible {
  outline-color: var(--dark-accent);
}


/* =========================================================
   TRANSIÇÕES
   ========================================================= */

html[data-theme] body,
html[data-theme] .hero,
html[data-theme] .panel,
html[data-theme] .habit-card,
html[data-theme] .calendar,
html[data-theme] .month,
html[data-theme] .day,
html[data-theme] .login-card,
html[data-theme] .profile-section,
html[data-theme] .preferences-section {
  transition:
    background-color .18s ease,
    color .18s ease,
    border-color .18s ease,
    box-shadow .18s ease;
}


/* =========================================================
   POWER HABITS - DARK THEME V2.1
   Ajustes de contraste e acabamento
   ========================================================= */


/* ---------------------------------------------------------
   BOTÃO SANDUÍCHE
   --------------------------------------------------------- */

html[data-theme="dark"] .menu-button {
  background: #302d29;
  border-color: #5a534b;

  box-shadow:
    0 5px 16px rgba(0, 0, 0, .22);
}

html[data-theme="dark"] .menu-button span {
  background: #f3eee8;
}

html[data-theme="dark"] .menu-button:hover {
  background: #39342f;
  border-color: #e37b32;
}

html[data-theme="dark"] .menu-button:hover span {
  background: #e88946;
}

html[data-theme="dark"] .menu-button.menu-open {
  background: #39342f;
  border-color: #e37b32;
}

html[data-theme="dark"] .menu-button.menu-open span {
  background: #f5f0e9;
}


/* ---------------------------------------------------------
   CARDS DE ESTATÍSTICAS
   --------------------------------------------------------- */

html[data-theme="dark"] .stats-grid > * {
  background: #2c2925 !important;
  color: #f5f0e9 !important;

  border-color: #4a443d !important;

  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.015);
}

html[data-theme="dark"] .stats-grid strong,
html[data-theme="dark"] .stats-grid b {
  color: #f5f0e9 !important;
}

html[data-theme="dark"] .stats-grid span,
html[data-theme="dark"] .stats-grid small,
html[data-theme="dark"] .stats-grid p {
  color: #bdb4aa !important;
}


/* ---------------------------------------------------------
   PROGRESSO / META
   --------------------------------------------------------- */

html[data-theme="dark"] .progress-wrap {
  background: #2c2925;
  border-color: #4a443d;
}

html[data-theme="dark"] .progress-labels {
  color: #bdb4aa;
}

html[data-theme="dark"] .progress-labels strong {
  color: #f5f0e9;
}

html[data-theme="dark"] .progress-bar {
  background: #464038;
  border-color: #565047;
}

html[data-theme="dark"] .progress-fill {
  background:
    linear-gradient(
      90deg,
      #d96f28,
      #ee914c
    );
}


/* ---------------------------------------------------------
   RESUMO SEMANAL
   --------------------------------------------------------- */

html[data-theme="dark"] .weekly-summary {
  background: #2c2925;
  border-color: #4a443d;
}

html[data-theme="dark"] .weekly-day {
  background: transparent;
  border-color: transparent;
}

html[data-theme="dark"] .weekly-bar {
  background: #474139;
  border-color: #554e46;
}

html[data-theme="dark"] .weekly-fill {
  background:
    linear-gradient(
      180deg,
      #e88946,
      #d96f28
    );
}

html[data-theme="dark"] .weekly-day-label {
  color: #bdb4aa;
}


/* ---------------------------------------------------------
   EVOLUÇÃO DO ANO
   --------------------------------------------------------- */

html[data-theme="dark"] .year-bars {
  color: #bdb4aa;
}

html[data-theme="dark"] .month-bar span {
  color: #aaa198;
}

html[data-theme="dark"] .month-bar .bar {
  background: #464038;
  border-color: #514b43;
}

html[data-theme="dark"] .month-bar .fill {
  background:
    linear-gradient(
      180deg,
      #e88946,
      #d96f28
    );
}


/* ---------------------------------------------------------
   OBSERVAÇÕES / ACORDEÕES
   --------------------------------------------------------- */

html[data-theme="dark"] .day-notes {
  background: #2c2925;
  border-color: #4a443d;
}

html[data-theme="dark"] .day-notes h4 {
  color: #f5f0e9;
}

html[data-theme="dark"] .day-notes p {
  color: #bdb4aa;
}


/* ---------------------------------------------------------
   CONTORNOS E FOCO
   --------------------------------------------------------- */

html[data-theme="dark"] .menu-button:focus-visible {
  outline: 2px solid #e37b32;
  outline-offset: 3px;

  box-shadow:
    0 0 0 4px rgba(227,123,50,.18);
}



/* =========================================================
   DARK THEME V2.2 - BOTÕES SECUNDÁRIOS
   ========================================================= */


/* Editar hábito */

html[data-theme="dark"] .habit-summary.login-button,
html[data-theme="dark"] .details-toggle {
  background: #282521;

  color: #f4eee8;

  border: 1px solid #514b44;

  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.015);
}


/* Hover */

html[data-theme="dark"] .habit-summary.login-button:hover,
html[data-theme="dark"] .details-toggle:hover {
  background: #302c27;

  border-color: #756b61;

  color: #fff;
}


/* Ver mais / Ver menos */

html[data-theme="dark"] .details-toggle {
  border-radius: 12px;
}


/* Botões ghost/secundários existentes */

html[data-theme="dark"] button.ghost,
html[data-theme="dark"] .ghost {
  background: transparent;

  color: #e18a4b;

  border: 1px solid #675d53;
}


/* Foco por teclado */

html[data-theme="dark"] .habit-summary.login-button:focus-visible,
html[data-theme="dark"] .details-toggle:focus-visible,
html[data-theme="dark"] button.ghost:focus-visible {
  outline: 2px solid #e37b32;
  outline-offset: 2px;

  border-color: #e37b32;

  box-shadow:
    0 0 0 4px rgba(227,123,50,.14);
}


/* Estado ativo, se aplicável */

html[data-theme="dark"] .habit-summary.login-button:active,
html[data-theme="dark"] .details-toggle:active {
  background: #37312b;
  border-color: #e37b32;
}


/* Mantém botões principais com definição nítida */

html[data-theme="dark"] .profile-save,
html[data-theme="dark"] .login-actions button {
  border: 1px solid #e88946;
}


/* Botão sanduíche - acabamento final */

html[data-theme="dark"] .menu-button {
  border: 1px solid #625a51;
}



/* =========================================================
   POWER HABITS - PUSH V1
   ========================================================= */

.push-preference {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.push-preference-copy {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.push-preference-copy strong {
  font-size: 15px;
  line-height: 1.3;
}

.push-preference-copy small {
  color: #6a625b;
  font-size: 13px;
  line-height: 1.4;
}

.push-status {
  font-size: 14px;
  line-height: 1.35;
  color: #6a625b;
}

.push-action {
  min-height: 44px;
  width: 100%;

  border: 1px solid #dd7a35;
  border-radius: 12px;

  background: transparent;
  color: #dd7a35;

  font: inherit;
  font-weight: 600;

  cursor: pointer;
}

.push-action:not(:disabled):hover {
  background:
    rgba(221, 122, 53, .08);
}

.push-action:disabled {
  opacity: .65;
  cursor: default;
}


/* Dark */

html[data-theme="dark"]
.push-preference-copy small,

html[data-theme="dark"]
.push-status {
  color: var(
    --dark-text-secondary,
    #bdb4aa
  );
}

html[data-theme="dark"]
.push-action {
  border-color:
    var(--dark-accent, #e37b32);

  color:
    var(--dark-accent, #e37b32);
}

html[data-theme="dark"]
.push-action:not(:disabled):hover {
  background:
    rgba(227, 123, 50, .10);
}


/* =========================================================
   POWER HABITS - CALENDARIO VISUAL V2
   Progresso agregado + habito selecionado + observacoes
   ========================================================= */

.day {
  isolation: isolate;
  overflow: visible;
}

.day-number {
  position: relative;
  z-index: 4;
  line-height: 1;
}

.day.not-applicable {
  background: color-mix(in srgb, var(--surface, #fff) 82%, #9aa0a6 18%);
  border-style: dashed;
  color: color-mix(in srgb, currentColor 55%, transparent);
}

.day.not-applicable .day-number {
  opacity: 0.62;
}

.day-not-applicable-marker {
  position: absolute;
  z-index: 5;
  right: 3px;
  bottom: 2px;
  font-size: 0.48rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  pointer-events: none;
}

.day.not-applicable .day-progress-ring,
.day.not-applicable .habit-day-check {
  display: none;
}

.day.future:not(.not-applicable) {
  opacity: 0.72;
}

/*
 * Visão geral:
 * anel proporcional ao percentual de hábitos concluídos.
 */
.day-progress-ring {
  position: absolute;
  z-index: 2;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  pointer-events: none;
  background:
    conic-gradient(
      var(--day-progress-color) var(--day-progress),
      rgba(0, 0, 0, 0.07) var(--day-progress)
    );
}

/*
 * Cria o centro vazado sem depender de mask,
 * melhorando compatibilidade com Safari/iOS.
 */
.day-progress-ring::after {
  content: "";
  position: absolute;
  inset: 1.5px;
  border-radius: 50%;
  background: #fdf8f1;
}

.current-month .day-progress-ring::after {
  background: #fff5e8;
}

/*
 * Observação existente:
 * marcador permanente, independente de já ter sido lida.
 */
.day-note-dot {
  position: absolute;
  z-index: 6;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-dark);
  box-shadow: 0 0 0 2px rgba(217, 119, 60, 0.12);
  pointer-events: none;
}

/*
 * Visão de hábito selecionado:
 * preenchimento suave na cor do hábito.
 */
.day.habit-day-done {
  background:
    color-mix(
      in srgb,
      var(--habit-day-color) 20%,
      #fdf8f1
    );
  border-color:
    color-mix(
      in srgb,
      var(--habit-day-color) 55%,
      rgba(0, 0, 0, 0.1)
    );
}

.current-month .day.habit-day-done {
  background:
    color-mix(
      in srgb,
      var(--habit-day-color) 20%,
      #fff5e8
    );
}

.habit-day-check {
  position: absolute;
  z-index: 5;
  right: 4px;
  bottom: 3px;
  color: var(--habit-day-color);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

/*
 * O marcador antigo de "nota não lida" não participa
 * mais da linguagem visual do calendário.
 */
.day.has-unread-notes::after {
  display: none !important;
}

@media (max-width: 980px) {
  .day-progress-ring {
    width: 27px;
    height: 27px;
  }

  .day-progress-ring::after {
    inset: 1.5px;
  }

  .day-note-dot {
    width: 5px;
    height: 5px;
    top: 3px;
    right: 3px;
  }

  .habit-day-check {
    right: 3px;
    bottom: 3px;
    font-size: 0.70rem;
  }
}

/* Tema escuro */
html[data-theme="dark"] .day-progress-ring::after {
  background: var(--surface, #1f1f1f);
}

html[data-theme="dark"] .current-month .day-progress-ring::after {
  background: var(--surface, #1f1f1f);
}

/* =========================================================
   POWER HABITS - CALENDARIO VISUAL V2.1
   Refinamentos de contexto e hierarquia visual
   ========================================================= */

/*
 * Dia atual:
 * apenas reforço tipográfico, sem nova borda ou cor.
 */
.day.today .day-number {
  font-weight: 700;
}

/*
 * Data selecionada:
 * destaque mais leve para não competir com o progresso.
 */
.day.selected {
  outline: 1px solid var(--accent-dark);
  outline-offset: 2px;
}

/*
 * Ponto de observação:
 * ligeiramente mais afastado do anel.
 */
.day-note-dot {
  top: 2px;
  right: 2px;
}

/*
 * Cabeçalho do mês atual com contexto do hábito selecionado.
 */
.month-current-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.month-habit-context {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-family: "Space Grotesk", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

.month-habit-context::before {
  content: "·";
  color: var(--muted);
}

.month-habit-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.month-habit-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

/*
 * Tema escuro.
 */
html[data-theme="dark"] .day.selected {
  outline-color: var(--dark-accent);
}

html[data-theme="dark"] .month-habit-context,
html[data-theme="dark"] .month-habit-context::before {
  color: var(--dark-text-secondary);
}

@media (max-width: 980px) {
  .day-note-dot {
    top: 1px;
    right: 1px;
  }

  .month-current-title {
    gap: 6px;
  }

  .month-habit-context {
    font-size: 0.66rem;
  }

  .month-habit-dot {
    width: 6px;
    height: 6px;
  }

  .month-habit-name {
    max-width: 130px;
  }
}

/* =========================================================
   POWER HABITS - CALENDARIO V2.1 - AJUSTES FINAIS
   ========================================================= */

.day-note-dot {
  background: #9f552d;
  box-shadow: 0 0 0 2px rgba(159, 85, 45, 0.12);
}

/* =========================================================
   POWER HABITS - CALENDARIO V2.1 - DARK MODE FINAL
   ========================================================= */

/*
 * Observações acima do calendário.
 */
html[data-theme="dark"] .selected-notes {
  background: var(--dark-surface-2);
  border-color: var(--dark-border);
  color: var(--dark-text-secondary);
}

html[data-theme="dark"] .selected-notes ul {
  color: var(--dark-text-secondary);
}

/*
 * Dia selecionado:
 * mantém a superfície neutra e usa apenas contorno.
 */
html[data-theme="dark"] .day.selected {
  background: var(--dark-surface-2);
  color: var(--dark-text);
  border-color: var(--dark-border);
  box-shadow: none;
  outline: 1px solid var(--dark-accent);
  outline-offset: 2px;
}

/*
 * Hábito concluído:
 * preenchimento discreto no dark mode.
 */
html[data-theme="dark"] .day.habit-day-done {
  background:
    color-mix(
      in srgb,
      var(--habit-day-color) 12%,
      var(--dark-surface-2)
    );

  border-color:
    color-mix(
      in srgb,
      var(--habit-day-color) 38%,
      var(--dark-border)
    );
}

html[data-theme="dark"] .current-month .day.habit-day-done {
  background:
    color-mix(
      in srgb,
      var(--habit-day-color) 12%,
      var(--dark-surface-2)
    );
}

/*
 * Quando o dia concluído também estiver selecionado,
 * preserva o preenchimento do hábito e adiciona somente o outline.
 */
html[data-theme="dark"] .day.habit-day-done.selected {
  background:
    color-mix(
      in srgb,
      var(--habit-day-color) 12%,
      var(--dark-surface-2)
    );

  border-color:
    color-mix(
      in srgb,
      var(--habit-day-color) 38%,
      var(--dark-border)
    );

  box-shadow: none;
  outline: 1px solid var(--dark-accent);
  outline-offset: 2px;
}

/*
 * Check com contraste adequado.
 */
html[data-theme="dark"] .habit-day-check {
  color:
    color-mix(
      in srgb,
      var(--habit-day-color) 75%,
      white
    );
}

/*
 * Marcador de observação:
 * âmbar fixo e legível no fundo escuro.
 */
html[data-theme="dark"] .day-note-dot {
  background: #e8a15d;
  box-shadow: 0 0 0 2px rgba(232, 161, 93, 0.16);
}

/*
 * Centro do anel:
 * usa exatamente a superfície das células.
 */
html[data-theme="dark"] .day-progress-ring::after,
html[data-theme="dark"] .current-month .day-progress-ring::after {
  background: var(--dark-surface-2);
}

/* =========================================================
   POWER HABITS - CALENDARIO V2.1
   Alinhamento horizontal dos dias da semana
   ========================================================= */

.weekdays span {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}


/* =========================================================
   POWER HABITS - ACCOUNT DELETE V1
   ========================================================= */

.profile-danger-zone {
  width: 100%;
  box-sizing: border-box;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid rgba(166, 55, 45, 0.22);
}

.profile-danger-copy h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: #a6372d;
}

.profile-danger-copy p {
  margin: 0 0 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #6f665e;
}

.profile-danger-button {
  width: 100%;
  min-height: 46px;
  padding: 11px 16px;
  border: 1px solid #b64337;
  border-radius: 14px;
  background: transparent;
  color: #a6372d;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.profile-danger-button:hover {
  background: rgba(182, 67, 55, 0.08);
}

.profile-danger-button:focus-visible {
  outline: 3px solid rgba(182, 67, 55, 0.28);
  outline-offset: 2px;
}

.account-delete-dialog {
  width: min(92vw, 480px);
  max-width: 480px;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: #fffaf4;
  color: #29231f;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.24);
}

.account-delete-dialog::backdrop {
  background: rgba(20, 16, 13, 0.62);
  backdrop-filter: blur(2px);
}

.account-delete-form {
  padding: 24px;
}

.account-delete-header h2 {
  margin: 0 0 10px;
  color: #a6372d;
}

.account-delete-header p {
  margin: 0;
  line-height: 1.55;
}

.account-delete-warning {
  margin-top: 18px;
  padding: 13px 14px;
  border: 1px solid rgba(182, 67, 55, 0.25);
  border-radius: 12px;
  background: rgba(182, 67, 55, 0.07);
  line-height: 1.45;
}

.account-delete-confirmation {
  display: grid;
  gap: 5px;
  margin-top: 20px;
}

.account-delete-confirmation strong {
  color: #a6372d;
}

#delete-account-confirmation {
  width: 100%;
  box-sizing: border-box;
  margin-top: 10px;
  padding: 12px 13px;
  border: 1px solid rgba(120, 100, 85, 0.35);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
}

.account-delete-status {
  min-height: 1.4em;
  margin: 12px 0 0;
  font-size: 0.88rem;
}

.account-delete-status.is-error {
  color: #a6372d;
}

.account-delete-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.account-delete-actions button {
  min-height: 44px;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.account-delete-cancel {
  border: 1px solid rgba(120, 100, 85, 0.3);
  background: transparent;
  color: inherit;
}

.account-delete-confirm {
  border: 1px solid #a6372d;
  background: #a6372d;
  color: #fff;
}

.account-delete-confirm:disabled,
.account-delete-cancel:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

html[data-theme="dark"] .profile-danger-copy p {
  color: rgba(255, 255, 255, 0.72);
}

html[data-theme="dark"] .profile-danger-copy h2,
html[data-theme="dark"] .profile-danger-button,
html[data-theme="dark"] .account-delete-header h2,
html[data-theme="dark"] .account-delete-confirmation strong,
html[data-theme="dark"] .account-delete-status.is-error {
  color: #f08c7f;
}

html[data-theme="dark"] .account-delete-dialog {
  background: #29231f;
  color: #f7eee7;
}

html[data-theme="dark"] #delete-account-confirmation {
  background: #211c19;
  color: #f7eee7;
  border-color: rgba(255, 255, 255, 0.18);
}

html[data-theme="dark"] .account-delete-confirm {
  background: #b84c40;
  border-color: #b84c40;
}

@media (max-width: 520px) {
  .account-delete-actions {
    grid-template-columns: 1fr;
  }

  .account-delete-confirm {
    order: 1;
  }

  .account-delete-cancel {
    order: 2;
  }
}


/* =========================================================
   POWER HABITS - ACCOUNT SECURITY V1
   ========================================================= */

.account-security-section {
  margin-top: 20px;
}

.account-security-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0;
  border-top: 1px solid rgba(120, 100, 85, 0.16);
}

.account-security-item:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.account-security-item:last-of-type {
  padding-bottom: 0;
}

.account-security-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.account-security-copy strong {
  font-size: 0.92rem;
}

.account-security-value {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  color: #6f665e;
}

.account-security-action {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid #dd7a35;
  border-radius: 12px;
  background: transparent;
  color: #c96d2d;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.account-security-action:hover {
  background: rgba(221, 122, 53, 0.08);
}

.account-security-action:focus-visible {
  outline: 3px solid rgba(221, 122, 53, 0.25);
  outline-offset: 2px;
}

.account-security-status {
  min-height: 0;
  margin: 14px 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
}

.account-security-status:empty {
  display: none;
}

.account-security-status.is-success {
  color: #287b68;
}

.account-security-status.is-error {
  color: #a6372d;
}


/* ---------- Dialog ---------- */

.account-security-dialog {
  width: min(92vw, 480px);
  max-width: 480px;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: #fffaf4;
  color: #29231f;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.24);
}

.account-security-dialog::backdrop {
  background: rgba(20, 16, 13, 0.62);
  backdrop-filter: blur(2px);
}

.account-security-form {
  padding: 24px;
}

.account-security-dialog-header h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.account-security-dialog-header p {
  margin: 0 0 20px;
  color: #6f665e;
  font-size: 0.9rem;
  line-height: 1.5;
}

.account-security-field {
  display: grid;
  gap: 7px;
  margin-top: 15px;
}

.account-security-field > span {
  font-size: 0.86rem;
  font-weight: 600;
}

.account-security-field input {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid rgba(120, 100, 85, 0.32);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
}

.account-security-field input:focus {
  outline: none;
  border-color: #dd7a35;
  box-shadow:
    0 0 0 3px rgba(221, 122, 53, 0.14);
}

.account-security-field input[readonly] {
  background: #f3eee7;
  color: #746b63;
}

.account-security-dialog-status {
  min-height: 1.35em;
  margin: 13px 0 0;
  font-size: 0.86rem;
  line-height: 1.4;
}

.account-security-dialog-status.is-error {
  color: #a6372d;
}

.account-security-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.account-security-actions button {
  min-height: 44px;
  padding: 10px 13px;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.account-security-cancel {
  border: 1px solid rgba(120, 100, 85, 0.3);
  background: transparent;
  color: inherit;
}

.account-security-confirm {
  border: 1px solid #dd7a35;
  background: #dd7a35;
  color: #fff;
}

.account-security-actions button:disabled {
  cursor: wait;
  opacity: 0.55;
}


/* ---------- Dark ---------- */

html[data-theme="dark"] .account-security-value,
html[data-theme="dark"] .account-security-dialog-header p {
  color: var(--dark-text-secondary);
}

html[data-theme="dark"] .account-security-item {
  border-color: var(--dark-border-soft);
}

html[data-theme="dark"] .account-security-action {
  color: var(--dark-accent);
  border-color: var(--dark-accent);
}

html[data-theme="dark"] .account-security-action:hover {
  background: var(--dark-accent-soft);
}

html[data-theme="dark"] .account-security-dialog {
  background: #29231f;
  color: #f7eee7;
}

html[data-theme="dark"] .account-security-field input {
  background: #211c19;
  color: #f7eee7;
  border-color: rgba(255, 255, 255, 0.18);
}

html[data-theme="dark"] .account-security-field input[readonly] {
  background: #24221f;
  color: #aaa198;
}

html[data-theme="dark"] .account-security-status.is-success {
  color: #72c6ad;
}

html[data-theme="dark"] .account-security-status.is-error,
html[data-theme="dark"] .account-security-dialog-status.is-error {
  color: #f08c7f;
}


/* ---------- Mobile ---------- */

@media (max-width: 520px) {
  .account-security-item {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .account-security-action {
    width: 100%;
  }

  .account-security-actions {
    grid-template-columns: 1fr;
  }

  .account-security-confirm {
    order: 1;
  }

  .account-security-cancel {
    order: 2;
  }
}

/* =========================================================
   POWER HABITS - TRANSITION EXPERIENCE V1
   ========================================================= */

.access-gate-layer[hidden] {
  display: none !important;
}

.access-gate-layer {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(25, 20, 14, 0.62);
  backdrop-filter: blur(5px);
  overflow-y: auto;
}

.access-gate-card {
  width: min(100%, 560px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 30px;
  border-radius: 26px;
  background:
    linear-gradient(
      145deg,
      #fffaf2 0%,
      #f9eddd 100%
    );
  color: #29231f;
  box-shadow:
    0 32px 90px rgba(0, 0, 0, 0.28);
  outline: none;
}

.access-gate-eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.7rem;
  font-weight: 700;
  color: #b86028;
}

.access-gate-card h2 {
  margin: 0;
  font-family:
    "Fraunces",
    "Times New Roman",
    serif;
  font-size:
    clamp(1.7rem, 5vw, 2.35rem);
  line-height: 1.12;
}

.access-gate-description,
.access-gate-premium-copy {
  margin: 18px 0 0;
  line-height: 1.6;
  color: #625b54;
}

.access-gate-premium-copy {
  font-weight: 600;
}

.access-gate-actions {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.access-gate-actions button {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.access-gate-primary {
  border: 1px solid #dd7a35;
  background: #dd7a35;
  color: #fff;
}

.access-gate-secondary {
  border: 1px solid rgba(120, 100, 85, 0.28);
  background: transparent;
  color: inherit;
}

.access-gate-primary:focus-visible,
.access-gate-secondary:focus-visible {
  outline: 3px solid rgba(221, 122, 53, 0.28);
  outline-offset: 2px;
}

.access-gate-status {
  min-height: 1.3em;
  margin: 14px 0 0;
  font-size: 0.86rem;
  line-height: 1.4;
  color: #625b54;
  text-align: center;
}

body.ph-access-gate-active {
  overflow: hidden;
}

html[data-theme="dark"] .access-gate-card {
  background:
    linear-gradient(
      145deg,
      #29231f 0%,
      #211c19 100%
    );
  color: #f7eee7;
}

html[data-theme="dark"] .access-gate-description,
html[data-theme="dark"] .access-gate-premium-copy,
html[data-theme="dark"] .access-gate-status {
  color: #c3b8ae;
}

html[data-theme="dark"] .access-gate-secondary {
  border-color: rgba(255, 255, 255, 0.18);
}

@media (max-width: 600px) {
  .access-gate-layer {
    padding: 14px;
  }

  .access-gate-card {
    width: 100%;
    max-height: calc(100vh - 28px);
    padding: 24px 20px;
    border-radius: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .access-gate-layer *,
  .access-gate-layer *::before,
  .access-gate-layer *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* POWER HABITS - TRANSITION EXPERIENCE V1 - JUSTIFIED COPY */

.access-gate-description,
.access-gate-premium-copy {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

/* POWER HABITS - TRANSITION EXPERIENCE V1 - JUSTIFY NO HYPHENS */

.access-gate-description,
.access-gate-premium-copy {
  text-align: justify;
  text-justify: inter-word;
  hyphens: none;
  -webkit-hyphens: none;
}

/* POWER HABITS - TRANSITION EXPERIENCE V1 - JUSTIFIED COPY */

.access-gate-description,
.access-gate-premium-copy {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

/* POWER HABITS - TRANSITION EXPERIENCE V1 - JUSTIFY NO HYPHENS */

.access-gate-description,
.access-gate-premium-copy {
  text-align: justify;
  text-justify: inter-word;
  hyphens: none;
  -webkit-hyphens: none;
}

/* POWER HABITS - TRANSITION EXPERIENCE V1 - PARAGRAPH INDENT */

.access-gate-description,
.access-gate-premium-copy {
  text-indent: 1.5em;
}

/* =========================================================
   POWER HABITS - ADVERTISING EXPERIENCE V1
   ========================================================= */

.ad-gate-layer[hidden] {
  display: none !important;
}

.ad-gate-layer {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(25, 20, 14, 0.72);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}

.ad-gate-card {
  width: min(100%, 520px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 24px;
  background:
    linear-gradient(
      145deg,
      #fffaf2 0%,
      #f8ead7 100%
    );
  color: #29231f;
  box-shadow:
    0 32px 90px rgba(0, 0, 0, 0.30);
  outline: none;
}

.ad-gate-label {
  margin: 0 0 14px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.68rem;
  font-weight: 700;
  color: #8a7567;
}

.ad-gate-media {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 240px;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.62);
}

.ad-gate-image,
.ad-gate-video {
  display: block;
  width: 100%;
  max-height: 52vh;
  object-fit: contain;
}

.ad-gate-image[hidden],
.ad-gate-video[hidden] {
  display: none !important;
}

.ad-gate-meta {
  margin-top: 18px;
  text-align: center;
}

.ad-gate-title {
  margin: 0;
  font-weight: 700;
  line-height: 1.4;
}

.ad-gate-countdown {
  min-height: 1.4em;
  margin: 8px 0 0;
  font-size: 0.88rem;
  color: #70645b;
}

.ad-gate-continue {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  padding: 12px 16px;
  border: none;
  border-radius: 14px;
  background: #dd7a35;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ad-gate-continue:disabled {
  opacity: 0.48;
  cursor: wait;
}

.ad-gate-continue:focus-visible {
  outline: 3px solid rgba(221, 122, 53, 0.28);
  outline-offset: 2px;
}

html[data-theme="dark"] .ad-gate-card {
  background:
    linear-gradient(
      145deg,
      #29231f 0%,
      #211c19 100%
    );
  color: #f7eee7;
}

html[data-theme="dark"] .ad-gate-media {
  background: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .ad-gate-countdown,
html[data-theme="dark"] .ad-gate-label {
  color: #c2b6ac;
}

@media (max-width: 600px) {
  .ad-gate-layer {
    padding: 14px;
  }

  .ad-gate-card {
    width: 100%;
    max-height: calc(100vh - 28px);
    padding: 20px;
    border-radius: 22px;
  }

  .ad-gate-media {
    min-height: 210px;
  }
}

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

/* =========================================================
   POWER HABITS - ADVERTISING EVENTS V1
   ========================================================= */

.ad-gate-open-link {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  padding: 11px 16px;
  border: 1px solid #dd7a35;
  border-radius: 14px;
  background: transparent;
  color: #b86028;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ad-gate-open-link[hidden] {
  display: none !important;
}

html[data-theme="dark"] .ad-gate-open-link {
  color: #f4a261;
  border-color: #f4a261;
}

/* POWER HABITS - ADVERTISING EVENTS V1 - HARDENING */

.ad-gate-open-link:disabled {
  opacity: 0.48;
  cursor: wait;
}

/* =========================================================
   POWER HABITS - ADVERTISING V1 FINAL HARDENING
   ========================================================= */

.ad-gate-card,
.ad-gate-meta,
.ad-gate-title {
  min-width: 0;
  max-width: 100%;
}

.ad-gate-meta {
  width: 100%;
}

.ad-gate-title {
  display: block;
  width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
  text-wrap: pretty;
}

@media (max-width: 600px) {
  .ad-gate-title {
    font-size: 0.95rem;
    line-height: 1.35;
  }
}


/* =========================================================
   HABIT CATEGORY UI V1
   ========================================================= */

.habit-form select,
.edit-panel select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: inherit;
}

.habit-form select:focus,
.edit-panel select:focus {
  outline: 2px solid rgba(221, 122, 53, 0.22);
  outline-offset: 1px;
}

html[data-theme="dark"] .habit-form select,
html[data-theme="dark"] .edit-panel select {
  background: var(--dark-surface, #262422);
  color: var(--dark-text, #f3f0eb);
  border-color: #777068;
}

/* =========================================================
   PHASE 5 - USER-FACING INSIGHTS
   ========================================================= */

.ai-actions-area {
  margin: 18px 0;
}

.ai-actions-area[hidden],
.ai-action-button[hidden],
.insights-modal-layer[hidden],
.insights-result[hidden] {
  display: none !important;
}

.ai-action-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ai-actions-area[data-actions="one"] .ai-action-bar {
  grid-template-columns: minmax(0, 1fr);
}

.ai-actions-area[data-actions="one"] .ai-action-bar > button {
  grid-column: 1 / -1;
}

.ai-action-button.habit-summary.login-button {
  width: 100%;
  min-height: 44px;
  margin: 0;
}

.ai-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

html.insights-modal-active,
body.insights-modal-active {
  overflow: hidden;
}

html.insights-modal-active {
  scrollbar-gutter: stable;
}

.insights-modal-layer {
  position: fixed;
  top: 0;
  left: 0;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  min-height: 100dvh;
  z-index: 10040;
  display: grid;
  place-items: center;
  isolation: isolate;
  box-sizing: border-box;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow: hidden;
}

.insights-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  min-height: 100dvh;
  background: rgba(15, 23, 42, 0.58);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.insights-modal {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px 24px;
  padding: 28px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28), 0 8px 20px rgba(15, 23, 42, 0.16);
}

.insights-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.insights-close:hover {
  border-color: rgba(217, 119, 60, 0.72);
  background: #fff3e3;
}

.insights-close:focus-visible {
  outline: 3px solid rgba(221, 122, 53, 0.38);
  outline-offset: 2px;
}

.insights-controls {
  display: flex;
  justify-content: flex-end;
}

.insights-copy h2,
.insights-copy p {
  margin-top: 0;
}

.insights-copy p:last-child {
  margin-bottom: 0;
  max-width: 70ch;
}

.insights-submit {
  min-width: 180px;
}

.insights-submit:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.insights-status,
.insights-result {
  grid-column: 1 / -1;
  margin: 0;
}

.insights-status[data-state="error"] {
  color: #9f2f24;
}

.insights-result {
  box-sizing: border-box;
  width: 100%;
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  color: inherit;
  font: inherit;
  line-height: 1.55;
  white-space: normal;
  overflow-wrap: anywhere;
}

.insights-result p {
  margin: 0;
}

.insights-result p + p {
  margin-top: 14px;
}

.insights-result strong {
  font-weight: 750;
}

html[data-theme="dark"] .insights-result {
  border-color: #625d57;
  background: var(--dark-surface-2, #2c2925);
  color: var(--dark-text, #f5f0e9);
}

html[data-theme="dark"] .insights-modal {
  color-scheme: dark;
  border-color: var(--dark-border, #4a443d);
  background: var(--dark-surface-1, #24221f);
  color: var(--dark-text, #f5f0e9);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.48), 0 8px 24px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .insights-modal .insights-copy h2,
html[data-theme="dark"] .insights-modal .insights-copy p,
html[data-theme="dark"] .insights-modal .insights-result,
html[data-theme="dark"] .insights-modal .insights-result strong {
  color: var(--dark-text, #f5f0e9);
}

html[data-theme="dark"] .insights-modal .eyebrow {
  color: #e5a06e;
}

html[data-theme="dark"] .insights-modal .insights-status {
  color: var(--dark-text-secondary, #bdb4aa);
}

html[data-theme="dark"] .insights-modal .insights-status[data-state="error"] {
  color: #ff9d91;
}

html[data-theme="dark"] .insights-close {
  border-color: #625d57;
  background: var(--dark-surface-2, #2c2925);
  color: var(--dark-text, #f5f0e9);
}

html[data-theme="dark"] .insights-close:hover {
  border-color: var(--dark-accent, #e37b32);
  background: var(--dark-surface-3, #332f2a);
}

html[data-theme="dark"] .insights-modal .insights-submit.habit-summary.login-button {
  background: #d9773c;
  color: #ffffff;
}

html[data-theme="dark"] .insights-modal .insights-submit.habit-summary.login-button:focus-visible {
  outline-color: rgba(244, 162, 97, 0.62);
}

html[data-theme="dark"] .insights-modal-backdrop {
  background: rgba(10, 9, 8, 0.54);
}

@media (max-width: 700px) {
  .ai-action-bar {
    gap: 8px;
  }

  .insights-modal {
    width: min(680px, calc(100vw - 28px));
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 24px 20px 20px;
  }

  .insights-controls {
    justify-content: stretch;
  }

  .insights-submit.habit-summary.login-button {
    width: 100%;
  }
}

@media (max-width: 330px) {
  .ai-action-bar {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .insights-modal-layer *,
  .insights-modal-layer *::before,
  .insights-modal-layer *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* Habit Goals A2 candidate. Scoped to avoid changing existing controls. */
.habit-goals {
  margin: 20px 0;
  padding: 16px 0;
  border-top: 1px solid var(--border, #d8dde3);
  border-bottom: 1px solid var(--border, #d8dde3);
}
.habit-goals[hidden], .habit-goals-form[hidden], .habit-goal-value-row[hidden],
.habit-goals [hidden] { display: none !important; }
.habit-goals-heading-row, .habit-goal-row-head, .habit-goal-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.habit-goals-heading-row h3, .habit-goals-heading-row p, .habit-goal-row h4 { margin: 0; }
.habit-goals-heading-row p { margin-top: 4px; color: var(--muted, #667085); font-size: 0.875rem; }
.habit-goals-status { min-height: 22px; margin: 10px 0; color: var(--muted, #667085); }
.habit-goals-status.is-error, .habit-goals-error { color: #a52828; }
.habit-goals-list { display: grid; gap: 8px; }
.habit-goal-row { position: relative; padding: 14px 52px 14px 14px; border: 1px solid var(--border, #d8dde3); border-radius: 8px; }
.habit-goal-identity { display: grid; gap: 3px; min-width: 0; }
.habit-goal-name { overflow-wrap: anywhere; }
.habit-goal-progress { color: var(--text, #1d2733); text-align: right; overflow-wrap: anywhere; font-size: 1rem; }
.habit-goal-status { color: var(--muted, #667085); font-size: 0.8rem; font-weight: 600; }
.is-complete .habit-goal-status { color: #176b42; }
.is-n_a .habit-goal-status { color: #59636f; }
.habit-goal-meter { height: 6px; margin-top: 12px; overflow: hidden; border-radius: 3px; background: #e5e9ed; }
.habit-goal-meter-fill { display: block; width: 0; height: 100%; background: #277454; }
.habit-goal-summary { display: block; margin-top: 3px; color: var(--muted, #667085); font-size: 0.75rem; }
.habit-goal-controls { justify-content: flex-end; margin-top: 12px; }
.habit-goal-entry { width: min(180px, 55%); min-height: 46px; font-size: 1rem; }
.habit-goal-save, .habit-goal-toggle { min-height: 46px; font-weight: 700; }
.habit-goal-actions { position: absolute; top: 10px; right: 8px; z-index: 2; }
.habit-goal-actions-toggle { display: grid; place-items: center; width: 40px; height: 40px; cursor: pointer; border-radius: 6px; color: #4b5563; font-size: 1.35rem; font-weight: 700; list-style: none; }
.habit-goal-actions-toggle::-webkit-details-marker { display: none; }
.habit-goal-actions-toggle:hover, .habit-goal-actions-toggle:focus-visible { background: #eef1f4; outline: 2px solid transparent; }
.habit-goal-config-actions { position: absolute; top: 42px; right: 0; display: grid; width: max-content; min-width: 160px; gap: 6px; padding: 8px; border: 1px solid var(--border, #d8dde3); border-radius: 8px; background: #fff; box-shadow: 0 8px 24px rgba(20, 24, 31, 0.14); }
.habit-goal-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 8px; }
.habit-goal-dialog::backdrop { background: rgba(20, 24, 31, 0.62); }
.habit-goal-dialog .habit-goals-form { margin: 0; border: 0; }
.habit-goal-dialog .ghost { color: #26313d; background: #eef1f4; border-color: #9aa5b1; }
#habit-goal-revise-weekdays { display: grid; grid-template-columns: repeat(7, minmax(44px, 1fr)); gap: 6px; }
.habit-goal-weekday-choice { display: grid; place-items: center; min-height: 44px; border: 1px solid var(--border, #d8dde3); border-radius: 6px; }
.habit-goals-form { display: grid; gap: 14px; margin-top: 14px; padding: 14px; border: 1px solid var(--border, #d8dde3); border-radius: 8px; }
.habit-goals-form fieldset { margin: 0; padding: 10px; border: 1px solid var(--border, #d8dde3); border-radius: 6px; }
.habit-goals-form fieldset > label { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; }
.habit-goal-value-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
#habit-goal-weekday-options { display: grid; grid-template-columns: repeat(7, minmax(36px, 1fr)); gap: 6px; margin-top: 8px; }
#habit-goal-weekday-options label { display: grid; place-items: center; min-height: 44px; border: 1px solid var(--border, #d8dde3); border-radius: 6px; }
#habit-goal-weekday-options input { margin: 0 0 3px; }
.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: 430px) {
  .habit-goals-heading-row, .habit-goal-row-head { align-items: flex-start; }
  .habit-goal-value-row { grid-template-columns: 1fr; }
  .habit-goal-row { padding-right: 48px; }
  .habit-goal-row-head { display: grid; gap: 8px; }
  .habit-goal-progress { text-align: left; }
  .habit-goal-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
  .habit-goal-entry { width: 100%; min-width: 0; }
  .habit-goal-toggle { grid-column: 1 / -1; }
  #habit-goal-weekday-options { grid-template-columns: repeat(4, minmax(44px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .habit-goals * { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}

/* Keep the primary first-habit action readable in every viewport. */
body[data-page="main"] #add-habit-button { color: #2b160d; }

/* =========================================================
   FIRST-USER UX V1-R2
   ========================================================= */

/*
 * The mobile rule for #add-habit-button sets display:block.
 * This selector intentionally has enough specificity to ensure
 * the JS .hidden state remains authoritative.
 */
body[data-page="main"] #add-habit-button.hidden {
  display: none !important;
}

/* Primary empty-state CTA in dark theme. */
html[data-theme="dark"] body[data-page="main"] #add-habit-button:not(.hidden) {
  background: #e37b32;
  color: #fff;
  border-color: #e88946;
}

html[data-theme="dark"] body[data-page="main"] #add-habit-button:not(.hidden):hover {
  background: #ee8740;
  color: #fff;
  border-color: #f0a064;
}

/* Clearer separation between legal links. */
.site-footer > span[aria-hidden="true"] {
  display: inline-block;
  margin-inline: 0.35rem;
}

/* =========================================================
   ZERO-HABIT PLACEHOLDER FINAL CLOSURE V1-R3

   With zero habits, #main-layout receives .no-habits.
   The details-placeholder is useful only when habits exist
   but none is selected, so suppress it in the true first-user
   empty state.
   ========================================================= */

body[data-page="main"] #main-layout.no-habits .details-placeholder {
  display: none !important;
}


/* UX-R1: all selectors are scoped to ALL_SUBGOALS presentation. */
#subgoal-hierarchy { --green: #207468; margin: 0 0 16px 12px; padding: 4px 0 4px 14px; border-inline-start: 2px solid var(--green); min-width: 0; font-size: .94rem; }
#subgoal-hierarchy[hidden] { display: none; }
#subgoal-hierarchy h3 { margin: 0; font-size: .9rem; color: var(--muted); font-weight: 500; }
#subgoal-progress { margin: 6px 0 10px; color: var(--muted); font-size: .85rem; }
#subgoal-hierarchy[data-completed="true"] #subgoal-progress { color: var(--green); }
#subgoal-hierarchy-list { display: grid; gap: 2px; }
#subgoal-hierarchy .subgoal-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: start; gap: 4px; padding: 2px 0; border: 0; background: none; box-shadow: none; min-width: 0; }
#subgoal-hierarchy form { display: grid; gap: 8px; margin: 0; min-width: 0; }
#subgoal-hierarchy .subgoal-daily label { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; cursor: pointer; overflow-wrap: anywhere; }
#subgoal-hierarchy input[type="checkbox"] { width: 22px; height: 22px; flex: 0 0 22px; margin: 0; accent-color: var(--green); }
#subgoal-hierarchy input:not([type="checkbox"]), #subgoal-hierarchy button { max-width: 100%; min-width: 0; }
#subgoal-hierarchy input[type="hidden"], #subgoal-hierarchy button[hidden] { display: none; }
#subgoal-hierarchy button, #subgoal-hierarchy summary, #subgoal-hierarchy input:not([type="checkbox"]) { min-height: 44px; }
#subgoal-hierarchy summary { cursor: pointer; display: flex; align-items: center; padding: 8px; border-radius: 8px; color: var(--ink); list-style: none; }
#subgoal-hierarchy summary::-webkit-details-marker { display: none; }
#subgoal-hierarchy summary:focus-visible, #subgoal-hierarchy input:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
#subgoal-hierarchy .subgoal-settings > summary { justify-content: center; width: 44px; margin-inline-start: auto; font-size: 1.3rem; }
#subgoal-hierarchy .subgoal-settings[open] { grid-column: 1 / -1; }
#subgoal-hierarchy .subgoal-settings form, #subgoal-hierarchy .subgoal-add form { margin: 4px 0 12px; padding: 10px; border: 1px solid var(--muted); border-radius: 8px; }
#subgoal-hierarchy .subgoal-settings label { display: grid; gap: 6px; }
#subgoal-hierarchy .subgoal-add { margin-top: 6px; }
#subgoal-hierarchy .subgoal-add > summary { font-size: .88rem; color: var(--muted); }
#subgoal-hierarchy .subgoal-inactive { display: grid; gap: 4px; min-height: 44px; color: var(--muted); overflow-wrap: anywhere; }
#subgoal-hierarchy small { color: var(--muted); }
.habit-card[data-completion-mode="ALL_SUBGOALS"] .subgoal-aggregate { display: inline-block; font-size: .8rem; color: #207468; white-space: nowrap; }
html[data-theme="dark"] #subgoal-hierarchy { --ink: var(--dark-text); --muted: var(--dark-text-secondary); --green: #78d2c4; }
html[data-theme="dark"] .habit-card[data-completion-mode="ALL_SUBGOALS"] .subgoal-aggregate { color: #78d2c4; }

@media (max-width: 600px) {
  .habit-form > label:has(input[type="color"]) + .habit-actions {
    margin-top: -4px;
  }
}
