@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --red: #dc2626;
  --red-dark: #b91c1c;
  --green: #10b981;
  --ink: #18181b;
  --muted: #71717a;
  --muted-soft: #a1a1aa;
  --line: #e4e4e7;
  --line-soft: #f0f0f2;
  --surface-soft: #fafafa;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: #fff; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #fff; color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(220, 38, 38, .2); outline-offset: 2px; }
button:disabled { cursor: not-allowed; }
svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell {
  position: relative;
  width: 100%;
  max-width: 560px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(26px, env(safe-area-inset-top)) 20px calc(112px + env(safe-area-inset-bottom));
}
.loading-state { padding-top: 40px; color: var(--muted); font-size: 14px; text-align: center; }
.noscript { margin: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); }

.home-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 55px; }
.header-title { min-width: 0; }
.eyebrow, .sheet-kicker { margin: 0 0 4px; color: var(--red); font-size: 10px; font-weight: 700; letter-spacing: .13em; line-height: 1.3; }
.home-header h1 { margin: 0; font-size: clamp(21px, 6vw, 25px); font-weight: 700; letter-spacing: -.045em; line-height: 1.2; }
.icon-button { display: inline-grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: #52525b; cursor: pointer; }
.icon-button svg { width: 21px; height: 21px; }
.icon-button:hover { border-color: #d4d4d8; color: var(--red); }

.date-section { margin: 22px -20px 20px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.date-strip { display: flex; gap: 7px; overflow-x: auto; padding: 12px 20px; scrollbar-width: none; overscroll-behavior-inline: contain; scroll-behavior: smooth; }
.date-strip::-webkit-scrollbar { display: none; }
.date-chip { display: flex; flex: 0 0 50px; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 62px; padding: 7px 3px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: #52525b; cursor: pointer; }
.date-chip:hover:not(.selected) { background: var(--surface-soft); }
.date-weekday { font-size: 9px; font-weight: 600; letter-spacing: .06em; color: #71717a; }
.date-number { font-size: 15px; font-weight: 600; line-height: 1; }
.date-chip.today:not(.selected) { color: var(--red); }
.date-chip.today:not(.selected) .date-weekday { color: var(--red); }
.date-chip.selected { background: var(--red); color: #fff; }
.date-chip.selected .date-weekday { color: rgba(255,255,255,.82); }

.dashboard { display: flex; flex-direction: column; gap: 16px; }
.filter-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding: 4px; border: 1px solid var(--line-soft); border-radius: 14px; background: #f7f7f8; }
.filter-tab { display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; min-height: 40px; padding: 6px 7px; border: 0; border-radius: 10px; background: transparent; color: #71717a; font-size: 12px; font-weight: 600; cursor: pointer; }
.filter-tab.active { background: var(--red); color: #fff; }
.tab-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: rgba(24,24,27,.06); font-size: 10px; font-weight: 700; }
.filter-tab.active .tab-count { background: rgba(255,255,255,.2); }

.progress-card { padding: 15px 16px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.progress-copy { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #52525b; font-size: 13px; line-height: 1.4; }
.progress-copy strong { color: var(--ink); font-weight: 600; }
.progress-copy .progress-percent { flex: 0 0 auto; color: var(--red); font-size: 13px; font-weight: 700; }
.progress-track { height: 5px; margin-top: 13px; overflow: hidden; border-radius: 999px; background: #f1f1f3; }
.progress-track > span { display: block; height: 100%; border-radius: inherit; background: var(--red); transition: width .18s ease; }

.habits-section { min-width: 0; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 3px 1px 11px; }
.section-heading h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.section-heading > span { color: var(--muted); font-size: 11px; }
.habit-list { display: flex; flex-direction: column; gap: 9px; }
.habit-card { display: flex; align-items: center; gap: 11px; min-height: 76px; padding: 12px 10px 12px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; }
.habit-card:hover { border-color: #d4d4d8; }
.habit-open { display: flex; flex: 1 1 auto; align-items: center; gap: 11px; min-width: 0; min-height: 50px; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.habit-open:focus-visible { outline: 3px solid rgba(220, 38, 38, .2); outline-offset: 2px; }
.habit-icon { display: grid; flex: 0 0 42px; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line-soft); border-radius: 11px; background: #fafafa; font-size: 20px; line-height: 1; }
.habit-copy { flex: 1 1 auto; min-width: 0; }
.habit-title-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.habit-title-line h3 { flex: 0 1 auto; min-width: 0; overflow: hidden; margin: 0; font-size: 13px; font-weight: 600; letter-spacing: -.015em; text-overflow: ellipsis; white-space: nowrap; }
.habit-card.is-done .habit-title-line h3 { color: #71717a; text-decoration: line-through; text-decoration-thickness: 1px; }
.priority { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 600; line-height: 1; }
.priority-low { background: #ecfdf5; color: #047857; }
.priority-medium { background: #fff7ed; color: #c2410c; }
.priority-high { background: #fef2f2; color: #b91c1c; }
.habit-meta { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; margin-top: 6px; color: #71717a; font-size: 10px; line-height: 1.3; white-space: nowrap; }
.habit-meta > :not(.streak) { overflow: hidden; text-overflow: ellipsis; }
.meta-dot { flex: 0 0 auto; color: #c4c4c9; }
.streak { flex: 0 0 auto; color: #71717a; }
.streak span { font-size: 10px; }
.habit-check { display: grid; flex: 0 0 44px; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.habit-check::before { content: ""; display: block; grid-area: 1 / 1; width: 22px; height: 22px; border: 1.5px solid #d4d4d8; border-radius: 50%; background: #fff; }
.habit-check:hover:not(:disabled)::before { border-color: var(--green); }
.habit-check.checked::before { border-color: var(--green); background: var(--green); }
.habit-check svg { grid-area: 1 / 1; z-index: 1; width: 15px; height: 15px; color: #fff; stroke-width: 2.5; }
.habit-check.future { opacity: .4; }
.habit-check.future::before { background: #f4f4f5; }

.empty-state { display: flex; flex-direction: column; align-items: center; padding: 34px 18px 22px; border: 1px dashed #dedee2; border-radius: var(--radius); text-align: center; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 12px; border-radius: 15px; background: #fef2f2; color: var(--red); }
.empty-icon svg { width: 23px; height: 23px; }
.empty-state h2 { margin: 0; font-size: 15px; font-weight: 650; }
.empty-state p { margin: 7px 0 17px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.button svg { width: 16px; height: 16px; }
.button-outline { border-color: #f2b7b7; background: #fff; color: var(--red); }
.button-outline:hover { background: #fef2f2; }
.button-muted { border-color: var(--line); background: #fff; color: #52525b; }
.button-primary { border-color: var(--red); background: var(--red); color: #fff; }
.button-primary:hover { border-color: var(--red-dark); background: var(--red-dark); }
.filter-empty { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 29px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius); color: var(--muted); font-size: 12px; }
.filter-empty p { margin: 0; }
.filter-empty-mark { color: var(--red); font-size: 17px; }
.floating-add { position: fixed; z-index: 5; right: max(20px, calc((100vw - 520px) / 2)); bottom: calc(18px + env(safe-area-inset-bottom)); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 54px; min-height: 52px; padding: 0 17px; border: 0; border-radius: 16px; background: var(--red); color: #fff; font-size: 13px; font-weight: 650; cursor: pointer; }
.floating-add:hover { background: var(--red-dark); }
.floating-add svg { width: 19px; height: 19px; stroke-width: 2.2; }

.sheet-backdrop { position: fixed; z-index: 20; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding-top: max(12px, env(safe-area-inset-top)); background: rgba(24, 24, 27, .30); }
.bottom-sheet { width: min(100%, 560px); max-height: min(92dvh, 860px); overflow-y: auto; overscroll-behavior: contain; padding: 8px 20px calc(20px + env(safe-area-inset-bottom)); border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; background: #fff; scrollbar-width: thin; }
.sheet-handle { width: 36px; height: 4px; margin: 1px auto 13px; border-radius: 999px; background: #e4e4e7; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.sheet-kicker { margin-bottom: 4px; font-size: 9px; }
.sheet-header h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.03em; }
.sheet-close { flex-basis: 40px; width: 40px; height: 40px; border-radius: 12px; }
.habit-sheet form { display: flex; flex-direction: column; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; padding: 0; border: 0; }
.form-field > label, .priority-field legend { color: #3f3f46; font-size: 11px; font-weight: 600; }
.required-mark { color: var(--red); }
.optional-label { margin-left: 4px; color: #a1a1aa; font-size: 10px; font-weight: 400; }
.form-field input[type="text"], .form-field select, .form-field textarea, .time-inputs input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font-size: 12px; }
.form-field input::placeholder, .form-field textarea::placeholder { color: #a1a1aa; }
.form-field select { appearance: auto; }
.form-field textarea { min-height: 74px; resize: vertical; }
.field-hint-row { display: flex; align-items: center; justify-content: space-between; min-height: 13px; margin-top: -3px; font-size: 10px; }
.field-error { color: var(--red); }
.char-count { color: #a1a1aa; }
.icon-select, .date-field { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; text-align: left; cursor: pointer; }
.icon-preview { display: grid; flex: 0 0 34px; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: #f7f7f8; font-size: 19px; }
.icon-select-copy { display: flex; flex: 1; flex-direction: column; gap: 2px; }
.icon-select-copy strong { font-size: 11px; font-weight: 600; }
.icon-select-copy small { color: var(--muted); font-size: 10px; }
.icon-select-chevron { color: #a1a1aa; }
.icon-select-chevron svg, .date-field > svg { width: 17px; height: 17px; }
.date-field { justify-content: space-between; min-height: 44px; color: #3f3f46; font-size: 12px; }
.date-field > span { display: flex; align-items: center; gap: 9px; }
.date-field > span svg { width: 17px; height: 17px; color: #71717a; }
.date-field > svg { color: #a1a1aa; }
.time-inputs { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 8px; }
.time-inputs > label { display: flex; flex-direction: column; gap: 6px; color: #71717a; font-size: 10px; }
.time-inputs input { padding: 8px; }
.time-divider { padding-bottom: 14px; color: #a1a1aa; font-size: 10px; }
.priority-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.priority-option { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; color: #52525b; font-size: 11px; cursor: pointer; }
.priority-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.priority-option.selected { border-color: currentColor; }
.priority-choice-low.selected { background: #f0fdf4; color: #047857; }
.priority-choice-medium.selected { background: #fff7ed; color: #c2410c; }
.priority-choice-high.selected { background: #fef2f2; color: #b91c1c; }
.priority-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sheet-actions { display: grid; grid-template-columns: .85fr 1.15fr; gap: 9px; margin-top: 3px; }
.delete-habit { display: block; min-height: 42px; padding: 7px; border: 0; background: transparent; color: var(--red); font-size: 12px; font-weight: 600; cursor: pointer; }

.icon-picker-panel, .calendar-popover { margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.icon-group-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 9px; scrollbar-width: thin; }
.icon-group-tab { flex: 0 0 auto; min-height: 40px; padding: 0 10px; border: 1px solid var(--line-soft); border-radius: 999px; background: #fff; color: #71717a; font-size: 10px; cursor: pointer; }
.icon-group-tab.active { border-color: var(--red); background: #fef2f2; color: var(--red); }
.icon-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.icon-option { display: grid; place-items: center; min-height: 45px; border: 1px solid var(--line-soft); border-radius: 10px; background: #fff; font-size: 21px; cursor: pointer; }
.icon-option.selected { border-color: var(--red); background: #fef2f2; }
.calendar-month { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; font-size: 12px; }
.calendar-arrow { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 9px; background: transparent; color: #52525b; cursor: pointer; }
.calendar-arrow:hover { background: #f4f4f5; }
.calendar-arrow svg { width: 17px; height: 17px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.calendar-weekdays { margin-bottom: 4px; color: #a1a1aa; font-size: 9px; font-weight: 600; text-align: center; }
.calendar-weekdays span { display: grid; place-items: center; min-height: 27px; }
.calendar-day { display: grid; place-items: center; min-width: 0; min-height: 40px; border: 0; border-radius: 9px; background: #fff; color: #3f3f46; font-size: 11px; cursor: pointer; }
.calendar-day:hover:not(.selected) { background: #f4f4f5; }
.calendar-day.today:not(.selected) { color: var(--red); font-weight: 700; }
.calendar-day.selected { background: var(--red); color: #fff; font-weight: 700; }
.calendar-blank { min-height: 40px; }

.week-switcher { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; margin: -4px 0 14px; }
.week-switcher > strong { flex: 1; text-align: center; font-size: 12px; font-weight: 650; }
.week-arrow { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: #52525b; cursor: pointer; }
.week-arrow:disabled { color: #d4d4d8; cursor: not-allowed; }
.week-arrow svg { width: 17px; height: 17px; }
.summary-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.summary-card { min-width: 0; min-height: 106px; padding: 13px 12px; border: 1px solid var(--line); border-radius: 12px; }
.summary-card > span { display: block; color: var(--muted); font-size: 10px; font-weight: 500; }
.summary-card > strong { display: block; margin-top: 7px; font-size: 23px; font-weight: 700; letter-spacing: -.04em; }
.summary-card > strong small { color: #a1a1aa; font-size: 14px; font-weight: 500; letter-spacing: 0; }
.summary-track { height: 4px; margin-top: 10px; overflow: hidden; border-radius: 9px; background: #f1f1f3; }
.summary-track > span { display: block; height: 100%; border-radius: inherit; background: var(--red); }
.summary-note { margin-top: 6px; color: #a1a1aa; font-size: 9px; }
.stats-section { margin-top: 21px; }
.stats-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.stats-section-heading h3 { margin: 0; font-size: 13px; font-weight: 650; }
.stats-section-heading > span { color: #a1a1aa; font-size: 9px; }
.daily-stats { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 12px 9px 9px; border: 1px solid var(--line); border-radius: 12px; }
.daily-stat { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.daily-bar-wrap { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 100%; height: 103px; }
.daily-percent { min-height: 14px; margin-bottom: 6px; color: #71717a; font-size: 9px; }
.daily-bar-track { display: flex; align-items: flex-end; justify-content: center; width: 20px; height: 72px; overflow: hidden; border-radius: 6px 6px 3px 3px; background: #f4f4f5; }
.daily-bar-fill { display: block; width: 100%; min-height: 0; border-radius: 6px 6px 3px 3px; background: #fca5a5; }
.daily-bar-fill.complete { background: var(--red); }
.daily-label { color: #71717a; font-size: 9px; }
.weekly-habit-list { display: flex; flex-direction: column; gap: 13px; }
.weekly-habit-row { min-width: 0; }
.weekly-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 10px; }
.weekly-row-top strong { overflow: hidden; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.weekly-row-top > span { display: flex; flex: 0 0 auto; gap: 9px; color: #71717a; }
.weekly-row-top b { color: var(--red); font-weight: 650; }
.weekly-progress { height: 4px; overflow: hidden; border-radius: 9px; background: #f1f1f3; }
.weekly-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--red); }
.stats-empty { padding: 18px 12px; border: 1px dashed var(--line); border-radius: 11px; color: var(--muted); font-size: 11px; text-align: center; }

@media (min-width: 600px) {
  .app-shell { padding-top: 38px; }
  .date-section { margin-top: 25px; }
  .bottom-sheet { margin-bottom: 0; border-bottom: 0; }
}
@media (max-width: 360px) {
  .app-shell { padding-right: 15px; padding-left: 15px; }
  .date-section { margin-right: -15px; margin-left: -15px; }
  .date-strip { padding-right: 15px; padding-left: 15px; }
  .habit-card { gap: 8px; padding-right: 7px; padding-left: 9px; }
  .habit-icon { flex-basis: 38px; width: 38px; height: 38px; }
  .habit-title-line h3 { font-size: 12px; }
  .priority { padding-right: 6px; padding-left: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
