:root {
  color-scheme: light;
  font: 16px/1.55 system-ui, "Microsoft YaHei UI", sans-serif;
  color: #25364d;
  background: #edf1f7;
  --paper: #f6f8fc;
  --card: #fff;
  --line: #dce3ee;
  --muted: #53647b;
  --accent: #294f83;
  --blue: #e5efff;
  --lavender: #eee8fb;
  --green: #e6f3eb;
  --yellow: #fff2d4;
  --gray: #eef1f6;
  --shadow: 0 6px 20px #3347670c, 0 2px 5px #33476708;
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at 12% 12%, #e1edfc, transparent 54%), radial-gradient(ellipse at 90% 82%, #eee8fb, transparent 48%), #edf1f7; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); border-radius: 11px; background: #fff; padding: 7px 13px; }
button:active:not(:disabled) { filter: brightness(.96); }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #4973a9; outline-offset: 2px; }
.primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 650; }
.selected { background: var(--blue); border-color: transparent; color: #294b77; font-weight: 700; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.5rem; letter-spacing: -.025em; }
h2 { font-size: 1rem; margin-top: 20px; }
small, .empty { color: var(--muted); }
#app {
  max-width: 700px;
  margin: auto;
  height: var(--visible-height, 100dvh);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  box-shadow: 0 0 64px #31476a1a;
}
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; isolation: isolate; overflow: hidden; }
.room {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: grid;
  align-content: center;
  overflow: hidden;
  background: linear-gradient(180deg, #e5edf8 0 42%, #efe0d7 90%);
}
.room-art { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.room > .room-art { mask-image: linear-gradient(to bottom, transparent, #000 13% 88%, transparent); }
.timer .timer-art { width: 68px; flex: none; border-radius: 4px; }
.chat-heading, .composer {
  background: #fffffff0;
  margin: 12px 16px 0;
  padding: 11px 13px;
  border: 1px solid #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.chat-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-heading h1 { display: flex; gap: 10px; align-items: center; font-size: 1.2rem; }
.chat-header-actions { display: flex; gap: 4px; align-items: center; flex: none; }
.history-toggle img { width: 20px; height: 20px; }
.room-mark { width: 32px; height: 32px; flex: none; border-radius: 11px; background: var(--blue); display: grid; place-items: center; }
.room-mark img { width: 18px; height: 18px; opacity: .72; }
.chat-heading [data-action="account"] { background: var(--lavender); border-color: transparent; color: #594483; flex: none; }
.row, .tabs, .examples { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.row label { display: inline-flex; align-items: center; gap: 5px; }
.chat-stream { position: relative; display: grid; grid-template-rows: minmax(0, 1fr); flex: 1; min-height: 0; }
.messages {
  --fade-top: 0px;
  --fade-bottom: 0px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px;
  mask-image: linear-gradient(to bottom, transparent, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent);
}
.more-above .messages { --fade-top: min(24px, 18%); }
.more-below .messages { --fade-bottom: min(24px, 18%); }
.chat-stream::before, .chat-stream::after {
  content: '';
  position: absolute;
  z-index: 1;
  inset-inline: 0;
  height: min(24px, 18%);
  pointer-events: none;
  backdrop-filter: blur(4px);
  opacity: 0;
}
.chat-stream::before { top: 0; mask-image: linear-gradient(#000, transparent); }
.chat-stream::after { bottom: 0; mask-image: linear-gradient(transparent, #000); }
.chat-stream.more-above::before, .chat-stream.more-below::after { opacity: 1; }
.bubble {
  max-width: 88%; width: fit-content; margin: 0 0 12px; border-radius: 5px 18px 18px 18px; background: #fffffff5;
  padding: 11px 14px; overflow-wrap: anywhere; box-shadow: var(--shadow);
}
.bubble > p { white-space: pre-wrap; }
.bubble.user { margin-left: auto; background: #e9f2ff; border-radius: 18px 5px 18px 18px; }
.message-date { display: grid; justify-items: center; margin: 6px 0 12px; font-size: .76rem; color: var(--muted); }
.message-date span { padding: 2px 10px; border-radius: 100px; background: #fffffff0; }
.message-time { display: block; margin-top: 4px; color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.bubble.user .message-time { text-align: right; }
.proposal { display: grid; gap: 7px; margin-top: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.proposal-label { justify-self: start; padding: 3px 8px; border-radius: 6px; background: var(--yellow); font-size: .82rem; }
.proposal-actions { justify-content: flex-end; margin-top: 3px; }
.proposal-actions button { min-height: 40px; padding: 6px 11px; border-radius: 9px; font-size: .88rem; font-weight: 550; }
.proposal-actions button:not(.primary) { background: var(--paper); }
.proposal small { display: block; }
.proposal ul { margin: 0; padding-left: 20px; }
.composer { margin: 0 16px 12px; flex: none; }
.discovery-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.discovery-actions button { display: inline-flex; align-items: center; gap: 4px; background: var(--blue); border: 1px solid transparent; color: #294b77; padding: 6px 8px; font-size: .82rem; font-weight: 650; white-space: nowrap; }
.discovery-actions img { width: 15px; height: 15px; opacity: .75; }
.discovery-actions [data-discovery="wheel"] { background: var(--yellow); color: #624b27; }
.discovery-actions [data-action="chat-option"] { background: var(--card); border-color: var(--line); color: var(--muted); }
.discovery-actions [aria-pressed="true"] { background: var(--blue); border-color: #7394bf; color: #294b77; }
.discovery-card { width: min(460px, 100%); max-width: 100%; white-space: normal; display: grid; gap: 11px; padding: 15px; }
.discovery-card h2 { margin-top: 0; font-size: 1.14rem; }
.discovery-card label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.discovery-card input, .discovery-card textarea, .discovery-card select { width: 100%; min-width: 0; font-size: 1rem; font-weight: 400; }
.discovery-card textarea { resize: vertical; }
.about-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.about-question { display: grid; gap: 4px; }
.about-question small { font-size: .8rem; }
.about-question textarea { background: #f8faff; }
.discovery-meta { color: var(--muted); font-size: .83rem; }
.wheel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.wheel-heading button { flex: none; }
.wheel-heading p { color: var(--muted); font-size: .87rem; }
.wheel-stage { --wheel-size: min(56vw, 228px); position: relative; padding-top: 8px; margin: 0 auto; }
.wheel-disk {
  position: relative; width: var(--wheel-size); aspect-ratio: 1; border: 5px solid #fff;
  border-radius: 50%; box-shadow: 0 0 0 1px #dce3ee, 0 6px 15px #33476724;
}
.wheel-disk::after { content: ''; position: absolute; inset: 46%; border: 2px solid #dce3ee; border-radius: 50%; background: #fff; }
.wheel-pointer { position: absolute; z-index: 1; top: 0; left: 50%; transform: translateX(-50%); width: 18px; height: 19px; background: #294f83; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.wheel-actions { justify-content: center; }
.wheel-result { display: grid; gap: 6px; background: var(--yellow); padding: 11px; border-radius: 11px; }
.wheel-result strong { font-size: 1.12rem; }
.wheel-save { padding: 9px 11px; border-radius: 11px; background: var(--blue); }
.wheel-save .row { margin-top: 5px; }
.wheel-confirm { display: grid; gap: 9px; padding: 12px; border: 1px solid #e1d6f0; border-radius: 12px; background: var(--lavender); }
.wheel-confirm p { font-weight: 650; }
.wheel-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.wheel-confirm-actions button { min-height: 40px; }
.wheel-confirm-actions .danger-action { color: white; background: #633f82; border-color: #633f82; }
.examples { margin-bottom: 8px; }
.examples button { padding: 4px 8px; font-size: .88rem; }
#chat-form { display: flex; align-items: flex-end; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 22px; background: #f4f7fc; }
#chat-form:focus-within { border-color: #95add0; }
.composer-buttons { display: flex; gap: 2px; flex: none; }
#chat-form .composer-circle { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; padding: 0; }
.composer-circle img { display: block; width: 19px; height: 19px; }
#chat-form [data-action="voice"] { background: transparent; border-color: transparent; }
#chat-form [data-action="voice"][aria-pressed="true"] { background: var(--lavender); border-color: #b6a2d7; }
.composer-send img { width: 22px; height: 22px; filter: invert(1); }
input, select, textarea { max-width: 100%; border: 1px solid var(--line); border-radius: 10px; background: white; padding: 7px 9px; }
#chat-form textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 100px; padding: 9px 4px 9px 10px; border: 0; outline: none; resize: none; field-sizing: content; background: transparent; }
.reply-wait { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .88rem; }
.reply-dots { display: inline-flex; align-items: center; gap: 4px; }
.reply-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: reply-pulse 1.15s ease-in-out infinite; }
.reply-dots i:nth-child(2) { animation-delay: .14s; }
.reply-dots i:nth-child(3) { animation-delay: .28s; }
@keyframes reply-pulse { 0%, 70%, 100% { opacity: .38; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .reply-dots i { animation: none; } }
.sheet { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 22px clamp(15px, 4.3vw, 26px); }
.schedule-sheet { background: linear-gradient(180deg, #eaf2ff, var(--paper) 250px); }
.progress-sheet { background: linear-gradient(180deg, #ecf5f1, var(--paper) 235px); }
.tabs { margin: 12px 0 16px; padding: 4px; background: #ffffffb8; border: 1px solid var(--line); border-radius: 15px; gap: 4px; }
.tabs button { flex: 1; background: transparent; border-color: transparent; min-height: 40px; padding-inline: 6px; white-space: nowrap; }
.tabs button.selected { background: var(--blue); }
.progress-sheet .tabs button.selected { background: var(--green); color: #275b47; }
.schedule-date { background: #ffffffbd; padding: 8px 10px; border-radius: 14px; justify-content: space-between; }
.section-heading, .demo-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-heading { margin-top: 16px; }
.section-heading h2 { margin: 0; }
.demo-banner { background: var(--yellow); padding: 6px 12px; font-size: .9rem; }
.counter-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.counter-value { font-size: 1.55rem; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; color: #2c604a; }
.counter-value span { font-size: .9rem; color: #4e695b; }
.counter-track { appearance: none; display: block; width: 100%; height: 6px; margin: 6px 0 9px; border: 0; border-radius: 10px; background: #d4e6dc; overflow: hidden; }
.counter-track::-webkit-progress-bar { background: #d4e6dc; }
.counter-track::-webkit-progress-value { background: #639a80; border-radius: 10px; }
.counter-track::-moz-progress-bar { background: #639a80; border-radius: 10px; }
.date-grid-wrap { overflow-x: auto; }
.date-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 8px; text-align: center; }
.date-grid .grid-weekday { color: var(--muted); font-size: .72rem; }
.date-grid .date-cell { min-width: 0; padding: 4px 0; border: 1px solid transparent; border-radius: 6px; font-variant-numeric: tabular-nums; font-size: .85rem; }
.date-grid .date-cell small { display: block; font-size: clamp(.55rem, 1.8vw, .68rem); }
.date-grid.compact { grid-auto-flow: column; grid-template: repeat(7, 22px) / 22px; grid-auto-columns: 22px; width: max-content; align-items: center; }
.date-grid.compact .date-cell { width: 22px; height: 22px; border-radius: 4px; }
.date-grid .level-0 { background: var(--gray); }
.date-grid .level-1 { background: #e8f4ec; }
.date-grid .level-2 { background: #d4eddc; }
.date-grid .level-3 { background: #b4dbc3; }
.date-grid .level-4 { background: #92c4aa; color: #214c3a; }
.date-grid .date-cell[aria-pressed="true"] { border-color: var(--accent); }
.date-detail:not(:empty) { display: block; margin-top: 7px; }
.progress-range, .record-range { margin: 8px 0 12px; }
.record-range { flex-wrap: nowrap; gap: 6px; }
.record-range label { min-width: 0; }
.record-arrows { display: flex; flex: none; gap: 5px; }
.record-arrows button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; }
.record-day h3 { margin: 14px 0 5px; font-size: .84rem; color: var(--muted); }
.item.record.record-alternate { border-left-color: #7caf92; }
.item, .summary { padding: 14px; margin: 8px 0; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: var(--shadow); overflow-wrap: anywhere; }
.item.counter { background: var(--green); border-color: #d6e9de; }
.item.goal { background: #eee8fb80; border-color: #e1d6f0; }
.item.goal > .item { background: #ffffffc2; }
.item.template { background: #fff2d480; border-color: #f3e5c2; }
.sop-edit-rows { display: grid; gap: 8px; }
.item.record { border-left: 3px solid #bdcdec; }
.empty { background: #ffffffa8; border: 1px dashed #dbe3ef; border-radius: 13px; margin: 8px 0; padding: 10px 12px; font-size: .92rem; }
.item small, .summary span { display: block; }
.item p, .item .row { margin-top: 5px; }
.task-actions { justify-content: flex-end; gap: 4px; }
.task-actions small { margin-right: auto; }
button.minor-delete { margin-left: auto; padding: 4px 8px; font-size: .78rem; color: #6a6076; }
.task-actions button.minor-delete { margin-left: 0; }
button.icon-button { display: inline-grid; place-items: center; width: 38px; min-height: 38px; padding: 0; flex: none; border-color: transparent; }
button.icon-button:not(.primary) { background: transparent; }
button.icon-button:not(.primary):hover { background: var(--blue); }
button.icon-button img { display: block; opacity: .76; }
button.icon-button.primary img { filter: invert(1); opacity: 1; }
.item ul { margin: 6px 0; padding-left: 20px; }
.summary { background: linear-gradient(112deg, #e1ecff, #eff6ff); border-color: #d7e5fa; padding: 15px; }
.summary-metrics { display: grid; grid-template-columns: 1fr 1fr; }
.progress-tools { justify-content: flex-end; gap: 6px; margin: 8px 0 14px; }
.progress-tools button { min-height: 38px; padding: 5px 8px; font-size: .82rem; }
.summary-metrics > div + div { border-left: 1px solid #cdddf4; padding-left: 14px; }
.summary-metrics small { display: block; margin-top: 3px; }
.summary strong { font-size: 1.9rem; letter-spacing: -.04em; line-height: 1.15; color: #294b77; font-variant-numeric: tabular-nums; }
.summary strong span { display: inline; font-size: .85rem; font-weight: 650; letter-spacing: 0; }
.timer { padding: 8px 12px; background: var(--yellow); border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timer-info { display: flex; align-items: center; gap: 8px; flex: 1 1 9rem; min-width: 0; }
.timer b { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.timer time { flex: none; font-variant-numeric: tabular-nums; }
.timer-actions { margin-inline-start: auto; justify-content: flex-end; }
.due-reminder { background: var(--yellow); border-top: 1px solid #eddbac; padding: 9px 12px; }
.due-reminder:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 7px; }
.due-reminder p { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 6px 12px max(6px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
nav button { min-height: 49px; background: transparent; border: 0; display: grid; gap: 2px; justify-items: center; align-content: center; padding: 3px; color: var(--muted); font-size: .82rem; }
nav button[aria-current="page"] { background: var(--blue); color: #294b77; font-weight: 700; }
nav button img { width: 19px; height: 19px; opacity: .72; }
dialog { border: 1px solid var(--line); border-radius: 20px; background: var(--paper); width: min(410px, calc(100% - 24px)); max-height: calc(var(--visible-height, 100dvh) - 24px); overflow: auto; box-shadow: 0 18px 48px #2e456a2e; }
dialog::backdrop { background: #27384c70; }
#history-dialog {
  position: fixed;
  inset: 0 max(0px, calc((100% - 700px) / 2)) 0 auto;
  width: min(700px, 100%);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  opacity: 0;
  transform: translateX(100%);
  transition: transform 230ms cubic-bezier(.22,.7,.2,1), opacity 180ms ease, display 230ms allow-discrete, overlay 230ms allow-discrete;
}
#history-dialog[open] { opacity: 1; transform: translateX(0); }
@starting-style { #history-dialog[open] { opacity: 0; transform: translateX(100%); } }
.history-layout { height: 100%; display: flex; flex-direction: column; }
.history-header { display: flex; align-items: center; gap: 8px; padding: max(12px, env(safe-area-inset-top)) 14px 10px; border-bottom: 1px solid var(--line); background: #e5efff; }
.history-header h2 { margin: 0; font-size: 1.12rem; }
.history-list { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 6px 16px max(16px, env(safe-area-inset-bottom)); }
.history-day { display: grid; gap: 8px; margin: 12px 0 18px; }
.history-day h3 { margin: 0 2px; color: var(--muted); font-size: .82rem; font-weight: 600; }
.history-entry { width: 100%; min-width: 0; display: grid; gap: 5px; padding: 12px 14px; text-align: left; border-radius: 12px; overflow-wrap: anywhere; }
.history-entry strong, .history-entry span { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.history-entry strong { -webkit-line-clamp: 2; }
.history-entry span { -webkit-line-clamp: 3; font-size: .87rem; color: var(--muted); }
.bubble[data-message-id] { scroll-margin-top: 29px; }
.bubble[data-message-id]:focus { outline: 2px solid #799ac7; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { #history-dialog { transition: none; } }
dialog form { display: grid; gap: 8px; }
dialog label { display: grid; gap: 4px; }
#account-dialog h2 { margin: 0 0 8px; }
#account-dialog > .row { margin-top: 12px; }
#account-status, #backup-summary { color: var(--muted); font-size: .9rem; }
.account-import { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; overflow-wrap: anywhere; }
.account-import h3 { margin: 0; font-size: 1rem; }
.account-import button { justify-self: start; }
.account-import input[type="file"] { width: 100%; min-width: 0; }
#backup-summary:empty { display: none; }
dialog label.check { display: flex; align-items: center; }
dialog fieldset { min-width: 0; margin: 0; border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 6px; }
dialog fieldset .row label { display: grid; }
.time-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.time-fields input { min-width: 0; width: 100%; }
.repeat-group { display: grid; gap: 8px; }
.repeat-group > div > small { margin-left: 4px; }
.repeat-group:not(:has(.repeat-days input:checked)) .repeat-end { display: none; }
.repeat-days { display: grid; grid-template-columns: repeat(7, minmax(0, 2.45rem)); gap: 5px; }
.repeat-days label { position: relative; display: grid; cursor: pointer; }
.repeat-days input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.repeat-days span { display: grid; place-items: center; width: 100%; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 50%; background: #fff; }
.repeat-days input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.repeat-days input:focus-visible + span { outline: 2px solid #4973a9; outline-offset: 2px; }
#notice:not(:empty) { position: fixed; z-index: 5; bottom: calc(75px + var(--viewport-inset, 0px)); left: 50%; transform: translateX(-50%); width: max-content; max-width: 90vw; padding: 8px 12px; border-radius: 11px; color: white; background: #263955; pointer-events: none; }

@media (max-width: 390px) {
  .chat-heading, .composer { margin-inline: 8px; padding-inline: 8px; }
  .messages { padding-inline: 8px; }
  .bubble { max-width: 94%; }
  .timer .timer-art { display: none; }
}

@media (max-height: 440px) {
  .chat-heading { margin-top: 4px; padding-block: 5px; }
  .composer { margin-bottom: 4px; padding-block: 5px; }
  .timer .timer-art { display: none; }
  #app:has(#chat-form textarea:focus) nav { display: none; }
}
