:root {
  color-scheme: light;
  --surface: #f2f3f7;
  --card: #fff;
  --ink: #182033;
  --muted: #576278;
  --border: #e2e6ef;
  --accent: #184fc6;
  --accent-tint: #e8efff;
  --control: #eef1f6;
  --red: #a03238;
  --red-bg: #fdecee;
  --shadow: 0 4px 18px #19274608, 0 1px 2px #19274608;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); color: var(--ink); }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button {
  min-height: 44px;
  padding: .57rem .8rem;
  border: 1px solid transparent;
  border-radius: .8rem;
  background: var(--control);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:active:not(:disabled) { filter: brightness(.94); }
button:disabled { opacity: .42; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: #fff; font-weight: 650; }
.secondary { background: var(--control); }
.compact { font-size: .86rem; }
.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sr { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }

.shell {
  max-width: 58rem;
  margin: auto;
  padding: max(.6rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) calc(6rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
.top, .heading, .section-head, .target { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.top { min-width: 0; padding: .35rem 0 .65rem; }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--ink); font-weight: 760; text-decoration: none; }
.mark {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: .75rem;
  background: linear-gradient(150deg, #5484f1, #1c52ce);
  box-shadow: 0 3px 7px #164dba25;
  color: #fff;
}
.mark .icon { width: 19px; height: 19px; }
.top-actions { display: flex; align-items: center; gap: .35rem; }
.toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .34rem;
  min-width: 44px;
  padding: .5rem .66rem;
  border-radius: .9rem;
  background: var(--card);
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: .83rem;
  font-weight: 620;
}
.toolbar-button[aria-current] { color: var(--accent); background: var(--accent-tint); }
#hide-keyboard { display: none; }
.heading { padding: 1.25rem 0 1rem; align-items: flex-end; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2.15rem, 8vw, 3.05rem); line-height: 1.04; letter-spacing: -.047em; }
h2 { font-size: 1.15rem; line-height: 1.25; letter-spacing: -.025em; }
h3 { font-size: .94rem; }
.eyebrow { text-transform: uppercase; color: var(--accent); letter-spacing: .085em; font-size: .72rem; font-weight: 730; margin-bottom: .29rem; }

.card, dialog {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: clamp(.88rem, 2.6vw, 1.23rem);
  box-shadow: var(--shadow);
}
.overview, .project-grid, .list-grid { display: grid; gap: .75rem; }
.inbox { margin-top: .75rem; }
.attention .section-head h2::before { content: ''; display: inline-block; width: .5rem; height: .5rem; margin: 0 .45rem .13rem 0; border-radius: 50%; background: #e06868; }
.section-head { min-height: 1.8rem; }
.badge { border-radius: 99px; padding: .18rem .58rem; font-size: .76rem; font-weight: 690; white-space: nowrap; background: var(--control); }
.warn { background: var(--red-bg); color: var(--red); }
.calm { background: var(--accent-tint); color: var(--accent); }
.stack { display: grid; gap: .25rem; margin-top: .55rem; }
.stack > .muted { padding: .3rem 0; }
.row, .notice {
  min-width: 0;
  width: 100%;
  padding: .62rem .72rem;
  border: 1px solid transparent;
  border-radius: .84rem;
  background: #f5f7fb;
  text-align: left;
  overflow-wrap: anywhere;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
.row strong, .notice strong { display: block; font-size: .94rem; font-weight: 680; }
.row small, .notice small { display: block; color: var(--muted); font-size: .78rem; }
.row .time { flex: none; color: var(--accent); font-size: .76rem; font-variant-numeric: tabular-nums; }
.task-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .3rem; }
.task-line .time { max-width: 5.8rem; text-align: right; }
.today-done { padding-inline: .58rem; color: var(--accent); background: var(--accent-tint); font-size: .82rem; }
.notice.highlight { outline: 2px solid var(--accent); }
.notice p { font-size: .85rem; }
.actions, .chips, .composer-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.actions { margin: .6rem 0 .1rem; }
.actions button { font-size: .86rem; }
.windows { border-top: 1px solid var(--border); margin-top: .85rem; padding-top: .65rem; }
.chips { margin-top: .42rem; }
.chip { border-radius: 99px; background: var(--accent-tint); color: var(--accent); font-size: .78rem; padding: .28rem .58rem; }
.hint, .muted { color: var(--muted); font-size: .88rem; }
.hint { background: var(--control); padding: .55rem .68rem; border-radius: .72rem; margin: .5rem 0; }
.notes { white-space: pre-wrap; overflow-wrap: anywhere; margin: .45rem 0; }
.agenda-date { width: auto; max-width: 10.4rem; min-width: 0; padding: .3rem .44rem; }

.bottom {
  position: fixed;
  z-index: 2;
  left: 50%;
  bottom: max(.45rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(36rem, calc(100% - 1.2rem));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .12rem;
  padding: .26rem;
  border: 1px solid #ffffffa0;
  border-radius: 1.2rem;
  background: #fffffff0;
  box-shadow: 0 8px 28px #25354d19, 0 2px 7px #25354d0c;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.bottom button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: .22rem;
  min-height: 49px;
  min-width: 0;
  padding: .26rem 0;
  border-radius: .9rem;
  background: transparent;
  color: var(--muted);
  font-size: .65rem;
  line-height: 1.12;
}
.bottom button[aria-current] { background: var(--accent-tint); color: var(--accent); font-weight: 740; }

.login { max-width: 25rem; margin: 2rem auto; }
.login p { margin: .55rem 0; }
input, textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .59rem .69rem;
  border: 1px solid var(--border);
  border-radius: .72rem;
  background: #f8f9fc;
  color: var(--ink);
  font-size: 16px;
}
textarea { resize: vertical; }
label { display: block; color: var(--muted); margin: .68rem 0 .28rem; font-size: .85rem; }
.check { display: inline-flex; align-items: center; gap: .43rem; min-height: 44px; margin: .1rem 0; }
.check input { width: 1.1rem; min-height: 1.1rem; margin: 0; accent-color: var(--accent); }
form > .primary { margin-top: .7rem; }
dialog { color: var(--ink); width: min(33rem, calc(100% - 1.25rem)); max-height: 86dvh; overflow: auto; }
dialog::backdrop { background: #15243b60; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog p { margin: .42rem 0; }
details { margin-top: .48rem; }
summary { color: var(--muted); font-size: .86rem; cursor: pointer; padding: .37rem 0; }
.project-accordion, .rubric-card { margin: 0; }
.project-accordion > summary { min-height: 44px; padding: .64rem .2rem; font-size: .98rem; color: var(--ink); font-weight: 700; }
.project-accordion > summary small { display: inline-block; margin-left: .52rem; font-size: .78rem; font-weight: 480; color: var(--muted); }
.project-accordion[open] > summary { border-bottom: 1px solid var(--border); }
.project-context .notes { max-height: 12rem; overflow: auto; }
.filter-row { display: flex; flex-wrap: wrap; column-gap: 1rem; }
.segments {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .15rem;
  padding: .2rem;
  border-radius: .85rem;
  background: #e8ebf2;
}
.catalog .segments { margin-top: .7rem; }
.segments button { padding-inline: .14rem; background: transparent; border-radius: .67rem; color: var(--muted); font-size: .83rem; }
.segments button[aria-pressed=true] { background: var(--card); color: var(--accent); box-shadow: var(--shadow); font-weight: 700; }
.rubric-card { --rubric: #255ab2; --rubric-bg: #e9f0ff; padding-block: .45rem; }
.rubric-card[data-rubric=personal] { --rubric: #a34650; --rubric-bg: #fcebf0; }
.rubric-card[data-rubric=leisure] { --rubric: #206957; --rubric-bg: #e1f4ea; }
.rubric-card[data-rubric=deferred] { --rubric: #8a560f; --rubric-bg: #fff1d9; }
.rubric-card[data-rubric=monitor] { --rubric: #6645aa; --rubric-bg: #eee8ff; }
.rubric-card[data-rubric=normal] { --rubric: #55617a; --rubric-bg: #edf0f5; }
.rubric-card > summary { display: flex; align-items: center; min-height: 48px; gap: .55rem; list-style: none; }
.rubric-card > summary::-webkit-details-marker { display: none; }
.rubric-card > summary::before { content: ''; width: .58rem; height: .58rem; border-radius: 50%; background: var(--rubric); }
.rubric-card > summary::after { content: ''; width: .4rem; height: .4rem; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); margin-right: .18rem; }
.rubric-card[open] > summary::after { transform: rotate(45deg); }
.rubric-name { flex: 1; color: var(--ink); font-weight: 700; font-size: 1rem; }
.rubric-card .badge, .add-in-list { color: var(--rubric); background: var(--rubric-bg); }
.rubric-card > .stack { margin: .25rem 0 .5rem; }
.add-in-list { justify-self: start; }

.stats-content, .stats-summary { display: grid; gap: .75rem; margin-top: .8rem; }
.stats-summary { grid-template-columns: 1fr 1fr; margin-top: 0; }
.metric:first-child { grid-column: 1 / -1; background: linear-gradient(150deg, #fff 38%, #e6eeff); }
.metric-value { margin: .25rem 0; font-size: clamp(1.28rem, 5.5vw, 2rem); font-weight: 760; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.chart-card > .muted { margin-top: .6rem; }
.activity-chart { display: flex; align-items: flex-end; gap: clamp(1px, .6vw, 5px); height: 8rem; padding-top: .35rem; margin: .8rem 0 .25rem; border-bottom: 1px solid var(--border); }
.activity-bar { flex: 1; min-width: 0; height: var(--bar-height); border-radius: .34rem .34rem 0 0; background: #729cf3; }
.activity-bar.peak { background: var(--accent); }
.chart-dates { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; }
.chart-details { margin-top: .65rem; }
.chart-details dl { display: grid; grid-template-columns: 1fr auto; gap: .28rem .7rem; color: var(--muted); margin: .2rem 0 0; font-size: .86rem; }
.chart-details dd { margin: 0; font-variant-numeric: tabular-nums; }

.chat-mode, .chat-mode body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
.chat-mode .shell {
  position: fixed;
  inset: var(--chat-top, 0px) 0 auto;
  height: var(--chat-height, 100dvh);
  display: flex;
  flex-direction: column;
  padding-bottom: max(.45rem, env(safe-area-inset-bottom));
}
.chat-mode .top { flex: none; border-bottom: 1px solid var(--border); }
.chat-mode #workspace { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-mode #assistant-pane { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.chat-mode .bottom { position: static; transform: none; flex: none; margin: .35rem auto 0; width: min(36rem, 100%); }
.keyboard-open .shell { padding-bottom: .25rem; }
.keyboard-open .top { padding-block: .15rem .35rem; }
.keyboard-open .bottom, .keyboard-open #stats-nav, .keyboard-open #options { display: none; }
.keyboard-open #hide-keyboard { display: inline-flex; color: var(--accent); }
.chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; width: min(100%, 45rem); margin-inline: auto; }
.chat-log { position: relative; display: flex; flex: 1; min-height: 0; flex-direction: column; overflow: auto; overscroll-behavior: contain; padding: .75rem .1rem .7rem; gap: .85rem; }
.chat-log > * { flex-shrink: 0; }
.chat-day { align-self: center; color: var(--muted); font-size: .74rem; background: #e9edf4; padding: .18rem .55rem; border-radius: 99px; }
.chat-typing { padding: .43rem .5rem; color: var(--muted); font-size: .84rem; }
.chat-latest { align-self: center; z-index: 1; min-width: 40px; min-height: 40px; margin-top: -44px; margin-bottom: 4px; padding: .4rem; border-radius: 50%; color: var(--accent); }
.bubble { min-width: 0; align-self: flex-start; width: 100%; padding: .2rem .35rem; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; width: fit-content; max-width: 87%; padding: .63rem .84rem; border-radius: 1.02rem 1.02rem .35rem 1.02rem; background: var(--accent-tint); color: #19386a; }
.message-text { line-height: 1.57; }
.message-text p, .message-text blockquote, .bubble.me .message-text { white-space: pre-wrap; }
.message-text > * + * { margin-top: .66rem; }
.message-text h2, .message-text h3 { line-height: 1.32; }
.message-text ul, .message-text ol { margin-bottom: 0; padding-left: 1.3rem; }
.message-text li + li { margin-top: .22rem; }
.message-text a { color: var(--accent); text-underline-offset: .18em; }
.message-text blockquote { padding-left: .7rem; margin-inline: 0; border-left: 3px solid #93acf1; color: var(--muted); }
.message-text code { padding: .07rem .23rem; border-radius: .25rem; background: #e6ebf3; font-size: .87em; }
.message-text pre { max-width: 100%; margin-bottom: 0; padding: .65rem; overflow: auto; background: #e6ebf3; border-radius: .7rem; }
.message-text pre code { padding: 0; }
.message-text hr { border: 0; border-top: 1px solid var(--border); }
.message-table { max-width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: .95rem; background: var(--card); }
.message-table table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.message-table th, .message-table td { padding: .55rem .65rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.message-table th { background: #e9effc; color: #31558f; font-weight: 700; }
.message-table tbody tr:last-child td { border-bottom: 0; }
.cell-label { display: none; }
.chat-plan { border: 1px solid var(--border); background: var(--card); border-radius: .9rem; padding: .7rem .8rem; margin-top: .6rem; }
.chat-plan ul { padding-left: 1.24rem; margin: .4rem 0; font-size: .89rem; }
.chat-plan li + li { margin-top: .23rem; }
.chat-footer { flex: none; min-width: 0; padding-top: .33rem; border-top: 1px solid var(--border); }
.target { font-size: .83rem; color: var(--accent); margin: 0 .1rem .15rem; }
.target span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose {
  display: flex;
  align-items: flex-end;
  gap: .2rem;
  margin: .24rem 0 .18rem;
  padding: .24rem .28rem .24rem .45rem;
  border: 1px solid var(--border);
  border-radius: 1.35rem;
  background: var(--card);
  box-shadow: var(--shadow);
}
.compose:focus-within { border-color: #9eb7f1; }
.compose textarea { flex: 1; min-height: 44px; max-height: min(10rem, calc(var(--chat-height, 100dvh) * .27)); padding: .6rem .33rem; resize: none; border: 0; background: transparent; line-height: 1.4; }
.compose textarea:focus { outline: none; }
.composer-actions { flex: none; flex-wrap: nowrap; gap: .17rem; }
.composer-actions button { display: grid; place-items: center; width: 44px; min-height: 44px; padding: .2rem; border-radius: 50%; }
.mic { touch-action: none; user-select: none; -webkit-user-select: none; }
.mic[aria-pressed=true] { background: var(--red); color: #fff; }
.voice-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .15rem .45rem; }
#voice-status { font-size: .76rem; padding: .16rem .3rem; }
#voice-status:empty { display: none; }
#voice-cancel { margin: .12rem 0; }

.planner-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.planner-fields > div, #planner-dialog input { min-width: 0; max-width: 100%; }
#planner-dialog input[type=date], #planner-dialog input[type=time] { appearance: none; -webkit-appearance: none; display: block; }
.planner-status { margin: .65rem 0 .3rem !important; }
.slots { display: flex; flex-wrap: wrap; gap: .35rem; max-height: 12rem; overflow: auto; margin-bottom: .55rem; }
.slots button { font-size: .86rem; }
.slots button[aria-pressed=true] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); font-weight: 720; }
.button-link { display: inline-flex; align-items: center; min-height: 44px; padding: .48rem .65rem; border-radius: .7rem; background: var(--accent-tint); color: var(--accent); text-decoration: none; font-size: .85rem; }
.toast { position: fixed; z-index: 3; left: 50%; bottom: calc(4.7rem + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(35rem, calc(100% - 1.35rem)); padding: .68rem .83rem; border-radius: .78rem; background: #254579; color: #fff; box-shadow: var(--shadow); }
.toast.error { background: var(--red); }
.keyboard-open .toast { top: calc(var(--chat-top, 0px) + env(safe-area-inset-top) + 3.4rem); bottom: auto; }

@media (min-width: 660px) {
  .overview { grid-template-columns: 1fr 1fr; align-items: start; }
  .list-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .stats-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric:first-child { grid-column: auto; }
}
@media (max-width: 520px) {
  .message-table table, .message-table tbody, .message-table tr, .message-table td { display: block; }
  .message-table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .message-table tbody tr { padding: .52rem .65rem; border-bottom: 1px solid var(--border); }
  .message-table tbody tr:last-child { border-bottom: 0; }
  .message-table tbody tr:nth-child(even) { background: #f7f9fe; }
  .message-table td { padding: .18rem 0; border: 0; }
  .cell-label { display: block; color: var(--muted); font-size: .72rem; font-weight: 690; }
}
@media (max-width: 390px) {
  .planner-fields { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 360px) {
  #stats-nav span { display: none; }
}
