:root {
  color-scheme: light;
  --page: #f3f5f4;
  --surface: #ffffff;
  --glass: rgba(255, 255, 255, 0.82);
  --glass-strong: rgba(255, 255, 255, 0.94);
  --surface-soft: #edf2ef;
  --ink: #18211e;
  --ink-soft: #3f4d47;
  --muted: #65706b;
  --line: rgba(80, 101, 92, 0.16);
  --line-strong: rgba(80, 101, 92, 0.26);
  --accent: #1f5a4e;
  --accent-hover: #17473e;
  --accent-soft: #e4efea;
  --blue: #315f86;
  --blue-soft: #e8eff5;
  --amber: #9a5d14;
  --amber-soft: #f7ecdc;
  --danger: #a53d3d;
  --danger-soft: #f8e7e7;
  --shadow: 0 18px 50px rgba(30, 45, 39, 0.12), 0 2px 8px rgba(30, 45, 39, 0.05);
  --shadow-soft: 0 8px 26px rgba(30, 45, 39, 0.06), 0 1px 3px rgba(30, 45, 39, 0.04);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 8% -12%, rgba(176, 218, 205, 0.38), transparent 68%),
    radial-gradient(760px 460px at 96% 12%, rgba(205, 220, 235, 0.34), transparent 66%),
    var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(49, 95, 134, 0.24);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100%, 1220px);
  margin: 0 auto;
  padding: 0 24px 112px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 245, 244, 0.8);
  backdrop-filter: saturate(145%) blur(22px);
  -webkit-backdrop-filter: saturate(145%) blur(22px);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-width: 0;
  gap: 10px;
}

.brand-mark {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #ffffff;
  border-radius: 50%;
  background: var(--accent);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.25;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(229, 233, 230, 0.72);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.75);
}

.view-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 16px;
  gap: 7px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.view-tab.is-active {
  color: var(--ink);
  background: var(--glass-strong);
  box-shadow: 0 2px 7px rgba(30, 45, 39, 0.1);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.account-button {
  display: inline-flex;
  min-width: 0;
  height: 40px;
  padding: 0 11px 0 6px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--glass);
  box-shadow: 0 2px 8px rgba(30, 45, 39, 0.04);
  cursor: pointer;
}

.account-button:hover {
  border-color: var(--line-strong);
  background: var(--glass-strong);
}

.account-avatar {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 750;
}

.account-avatar svg {
  width: 16px;
  height: 16px;
}

.account-name {
  max-width: 88px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-label-short {
  display: none;
}

.icon-button,
.quiet-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  height: 40px;
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-button {
  width: 40px;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--glass);
  box-shadow: 0 2px 8px rgba(30, 45, 39, 0.035);
}

.icon-button:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.icon-button-accent {
  color: var(--accent);
  border-color: #bdd1c8;
  background: var(--accent-soft);
}

.primary-button {
  padding: 0 16px;
  gap: 8px;
  border: 1px solid var(--accent);
  color: #ffffff;
  background: var(--accent);
  font-weight: 650;
  box-shadow: 0 3px 8px rgba(31, 90, 78, 0.18);
}

.primary-button:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.secondary-button {
  padding: 0 14px;
  gap: 8px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--glass-strong);
  font-weight: 600;
}

.secondary-button:hover,
.quiet-button:hover {
  border-color: var(--line-strong);
  background: #eef1ef;
}

.quiet-button {
  padding: 0 13px;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  font-weight: 600;
}

.summary-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  align-items: stretch;
  min-height: 132px;
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.summary-item {
  display: flex;
  min-width: 0;
  padding: 23px 28px;
  flex-direction: column;
  justify-content: center;
}

.summary-divider {
  width: 1px;
  margin: 24px 0;
  background: var(--line);
}

.summary-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.summary-value {
  display: flex;
  flex-wrap: wrap;
  column-gap: 6px;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.summary-year .summary-value {
  color: var(--accent);
}

.summary-meta {
  min-height: 20px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.trend-up {
  color: var(--accent) !important;
}

.trend-down {
  color: var(--danger) !important;
}

.trend-new {
  color: var(--blue) !important;
}

.trend-neutral {
  color: var(--muted) !important;
}

main {
  margin-top: 24px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 0.8fr);
  align-items: stretch;
  gap: 20px;
}

.calendar-tool,
.month-goal-card,
.day-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.calendar-side {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  min-width: 0;
  min-height: 0;
  gap: 20px;
  contain: size;
}

.month-goal-card {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  cursor: pointer;
  text-align: left;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.month-goal-card:hover,
.month-goal-card:focus-visible {
  border-color: var(--line-strong);
  background: var(--glass-strong);
}

.month-goal-top,
.day-panel-header {
  display: flex;
  flex: 0 0 70px;
  width: 100%;
  padding: 0 22px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.46);
}

.month-goal-label {
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.month-goal-edit {
  cursor: inherit;
}

.month-goal-edit svg {
  width: 18px;
  height: 18px;
}

.month-goal-value,
.day-total {
  margin: 20px 22px 0;
  color: var(--accent);
  font-size: 25px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.month-goal-card:has(.month-goal-track:not([hidden])) .month-goal-value {
  font-size: 48px;
  line-height: 1.15;
}

.month-goal-track {
  display: block;
  flex: 0 0 4px;
  height: 4px;
  margin: 0 22px 24px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(31, 90, 78, 0.12);
}

.month-goal-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 320ms ease;
}

.month-goal-meta,
.day-date {
  min-height: 18px;
  margin: 6px 22px 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.month-goal-meta {
  margin-top: auto;
  margin-bottom: 8px;
}

.calendar-tool {
  min-width: 0;
  overflow: hidden;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  padding: 0 17px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.46);
}

.month-navigation {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.month-navigation .icon-button {
  width: 36px;
  height: 36px;
  border-color: transparent;
  background: transparent;
}

.month-navigation h1,
.analysis-header h1 {
  margin: 0;
  color: var(--ink);
  font-size: 21px;
  line-height: 1.3;
}

.month-navigation h1 {
  width: 146px;
  text-align: center;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  height: 36px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #fafbfa;
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}

.calendar-grid {
  grid-template-rows: repeat(6, minmax(76px, 1fr));
  min-height: 456px;
}

.calendar-day {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  padding: 9px 9px 8px;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  cursor: pointer;
  isolation: isolate;
  overflow: hidden;
}

.calendar-day::after {
  position: absolute;
  z-index: 8;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: saturate(125%) blur(12px);
  -webkit-backdrop-filter: saturate(125%) blur(12px);
  transition: opacity 180ms ease;
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day:nth-last-child(-n + 7) {
  border-bottom: 0;
}

.calendar-day:hover {
  background: rgba(248, 251, 249, 0.82);
}

@media (hover: hover) and (pointer: fine) {
  .calendar-day:hover::after,
  .calendar-day:hover .day-duration { opacity: 1; }
}

.calendar-day.is-outside {
  color: #68736e;
  background: #fafbfa;
}

.calendar-day.is-outside .day-water {
  opacity: 0.56;
}

.calendar-day.is-selected {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.calendar-day.is-today .day-number {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
}

.calendar-day.has-records:not(.is-today) .day-number {
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.78);
}

.day-water,
.day-hour-grid,
.day-wave-art {
  position: absolute;
  pointer-events: none;
}

.day-water {
  z-index: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--day-fill, 0%);
  min-height: 0;
  transition: height 460ms cubic-bezier(0.22, 0.8, 0.26, 1);
}

.calendar-day:not(.has-records) .day-water {
  display: none;
}

.day-wave-art {
  z-index: 1;
  left: 54%;
  bottom: clamp(0px, calc(var(--day-fill, 0%) - 2px), calc(100% - 22px));
  width: 32px;
  height: auto;
  transform: translateX(-50%);
  transform-origin: center bottom;
  transition: bottom 460ms ease;
}

.day-wave-art img {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  transform-origin: 50% 90%;
  animation: boat-rock var(--wave-period, 5s) ease-in-out infinite;
  filter: drop-shadow(0 1px 1px rgba(38, 100, 132, .14));
}

.day-water::before,
.day-water::after {
  position: absolute;
  left: 0;
  content: "";
}

.day-water::before {
  top: max(calc(var(--wave-height) / -2), -50%);
  width: 200%;
  height: min(var(--wave-height), 100%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 32' preserveAspectRatio='none'%3E%3Cpath d='M0 16 Q30 0 60 16 T120 16 T180 16 T240 16 V32 H0Z' fill='%2396cee3'/%3E%3C/svg%3E") 0 0 / 50% 100% repeat-x;
  animation: day-wave-scroll var(--wave-period, 5s) linear infinite;
}

.day-water::after {
  top: max(0px, min(calc(var(--wave-height) / 2 - .2px), calc(50% - .2px)));
  right: 0;
  bottom: 0;
  background: linear-gradient(#96cee3, #66b0d3);
}

.day-hour-grid {
  display: none;
}

@keyframes day-wave-scroll {
  from { transform: translate3d(-50%, 0, 0); }
  to { transform: translate3d(0, 0, 0); }
}

@keyframes boat-rock {
  0%, 100% { transform: translateY(var(--boat-bob)) rotate(calc(var(--boat-tilt) * -1)); }
  50% { transform: translateY(calc(var(--boat-bob) * -1)) rotate(var(--boat-tilt)); }
}

.day-number {
  display: block;
  position: relative;
  z-index: 3;
  width: 26px;
  height: 26px;
  color: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  line-height: 26px;
  text-align: center;
}

.day-duration {
  position: absolute;
  z-index: 9;
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 4px;
  width: calc(100% - 8px);
  max-width: calc(100% - 8px);
  min-width: 0;
  padding: 0;
  color: #174b63;
  background: transparent;
  text-shadow: 0 1px 8px rgba(255, 255, 255, 0.88), 0 0 2px rgba(255, 255, 255, 0.9);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, -50%);
  transform-origin: center;
  transition: opacity 180ms ease;
  white-space: nowrap;
}

.day-duration > span { white-space: nowrap; }

.calendar-day.is-outside .day-duration {
  color: #416b7a;
}

.day-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.day-panel-header,
.analysis-header,
.section-heading,
.ai-panel-header,
.dialog-header,
.settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.day-panel h2,
.section-heading h2,
.ai-panel h2,
.dialog-header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.record-list {
  flex: 1;
  min-height: 0;
  margin: 14px 22px 16px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.record-list .empty-state {
  height: 100%;
  min-height: 0;
  padding: 12px 0;
}

.record-list .empty-state svg {
  width: 20px;
  height: 20px;
  margin-bottom: 6px;
}

.record-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  min-height: 58px;
  padding: 12px 0;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

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

.record-duration {
  display: flex;
  min-width: 0;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.record-duration small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.record-note {
  display: block;
  max-width: 100%;
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-size: 11px;
  font-style: normal;
  font-weight: 500;
  line-height: 1.4;
}

.record-actions {
  display: flex;
  gap: 4px;
}

.record-actions .icon-button {
  width: 36px;
  height: 36px;
  border-color: transparent;
  background: transparent;
}

.record-actions .delete-record:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-state {
  display: flex;
  min-height: 165px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 24px;
  height: 24px;
  margin-bottom: 10px;
  color: #8a9892;
}

.empty-state p {
  margin: 0;
  font-size: 13px;
}

.analysis-header {
  min-height: 58px;
}

.analysis-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  margin-top: 28px;
  align-items: start;
  gap: 24px;
}

.analysis-main {
  min-width: 0;
  grid-column: 1;
  grid-row: 1;
}

.analysis-main .analysis-section:first-child {
  padding-top: 0;
}

.ai-status-button {
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa39f;
}

.ai-status-button.is-connected .status-dot {
  background: #2b8a66;
  box-shadow: 0 0 0 4px rgba(43, 138, 102, 0.11);
}

.ai-status-button.is-protected .status-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(154, 93, 20, 0.11);
}

.trend-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.35);
}

.trend-block {
  display: flex;
  min-width: 0;
  min-height: 122px;
  padding: 22px 28px;
  flex-direction: column;
  justify-content: center;
}

.trend-block + .trend-block {
  border-left: 1px solid var(--line);
}

.trend-block > span,
.trend-block small {
  color: var(--muted);
  font-size: 12px;
}

.trend-block strong {
  margin: 2px 0;
  overflow-wrap: anywhere;
  font-size: 26px;
  line-height: 1.3;
}

.analysis-section {
  padding: 34px 0;
  border-bottom: 1px solid var(--line);
}

.monthly-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: stretch;
  height: 266px;
  margin-top: 20px;
  padding: 18px 6px 0;
  gap: 8px;
  border-bottom: 1px solid var(--line-strong);
}

.bar-button {
  display: grid;
  min-width: 0;
  height: 100%;
  padding: 0;
  grid-template-rows: minmax(0, 1fr) 28px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.bar-plot {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.bar-value {
  width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-fill {
  width: min(100%, 28px);
  height: 3px;
  border-radius: 4px 4px 0 0;
  background: #668b80;
  transition: height 220ms ease, background-color 180ms ease;
}

.bar-level-1 { height: 19px; }
.bar-level-2 { height: 38px; }
.bar-level-3 { height: 57px; }
.bar-level-4 { height: 76px; }
.bar-level-5 { height: 95px; }
.bar-level-6 { height: 114px; }
.bar-level-7 { height: 133px; }
.bar-level-8 { height: 152px; }
.bar-level-9 { height: 171px; }
.bar-level-10 { height: 190px; }

.bar-button:hover .bar-fill,
.bar-button.is-current .bar-fill {
  background: var(--accent);
}

.bar-button.is-future {
  opacity: 0.46;
}

.bar-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 28px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-button.is-current .bar-label {
  color: var(--accent);
}

.quarter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 20px;
  gap: 10px;
}

.quarter-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: 0 5px 18px rgba(30, 45, 39, 0.045);
}

.quarter-card.is-current {
  border-color: #9fbdb2;
  box-shadow: inset 0 3px 0 var(--accent);
}

.quarter-card.is-future {
  opacity: 0.58;
}

.quarter-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.quarter-name {
  font-size: 15px;
  font-weight: 750;
}

.quarter-range {
  color: var(--muted);
  font-size: 11px;
}

.quarter-total {
  display: block;
  margin-top: 16px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.quarter-trend {
  display: block;
  min-height: 19px;
  margin-top: 5px;
  font-size: 12px;
}

.quarter-current-tag {
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 700;
}

.table-wrap {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: 0 5px 18px rgba(30, 45, 39, 0.04);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 46px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  text-align: left;
}

th {
  height: 40px;
  color: var(--muted);
  background: rgba(242, 245, 243, 0.9);
  font-size: 11px;
  font-weight: 700;
}

th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  text-align: right;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td {
  font-variant-numeric: tabular-nums;
}

.ai-panel {
  margin-top: 34px;
  padding: 24px;
  border: 1px solid #d6e0e8;
  border-radius: var(--radius);
  background: rgba(232, 239, 245, 0.78);
  box-shadow: 0 8px 26px rgba(49, 95, 134, 0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.analysis-chat {
  scroll-margin-top: 110px;
  position: sticky;
  top: 102px;
  display: grid;
  min-width: 0;
  height: min(690px, calc(100dvh - 126px));
  min-height: 520px;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: var(--shadow-soft);
  backdrop-filter: saturate(135%) blur(20px);
  -webkit-backdrop-filter: saturate(135%) blur(20px);
  grid-column: 2;
  grid-row: 1;
}

.chat-header {
  display: flex;
  min-height: 74px;
  padding: 15px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
}

.chat-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.chat-heading h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.chat-icon {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
  background: var(--blue-soft);
}

.chat-icon svg {
  width: 18px;
  height: 18px;
}

.chat-clear-button {
  width: 36px;
  height: 36px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.chat-clear-button:not(:disabled):hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.chat-status {
  display: flex;
  min-height: 34px;
  padding: 0 16px;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: rgba(249, 250, 249, 0.58);
  font-size: 11px;
  font-weight: 600;
}

.chat-status.is-connected .status-dot {
  background: #2b8a66;
}

.chat-messages {
  display: flex;
  min-height: 0;
  padding: 18px 14px;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.chat-empty {
  display: grid;
  min-height: 100%;
  padding: 28px 18px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  text-align: center;
}

.chat-message {
  display: flex;
  max-width: 92%;
  align-items: flex-start;
  gap: 8px;
}

.chat-message p {
  margin: 0;
  padding: 9px 11px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 7px 18px rgba(30, 45, 39, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  font-size: 13px;
  line-height: 1.65;
}

.chat-message.is-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.is-user p {
  color: #ffffff;
  border-color: var(--accent);
  background: linear-gradient(145deg, rgba(31, 90, 78, 0.96), rgba(38, 113, 101, 0.92));
  box-shadow: 0 8px 20px rgba(31, 90, 78, 0.17), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.chat-message.is-pending p {
  opacity: 0.86;
}

.chat-message.is-thinking {
  animation: chat-thinking-in 220ms ease-out both;
}

.chat-thinking-bubble {
  display: inline-flex;
  min-width: 58px;
  min-height: 38px;
  padding: 9px 12px !important;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--blue) !important;
  background: rgba(255, 255, 255, 0.68) !important;
}

.thinking-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: thinking-dot-bounce 1.2s ease-in-out infinite;
}

.thinking-dot:nth-child(2) {
  animation-delay: 120ms;
}

.thinking-dot:nth-child(3) {
  animation-delay: 240ms;
}

.chat-message-avatar {
  display: grid;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
  background: var(--blue-soft);
}

.chat-message-avatar svg {
  width: 13px;
  height: 13px;
}

.chat-form {
  display: grid;
  padding: 12px;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: end;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(18px) saturate(125%);
  -webkit-backdrop-filter: blur(18px) saturate(125%);
}

.chat-form textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 116px;
  padding: 10px 12px;
  resize: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  line-height: 1.45;
}

.chat-input-options {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 10px;
}

.chat-search-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  cursor: pointer;
  font-size: 11px;
}

.chat-search-option input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.chat-sources { display: block; margin-top: 10px; font-size: 11px; line-height: 1.6; }
.chat-sources summary { cursor: pointer; color: var(--muted); }
.chat-sources a { display: block; margin-top: 5px; color: var(--accent); overflow-wrap: anywhere; }

.chat-form textarea::placeholder {
  color: #67726c;
}

.chat-form textarea:focus {
  border-color: rgba(31, 90, 78, 0.5);
  box-shadow: 0 0 0 4px rgba(31, 90, 78, 0.1), inset 0 1px 2px rgba(30, 45, 39, 0.035);
}

.chat-send-button {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
}

.chat-send-button:not(:disabled):hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.chat-send-button.is-thinking {
  border-color: rgba(31, 90, 78, 0.5);
  background: rgba(31, 90, 78, 0.86);
}

.chat-thinking-spinner {
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: chat-thinking-spin 0.85s linear infinite;
}

@keyframes chat-thinking-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes thinking-dot-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@keyframes chat-thinking-spin {
  to { transform: rotate(360deg); }
}

.ai-title-wrap {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.ai-icon,
.settings-icon {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
  background: #dce8f1;
}

.ai-content {
  min-height: 98px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #ccd9e3;
  color: #273b4b;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.ai-content p {
  margin: 0;
}

.ai-content ul { margin: 0; padding-left: 1.3em; }
.ai-content li + li, .ai-content p + p { margin-top: 7px; }

.ai-content.is-loading {
  color: var(--muted);
}

.ai-updated {
  min-height: 18px;
  margin: 10px 0 0;
  color: #526572;
  font-size: 11px;
  text-align: right;
}

.app-dialog {
  width: min(500px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  margin: auto;
  padding: 24px;
  overflow-y: auto;
  border: 1px solid rgba(80, 101, 92, 0.2);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  backdrop-filter: saturate(140%) blur(24px);
  -webkit-backdrop-filter: saturate(140%) blur(24px);
}

.app-dialog::backdrop {
  background: rgba(24, 31, 28, 0.34);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dialog-close {
  border-color: transparent;
}

.field {
  display: flex;
  margin-top: 22px;
  flex-direction: column;
  gap: 7px;
}

.field > span,
.duration-fields legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field input,
.duration-fields input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(250, 252, 251, 0.92);
  box-shadow: inset 0 1px 2px rgba(30, 45, 39, 0.035);
}

.field input {
  padding: 0 13px;
}

.field input:focus,
.duration-fields input:focus {
  border-color: var(--blue);
  background: var(--surface);
}

.duration-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  margin: 14px 0 0;
  padding: 0;
  gap: 10px;
  border: 0;
}

.duration-fields legend {
  grid-column: 1 / -1;
  margin-bottom: 10px;
  padding: 0;
}

.record-current-total {
  display: flex;
  margin-top: 16px;
  padding: 11px 13px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(31, 90, 78, 0.12);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--accent-soft);
  font-size: 12px;
}

.record-current-total strong {
  color: var(--accent);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.adjustment-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.adjustment-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.adjustment-button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
}

.adjustment-button.is-active {
  border-color: rgba(31, 90, 78, 0.16);
  color: var(--accent);
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(30, 45, 39, 0.08);
}

.record-details {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.record-start-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.record-start-toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

.time-lock-picker {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
  align-items: center;
  width: min(100%, 256px);
  height: 108px;
  margin: 10px auto 0;
}

.time-lock-picker::before {
  position: absolute;
  inset: 36px 0;
  content: "";
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(226, 238, 232, 0.65);
  pointer-events: none;
}

.time-wheel {
  position: relative;
  height: 108px;
  padding-block: 36px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
  -webkit-mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
}

.time-wheel::-webkit-scrollbar { display: none; }

.time-wheel-option {
  height: 36px;
  line-height: 36px;
  scroll-snap-align: center;
  color: var(--muted);
  font-size: 23px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.time-wheel-option[aria-selected="true"] { color: var(--accent); }
.time-lock-colon { position: relative; text-align: center; font-size: 20px; color: var(--accent); }
.time-wheel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.period-picker {
  margin: 15px 0 0;
  padding: 0;
  border: 0;
}

.period-picker legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.period-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 7px;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.period-option {
  min-height: 34px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.period-option:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
}

.period-option.is-active {
  border-color: rgba(31, 90, 78, 0.16);
  color: var(--accent);
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(30, 45, 39, 0.08);
}

.record-note-field {
  margin-top: 15px;
}

.duration-fields label {
  position: relative;
  display: block;
}

.duration-fields input {
  padding: 0 47px 0 14px;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.duration-fields label span {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--muted);
  font-size: 12px;
  transform: translateY(-50%);
  pointer-events: none;
}

.duration-separator {
  height: 48px;
  color: var(--muted);
  font-size: 22px;
  line-height: 48px;
}

.form-error {
  min-height: 21px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.form-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  margin-top: 4px;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

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

.goal-dialog {
  width: min(420px, calc(100% - 28px));
}

.goal-duration-fields {
  margin-top: 24px;
}

.goal-duration-fields input { appearance: textfield; -moz-appearance: textfield; }
.goal-duration-fields input::-webkit-inner-spin-button,
.goal-duration-fields input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.goal-repeat-option {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.goal-repeat-option small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.goal-repeat-option input {
  position: absolute;
  right: 0;
  width: 44px;
  height: 44px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.goal-repeat-switch {
  flex: 0 0 44px;
  height: 26px;
  padding: 3px;
  border-radius: 20px;
  background: #d6dfda;
  transition: background 160ms ease;
  pointer-events: none;
}

.goal-repeat-switch::after {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(30, 45, 39, 0.18);
  transition: transform 160ms ease;
}

.goal-repeat-option input:checked + .goal-repeat-switch { background: var(--accent); }
.goal-repeat-option input:checked + .goal-repeat-switch::after { transform: translateX(18px); }
.goal-repeat-option input:focus-visible + .goal-repeat-switch {
  outline: 3px solid rgba(49, 95, 134, 0.3);
  outline-offset: 3px;
}

.goal-clear-button {
  margin-right: auto;
  border-color: transparent;
  color: var(--danger);
  background: transparent;
}

.account-dialog {
  width: min(460px, calc(100% - 28px));
}

.account-dialog-header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.account-view {
  padding-top: 2px;
}

.account-view .field {
  margin-top: 18px;
}

.account-submit-button {
  width: 100%;
  margin-top: 2px;
}

.account-switch-button {
  display: block;
  min-height: 40px;
  margin: 10px auto 0;
  padding: 0 12px;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.account-switch-button:hover {
  color: var(--accent-hover);
}

.profile-summary {
  display: flex;
  min-width: 0;
  margin-top: 18px;
  padding: 14px 0 18px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.profile-avatar {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  font-size: 17px;
  font-weight: 750;
}

.profile-summary > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.profile-summary strong,
.profile-summary span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-summary strong {
  font-size: 15px;
}

.profile-summary div span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.profile-actions {
  display: flex;
  margin-top: 2px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.danger-button {
  display: inline-flex;
  flex: 0 0 auto;
  height: 40px;
  padding: 0 13px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #e4bebe;
  border-radius: var(--radius);
  color: var(--danger);
  background: rgba(255, 255, 255, 0.76);
  font-weight: 650;
  cursor: pointer;
}

.danger-button:hover {
  background: var(--danger-soft);
}

.settings-section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.settings-heading {
  justify-content: flex-start;
  gap: 12px;
}

.settings-heading h3,
.settings-heading p {
  margin: 0;
}

.settings-heading h3 {
  font-size: 15px;
}

.settings-heading p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.settings-icon {
  color: var(--accent);
  background: var(--accent-soft);
}

.settings-icon-blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.inline-actions,
.backup-actions {
  display: flex;
  margin-top: 13px;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-admin-link {
  text-decoration: none;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex;
  max-width: calc(100% - 28px);
  min-height: 48px;
  padding: 8px 9px 8px 16px;
  align-items: center;
  gap: 15px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  color: #ffffff;
  background: #202a27;
  box-shadow: 0 10px 30px rgba(17, 25, 22, 0.25);
  transform: translateX(50%);
}

.toast span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast button {
  min-width: 54px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: #d9eee7;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 750;
  cursor: pointer;
}

.username-reminder {
  position: fixed;
  z-index: 90;
  right: 24px;
  bottom: max(24px, env(safe-area-inset-bottom));
  display: grid;
  width: min(390px, calc(100% - 32px));
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 15px 14px 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 18px 46px rgba(36, 79, 74, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(150%) blur(22px);
  -webkit-backdrop-filter: saturate(150%) blur(22px);
  animation: reminder-in 320ms cubic-bezier(0.22, 0.8, 0.26, 1) both;
}

.username-reminder-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  color: #246e82;
  background: rgba(181, 229, 241, 0.68);
}

.username-reminder-icon svg {
  width: 17px;
  height: 17px;
}

.username-reminder-copy {
  min-width: 0;
}

.username-reminder-copy strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.username-reminder-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.username-reminder-copy code {
  padding: 2px 5px;
  border-radius: 6px;
  color: #246e82;
  background: rgba(185, 230, 240, 0.46);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
}

.username-reminder-actions {
  display: flex;
  margin-top: 9px;
  align-items: center;
  gap: 12px;
}

.username-reminder-edit,
.username-reminder-later,
.username-reminder-close {
  border: 0;
  cursor: pointer;
}

.username-reminder-edit {
  min-height: 30px;
  padding: 0 11px;
  border-radius: 9px;
  color: #fff;
  background: #287b8c;
  font-size: 12px;
  font-weight: 700;
}

.username-reminder-edit:hover {
  background: #1d6170;
}

.username-reminder-later {
  padding: 4px 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.username-reminder-later:hover {
  color: var(--ink);
}

.username-reminder-close {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 20px;
  line-height: 20px;
}

.username-reminder-close:hover {
  color: var(--ink);
  background: rgba(31, 90, 78, 0.08);
}

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

@media (max-width: 1024px) {
  .analysis-layout {
    grid-template-columns: 1fr;
  }

  .analysis-chat {
    position: static;
    top: auto;
    width: 100%;
    height: 600px;
    min-height: 500px;
    grid-column: auto;
    grid-row: auto;
  }

  .analysis-main {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 12px 0;
    gap: 10px;
  }

  .view-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .view-tab {
    flex: 1;
  }

  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .calendar-side {
    grid-template-rows: auto auto;
    gap: 14px;
    contain: none;
  }

  .month-goal-card,
  .day-panel {
    min-height: 272px;
  }

  .record-list {
    overflow: visible;
  }

  .record-list .empty-state {
    min-height: 62px;
  }

  .quarter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 110px max(12px, env(safe-area-inset-left));
  }

  .topbar {
    min-height: 0;
  }

  .brand-mark {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .brand-copy small {
    font-size: 11px;
  }

  .header-actions .icon-button {
    width: 38px;
    height: 38px;
  }

  .header-actions .primary-button {
    height: 38px;
    padding: 0 10px;
    gap: 6px;
  }

  .header-actions .account-button {
    height: 38px;
    padding: 0 9px 0 5px;
    gap: 6px;
  }

  .header-actions .account-avatar {
    flex-basis: 26px;
    width: 26px;
    height: 26px;
  }

  .header-actions .account-name {
    max-width: 48px;
  }

  .record-label-full {
    display: none;
  }

  .record-label-short {
    display: inline;
  }

  .summary-band {
    min-height: 116px;
    margin-top: 15px;
  }

  .summary-item {
    padding: 16px 14px;
  }

  .summary-divider {
    margin: 18px 0;
  }

  .summary-value {
    font-size: clamp(18px, 5vw, 21px);
    display: flex;
    flex-wrap: wrap;
    column-gap: 5px;
  }

  .summary-value > span { white-space: nowrap; }

  .calendar-day { touch-action: manipulation; }
  .record-actions { padding-right: 48px; }
  .record-row { gap: 6px; }
  .field input { font-size: 16px; }

  .summary-meta {
    font-size: 11px;
  }

  main {
    margin-top: 14px;
  }

  .calendar-toolbar {
    height: 62px;
    padding: 0 10px;
  }

  .month-navigation {
    gap: 0;
  }

  .month-navigation h1 {
    width: 112px;
    font-size: 18px;
  }

  .calendar-grid {
    grid-template-rows: repeat(6, 58px);
    min-height: 348px;
  }

  .calendar-day {
    padding: 5px 4px 4px;
    gap: 2px;
  }

  .day-number {
    width: 24px;
    height: 24px;
    font-size: 12px;
    line-height: 24px;
  }

  .day-wave-art { width: 24px; }
  .analysis-chat { scroll-margin-top: 124px; }

  .calendar-day.is-today .day-number {
    width: 24px;
    height: 24px;
  }

  .day-duration {
    font-size: 13px;
  }

  .month-goal-top,
  .day-panel-header {
    flex-basis: 62px;
    padding: 0 80px 0 18px;
  }

  .month-goal-card,
  .day-panel {
    min-height: 252px;
  }

  .month-goal-value,
  .day-total {
    margin: 18px 18px 0;
    font-size: 22px;
  }

  .month-goal-track {
    margin: 0 18px 22px;
  }

  .month-goal-card:has(.month-goal-track:not([hidden])) .month-goal-value {
    font-size: 42px;
  }

  .month-goal-meta,
  .day-date {
    margin-right: 18px;
    margin-left: 18px;
  }

  .record-list {
    margin-right: 18px;
    margin-left: 18px;
  }

  .analysis-header {
    align-items: flex-start;
  }

  .analysis-layout {
    gap: 16px;
  }

  .ai-status-button {
    height: 36px;
    padding: 0 8px;
    font-size: 12px;
  }

  .trend-block {
    min-height: 108px;
    padding: 16px 14px;
  }

  .trend-block strong {
    font-size: 21px;
  }

  .analysis-section {
    padding: 28px 0;
  }

  .monthly-chart {
    height: 220px;
    padding: 12px 0 0;
    grid-template-columns: repeat(12, minmax(40px, 1fr));
    gap: 3px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .bar-button {
    min-width: 40px;
  }

  .bar-fill {
    width: min(100%, 18px);
  }

  .bar-level-1 { height: 15px; }
  .bar-level-2 { height: 30px; }
  .bar-level-3 { height: 45px; }
  .bar-level-4 { height: 60px; }
  .bar-level-5 { height: 75px; }
  .bar-level-6 { height: 90px; }
  .bar-level-7 { height: 105px; }
  .bar-level-8 { height: 120px; }
  .bar-level-9 { height: 135px; }
  .bar-level-10 { height: 150px; }

  .bar-value {
    visibility: hidden;
    height: 0;
  }

  .bar-plot {
    gap: 0;
  }

  .quarter-grid {
    gap: 8px;
  }

  .quarter-card {
    padding: 14px;
  }

  .quarter-total {
    font-size: 17px;
  }

  th,
  td {
    padding: 0 10px;
    font-size: 12px;
  }

  .ai-panel {
    padding: 18px;
  }

  .ai-panel-header {
    align-items: flex-start;
    gap: 10px;
  }

  .ai-panel-header .secondary-button {
    width: 40px;
    padding: 0;
  }

  .ai-panel-header .secondary-button span {
    position: absolute;
    overflow: hidden;
    width: 1px;
    height: 1px;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .analysis-chat {
    height: min(560px, calc(100dvh - 148px));
    min-height: min(340px, calc(100dvh - 148px));
  }

  .chat-header {
    min-height: 68px;
    padding: 13px 14px;
  }

  .chat-status {
    padding: 0 14px;
  }

  .chat-messages {
    padding: 15px 12px;
  }

  .chat-form {
    padding: 10px;
  }

  .app-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px - env(safe-area-inset-top));
    margin: auto 8px 8px;
    padding: 20px 20px max(20px, env(safe-area-inset-bottom));
  }

  .record-dialog .dialog-actions {
    position: sticky;
    bottom: calc(-1 * max(20px, env(safe-area-inset-bottom)));
    margin: 8px -4px 0;
    padding: 12px 4px;
    background: var(--glass-strong);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .username-reminder {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100% - 24px);
  }

  .dialog-actions .save-record-button,
  .dialog-actions .save-goal-button {
    flex: 1;
  }
}

@media (max-width: 360px) {
  .brand-copy small {
    display: none;
  }

  .primary-button {
    padding: 0 10px;
  }

  .header-actions {
    gap: 5px;
  }

  .header-actions .account-button {
    height: 36px;
    padding: 0 7px 0 5px;
  }

  .header-actions .account-name {
    max-width: 36px;
    font-size: 12px;
  }

  .header-actions .icon-button,
  .header-actions .primary-button {
    height: 36px;
  }

  .header-actions .icon-button {
    width: 36px;
  }

  .header-actions .primary-button {
    padding: 0 8px;
    gap: 5px;
  }

  .summary-value {
    font-size: 19px;
  }

  .summary-meta {
    line-height: 1.35;
    white-space: normal;
  }

  .quarter-card {
    padding: 12px;
  }

  .profile-actions {
    gap: 6px;
  }

  .profile-actions .primary-button,
  .danger-button {
    padding: 0 10px;
    gap: 6px;
    font-size: 13px;
  }
}

.quick-actions {
  position: fixed;
  z-index: 60;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
}

.quick-toggle {
  display: grid;
  width: 62px;
  height: 62px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .46);
  border-radius: 50%;
  color: white;
  background: linear-gradient(145deg, rgba(48, 107, 94, .9), rgba(24, 71, 60, .95));
  box-shadow: 0 8px 30px rgba(25, 73, 62, .24), inset 0 1px 1px rgba(255, 255, 255, .46);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  cursor: pointer;
  transition: transform 220ms ease, box-shadow 220ms ease;
}
.quick-toggle svg { width: 29px; height: 29px; stroke-width: 1.65; transition: transform 360ms cubic-bezier(.2, .8, .2, 1.2); }
.quick-toggle:active { transform: scale(.94); }
.is-open .quick-toggle svg { transform: rotate(135deg); }
.quick-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(24, 39, 33, .09); animation: quick-backdrop-in 180ms ease both; }
.quick-menu {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 198px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 23px;
  background: rgba(251, 253, 252, .86);
  box-shadow: 0 18px 50px rgba(30, 45, 39, .16), inset 0 1px 0 white;
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  transform-origin: calc(100% - 31px) calc(100% + 44px);
  transform: translateY(12px) scale(.65);
  opacity: 0;
  visibility: hidden;
  transition: transform 300ms cubic-bezier(.16, 1, .3, 1.12), opacity 180ms ease, visibility 300ms;
}
.is-open .quick-menu { transform: translateY(0) scale(1); opacity: 1; visibility: visible; }
.quick-option { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px; border: 0; border-radius: 16px; color: var(--ink); background: transparent; text-align: left; font-size: 14px; font-weight: 650; cursor: pointer; }
.quick-option:hover, .quick-option:focus-visible { background: rgba(31, 90, 78, .07); }
.quick-option-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: var(--accent); background: var(--accent-soft); }
.quick-option-icon.is-blue { color: var(--blue); background: var(--blue-soft); }
.username-reminder { bottom: max(104px, calc(env(safe-area-inset-bottom) + 80px)); }
.toast { bottom: max(104px, calc(env(safe-area-inset-bottom) + 80px)); }
@keyframes quick-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 640px) {
  .quick-actions { right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); }
  .quick-toggle { width: 58px; height: 58px; }
  .quick-menu { bottom: 72px; }
  .chat-form textarea { font-size: 16px; }
}

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