:root {
  color-scheme: light;
  --ink: #24313d;
  --ink-soft: #65727d;
  --paper: #fffdf9;
  --paper-soft: #fff8ef;
  --line: rgba(46, 57, 69, 0.11);
  --orange: #ff8a65;
  --orange-deep: #ed6b48;
  --yellow: #ffd166;
  --green: #54b89b;
  --blue: #68a7e8;
  --purple: #9c83dc;
  --red: #e76767;
  --shadow: 0 20px 55px rgba(83, 67, 54, 0.11);
  --shadow-soft: 0 10px 28px rgba(88, 72, 58, 0.08);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 17px;
  --radius-sm: 12px;
  --font-sans: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 4%, rgba(255, 209, 102, 0.28), transparent 27rem),
    radial-gradient(circle at 92% 10%, rgba(104, 167, 232, 0.17), transparent 29rem),
    linear-gradient(150deg, #fffaf3 0%, #fffdf9 48%, #f7fbff 100%);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  content: "";
  opacity: 0.42;
  background-image: radial-gradient(rgba(58, 69, 78, 0.12) 0.7px, transparent 0.7px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, black, transparent 65%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(104, 167, 232, 0.38);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

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

.page-glow {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
}

.page-glow--one {
  top: 23rem;
  left: -8rem;
  width: 18rem;
  height: 18rem;
  background: rgba(255, 138, 101, 0.09);
}

.page-glow--two {
  right: -10rem;
  bottom: 5rem;
  width: 25rem;
  height: 25rem;
  background: rgba(84, 184, 155, 0.08);
}

.share-banner {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 12px clamp(18px, 4vw, 40px);
  color: #f8fffc;
  background: #277c68;
  box-shadow: 0 8px 24px rgba(25, 87, 72, 0.17);
}

.share-banner div:first-child {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.share-banner span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.88rem;
}

.share-banner__actions {
  display: flex;
  gap: 8px;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 46px 0 28px;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 34px;
}

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

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--orange-deep);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 5px rgba(255, 138, 101, 0.14);
}

.full-date {
  margin: 0;
  color: #182736;
  font-size: clamp(2.15rem, 5.4vw, 4.2rem);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -0.055em;
}

.date-subtitle {
  margin: 11px 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
}

.button,
.icon-button {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease, opacity 160ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 7px;
  padding: 11px 17px;
  border-radius: 14px;
  font-size: 0.91rem;
  font-weight: 750;
  white-space: nowrap;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-2px);
}

.button:active,
.icon-button:active {
  transform: translateY(0) scale(0.98);
}

.button--primary {
  color: #fff;
  background: linear-gradient(135deg, #ff9675, #f27753);
  box-shadow: 0 10px 22px rgba(237, 107, 72, 0.23);
}

.button--primary:hover {
  box-shadow: 0 14px 27px rgba(237, 107, 72, 0.29);
}

.button--soft {
  color: #42515e;
  border: 1px solid rgba(72, 84, 96, 0.09);
  background: #f4f1ec;
}

.button--soft:hover {
  color: #273744;
  background: #ebe7e1;
}

.button--ghost {
  color: var(--ink-soft);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.button--danger-soft {
  color: #b84a4a;
  border: 1px solid rgba(231, 103, 103, 0.18);
  background: #fff1f1;
}

.button--small {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 11px;
  font-size: 0.82rem;
}

.button[disabled],
.icon-button[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 20px rgba(76, 67, 59, 0.06);
  backdrop-filter: blur(10px);
}

.icon-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, 0.75fr);
  gap: 20px;
  margin-bottom: 52px;
}

.progress-card,
.date-card,
.ranking-card {
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.progress-card {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 4vw, 38px);
  border-radius: var(--radius-xl);
}

.progress-card::after {
  position: absolute;
  top: -55px;
  right: -55px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  content: "";
  background: radial-gradient(circle, rgba(255, 209, 102, 0.36), rgba(255, 209, 102, 0));
  pointer-events: none;
}

.progress-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.progress-card h2,
.date-card h2,
.section-heading h2,
.ranking-card h3,
.modal h2,
.modal h3 {
  margin: 0;
  letter-spacing: -0.03em;
}

.progress-card h2 {
  max-width: 500px;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
}

.progress-message {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.progress-ring {
  --progress: 0;
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 136px;
  height: 136px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--orange) calc(var(--progress) * 1turn), rgba(255, 138, 101, 0.14) 0);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.progress-ring::before {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  content: "";
  background: #fffaf4;
  box-shadow: inset 0 4px 18px rgba(111, 84, 65, 0.06);
}

.progress-ring__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.progress-ring__inner strong {
  margin-bottom: 1px;
  color: var(--ink);
  font-size: 2.05rem;
  font-weight: 900;
  line-height: 1;
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 28px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 138, 101, 0.13);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffb06f, #ff8061);
  transition: width 450ms cubic-bezier(0.22, 1, 0.36, 1);
}

.daily-quote {
  margin-top: 16px;
  color: #927761;
  font-size: 0.82rem;
}

.date-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 25px;
  border-radius: var(--radius-xl);
}

.date-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.date-card h2 {
  font-size: 1.55rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  color: #766a5e;
  border-radius: 999px;
  background: #f2eee9;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge--green {
  color: #25755f;
  background: #e8f7f1;
}

.status-badge--cloud {
  color: #356b9c;
  background: #ebf5ff;
}

.status-badge--error {
  color: #a54444;
  background: #fff0f0;
}

.date-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 25px 0 15px;
}

.date-tab {
  min-height: 65px;
  padding: 9px 4px;
  color: var(--ink-soft);
  border: 1px solid rgba(59, 69, 77, 0.08);
  border-radius: 15px;
  background: #f8f5f0;
  cursor: pointer;
  transition: 160ms ease;
}

.date-tab span,
.date-tab small {
  display: block;
}

.date-tab span {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
}

.date-tab small {
  margin-top: 5px;
  font-size: 0.68rem;
}

.date-tab:hover {
  border-color: rgba(255, 138, 101, 0.3);
  transform: translateY(-1px);
}

.date-tab.is-active {
  color: #a54e36;
  border-color: rgba(255, 138, 101, 0.35);
  background: linear-gradient(145deg, #fff4e9, #ffe8dc);
  box-shadow: 0 7px 18px rgba(237, 107, 72, 0.1);
}

.date-helper {
  margin: 0;
  color: #8b8179;
  font-size: 0.76rem;
  line-height: 1.55;
}

.content-section {
  margin-bottom: 58px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.section-heading h2 {
  font-size: clamp(1.65rem, 3.5vw, 2.35rem);
}

.section-meta,
.period-range {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.83rem;
}

.habit-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.habit-card {
  --habit-color: #ff8a65;
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 96px;
  gap: 15px;
  padding: 17px 15px 17px 18px;
  overflow: hidden;
  border: 1px solid rgba(53, 64, 74, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  animation: card-in 320ms both;
}

.habit-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  content: "";
  background: var(--habit-color);
}

.habit-card:hover {
  border-color: color-mix(in srgb, var(--habit-color) 35%, transparent);
  box-shadow: 0 16px 34px rgba(70, 60, 50, 0.11);
  transform: translateY(-3px);
}

.habit-card.is-complete {
  border-color: color-mix(in srgb, var(--habit-color) 40%, transparent);
  background: color-mix(in srgb, var(--habit-color) 7%, white);
}

.habit-check {
  position: relative;
  display: grid;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--habit-color);
  border: 0;
  border-radius: 17px;
  background: color-mix(in srgb, var(--habit-color) 13%, white);
  cursor: pointer;
  transition: 180ms ease;
}

.habit-check:hover {
  transform: scale(1.05) rotate(-2deg);
}

.habit-check:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.habit-check__emoji {
  font-size: 1.65rem;
  line-height: 1;
}

.habit-check__mark {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  color: #fff;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--habit-color);
  font-size: 0.74rem;
  font-weight: 900;
  opacity: 0;
  transform: scale(0.4);
  transition: 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.habit-card.is-complete .habit-check__mark {
  opacity: 1;
  transform: scale(1);
}

.habit-card__content {
  min-width: 0;
}

.habit-card__title-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.habit-card h3 {
  overflow: hidden;
  margin: 0;
  font-size: 1.02rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-card.is-complete h3 {
  color: #41535d;
}

.habit-note {
  overflow: hidden;
  margin: 6px 0 0;
  color: #7b858d;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-streak {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  margin-top: 7px;
  padding: 3px 8px;
  color: #836949;
  border-radius: 999px;
  background: #fff5dc;
  font-size: 0.69rem;
  font-weight: 800;
}

.habit-streak.is-empty {
  color: #878e93;
  background: #f1f2f2;
}

.habit-actions {
  position: relative;
  align-self: start;
}

.more-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #80878c;
  border: 0;
  border-radius: 11px;
  background: transparent;
  cursor: pointer;
  letter-spacing: 1px;
  transition: 150ms ease;
}

.more-button:hover {
  color: var(--ink);
  background: rgba(52, 63, 73, 0.06);
}

.habit-menu {
  position: absolute;
  top: 39px;
  right: 0;
  z-index: 15;
  display: grid;
  min-width: 132px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(56, 49, 43, 0.16);
  animation: menu-in 150ms ease both;
}

.habit-menu button {
  padding: 9px 10px;
  text-align: left;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
}

.habit-menu button:hover {
  background: #f5f2ed;
}

.habit-menu button:disabled {
  cursor: default;
  opacity: 0.35;
}

.habit-menu .menu-danger {
  color: #ba4a4a;
}

.empty-state {
  padding: 42px 24px;
  text-align: center;
  border: 1px dashed rgba(77, 91, 103, 0.2);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.62);
}

.empty-state__art {
  font-size: 3.4rem;
  animation: float 3.5s ease-in-out infinite;
}

.empty-state h3 {
  margin: 12px 0 7px;
  font-size: 1.4rem;
}

.empty-state p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 22px 0;
}

.suggestion-chip {
  padding: 9px 13px;
  color: #4e5d68;
  border: 1px solid rgba(62, 75, 85, 0.1);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(76, 66, 56, 0.06);
  transition: 160ms ease;
}

.suggestion-chip:hover {
  color: #b34f33;
  border-color: rgba(255, 138, 101, 0.34);
  background: #fff7f1;
  transform: translateY(-2px);
}

.stats-section {
  position: relative;
  padding: clamp(24px, 4vw, 38px);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 248, 239, 0.92), rgba(244, 249, 255, 0.88));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8), var(--shadow-soft);
}

.section-heading--stats {
  align-items: center;
}

.segmented-control {
  display: flex;
  padding: 4px;
  border: 1px solid rgba(74, 84, 93, 0.08);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.72);
}

.segmented-control button {
  min-width: 70px;
  padding: 8px 13px;
  color: #7a8389;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
  transition: 150ms ease;
}

.segmented-control button.is-active {
  color: #273640;
  background: #fff;
  box-shadow: 0 5px 13px rgba(69, 62, 56, 0.09);
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.metric-card span {
  display: block;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  letter-spacing: -0.04em;
}

.metric-card small {
  display: block;
  margin-top: 5px;
  color: #92999e;
  font-size: 0.68rem;
}

.ranking-card {
  padding: 22px;
  border-radius: 22px;
}

.ranking-card__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.ranking-card__header h3 {
  font-size: 1.1rem;
}

.ranking-card__header p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.ranking-list {
  display: grid;
}

.ranking-row {
  display: grid;
  grid-template-columns: 34px auto minmax(100px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(55, 65, 75, 0.07);
}

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

.rank-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #7e8388;
  border-radius: 9px;
  background: #f2f1ee;
  font-size: 0.72rem;
  font-weight: 850;
}

.ranking-row:nth-child(1) .rank-number {
  color: #8c5d10;
  background: #fff0bd;
}

.ranking-row:nth-child(2) .rank-number {
  color: #61717e;
  background: #edf1f4;
}

.ranking-row:nth-child(3) .rank-number {
  color: #985d36;
  background: #f9e6d8;
}

.rank-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 13px;
  background: color-mix(in srgb, var(--habit-color) 14%, white);
  font-size: 1.25rem;
}

.rank-info {
  min-width: 0;
}

.rank-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.rank-title {
  overflow: hidden;
  font-size: 0.85rem;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-rate {
  color: var(--ink-soft);
  font-size: 0.7rem;
  white-space: nowrap;
}

.rank-progress {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(73, 83, 93, 0.08);
}

.rank-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--habit-color);
  transition: width 450ms ease;
}

.rank-streak {
  min-width: 74px;
  color: #3d4b55;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 800;
}

.rank-streak small {
  display: block;
  margin-top: 3px;
  color: #91989d;
  font-size: 0.64rem;
  font-weight: 600;
}

.ranking-empty {
  padding: 35px 10px;
  color: var(--ink-soft);
  text-align: center;
  font-size: 0.84rem;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 4px 0;
  color: #8a9399;
  font-size: 0.73rem;
}

.app-footer p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.footer-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}

.text-button {
  padding: 3px 0;
  color: #7b858b;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  cursor: pointer;
  font-size: 0.73rem;
}

.modal {
  width: min(540px, calc(100% - 28px));
  max-height: min(88vh, 820px);
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  border: 0;
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 30px 80px rgba(44, 39, 36, 0.24);
}

.modal--settings {
  width: min(700px, calc(100% - 28px));
}

.modal::backdrop {
  background: rgba(33, 43, 52, 0.38);
  backdrop-filter: blur(5px);
}

.modal[open] {
  animation: modal-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line);
}

.modal__header h2 {
  font-size: 1.45rem;
}

.modal__close {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  color: #7b858c;
  border: 0;
  border-radius: 12px;
  background: #f3f0eb;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  transition: 150ms ease;
}

.modal__close:hover {
  color: var(--ink);
  background: #ebe7e0;
  transform: rotate(4deg);
}

.modal__body {
  max-height: calc(88vh - 150px);
  padding: 22px 26px;
  overflow-y: auto;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 26px 22px;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.95);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 19px;
  border: 0;
  padding: 0;
}

.field > span,
.field legend {
  color: #4d5963;
  font-size: 0.79rem;
  font-weight: 760;
}

.field em {
  color: #9aa0a4;
  font-size: 0.67rem;
  font-style: normal;
  font-weight: 600;
}

.field input,
.field textarea {
  width: 100%;
  color: var(--ink);
  border: 1px solid rgba(61, 73, 84, 0.13);
  border-radius: 13px;
  outline: 0;
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input {
  height: 45px;
  padding: 0 13px;
}

.field textarea {
  min-height: 72px;
  padding: 12px 13px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #abb1b5;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(255, 138, 101, 0.55);
  box-shadow: 0 0 0 4px rgba(255, 138, 101, 0.1);
}

.field-error {
  min-height: 0;
  color: #b84a4a;
  font-size: 0.72rem;
}

.field-error:not(:empty) {
  min-height: 16px;
}

.emoji-picker,
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.emoji-choice {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 2px solid transparent;
  border-radius: 14px;
  background: #f5f2ed;
  cursor: pointer;
  font-size: 1.45rem;
  transition: 150ms ease;
}

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

.emoji-choice.is-selected {
  border-color: var(--orange);
  background: #fff1e7;
  box-shadow: 0 7px 16px rgba(237, 107, 72, 0.12);
}

.color-choice {
  position: relative;
  width: 38px;
  height: 38px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--choice-color);
  box-shadow: 0 0 0 1px rgba(58, 67, 75, 0.12);
  cursor: pointer;
  transition: 150ms ease;
}

.color-choice:hover {
  transform: scale(1.08);
}

.color-choice.is-selected::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  content: "✓";
  font-size: 0.85rem;
  font-weight: 900;
}

.settings-body {
  display: grid;
  gap: 15px;
}

.settings-section {
  padding: 19px;
  border: 1px solid rgba(62, 73, 82, 0.08);
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.64);
}

.settings-section--danger {
  border-color: rgba(231, 103, 103, 0.15);
  background: rgba(255, 246, 246, 0.7);
}

.settings-section__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.settings-section h3 {
  font-size: 1rem;
}

.settings-section h4 {
  margin: 0;
  font-size: 0.86rem;
}

.settings-section__heading p,
.auth-panel__header p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 0.73rem;
  line-height: 1.55;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 15px;
}

.button-row--end {
  justify-content: flex-end;
}

.cloud-grid,
.auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.cloud-grid .field,
.auth-grid .field {
  margin-bottom: 0;
}

.auth-panel {
  margin-top: 17px;
  padding: 16px;
  border-radius: 15px;
  background: #f6f3ee;
}

.auth-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.account-email {
  max-width: 200px;
  overflow: hidden;
  color: #4d718e;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 27px;
  flex: 0 0 auto;
}

.switch input {
  width: 0;
  height: 0;
  opacity: 0;
}

.switch span:not(.sr-only) {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #d9d9d6;
  cursor: pointer;
  transition: 180ms ease;
}

.switch span:not(.sr-only)::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  content: "";
  background: #fff;
  box-shadow: 0 2px 7px rgba(44, 49, 53, 0.2);
  transition: 180ms ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::before {
  transform: translateX(19px);
}

.reminder-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: 15px;
}

.field--inline {
  width: 150px;
  margin: 0;
}

.field--inline input {
  margin-top: 1px;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: grid;
  width: min(360px, calc(100% - 40px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  color: #fbfdfc;
  border-radius: 14px;
  background: #2d3b45;
  box-shadow: 0 15px 38px rgba(37, 45, 52, 0.24);
  font-size: 0.81rem;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.toast.is-success {
  background: #2d8069;
}

.toast.is-error {
  background: #a74949;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition: 180ms ease;
}

.noscript-message {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 30px;
  color: #fff;
  background: #2d3b45;
  text-align: center;
}

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

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-5px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}

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

  .date-card {
    min-height: 220px;
  }

  .habit-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 28px, 1180px);
    padding-top: 28px;
  }

  .app-header {
    align-items: center;
    margin-bottom: 25px;
  }

  .full-date {
    font-size: clamp(1.9rem, 10vw, 2.8rem);
    letter-spacing: -0.045em;
  }

  .date-subtitle {
    display: none;
  }

  .header-actions {
    padding-top: 0;
  }

  .header-actions .button {
    width: 44px;
    padding: 0;
    overflow: hidden;
    color: transparent;
    gap: 0;
  }

  .header-actions .button span {
    color: #fff;
    font-size: 1.3rem;
  }

  .progress-card__top {
    align-items: flex-start;
  }

  .progress-ring {
    width: 104px;
    height: 104px;
  }

  .progress-ring__inner strong {
    font-size: 1.55rem;
  }

  .progress-card {
    padding: 24px 20px;
  }

  .progress-card h2 {
    font-size: 1.42rem;
  }

  .progress-message {
    max-width: 190px;
    font-size: 0.8rem;
  }

  .content-section {
    margin-bottom: 43px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .section-heading--stats {
    align-items: center;
  }

  .stats-section {
    padding: 23px 15px 15px;
  }

  .stats-summary {
    grid-template-columns: 1fr;
  }

  .metric-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .metric-card strong {
    grid-row: span 2;
    margin: 0;
    font-size: 1.5rem;
  }

  .metric-card small {
    margin-top: 3px;
  }

  .ranking-card {
    padding: 17px 13px;
  }

  .ranking-row {
    grid-template-columns: 28px auto minmax(70px, 1fr);
    gap: 9px;
  }

  .rank-streak {
    grid-column: 3;
    min-width: 0;
    margin-top: -3px;
    text-align: left;
  }

  .rank-streak small {
    display: inline;
    margin-left: 4px;
  }

  .share-banner,
  .share-banner div:first-child {
    align-items: flex-start;
    flex-direction: column;
  }

  .share-banner {
    gap: 10px;
  }

  .app-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .modal {
    width: calc(100% - 16px);
    max-height: 92vh;
    border-radius: 22px;
  }

  .modal__body {
    max-height: calc(92vh - 150px);
    padding: 20px 18px;
  }

  .modal__header,
  .modal__footer {
    padding-right: 18px;
    padding-left: 18px;
  }

  .cloud-grid,
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .settings-section__heading {
    align-items: flex-start;
  }

  .reminder-row {
    align-items: stretch;
    flex-direction: column;
  }

  .field--inline {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* Mobile overflow safeguards */
.dashboard-grid > *,
.content-section,
.stats-section,
.ranking-card,
.progress-card__top > div:first-child,
.ranking-card__header > div,
.rank-info {
  min-width: 0;
}

.habit-card__title-row h3,
.progress-card h2 {
  overflow-wrap: anywhere;
}

@media (max-width: 680px) {
  .app-shell {
    width: calc(100% - 28px);
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .header-actions {
    justify-content: flex-end;
    padding-top: 0;
  }

  .progress-card__top {
    gap: 14px;
  }

  .progress-card__top > div:first-child {
    flex: 1 1 auto;
  }

  .progress-message {
    max-width: 175px;
  }

  .progress-ring {
    width: 94px;
    height: 94px;
  }

  .progress-ring__inner strong {
    font-size: 1.45rem;
  }

  .date-card,
  .date-tabs,
  .date-tab {
    min-width: 0;
  }

  .date-tab {
    padding-right: 2px;
    padding-left: 2px;
  }

  .ranking-card__header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .rank-progress {
    max-width: 100%;
  }
}
@media (max-width: 680px) {
  .full-date {
    font-size: clamp(1.75rem, 8vw, 2.5rem);
    line-height: 1.18;
    overflow-wrap: anywhere;
  }
}