:root {
  color-scheme: light;
  --bg: #f2f5f0;
  --bg-soft: #e9efe8;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-muted: #f7f9f5;
  --surface-hover: #f2f6f1;
  --text: #20302a;
  --text-soft: #66746e;
  --text-faint: #95a099;
  --border: #e3e9e1;
  --border-strong: #d7dfd5;
  --primary: #3d6f5b;
  --primary-deep: #315b4a;
  --primary-soft: #e5f0e9;
  --primary-faint: #f0f7f2;
  --orange: #eb8b5b;
  --blue: #608da8;
  --purple: #8a77a9;
  --danger: #cc5d54;
  --danger-soft: #fff0ee;
  --shadow-sm: 0 8px 24px rgba(38, 61, 49, 0.055);
  --shadow-md: 0 18px 50px rgba(38, 61, 49, 0.095);
  --shadow-lg: 0 28px 80px rgba(31, 49, 40, 0.18);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-xl: 34px;
  --ease: cubic-bezier(0.2, 0.75, 0.25, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131a17;
  --bg-soft: #18231e;
  --surface: rgba(28, 38, 33, 0.9);
  --surface-solid: #1c2621;
  --surface-muted: #202c26;
  --surface-hover: #25332c;
  --text: #edf3ee;
  --text-soft: #aab7af;
  --text-faint: #7f8e85;
  --border: #2c3b33;
  --border-strong: #3a4b42;
  --primary: #75b493;
  --primary-deep: #97c8aa;
  --primary-soft: #263c31;
  --primary-faint: #21332a;
  --orange: #ee9d72;
  --blue: #83afc8;
  --purple: #ad99ca;
  --danger: #e17b70;
  --danger-soft: #3b2826;
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 18px 50px rgba(0, 0, 0, 0.23);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 5% 5%, rgba(122, 177, 145, 0.14), transparent 24rem),
    radial-gradient(circle at 100% 35%, rgba(235, 139, 91, 0.09), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: "MiSans", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 220ms ease, color 220ms ease;
}

body.modal-open { overflow: hidden; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 2px;
}

svg { display: block; }

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

.ambient-one {
  top: 26rem;
  left: -8rem;
  width: 22rem;
  height: 22rem;
  background: radial-gradient(circle, rgba(105, 157, 128, 0.14), transparent 68%);
}

.ambient-two {
  right: -10rem;
  bottom: 5rem;
  width: 26rem;
  height: 26rem;
  background: radial-gradient(circle, rgba(235, 139, 91, 0.11), transparent 68%);
}

.app-shell {
  width: min(1360px, calc(100% - 44px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #477e66, #315d4b);
  box-shadow: 0 8px 20px rgba(49, 93, 75, 0.24);
  color: white;
  transform: rotate(-3deg);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.brand strong, .brand small { display: block; }
.brand strong { margin-bottom: 2px; font-size: 16px; font-weight: 750; letter-spacing: 0.01em; }
.brand small { color: var(--text-faint); font-size: 11px; letter-spacing: 0.04em; }
.top-actions { display: flex; gap: 9px; }

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text-soft);
  cursor: pointer;
  transition: transform 160ms var(--ease), border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.icon-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-solid);
  color: var(--primary);
  transform: translateY(-1px);
}

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

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.theme-icon { grid-area: 1 / 1; }
.moon-icon { display: none; }
:root[data-theme="dark"] .sun-icon { display: none; }
:root[data-theme="dark"] .moon-icon { display: block; }

.hero-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 42px;
  min-height: 308px;
  padding: 48px 54px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.11), transparent 50%),
    linear-gradient(135deg, #386651 0%, #477a62 52%, #5d8e73 100%);
  box-shadow: 0 24px 60px rgba(50, 91, 72, 0.2);
  color: #fff;
}

:root[data-theme="dark"] .hero-card {
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.04), transparent 50%),
    linear-gradient(135deg, #264738 0%, #315b49 52%, #3c6d56 100%);
}

.hero-copy { position: relative; z-index: 2; align-self: center; max-width: 680px; }
.eyebrow, .section-kicker { display: block; color: var(--text-faint); font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.hero-copy .eyebrow { margin-bottom: 10px; color: rgba(255, 255, 255, 0.68); }

.hero-copy h1 {
  margin: 0;
  font-size: clamp(36px, 4vw, 56px);
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.06;
}

.hero-copy h1 span { color: #d7eadf; }
.hero-copy p { max-width: 550px; margin: 18px 0 0; color: rgba(255, 255, 255, 0.72); font-size: 14px; line-height: 1.8; }

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  padding: 0 18px;
  border: 0;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 160ms var(--ease), background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.primary-button { background: var(--primary); box-shadow: 0 8px 20px rgba(49, 93, 75, 0.2); color: #fff; }
.primary-button:hover { background: var(--primary-deep); box-shadow: 0 10px 26px rgba(49, 93, 75, 0.27); transform: translateY(-1px); }
.primary-button:active, .secondary-button:active, .ghost-button:active, .danger-button:active { transform: translateY(0) scale(0.98); }
.primary-button svg, .secondary-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.hero-add-button { min-height: 47px; margin-top: 28px; padding: 0 21px; background: #f8fbf8; box-shadow: 0 12px 28px rgba(19, 45, 33, 0.22); color: #315c4a; }
.hero-add-button:hover { background: #fff; color: #284c3d; }
.secondary-button { border: 1px solid var(--border); background: var(--surface-solid); color: var(--text); }
.secondary-button:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); background: var(--primary-faint); color: var(--primary); }
.ghost-button { background: transparent; color: var(--text-soft); }
.ghost-button:hover { background: var(--surface-muted); color: var(--text); }
.danger-button { background: var(--danger-soft); color: var(--danger); }
.danger-button:hover { background: color-mix(in srgb, var(--danger-soft) 84%, var(--danger)); }
.text-button { min-height: 34px; padding: 0 10px; background: transparent; color: var(--text-soft); font-size: 12px; }
.text-button:hover { color: var(--primary); }
.compact-button { min-height: 38px; padding: 0 14px; border-radius: 11px; }

.hero-progress {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  min-width: 310px;
}

.progress-ring {
  --progress: 0;
  position: relative;
  display: grid;
  width: 158px;
  height: 158px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#d9eee1 calc(var(--progress) * 1%), rgba(255, 255, 255, 0.16) 0);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 16px 45px rgba(21, 51, 38, 0.2);
  transition: background 500ms var(--ease);
}

.progress-ring::before {
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 50%;
  background: rgba(40, 78, 61, 0.93);
  content: "";
}

.progress-ring-inner { position: relative; z-index: 1; text-align: center; }
.progress-ring-inner strong { display: block; margin-bottom: 3px; font-size: 33px; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.progress-ring-inner span { color: rgba(255, 255, 255, 0.58); font-size: 11px; letter-spacing: 0.08em; }
.hero-progress-copy { min-width: 98px; }
.hero-progress-copy strong, .hero-progress-copy span { display: block; }
.hero-progress-copy strong { margin-bottom: 5px; font-size: 21px; font-variant-numeric: tabular-nums; }
.hero-progress-copy span { max-width: 120px; color: rgba(255, 255, 255, 0.63); font-size: 12px; line-height: 1.55; }
.hero-decoration { position: absolute; inset: 0; pointer-events: none; }
.deco-dot, .deco-line { position: absolute; display: block; border-radius: 999px; background: rgba(255, 255, 255, 0.12); }
.dot-a { top: 33px; right: 39%; width: 8px; height: 8px; }
.dot-b { right: 34px; bottom: 32px; width: 14px; height: 14px; background: rgba(244, 171, 124, 0.55); }
.deco-line { right: -35px; bottom: 58px; width: 160px; height: 1px; transform: rotate(-38deg); }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin: -20px 26px 24px;
  position: relative;
  z-index: 4;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 17px 18px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}

.stat-icon { display: grid; flex: 0 0 auto; width: 38px; height: 38px; place-items: center; border-radius: 12px; }
.stat-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }
.stat-icon-sage { background: var(--primary-soft); color: var(--primary); }
.stat-icon-orange { background: color-mix(in srgb, var(--orange) 14%, transparent); color: var(--orange); }
.stat-icon-blue { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.stat-icon-purple { background: color-mix(in srgb, var(--purple) 14%, transparent); color: var(--purple); }
.stat-item div { min-width: 0; }
.stat-item strong, .stat-item span { display: block; }
.stat-item strong { color: var(--text); font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-item span { overflow: hidden; margin-top: 1px; color: var(--text-faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.72fr); gap: 20px; align-items: start; }
.main-column, .side-column { display: grid; gap: 20px; }

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}

.date-panel, .habits-panel, .rhythm-panel, .encouragement-panel, .mini-tip-panel { padding: 25px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 20px; font-weight: 750; letter-spacing: -0.025em; }
.date-heading { margin-bottom: 20px; }
.week-navigation { display: flex; align-items: center; gap: 4px; }
.small-icon-button { width: 34px; height: 34px; border-radius: 11px; box-shadow: none; }
.small-icon-button svg { width: 17px; height: 17px; }
.small-icon-button:disabled { cursor: not-allowed; opacity: 0.35; transform: none; }
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }

.day-button {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 77px;
  padding: 11px 5px 9px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms var(--ease), color 160ms ease;
}

.day-button:hover:not(:disabled) { background: var(--surface-muted); transform: translateY(-1px); }
.day-button.selected { border-color: color-mix(in srgb, var(--primary) 20%, transparent); background: var(--primary-soft); color: var(--primary); }
.day-button.today:not(.selected)::after { position: absolute; top: 7px; right: 11px; width: 5px; height: 5px; border-radius: 50%; background: var(--orange); content: ""; }
.day-button:disabled { color: var(--text-faint); cursor: not-allowed; opacity: 0.48; }
.day-button .day-name { font-size: 11px; font-weight: 650; }
.day-button .day-number { margin: 4px 0; font-size: 19px; font-weight: 740; font-variant-numeric: tabular-nums; }
.day-button .day-state { min-height: 11px; font-size: 9px; font-weight: 650; }
.day-button.has-completion .day-state { color: var(--primary); }

.habits-heading { margin-bottom: 18px; align-items: flex-end; }
.habits-toolbar { display: flex; align-items: center; gap: 10px; }
.segmented-control { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: var(--surface-muted); }
.segmented-control button { min-height: 32px; padding: 0 11px; border: 0; border-radius: 9px; background: transparent; color: var(--text-faint); font-size: 11px; font-weight: 650; cursor: pointer; transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease; }
.segmented-control button:hover { color: var(--text); }
.segmented-control button.active { background: var(--surface-solid); box-shadow: 0 4px 11px rgba(37, 59, 48, 0.07); color: var(--primary); }
.habit-list { display: grid; gap: 10px; }

.habit-card {
  position: relative;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 80px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-solid);
  transition: border-color 180ms ease, background-color 180ms ease, transform 180ms var(--ease), box-shadow 180ms ease, opacity 180ms ease;
  animation: card-in 280ms var(--ease) both;
}

@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.habit-card:hover { border-color: color-mix(in srgb, var(--primary) 22%, var(--border)); box-shadow: 0 10px 28px rgba(39, 62, 50, 0.07); transform: translateY(-1px); }
.habit-card.completed { border-color: color-mix(in srgb, var(--primary) 18%, var(--border)); background: color-mix(in srgb, var(--primary-faint) 78%, var(--surface-solid)); }

.habit-check {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: transform 180ms var(--ease), border-color 180ms ease, background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.habit-check:hover { border-color: var(--primary); color: color-mix(in srgb, var(--primary) 28%, transparent); transform: scale(1.05); }
.habit-check:active { transform: scale(0.94); }
.habit-check svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.4; }
.habit-card.completed .habit-check { border-color: var(--primary); background: var(--primary); box-shadow: 0 7px 18px color-mix(in srgb, var(--primary) 23%, transparent); color: #fff; animation: check-pop 320ms var(--ease); }
@keyframes check-pop { 0% { transform: scale(0.75); } 55% { transform: scale(1.12); } 100% { transform: scale(1); } }

.habit-emoji { display: grid; width: 50px; height: 50px; place-items: center; border-radius: 16px; font-size: 24px; transition: transform 180ms var(--ease), filter 180ms ease; }
.habit-card:hover .habit-emoji { transform: rotate(-3deg) scale(1.04); }
.habit-card.completed .habit-emoji { filter: saturate(0.72); }
.emoji-sage { background: #e8f2ea; }
.emoji-coral { background: #fcece4; }
.emoji-sky { background: #e8f1f5; }
.emoji-lilac { background: #eeeaf5; }
.emoji-sand { background: #f8f0df; }
:root[data-theme="dark"] .emoji-sage { background: #294036; }
:root[data-theme="dark"] .emoji-coral { background: #463128; }
:root[data-theme="dark"] .emoji-sky { background: #293c46; }
:root[data-theme="dark"] .emoji-lilac { background: #382f43; }
:root[data-theme="dark"] .emoji-sand { background: #443b28; }
.habit-copy { min-width: 0; }
.habit-name-row { display: flex; align-items: center; gap: 9px; }
.habit-name { overflow: hidden; margin: 0; color: var(--text); font-size: 15px; font-weight: 700; letter-spacing: -0.015em; text-overflow: ellipsis; white-space: nowrap; }
.habit-card.completed .habit-name { color: var(--text-soft); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text-soft) 45%, transparent); }
.completed-badge { display: none; flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 9px; font-weight: 750; letter-spacing: 0.03em; }
.habit-card.completed .completed-badge { display: inline-flex; }
.habit-meta { display: flex; align-items: center; min-width: 0; margin-top: 6px; color: var(--text-faint); font-size: 11px; }
.habit-frequency, .habit-streak { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-separator { padding: 0 5px; }
.habit-card-actions { position: relative; }

.habit-menu-button {
  display: grid;
  width: 35px;
  height: 35px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.habit-menu-button:hover, .habit-menu-button[aria-expanded="true"] { background: var(--surface-muted); color: var(--text); }
.habit-menu-button svg { width: 19px; height: 19px; fill: currentColor; }
.habit-context-menu { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; display: none; width: 124px; padding: 5px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-solid); box-shadow: var(--shadow-md); }
.habit-context-menu.open { display: grid; animation: menu-in 160ms var(--ease) both; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.habit-context-menu button { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 9px; border: 0; border-radius: 8px; background: transparent; color: var(--text-soft); font-size: 12px; text-align: left; cursor: pointer; }
.habit-context-menu button:hover { background: var(--surface-muted); color: var(--text); }
.habit-context-menu button:last-child:hover { background: var(--danger-soft); color: var(--danger); }
.habit-context-menu svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.empty-state { display: grid; justify-items: center; padding: 44px 20px 38px; text-align: center; }
.empty-illustration { position: relative; display: grid; width: 92px; height: 92px; margin-bottom: 17px; place-items: center; border-radius: 30px; background: linear-gradient(145deg, var(--primary-soft), var(--surface-muted)); color: var(--primary); transform: rotate(-3deg); }
.empty-illustration::after { position: absolute; top: 9px; right: 10px; width: 14px; height: 14px; border-radius: 50%; background: color-mix(in srgb, var(--orange) 60%, transparent); content: ""; }
.empty-illustration svg { width: 42px; height: 42px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.55; }
.empty-state h3 { margin: 0 0 8px; font-size: 17px; }
.empty-state p { max-width: 340px; margin: 0 0 19px; color: var(--text-faint); font-size: 12px; line-height: 1.7; }

.rhythm-panel { min-height: 294px; }
.compact-heading { align-items: flex-start; }
.compact-heading h2 { font-size: 18px; }
.week-total { padding: 7px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 10px; font-weight: 700; }
.rhythm-chart { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: end; height: 150px; margin-top: 22px; padding-top: 12px; }
.rhythm-day { position: relative; display: grid; height: 100%; grid-template-rows: 1fr auto; gap: 7px; align-items: end; justify-items: center; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; }
.rhythm-bar-track { position: relative; width: 100%; max-width: 24px; height: 100%; overflow: hidden; border-radius: 999px; background: var(--surface-muted); }
.rhythm-bar-fill { position: absolute; right: 0; bottom: 0; left: 0; min-height: 0; border-radius: 999px; background: linear-gradient(180deg, #6fa387, #477b63); transition: height 520ms var(--ease); }
.rhythm-day.complete .rhythm-bar-fill { background: linear-gradient(180deg, #79b08f, #3e725a); }
.rhythm-day.future .rhythm-bar-track { border: 1px dashed var(--border-strong); background: transparent; }
.rhythm-day.future .rhythm-bar-fill { display: none; }
.rhythm-day:hover .rhythm-bar-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent); }
.rhythm-day-label { font-size: 9px; font-weight: 650; }
.rhythm-day.selected .rhythm-day-label { color: var(--primary); }
.rhythm-day.selected .rhythm-bar-track { outline: 2px solid color-mix(in srgb, var(--primary) 27%, transparent); outline-offset: 2px; }
.chart-legend { display: flex; align-items: center; gap: 15px; margin-top: 16px; color: var(--text-faint); font-size: 9px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.completed-dot { background: var(--primary); }
.scheduled-dot { border: 1px solid var(--border-strong); background: var(--surface-muted); }

.encouragement-panel { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 15px; overflow: hidden; background: radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--orange) 14%, transparent), transparent 12rem), var(--surface); }
.encouragement-icon { display: grid; width: 47px; height: 47px; place-items: center; border-radius: 16px; background: color-mix(in srgb, var(--orange) 13%, transparent); color: var(--orange); }
.encouragement-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.encouragement-panel h2 { margin: 5px 0 7px; font-size: 17px; }
.encouragement-panel p { margin: 0; color: var(--text-faint); font-size: 11px; line-height: 1.7; }
.mini-tip-panel { display: flex; align-items: center; gap: 11px; padding: 15px 18px; color: var(--text-faint); }
.mini-tip-panel p { margin: 0; font-size: 10px; line-height: 1.6; }
.mini-tip-icon { color: var(--primary); font-size: 18px; }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 28px 4px 2px; color: var(--text-faint); font-size: 10px; }

.floating-add-button {
  position: fixed;
  z-index: 30;
  right: max(22px, calc((100vw - 1360px) / 2 + 22px));
  bottom: 23px;
  display: none;
  width: 55px;
  height: 55px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 19px;
  background: var(--primary);
  box-shadow: 0 15px 35px rgba(48, 91, 72, 0.32);
  color: #fff;
  cursor: pointer;
}

.floating-add-button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.1; }
.modal { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 20px; border: 0; background: transparent; color: var(--text); }
.modal[open] { display: grid; place-items: center; }
.modal::backdrop { background: rgba(21, 31, 26, 0.46); backdrop-filter: blur(8px); animation: backdrop-in 180ms ease both; }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card { width: min(530px, 100%); max-height: min(780px, calc(100vh - 30px)); overflow-y: auto; padding: 27px; border: 1px solid var(--border); border-radius: 25px; background: var(--surface-solid); box-shadow: var(--shadow-lg); animation: modal-in 260ms var(--ease) both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.modal-header h2 { margin: 5px 0 0; font-size: 23px; letter-spacing: -0.03em; }
.modal-close { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; box-shadow: none; }
.form-field { display: block; min-width: 0; margin: 0 0 20px; padding: 0; border: 0; }
.form-field > span, .form-field > legend { display: block; margin-bottom: 9px; color: var(--text); font-size: 12px; font-weight: 700; }
.form-field input[type="text"] { width: 100%; height: 49px; padding: 0 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-muted); color: var(--text); transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease; }
.form-field input[type="text"]::placeholder { color: var(--text-faint); }
.form-field input[type="text"]:focus { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); outline: 0; background: var(--surface-solid); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 10%, transparent); }
.field-error { display: block; min-height: 15px; margin-top: 5px; color: var(--danger); font-size: 10px; }
.form-hint { display: block; margin-top: 9px; color: var(--text-faint); font-size: 10px; line-height: 1.5; }
.emoji-picker { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; }
.emoji-option { display: grid; aspect-ratio: 1; padding: 0; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-muted); font-size: 19px; cursor: pointer; transition: border-color 160ms ease, background-color 160ms ease, transform 160ms var(--ease); }
.emoji-option:hover { transform: translateY(-1px) scale(1.03); }
.emoji-option.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 10%, transparent); }
.color-picker { display: flex; flex-wrap: wrap; gap: 9px; }
.color-option { position: relative; width: 35px; height: 35px; padding: 0; border: 2px solid transparent; border-radius: 50%; cursor: pointer; transition: transform 160ms var(--ease), border-color 160ms ease; }
.color-option:hover { transform: scale(1.06); }
.color-option.selected { border-color: var(--surface-solid); box-shadow: 0 0 0 2px currentColor; }
.color-option.selected::after { position: absolute; inset: 3px; display: grid; place-items: center; color: #fff; content: "✓"; font-size: 14px; font-weight: 800; }
.color-sage { background: #72a98a; color: #72a98a; }
.color-coral { background: #e89b73; color: #e89b73; }
.color-sky { background: #7da8bf; color: #7da8bf; }
.color-lilac { background: #9b8ab7; color: #9b8ab7; }
.color-sand { background: #d5b36f; color: #d5b36f; }
.weekday-picker { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.weekday-option { min-width: 0; height: 39px; padding: 0; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-muted); color: var(--text-faint); font-size: 11px; font-weight: 650; cursor: pointer; transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease; }
.weekday-option.selected { border-color: color-mix(in srgb, var(--primary) 25%, var(--border)); background: var(--primary-soft); color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 27px; padding-top: 20px; border-top: 1px solid var(--border); }
.settings-card { width: min(570px, 100%); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.setting-row-stacked { align-items: flex-start; }
.setting-row strong, .setting-row span { display: block; }
.setting-row strong { margin-bottom: 4px; font-size: 13px; }
.setting-row span { color: var(--text-faint); font-size: 10px; line-height: 1.55; }
.select-control { min-width: 100px; height: 42px; padding: 0 33px 0 12px; border: 1px solid var(--border); border-radius: 12px; background-color: var(--surface-muted); color: var(--text); cursor: pointer; }
.settings-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.settings-actions .secondary-button { min-height: 39px; padding: 0 13px; }
.settings-divider { height: 1px; margin: 21px 0; background: var(--border); }
.danger-setting-row strong { color: var(--danger); }
.danger-setting-row .danger-button { min-height: 39px; padding: 0 14px; }
.compact-modal { place-items: center; }
.confirm-card { width: min(390px, 100%); padding: 31px; text-align: center; }
.confirm-icon { display: grid; width: 52px; height: 52px; margin: 0 auto 17px; place-items: center; border-radius: 17px; background: var(--danger-soft); color: var(--danger); font-size: 22px; font-weight: 800; }
.confirm-card h2 { margin: 0 0 8px; font-size: 20px; }
.confirm-card p { margin: 0; color: var(--text-faint); font-size: 12px; line-height: 1.7; }
.centered-actions { justify-content: center; }
.toast-region { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; min-width: 220px; max-width: min(360px, calc(100vw - 44px)); padding: 12px 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-solid); box-shadow: var(--shadow-md); color: var(--text); font-size: 12px; animation: toast-in 260ms var(--ease) both; }
.toast::before { display: block; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--primary); content: ""; }
.toast.error::before { background: var(--danger); }
.toast.leaving { animation: toast-out 180ms ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

@media (max-width: 1080px) {
  .content-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .mini-tip-panel { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .app-shell { width: min(100% - 28px, 740px); padding-top: 17px; }
  .hero-card { grid-template-columns: 1fr; gap: 30px; padding: 35px 31px; }
  .hero-progress { justify-content: flex-start; }
  .hero-copy h1 { font-size: clamp(34px, 8vw, 48px); }
  .stats-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: -16px 18px 20px; }
  .habits-heading { align-items: flex-start; }
  .habits-toolbar { align-items: flex-end; flex-direction: column-reverse; }
}

@media (max-width: 640px) {
  body { background: radial-gradient(circle at 5% 5%, rgba(122, 177, 145, 0.13), transparent 18rem), var(--bg); }
  .app-shell { width: min(100% - 22px, 520px); padding-top: 12px; }
  .topbar { min-height: 55px; margin-bottom: 14px; }
  .brand small { display: none; }
  .brand-mark { width: 39px; height: 39px; border-radius: 13px; }
  .icon-button { width: 39px; height: 39px; border-radius: 13px; }
  .hero-card { min-height: 0; padding: 29px 24px 26px; border-radius: 27px; }
  .hero-copy h1 { font-size: clamp(31px, 10.5vw, 42px); line-height: 1.08; }
  .hero-copy p { margin-top: 14px; font-size: 12px; }
  .hero-add-button { margin-top: 22px; }
  .hero-progress { gap: 17px; }
  .progress-ring { width: 124px; height: 124px; }
  .progress-ring::before { inset: 10px; }
  .progress-ring-inner strong { font-size: 27px; }
  .hero-progress-copy strong { font-size: 18px; }
  .stats-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: -14px 11px 16px; }
  .stat-item { gap: 9px; padding: 13px 11px; border-radius: 16px; }
  .stat-icon { width: 32px; height: 32px; border-radius: 10px; }
  .stat-icon svg { width: 16px; height: 16px; }
  .stat-item strong { font-size: 17px; }
  .stat-item span { font-size: 9px; }
  .content-grid, .main-column, .side-column { gap: 14px; }
  .side-column { grid-template-columns: 1fr; }
  .mini-tip-panel { grid-column: auto; }
  .date-panel, .habits-panel, .rhythm-panel, .encouragement-panel, .mini-tip-panel { padding: 20px 17px; border-radius: 22px; }
  .date-heading { align-items: flex-start; margin-bottom: 16px; }
  .date-heading h2 { font-size: 17px; }
  .week-navigation { gap: 1px; }
  .text-button { padding: 0 5px; font-size: 10px; }
  .small-icon-button { width: 31px; height: 31px; }
  .week-strip { gap: 3px; }
  .day-button { min-height: 68px; padding: 8px 2px 7px; border-radius: 13px; }
  .day-button .day-name { font-size: 9px; }
  .day-button .day-number { font-size: 16px; }
  .day-button .day-state { font-size: 8px; }
  .habits-heading { display: grid; gap: 14px; margin-bottom: 16px; }
  .habits-toolbar { width: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
  .segmented-control { flex: 1 1 auto; }
  .segmented-control button { flex: 1 1 0; padding: 0 7px; }
  .compact-button { padding: 0 12px; }
  .habit-card { grid-template-columns: auto minmax(0, 1fr) auto; gap: 11px; min-height: 74px; padding: 11px 10px; border-radius: 16px; }
  .habit-check { width: 34px; height: 34px; }
  .habit-emoji { display: none; }
  .habit-name { font-size: 14px; }
  .completed-badge { display: none !important; }
  .habit-meta { font-size: 10px; }
  .habit-menu-button { width: 32px; height: 32px; }
  .rhythm-panel { min-height: 270px; }
  .rhythm-chart { height: 135px; }
  .encouragement-panel { padding: 19px 17px; }
  .floating-add-button { display: grid; right: 17px; bottom: 17px; }
  footer { padding-bottom: 72px; }
  .modal { align-items: end; padding: 0; }
  .modal-card { width: 100%; max-height: 91vh; padding: 23px 19px calc(23px + env(safe-area-inset-bottom)); border-radius: 25px 25px 0 0; animation-name: bottom-sheet-in; }
  @keyframes bottom-sheet-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
  .emoji-picker { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
  .emoji-option { border-radius: 10px; font-size: 17px; }
  .weekday-picker { gap: 4px; }
  .weekday-option { height: 37px; }
  .setting-row { align-items: flex-start; flex-direction: column; gap: 13px; }
  .settings-actions { width: 100%; }
  .settings-actions .secondary-button { flex: 1 1 0; }
  .danger-setting-row { gap: 14px; }
  .toast-region { right: 12px; bottom: 12px; left: 12px; }
  .toast { min-width: 0; max-width: none; }
}

@media (max-width: 380px) {
  .hero-progress-copy { display: none; }
  .week-navigation .text-button { max-width: 58px; white-space: normal; }
  .habit-card { grid-template-columns: auto minmax(0, 1fr) auto; }
  .habit-streak, .meta-separator { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

.footer-meta { display: inline-flex; align-items: center; gap: 7px; }
.footer-meta a { color: var(--text-soft); text-decoration: none; }
.footer-meta a:hover { color: var(--primary); }
.footer-meta i { font-style: normal; opacity: 0.55; }
.legal-shell { width: min(860px, calc(100% - 32px)); margin: 0 auto; padding: 26px 0 48px; }
.legal-card { margin-top: 30px; padding: clamp(28px, 6vw, 58px); border: 1px solid var(--border); border-radius: 30px; background: var(--surface); box-shadow: var(--shadow-md); backdrop-filter: blur(18px); }
.legal-card h1 { margin: 8px 0 10px; font-size: clamp(32px, 6vw, 52px); letter-spacing: -0.045em; line-height: 1.08; }
.legal-intro { max-width: 680px; margin: 0; color: var(--text-soft); font-size: 14px; line-height: 1.9; }
.legal-card h2 { margin: 34px 0 10px; font-size: 18px; letter-spacing: -0.02em; }
.legal-card p, .legal-card li { color: var(--text-soft); font-size: 13px; line-height: 1.9; }
.legal-card ul { margin: 8px 0; padding-left: 20px; }
.legal-card code { padding: 2px 6px; border-radius: 7px; background: var(--surface-muted); color: var(--primary); font-size: 0.92em; }
.legal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.legal-footer { margin-top: 19px; color: var(--text-faint); font-size: 11px; text-align: center; }
.not-found { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.not-found-card { width: min(560px, 100%); padding: 48px 34px; border: 1px solid var(--border); border-radius: 30px; background: var(--surface); box-shadow: var(--shadow-md); text-align: center; }
.not-found-code { color: var(--primary); font-size: 76px; font-weight: 800; letter-spacing: -0.08em; line-height: 1; }
.not-found-card h1 { margin: 18px 0 9px; font-size: 26px; }
.not-found-card p { margin: 0 auto 25px; color: var(--text-faint); font-size: 13px; line-height: 1.75; }
@media (max-width: 640px) {
  footer { align-items: flex-start; flex-direction: column; }
  .legal-card { padding: 28px 21px; border-radius: 24px; }
}
