@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Fraunces:wght@500;700&display=swap");

: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: 38px;
  height: 38px;
  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-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;
}

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

.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: "V\A V";
  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: rotate(180deg);
}

.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: 1fr auto;
  gap: 10px;
  margin: 12px 0 6px;
}

.faq-search input {
  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 {
  max-width: 560px;
  margin: 0 auto;
}

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

.assistant-inline {
  display: none !important;
}

.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-chatbar {
  width: 100%;
  max-width: 100%;
  margin: 0 0 12px;
}

.habits-chatbar .hero-chatbar__form {
  margin: 0;
  width: 100%;
  display: block;
}

.hero-chatbar__input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: 52px;
  border-radius: 9999px;
  border: 2px solid #F27A5A;
  background: #F7F7F7;
  color: #222;
  padding: 0 18px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.hero-chatbar__input::placeholder {
  color: #9A9A9A;
}

.hero-chatbar__input:hover {
  border-color: #F27A5A;
}

.hero-chatbar__input:focus {
  border-color: #F27A5A;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(242, 122, 90, 0.18);
}

@media (max-width: 480px) {
  .hero-chatbar__input {
    height: 48px;
    font-size: 16px;
    padding: 0 16px;
  }
}

.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: 52px;
  height: 44px;
  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;
}

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

.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"] .layout {
    display: contents;
  }

  body[data-page="main"] .habits {
    grid-column: 1 / 2;
    grid-row: 2;
  }

  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 {
    grid-column: 2 / 3;
    grid-row: 2;
    align-self: start;
  }

  body[data-page="main"] .details {
    grid-column: 2 / 3;
    grid-row: 3;
    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: 2 !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: 36px;
    height: 36px;
  }

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

}
