: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;
  --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: 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 56px;
}

.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 {
  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: start;
  gap: 20px;
}

.calendar-tool,
.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-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);
  cursor: pointer;
}

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

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

.calendar-day:hover {
  background: #f8fbf9;
}

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

.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);
}

.day-number {
  display: block;
  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 {
  display: block;
  width: 100%;
  overflow: hidden;
  color: var(--accent);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day.is-outside .day-duration {
  color: #506f65;
}

.day-panel {
  min-height: 368px;
  padding: 22px;
}

.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;
}

.day-total {
  margin-top: 22px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-size: 25px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.record-list {
  margin-top: 8px;
}

.record-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 58px;
  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-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 {
  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);
  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: var(--accent);
}

.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);
}

.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-form textarea::placeholder {
  color: #67726c;
}

.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);
}

.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.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: 20px 0 0;
  padding: 0;
  gap: 10px;
  border: 0;
}

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

.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;
}

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

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

.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;
}

.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;
}

@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;
  }

  .day-panel {
    min-height: 0;
  }

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

@media (max-width: 640px) {
  .app-shell {
    padding: 0 12px 44px;
  }

  .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: 21px;
  }

  .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;
  }

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

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

  .day-panel {
    padding: 18px;
  }

  .day-total {
    margin-top: 16px;
    padding: 14px 0;
    font-size: 22px;
  }

  .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 - 24px));
    min-height: 460px;
  }

  .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);
    margin: auto 8px 8px;
    padding: 20px 20px max(20px, env(safe-area-inset-bottom));
  }

  .dialog-actions .save-record-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;
  }
}

@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;
  }
}
