/* Design lock: Telegram-native surfaces and typography; Habitify's day-first
   list; Loop's record-based calendar. Accent is reserved for actions/states. */
:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-secondary-bg-color, #f2f5f7);
  --surface: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #18232d);
  --muted: var(--tg-theme-hint-color, #647381);
  --accent: var(--tg-theme-button-color, #176f88);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --link: var(--tg-theme-link-color, #176f88);
  --line: color-mix(in srgb, var(--text) 13%, var(--surface));
  --soft: color-mix(in srgb, var(--accent) 9%, var(--surface));
  --danger: var(--tg-theme-destructive-text-color, #ba3e42);
  --success: #19836e;
  --warning: #a8621f;
  --radius: 18px;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--app-safe-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--app-safe-bottom, 0px));
  font-family: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: var(--tg-theme-secondary-bg-color, #11191f); --surface: var(--tg-theme-bg-color, #1c2931); --text: var(--tg-theme-text-color, #edf4f5); --muted: var(--tg-theme-hint-color, #a5b6bc); --accent: var(--tg-theme-button-color, #64c5cf); --accent-text: var(--tg-theme-button-text-color, #102c32); --link: var(--tg-theme-link-color, #80d0dd); --danger: var(--tg-theme-destructive-text-color, #ff9091); --success: #74d6ba; --warning: #edc178; }
}
:root[data-theme="dark"] { --bg: var(--tg-theme-secondary-bg-color, #11191f); --surface: var(--tg-theme-bg-color, #1c2931); --text: var(--tg-theme-text-color, #edf4f5); --muted: var(--tg-theme-hint-color, #a5b6bc); --accent: var(--tg-theme-button-color, #64c5cf); --accent-text: var(--tg-theme-button-text-color, #102c32); --link: var(--tg-theme-link-color, #80d0dd); --danger: var(--tg-theme-destructive-text-color, #ff9091); --success: #74d6ba; --warning: #edc178; }
:root[data-theme="light"] { --bg: var(--tg-theme-secondary-bg-color, #f2f5f7); --surface: var(--tg-theme-bg-color, #fff); --text: var(--tg-theme-text-color, #18232d); --muted: var(--tg-theme-hint-color, #647381); --accent: var(--tg-theme-button-color, #176f88); --accent-text: var(--tg-theme-button-text-color, #fff); --link: var(--tg-theme-link-color, #176f88); --danger: var(--tg-theme-destructive-text-color, #ba3e42); --success: #19836e; --warning: #a8621f; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body { margin: 0; min-width: 300px; min-height: 100vh; background: var(--bg); }
button, input, textarea, select { font: inherit; }
button, a, label { -webkit-tap-highlight-color: color-mix(in srgb, var(--accent) 20%, transparent); }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
p { margin: 0; line-height: 1.52; overflow-wrap: anywhere; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.025em; text-wrap: balance; overflow-wrap: anywhere; }
h1 { font-size: 29px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
a { color: var(--link); overflow-wrap: anywhere; }
.app-shell { max-width: 680px; margin: 0 auto; min-height: 100vh; min-height: var(--stable-height, 100vh); padding-bottom: calc(86px + var(--safe-bottom)); }
.initial-loading { padding: calc(32px + var(--safe-top)) 22px; color: var(--muted); }
.topbar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 12px; padding: calc(12px + var(--safe-top)) 20px 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brandmark { flex: 0 0 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; background: var(--text); color: var(--surface); font-size: 13px; font-weight: 750; letter-spacing: -.04em; }
.brandcopy { flex: 1; min-width: 0; }
.brandcopy strong { display: block; font-size: 15px; line-height: 1.2; }
.brandcopy small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.icon-button { display: inline-grid; place-items: center; min-height: 44px; min-width: 44px; padding: 8px; border: 0; border-radius: 14px; color: var(--text); background: transparent; }
.icon-button:hover { background: var(--soft); }
.icon { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
main { padding: 24px 20px 20px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.stack-sm { display: flex; flex-direction: column; gap: 11px; }
.stack-xs { display: flex; flex-direction: column; gap: 7px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; }
.page-intro { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.eyebrow { color: var(--link); font-size: 12px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.muted, .help { color: var(--muted); }
.small { font-size: 13px; line-height: 1.45; }
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.surface.compact { padding: 16px; }
.surface.soft { background: var(--soft); }
.divider { border: 0; border-top: 1px solid var(--line); margin: 0; }
.row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.grow { flex: 1; min-width: 0; }
.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 14px; padding: 11px 17px; font-size: 15px; font-weight: 650; text-decoration: none; text-align: center; line-height: 1.25; background: var(--accent); color: var(--accent-text); }
.button.secondary { background: var(--surface); border-color: var(--line); color: var(--text); }
.button.tertiary { background: var(--soft); color: var(--link); }
.button.danger { background: var(--surface); border-color: color-mix(in srgb, var(--danger) 45%, var(--surface)); color: var(--danger); }
.button.selected { border-color: var(--accent); background: var(--soft); color: var(--link); }
.button.block { width: 100%; }
.button.small-button { min-height: 44px; padding: 9px 12px; font-size: 13px; }
.link-button { display: inline-flex; align-items: center; min-height: 44px; border: 0; background: transparent; color: var(--link); font-weight: 650; padding: 8px 0; text-align: left; }
.danger-text { color: var(--danger); }
.pill { display: inline-flex; width: fit-content; align-items: center; gap: 5px; border-radius: 100px; padding: 5px 10px; font-size: 12px; font-weight: 650; background: var(--soft); color: var(--link); }
.pill.neutral { background: var(--bg); color: var(--muted); }
.pill.success { background: color-mix(in srgb, var(--success) 14%, var(--surface)); color: var(--success); }
.pill.warning { background: color-mix(in srgb, var(--warning) 14%, var(--surface)); color: var(--warning); }
.outcomes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.outcomes .button { padding-inline: 5px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metric { padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.metric strong { display: block; font-size: 25px; font-variant-numeric: tabular-nums; }
.metric span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.form { display: flex; flex-direction: column; gap: 17px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span, .field > label, .field-label { font-size: 14px; font-weight: 650; line-height: 1.3; }
input:not([type=checkbox]):not([type=radio]), textarea, select { min-height: 48px; width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: var(--surface); }
textarea { min-height: 105px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .9; }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 9px 0; line-height: 1.4; }
.check input { width: 21px; height: 21px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check span { flex: 1; }
.notice { padding: 14px 16px; border-radius: 14px; background: var(--soft); color: var(--text); font-size: 14px; line-height: 1.5; }
.error { border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--surface)); background: var(--surface); color: var(--danger); }
.error:empty { display: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.form-actions > * { flex: 1 1 120px; }
.question-number { font-size: 13px; color: var(--muted); }
.weekday-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.day-toggle { min-width: 0; min-height: 44px; padding: 4px 0; font-size: 13px; border-radius: 11px; }
.calendar-week, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.calendar-week { color: var(--muted); font-size: 11px; font-weight: 650; text-align: center; }
.calendar-day { min-height: 48px; padding: 5px 1px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--text); display: grid; justify-items: center; align-content: center; gap: 3px; font-size: 13px; }
.calendar-day.active { border-color: var(--accent); background: var(--soft); }
.calendar-day.empty { border-color: transparent; background: transparent; }
.habit-row { width: 100%; text-align: left; color: var(--text); font: inherit; }
.idea summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 650; cursor: pointer; list-style: none; }
.idea summary::-webkit-details-marker { display: none; }
.idea summary::after { content: '+'; color: var(--link); font-size: 21px; font-weight: 400; }
.idea[open] summary::after { content: '−'; }
.idea-body { padding: 8px 0 3px; }
.dots { display: flex; gap: 2px; min-height: 5px; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.dot.done, .dot.minimum { background: var(--success); }
.dot.skipped { background: var(--warning); }
.dot.unknown { background: var(--muted); }
.tabbar { position: fixed; z-index: 5; left: 50%; transform: translateX(-50%); bottom: 0; width: min(100%, 680px); display: grid; grid-template-columns: repeat(5, 1fr); padding: 7px 6px calc(7px + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.tab { min-width: 0; min-height: 50px; border: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 600; }
.tab[aria-current=page] { color: var(--link); }
.tab .icon { width: 20px; height: 20px; }
.conversation { display: flex; flex-direction: column; gap: 10px; }
.bubble { border-radius: 16px; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--line); line-height: 1.5; }
.bubble.mine { background: var(--soft); border-color: transparent; }
.long-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.meeting-title { font-weight: 700; overflow-wrap: anywhere; }
.empty-state { padding: 24px 20px; text-align: left; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (min-width: 600px) { main { padding-inline: 32px; } .topbar { padding-inline: 32px; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
