:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --panel: #ffffff;
  --ink: #171716;
  --muted: #66645d;
  --line: #dedbd2;
  --accent: #007aff;
  --accent-ink: #ffffff;
  --blue: #0a84ff;
  --warn: #a84324;
  --type-event: #007aff;
  --type-travel: #5856d6;
  --type-eating: #8a5a12;
  --type-sleeping: #6b627b;
  --type-other: #74716a;
  --type-event-bg: #eef6ff;
  --type-travel-bg: #f3f2ff;
  --type-eating-bg: #f8f4eb;
  --type-sleeping-bg: #f4f2f7;
  --type-other-bg: #f7f6f2;
  --soft: #ece8dc;
  --surface: #ffffff;
  --ink-contrast: #ffffff;
  --header-bg: rgb(245 243 238 / 92%);
  --header-border: rgb(222 219 210 / 80%);
  --focus-ring: rgb(0 122 255 / 24%);
  --primary-hover: #006ee6;
  --primary-shadow: 0 8px 22px rgb(0 122 255 / 18%);
  --segmented-shadow: 0 1px 6px rgb(30 30 24 / 12%);
  --timeline-line: rgb(222 219 210 / 55%);
  --overlay: rgb(23 23 22 / 26%);
  --drawer-backdrop: rgb(245 243 238 / 16%);
  --drawer-glass: rgb(255 255 255 / 54%);
  --drawer-glass-strong: rgb(255 255 255 / 78%);
  --drawer-gradient-start: rgb(245 243 238 / 48%);
  --message-assistant-bg: rgb(255 255 255 / 64%);
  --message-user-bg: #1f7aff;
  --message-user-ink: #ffffff;
  --subtle-ink-bg: rgb(23 23 22 / 7%);
  --code-bg: rgb(23 23 22 / 8%);
  --pre-bg: #f0ede5;
  --accent-bg: rgb(0 122 255 / 12%);
  --accent-bg-strong: rgb(0 122 255 / 14%);
  --accent-bg-soft: rgb(0 122 255 / 8%);
  --warn-bg: rgb(168 67 36 / 10%);
  --warn-bg-strong: rgb(168 67 36 / 12%);
  --place-underline: rgb(0 122 255 / 36%);
  --panel-shadow: 0 18px 60px rgb(23 23 22 / 24%);
  --message-shadow: 0 8px 26px rgb(23 23 22 / 10%);
  --composer-shadow: 0 10px 34px rgb(23 23 22 / 12%);
  --desktop-drawer-border: rgb(255 255 255 / 24%);
  --desktop-drawer-shadow: -16px 0 48px rgb(23 23 22 / 8%);
  --desktop-left-drawer-shadow: 16px 0 48px rgb(23 23 22 / 8%);
  --shadow: none;
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111112;
    --panel: #1b1b1d;
    --ink: #f3f0e8;
    --muted: #aaa49a;
    --line: #303033;
    --accent: #66adff;
    --accent-ink: #08111c;
    --blue: #66adff;
    --warn: #ff9a76;
    --type-event: #66adff;
    --type-travel: #9f9cff;
    --type-eating: #e1b76a;
    --type-sleeping: #b8adc8;
    --type-other: #aaa49a;
    --type-event-bg: #182738;
    --type-travel-bg: #23203a;
    --type-eating-bg: #2a2417;
    --type-sleeping-bg: #25212d;
    --type-other-bg: #1d1d1f;
    --soft: #252527;
    --surface: #202023;
    --ink-contrast: #111112;
    --header-bg: rgb(17 17 18 / 88%);
    --header-border: rgb(48 48 51 / 82%);
    --focus-ring: rgb(102 173 255 / 34%);
    --primary-hover: #86bdff;
    --primary-shadow: none;
    --segmented-shadow: none;
    --timeline-line: rgb(74 74 78 / 50%);
    --overlay: rgb(0 0 0 / 54%);
    --drawer-backdrop: rgb(0 0 0 / 30%);
    --drawer-glass: rgb(32 32 35 / 72%);
    --drawer-glass-strong: rgb(32 32 35 / 86%);
    --drawer-gradient-start: rgb(17 17 18 / 64%);
    --message-assistant-bg: rgb(32 32 35 / 82%);
    --message-user-bg: #257de8;
    --message-user-ink: #ffffff;
    --subtle-ink-bg: rgb(255 255 255 / 8%);
    --code-bg: rgb(255 255 255 / 10%);
    --pre-bg: #242426;
    --accent-bg: rgb(102 173 255 / 16%);
    --accent-bg-strong: rgb(102 173 255 / 20%);
    --accent-bg-soft: rgb(102 173 255 / 10%);
    --warn-bg: rgb(255 154 118 / 14%);
    --warn-bg-strong: rgb(255 154 118 / 18%);
    --place-underline: rgb(102 173 255 / 48%);
    --panel-shadow: 0 20px 64px rgb(0 0 0 / 42%);
    --message-shadow: none;
    --composer-shadow: 0 14px 40px rgb(0 0 0 / 28%);
    --desktop-drawer-border: rgb(255 255 255 / 10%);
    --desktop-drawer-shadow: -18px 0 52px rgb(0 0 0 / 28%);
    --desktop-left-drawer-shadow: 18px 0 52px rgb(0 0 0 / 28%);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
  color: var(--ink);
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  font-size: 12px;
}

body[data-chat-open="true"] {
  overflow: hidden;
}

body[data-modal-open="true"] {
  overflow: hidden;
}

button,
a,
textarea,
input,
select {
  font: inherit;
}

button,
a {
  min-height: 36px;
  max-width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--ink);
  color: var(--ink-contrast);
  text-decoration: none;
  line-height: 1;
  font-weight: 730;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
  -webkit-tap-highlight-color: transparent;
}

button:hover,
a:hover {
  transform: translateY(-1px);
}

button:active,
a:active {
  transform: translateY(0);
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

button svg,
a svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-icon-only] {
  width: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: 999px;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 7px;
  background: var(--header-bg);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--header-border);
}

header section {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

p,
h1,
h2,
h3,
dl,
dd,
menu {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  line-height: 1.18;
  letter-spacing: 0;
}

h3 {
  font-size: 13px;
  line-height: 1.22;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.35;
}

header p {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 2px;
  background: var(--soft);
  border-radius: var(--radius);
}

nav button {
  min-height: 32px;
  background: transparent;
  color: var(--muted);
}

nav button[aria-current="page"] {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--segmented-shadow);
}

main {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 8px 8px calc(58px + env(safe-area-inset-bottom));
  overflow-x: clip;
}

main > section {
  display: grid;
  gap: 10px;
}

[data-next-card],
article[data-entry] {
  display: grid;
  gap: 6px;
  padding: 8px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

[data-next-card] {
  min-height: 108px;
  align-content: start;
  background: var(--panel);
}

[data-next-card] > p {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

[data-next-card] > p[data-agenda-status] {
  min-height: 14px;
  color: var(--muted);
  font-weight: 650;
  text-transform: none;
  letter-spacing: 0;
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

dt {
  color: var(--muted);
  font-size: 10px;
}

dd {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

menu {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
}

menu button,
menu a,
[data-prompts] button,
[data-day-tabs] button {
  min-height: 36px;
  background: var(--soft);
  color: var(--ink);
}

menu button:first-child,
form button,
[data-variant="primary"],
[data-chat-fab],
[data-dev-chat-fab] {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--primary-shadow);
}

menu button:first-child:hover,
form button:hover,
[data-variant="primary"]:hover,
[data-chat-fab]:hover,
[data-dev-chat-fab]:hover {
  background: var(--primary-hover);
}

[data-day-tabs] {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

[data-day-tabs]::-webkit-scrollbar {
  display: none;
}

[data-day-tabs] button {
  flex: 0 0 auto;
  min-width: 42px;
  padding: 0 8px;
}

[data-day-tabs] button[aria-selected="true"] {
  background: var(--ink);
  color: var(--ink-contrast);
}

[data-route-list],
[data-reference-list] {
  display: grid;
  gap: 6px;
}

[data-panel="crm"] {
  gap: 8px;
}

[data-crm-card],
article[data-lead] {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

[data-crm-card] header,
article[data-lead] header {
  position: static;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}

[data-crm-card] header section,
article[data-lead] header section {
  display: grid;
  gap: 3px;
}

[data-crm-card] header p {
  color: var(--accent);
}

[data-lead-form] {
  display: grid;
  gap: 8px;
}

[data-lead-form] label {
  min-width: 0;
  display: grid;
  gap: 4px;
}

[data-lead-form] label > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-lead-form] input,
[data-lead-form] select,
[data-lead-form] textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
}

[data-lead-form] textarea {
  min-height: 72px;
  resize: vertical;
}

[data-card-scan] {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 8px;
  align-items: center;
}

[data-card-scan] [data-card-scan-button] {
  min-height: 34px;
  max-width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--ink);
  color: var(--ink-contrast);
  font-weight: 730;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

[data-card-scan] [data-card-scan-button][aria-disabled="true"] {
  cursor: wait;
  opacity: 0.58;
  pointer-events: none;
}

[data-card-scan] [data-card-scan-button] > span {
  color: inherit;
  font-size: 12px;
  font-weight: 730;
  letter-spacing: 0;
  text-transform: none;
}

[data-card-scan] [data-card-scan-button] svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-card-scan] [data-card-input] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

[data-card-scan] p {
  font-size: 11px;
}

[data-card-scan] img {
  grid-column: 1 / -1;
  width: 100%;
  height: 140px;
  max-height: none;
  object-fit: contain;
  object-position: center center;
  border-radius: var(--radius);
  background: var(--soft);
}

[data-lead-fields],
[data-lead-meta] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

[data-send-follow-up] {
  min-height: 36px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

[data-send-follow-up] input {
  width: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--accent);
}

[data-send-follow-up] > span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 730;
  letter-spacing: 0;
  text-transform: none;
}

[data-send-follow-up] small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
  white-space: nowrap;
}

[data-lead-error] {
  padding: 7px 8px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
}

[data-leads-list] {
  display: grid;
  gap: 8px;
}

[data-leads-list] > section {
  display: grid;
  gap: 6px;
}

[data-leads-list] h2 {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

article[data-lead] {
  gap: 7px;
}

article[data-lead] header h3 {
  overflow-wrap: anywhere;
}

article[data-lead] header p {
  font-size: 11px;
}

article[data-lead] header button {
  min-height: 30px;
  width: 30px;
  min-width: 30px;
  background: var(--soft);
  color: var(--muted);
}

article[data-lead] > p {
  color: var(--ink);
  font-size: 12px;
}

[data-lead-tags] {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

[data-lead-tags] span,
[data-lead-tags] a {
  min-height: 0;
  padding: 4px 6px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 10px;
  font-weight: 720;
  line-height: 1;
  text-decoration: none;
}

[data-lead-tags] a {
  color: var(--accent);
}

[data-lead-tags] [data-email-status="sent"] {
  background: var(--accent-bg-strong);
  color: var(--accent);
}

[data-lead-tags] [data-email-status="failed"] {
  background: var(--warn-bg-strong);
  color: var(--warn);
}

[data-lead-tags] [data-email-status="skipped"] {
  color: var(--muted);
}

[data-timeline] {
  --slot-height: 8px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) minmax(72px, 0.36fr);
  grid-template-rows: repeat(var(--slots), var(--slot-height));
  column-gap: 6px;
  min-height: calc(var(--slots) * var(--slot-height));
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--slot-height) * 4 - 1px),
    var(--timeline-line) calc(var(--slot-height) * 4 - 1px),
    var(--timeline-line) calc(var(--slot-height) * 4)
  );
}

[data-time-rail] {
  grid-column: 1;
  grid-row: 1 / -1;
  display: grid;
  grid-template-rows: repeat(var(--slots), var(--slot-height));
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

[data-time-rail] time {
  transform: translateY(-7px);
}

[data-timeline] article[data-entry] {
  grid-column: 2;
  min-height: 24px;
  overflow: hidden;
  align-self: stretch;
}

article[data-entry] {
  box-shadow: none;
  border: 1px solid var(--line);
  background: var(--type-other-bg);
  content-visibility: auto;
  contain-intrinsic-size: auto 140px;
  cursor: pointer;
}

[data-timeline] article[data-entry] header {
  gap: 2px;
}

[data-timeline] article[data-entry] header div {
  align-items: start;
}

[data-timeline] article[data-entry] h3 {
  font-size: 11px;
  line-height: 1.15;
}

[data-timeline] article[data-entry] time {
  font-size: 10px;
}

[data-timeline] article[data-entry] [data-meta],
[data-timeline] article[data-entry] > p {
  display: none;
}

article[data-entry][data-type="event"] {
  background: var(--type-event-bg);
}

article[data-entry][data-type="travel"] {
  background: var(--type-travel-bg);
}

article[data-entry][data-type="eating"] {
  background: var(--type-eating-bg);
}

article[data-entry][data-type="sleeping"] {
  background: var(--type-sleeping-bg);
}

article[data-entry][data-type="travel"],
article[data-entry][data-type="eating"],
article[data-entry][data-type="sleeping"] {
  color: var(--muted);
}

[data-timeline] article[data-entry][data-option="true"] {
  grid-column: 3;
  border-style: dashed;
  background: var(--type-event-bg);
  color: var(--muted);
}

[data-timeline] article[data-entry][data-option="true"] h3 {
  font-weight: 650;
}

[data-timeline] article[data-entry][data-option="true"] [data-meta] {
  display: flex;
}

article[data-entry] header {
  position: static;
  display: grid;
  gap: 4px;
  padding: 0;
  background: transparent;
  border: 0;
  backdrop-filter: none;
}

article[data-entry] header div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

article[data-entry] time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

[data-place-link] {
  min-height: 0;
  max-width: 100%;
  padding: 0;
  display: inline-flex;
  align-items: start;
  justify-content: start;
  gap: 4px;
  border-radius: 0;
  background: transparent;
  color: inherit;
  line-height: 1.25;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--place-underline);
  text-underline-offset: 3px;
  white-space: normal;
  overflow-wrap: anywhere;
}

[data-place-link]:hover {
  background: transparent;
  color: var(--accent);
  transform: none;
}

[data-place-link] svg {
  width: 12px;
  height: 12px;
  margin-top: 1px;
  color: var(--accent);
}

[data-meta] {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

[data-meta] span {
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

[data-meta] [data-status="registered"] {
  background: var(--accent-bg-strong);
  color: var(--accent);
}

[data-meta] [data-status="applied"],
[data-meta] [data-status="waitlisted"] {
  background: var(--warn-bg-strong);
  color: var(--warn);
}

[data-entry] p {
  font-size: 12px;
}

article[data-entry] > p {
  color: var(--muted);
}

[data-entry] textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  color: var(--ink);
  background: var(--surface);
}

[data-chat-fab],
[data-dev-chat-fab] {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  min-width: 54px;
  min-height: 38px;
  padding-inline: 12px;
}

[data-chat-fab-side="left"] {
  right: auto;
  left: 16px;
}

[data-event-backdrop] {
  position: fixed;
  inset: 0;
  z-index: 28;
  background: var(--overlay);
  backdrop-filter: blur(3px);
}

[data-event-modal] {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 35;
  display: grid;
  gap: 10px;
  width: min(520px, calc(100vw - 24px));
  max-height: min(78dvh, 620px);
  overflow-y: auto;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--panel-shadow);
  transform: translate(-50%, -50%);
}

[data-event-modal][hidden],
[data-event-backdrop][hidden] {
  display: none;
}

[data-event-modal] header {
  position: static;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}

[data-event-modal] header section {
  display: grid;
  gap: 4px;
}

[data-event-modal] header p {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

[data-event-modal] header button {
  min-height: 34px;
  background: var(--soft);
  color: var(--ink);
}

[data-event-modal] menu {
  gap: 6px;
}

[data-event-detail]:empty {
  display: none;
}

[data-agent-backdrop] {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: var(--drawer-backdrop);
  backdrop-filter: blur(6px) saturate(1.05);
}

[data-agent-drawer] {
  background-color: transparent;
  position: fixed;
  inset: 0;
  z-index: 30;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "header"
    "history"
    "log"
    "composer";
  gap: 5px;
  padding: calc(8px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom));
  border-radius: 0;
  background:
    linear-gradient(180deg, var(--drawer-gradient-start), transparent 112px),
    transparent;
  box-shadow: none;
  overflow: hidden;
}

[data-agent-drawer][hidden],
[data-agent-backdrop][hidden] {
  display: none;
}

[data-agent-header] {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px 4px;
}

[data-agent-header] section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

[data-agent-header] p {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

[data-agent-header] small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

[data-agent-header] button {
  min-height: 34px;
  background: var(--drawer-glass);
  color: var(--ink);
  backdrop-filter: blur(18px);
}

[data-agent-tools] {
  flex: 0 0 auto;
  gap: 5px;
}

[data-agent-tools] button,
[data-agent-tools] button:first-child {
  min-height: 34px;
  background: var(--drawer-glass);
  color: var(--ink);
  box-shadow: none;
  backdrop-filter: blur(18px);
}

[data-agent-tools] button[aria-expanded="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

[data-chat-history] {
  grid-area: history;
  max-height: min(28dvh, 220px);
  overflow-y: auto;
  display: grid;
  gap: 4px;
  padding: 5px;
  border-radius: 14px;
  background: var(--drawer-glass);
  backdrop-filter: blur(18px);
  overscroll-behavior: contain;
}

[data-chat-history] p {
  padding: 7px 8px;
  color: var(--muted);
}

[data-chat-history-item] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 2px;
}

[data-chat-history] button {
  width: 100%;
  min-height: 34px;
  justify-content: start;
  gap: 6px;
  padding: 6px 8px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  text-align: left;
}

[data-chat-history] button:hover {
  background: var(--accent-bg-soft);
  transform: none;
}

[data-chat-history] button[aria-current="true"] {
  background: var(--accent-bg);
  color: var(--accent);
}

[data-chat-history] button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-chat-history] button time {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

[data-chat-history-delete] {
  padding: 0;
  justify-content: center;
  color: var(--muted);
}

[data-chat-history-delete]:hover {
  background: var(--warn-bg);
  color: var(--warn);
}

[data-chat-log],
[data-dev-chat-log] {
  grid-area: log;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 30px 2px 8px;
  mask-image: linear-gradient(to bottom, transparent 0, #000 36px, #000 100%);
  overscroll-behavior: contain;
}

[data-chat-log][data-empty="true"],
[data-dev-chat-log][data-empty="true"] {
  justify-content: center;
  padding-inline: 18px;
}

[data-dev-thread-list] {
  display: grid;
  gap: 6px;
}

[data-dev-thread-row] {
  width: 100%;
  min-height: 78px;
  display: grid;
  gap: 5px;
  position: relative;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--drawer-glass);
  color: var(--ink);
  box-shadow: none;
  text-align: left;
  backdrop-filter: blur(18px);
  content-visibility: auto;
  contain-intrinsic-size: 78px;
}

[data-dev-thread-row]:hover {
  background: var(--accent-bg-soft);
  transform: none;
}

[data-dev-thread-row][data-unread="true"] {
  padding-left: 20px;
}

[data-dev-thread-row][data-unread="true"]::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

[data-dev-thread-head] {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

[data-dev-thread-head] strong,
[data-dev-thread-latest],
[data-dev-thread-row] small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-dev-thread-head] strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
}

[data-dev-thread-head] time,
[data-dev-thread-row] small {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

[data-dev-thread-latest] {
  display: -webkit-box;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

[data-dev-notice] {
  width: min(100%, 340px);
  display: grid;
  gap: 7px;
  justify-self: center;
  align-self: center;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--drawer-glass);
  color: var(--muted);
  backdrop-filter: blur(18px);
}

[data-dev-notice] strong {
  color: var(--ink);
  font-size: 13px;
}

[data-dev-notice] p {
  margin: 0;
}

[data-dev-notice] button {
  width: max-content;
  min-height: 32px;
  padding: 0 10px;
  background: var(--accent);
  color: var(--accent-ink);
}

[data-message] {
  position: relative;
  width: max-content;
  max-width: min(82%, 680px);
  padding: 7px 9px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  box-shadow: var(--message-shadow);
}

[data-message="assistant"] {
  width: 100%;
  max-width: 100%;
  align-self: start;
  padding: 10px 42px 10px 11px;
  background: var(--message-assistant-bg);
  border: 0;
  border-radius: 10px;
  border-bottom-left-radius: 3px;
  font-size: 12px;
  line-height: 1.44;
  box-shadow: none;
  backdrop-filter: blur(18px);
}

[data-empty-message] {
  width: min(100%, 320px);
  justify-self: center;
  align-self: center;
  padding: 18px;
  text-align: center;
}

[data-message="user"] {
  align-self: end;
  background: var(--message-user-bg);
  color: var(--message-user-ink);
  border-bottom-right-radius: 3px;
  white-space: pre-wrap;
}

[data-message][data-dev-event-type="progress"] {
  width: 100%;
  max-width: 100%;
  padding: 5px 7px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  backdrop-filter: none;
}

[data-message][data-dev-event-type="error"] {
  background: var(--warn-bg-strong);
  color: var(--warn);
}

[data-message][data-dev-event-type="result"] {
  background: var(--accent-bg);
}

[data-dev-event-meta] {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

[data-message-content] {
  min-width: 0;
}

[data-message][data-streaming="true"] [data-message-content]:not([data-streaming-rows]) p::after {
  display: inline-block;
  inline-size: 3ch;
  margin-left: 1px;
  overflow: hidden;
  white-space: nowrap;
  line-height: inherit;
  vertical-align: baseline;
  content: "...";
}

[data-stream-row] {
  opacity: 1;
  animation: stream-row-in 440ms ease-out both;
}

[data-message-tools] {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  padding: 0;
  opacity: 0.62;
  transition: opacity 140ms ease;
}

[data-message]:hover [data-message-tools],
[data-message]:focus-within [data-message-tools] {
  opacity: 1;
}

[data-message-tools] button,
[data-message-tools] button:first-child {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  background: var(--subtle-ink-bg);
  color: var(--muted);
  box-shadow: none;
}

[data-message-tools] button[data-copied="true"] {
  background: var(--accent-bg);
  color: var(--accent);
}

[data-message] p,
[data-message] ul,
[data-message] ol,
[data-message] blockquote,
[data-message] pre {
  margin: 0;
}

[data-message-content] > * + * {
  margin-top: 10px;
}

[data-message-content] > :not(h3, h4) + h3,
[data-message-content] > :not(h3, h4) + h4 {
  margin-top: 16px;
}

[data-message] ul,
[data-message] ol {
  display: grid;
  gap: 6px;
  padding-left: 18px;
}

[data-message] li {
  line-height: 1.42;
}

[data-message] h3,
[data-message] h4 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.32;
}

[data-message] strong {
  color: var(--ink);
  font-weight: 760;
}

[data-message] blockquote {
  padding-left: 9px;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

[data-message] code {
  padding: 1px 4px;
  border-radius: 5px;
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

[data-message] pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 9px;
  border-radius: var(--radius);
  background: var(--pre-bg);
}

[data-message] pre code {
  padding: 0;
  background: transparent;
}

[data-message] a {
  min-height: 0;
  display: inline;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}

[data-dev-result-data] {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 9px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
}

[data-dev-result-data] dt,
[data-dev-result-data] dd {
  margin: 0;
}

[data-dev-result-data] dd {
  overflow-wrap: anywhere;
}

[data-dev-technical] {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--drawer-glass);
  color: var(--muted);
  backdrop-filter: blur(18px);
}

[data-dev-technical] summary {
  min-height: 30px;
  cursor: pointer;
  color: var(--ink);
  font-size: 12px;
}

[data-dev-technical] ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
}

[data-dev-technical] li {
  overflow-wrap: anywhere;
}

[data-dev-technical] p {
  margin: 3px 0 0;
}

[data-dev-technical] pre {
  max-height: 180px;
  overflow: auto;
  margin: 4px 0 0;
  white-space: pre-wrap;
}

[data-actions] {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

[data-actions] button {
  background: var(--blue);
  color: var(--accent-ink);
}

[data-agent-composer] {
  grid-area: composer;
  min-width: 0;
  display: grid;
  gap: 6px;
  align-self: end;
}

[data-dev-deploy-control] {
  width: max-content;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: var(--radius);
  background: var(--drawer-glass);
  color: var(--ink);
  font-size: 12px;
  backdrop-filter: blur(18px);
}

[data-dev-deploy-control] input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

form[data-chat-form],
form[data-dev-chat-form] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px;
  padding: 6px;
  border-radius: 20px;
  background: var(--drawer-glass-strong);
  box-shadow: var(--composer-shadow);
  backdrop-filter: blur(22px);
}

form[data-chat-form] textarea,
form[data-dev-chat-form] textarea {
  width: 100%;
  min-height: 42px;
  height: 42px;
  max-height: 160px;
  border: 0;
  border-radius: 16px;
  padding: 8px 10px;
  color: var(--ink);
  background: transparent;
  font-size: 14px;
  line-height: 1.35;
  resize: none;
}

form[data-chat-form] textarea:focus,
form[data-dev-chat-form] textarea:focus {
  outline: 2px solid var(--focus-ring);
}

[data-dev-composer-error] {
  grid-column: 1 / -1;
  margin: -1px 4px 2px;
  color: var(--warn);
  font-size: 11px;
}

[data-prompts] {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

[data-prompts]::-webkit-scrollbar {
  display: none;
}

[data-prompts] button {
  flex: 0 0 auto;
  background: var(--drawer-glass);
  backdrop-filter: blur(18px);
}

@keyframes typing-dots {
  0% {
    opacity: 0.32;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.32;
  }
}

@keyframes stream-row-in {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-stream-row] {
    animation: none;
  }
}

@media (min-width: 760px) {
  header {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  nav {
    width: 330px;
  }

  main {
    padding-top: 24px;
  }

  [data-route-list],
  [data-reference-list] {
    align-items: start;
  }

  [data-reference-list] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  [data-panel="crm"] {
    grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.1fr);
    align-items: start;
  }

  [data-timeline] {
    --slot-height: 12px;
  }

  [data-next-card] {
    min-height: 150px;
  }

  [data-chat-fab],
  [data-dev-chat-fab] {
    right: calc((100vw - min(960px, 100vw)) / 2 + 24px);
  }

  [data-chat-fab-side="left"] {
    right: auto;
    left: calc((100vw - min(960px, 100vw)) / 2 + 24px);
  }

  [data-agent-drawer] {
    right: 0;
    left: auto;
    width: min(480px, 42vw);
    border-left: 1px solid var(--desktop-drawer-border);
    box-shadow: var(--desktop-drawer-shadow);
  }

  [data-agent-drawer][data-agent-side="left"] {
    right: auto;
    left: 0;
    border-right: 1px solid var(--desktop-drawer-border);
    border-left: 0;
    box-shadow: var(--desktop-left-drawer-shadow);
  }

  [data-event-modal] {
    width: min(520px, calc(100vw - 48px));
  }
}
