:root {
  color-scheme: light;
  --ink: #142442;
  --muted: #53657f;
  --line: #d9e2ef;
  --surface: #fff;
  --backdrop: #edf3fa;
  --primary: #2457c3;
  --primary-hover: #19459f;
  --pale: #eef4ff;
  --navy: #13274b;
  --good: #176650;
  --danger: #9b283d;
  --depth: 0 12px 28px #172b5111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--backdrop);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; min-height: 100vh; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.16; }
h1 { font-size: clamp(1.85rem, 4.5vw, 3.05rem); letter-spacing: -0.035em; }
h2 { font-size: 1.42rem; letter-spacing: -0.02em; }
h3 { font-size: 1.1rem; }
p { color: var(--muted); }
a { color: var(--primary); }
a, button, [role="button"], input, select, textarea { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #417cf5;
  outline-offset: 3px;
}
button, input, textarea, select { font: inherit; }
button, .button, .file-trigger { cursor: pointer; }
button:disabled, select:disabled, input:disabled, textarea:disabled { cursor: default; opacity: .60; }
input:not([type="file"]), textarea, select {
  display: block;
  width: 100%;
  min-height: 2.8rem;
  margin: 0;
  padding: .52rem .76rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #b9c9df;
  border-radius: .54rem;
}
input::placeholder, textarea::placeholder { color: #697a93; }
textarea { resize: vertical; }
select {
  appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
label { display: grid; gap: .34rem; font-size: .94rem; font-weight: 600; }
label small { font-size: .83rem; color: var(--muted); font-weight: 400; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: start;
  gap: .35rem;
  min-height: 2.8rem;
  padding: .56rem 1rem;
  border: 1px solid transparent;
  border-radius: .58rem;
  color: inherit;
  font-size: .94rem;
  font-weight: 650;
  line-height: 1.28;
  text-decoration: none;
  text-align: center;
}
.button.compact { min-height: 2.3rem; padding: .40rem .73rem; font-size: .88rem; }
.button.primary { color: #fff; background: var(--primary); }
.button.primary:hover:not(:disabled) { background: var(--primary-hover); }
.button.secondary { color: #194998; border-color: #bfcee5; background: var(--surface); }
.button.secondary:hover:not(:disabled) { background: var(--pale); border-color: #94ace0; }
.button.light { background: #fff; color: #193a77; }
.button.light:hover { background: #e5efff; }
.button.danger { color: var(--danger); border-color: #e6c1c9; background: #fff; }
.button.danger:hover { background: #fff1f3; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem max(1rem, calc((100vw - 1170px) / 2));
  gap: .8rem;
  min-height: 4.4rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; gap: .6rem; align-items: center; color: var(--ink); font-weight: 700; text-decoration: none; }
.brand-mark, .chat-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: .66rem;
  font-size: 1.22rem;
  font-weight: 750;
  background: var(--primary);
  color: #fff;
}
.home-content { max-width: 1170px; padding: 0 1rem 3rem; margin: 2rem auto 0; }
.hero {
  display: grid;
  align-items: end;
  min-height: 20rem;
  padding: clamp(1.4rem, 6vw, 4.25rem);
  color: #fff;
  background: radial-gradient(ellipse at 105% 95%, #427be7 0, transparent 62%), linear-gradient(115deg, #14264b, #1d4b9d);
  border-radius: 1rem;
  box-shadow: var(--depth);
}
.hero h1 { max-width: 32rem; }
.hero p { max-width: 32rem; margin: .9rem 0 1.38rem; color: #e4edfc; font-size: 1.06rem; }
.demo-section { margin-top: 2rem; }
.demo-section > p { margin: .42rem 0 1rem; }
.demo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.demo-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: .80rem; box-shadow: var(--depth); }
.demo-card { display: grid; gap: .63rem; justify-items: start; padding: 1.2rem; }
.auth-panel { max-width: min(27rem, calc(100% - 2rem)); margin: clamp(2rem, 12vh, 7rem) auto; padding: 1.55rem; }
.auth-panel h1 { font-size: 1.75rem; }
.auth-panel p { margin: .6rem 0 1.25rem; }
.form-stack { display: grid; gap: .9rem; justify-items: start; }
.form-stack label { width: 100%; }
.workspace {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  align-items: start;
  gap: clamp(1rem, 3vw, 2rem);
  max-width: 1170px;
  margin: 1.7rem auto 0;
  padding: 0 1rem 3rem;
}
.property-sidebar { min-width: 0; }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; gap: .45rem; margin-bottom: .7rem; }
.sidebar-heading h2 { font-size: 1.2rem; }
.property-list { display: grid; gap: .43rem; }
.property-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: .55rem .75rem;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: .55rem;
}
.property-choice:hover { background: var(--surface); }
.property-choice[aria-current="true"] { background: #deebff; border-color: #bdcfee; }
.property-choice strong { overflow-wrap: anywhere; }
.property-choice small { color: var(--muted); }
.property-main h1 { font-size: clamp(1.65rem, 4vw, 2.42rem); overflow-wrap: anywhere; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading p { margin-top: .32rem; }
.section-tabs { display: flex; flex-wrap: wrap; gap: .34rem; border-bottom: 1px solid #c9d6e9; margin-bottom: .85rem; }
.section-tabs button {
  padding: .60rem .65rem;
  min-height: 2.6rem;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  font-size: .93rem;
  color: var(--muted);
}
.section-tabs button:hover { color: var(--primary); }
.section-tabs button[aria-pressed="true"] { color: #214ba2; border-bottom-color: var(--primary); font-weight: 650; }
.editor { padding: clamp(.9rem, 2.5vw, 1.45rem); min-width: 0; }
.editor > :first-child { margin-top: 0; }
.editor h2 + p { margin-top: .35rem; }
.editor h2:not(:first-child) { margin-top: 1.2rem; }
.editor h3 { margin-top: .65rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .78rem 1rem; margin: .85rem 0 .2rem; align-items: start; }
.form-grid > *, .field-wide { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.surface-section { display: grid; gap: .62rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.surface-section .form-grid { margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .48rem; }
.helper { color: var(--muted); font-size: .88rem; }
.callout { padding: .68rem .82rem; background: var(--pale); color: #35527e; border: 1px solid #cbdbf1; border-radius: .55rem; font-size: .91rem; }
.save-bar { display: flex; align-items: center; gap: .75rem; margin-top: .75rem; }
.save-bar span { color: var(--muted); font-size: .89rem; }
.toast:empty { display: none; }
.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 2;
  max-width: min(calc(100vw - 2rem), 27rem);
  padding: .66rem .9rem;
  color: #fff;
  background: var(--navy);
  border-radius: .55rem;
  box-shadow: var(--depth);
}
.toast[data-level="error"] { background: #84283b; }
.entry-list { display: grid; gap: .72rem; }
.entry-card { padding: .75rem; border: 1px solid var(--line); border-radius: .58rem; min-width: 0; }
.entry-card > summary { cursor: pointer; color: var(--ink); font-weight: 650; overflow-wrap: anywhere; }
.entry-card > summary::marker { color: var(--muted); }
.entry-card .row-actions { margin-top: .65rem; }
.entry-card > p { white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-card .meta { font-size: .84rem; margin: .22rem 0 .35rem; }
.handoff-reply { margin-top: .65rem; }
.handoff-reply summary { cursor: pointer; color: var(--primary); font-weight: 650; }
.handoff-reply form { margin-top: .54rem; }
.status-tag { display: inline-block; padding: .15rem .46rem; border-radius: .38rem; font-size: .79rem; font-weight: 650; line-height: 1.4; color: #486286; background: #edf3fc; }
.status-tag[data-status="published"], .status-tag[data-status="sent"] { color: var(--good); background: #e7f8f1; }
.status-tag[data-status="failed"] { color: var(--danger); background: #fff0f2; }
.inline-files input[type="file"] { width: 100%; min-width: 0; font-size: .9rem; }
.inline-files input[type="file"]::file-selector-button { border: 1px solid var(--line); color: var(--ink); background: var(--pale); border-radius: .34rem; padding: .35rem .55rem; }

.chat-page { display: grid; place-items: center; padding: clamp(.7rem, 4vh, 2.1rem) 1rem; height: 100dvh; }
.chat-shell {
  width: min(100%, 44rem);
  height: min(100%, 50rem);
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid #cbd7e8;
  border-radius: .95rem;
  background: var(--surface);
  box-shadow: 0 17px 55px #13274b1c;
  overflow: hidden;
}
.chat-page.embedded { padding: 0; }
.chat-page.embedded .chat-shell { width: 100%; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
.chat-header { display: flex; align-items: center; gap: .75rem; padding: .91rem 1rem; color: #fff; background: var(--navy); }
.chat-header h1 { font-size: clamp(1.15rem, 3vw, 1.42rem); letter-spacing: -.015em; overflow-wrap: anywhere; }
.chat-header p { margin-top: .1rem; color: #c5d9f7; font-size: .84rem; }
.chat-header .header-button { margin-left: auto; align-self: center; color: #fff; background: #253f67; border-color: #5c78a1; }
.chat-header .header-button:hover:not(:disabled) { background: #385583; }
.chat-header .chat-mark { width: 2.5rem; height: 2.5rem; }
.chat-feed { display: flex; flex-direction: column; gap: .65rem; padding: 1rem; overflow-y: auto; background: #f3f7fc; }
.message { align-self: flex-start; width: fit-content; max-width: min(91%, 35rem); padding: .65rem .8rem .68rem; border: 1px solid #e0e9f4; border-radius: .80rem .80rem .80rem .23rem; background: #fff; overflow-wrap: anywhere; }
.message[data-role="user"] { align-self: flex-end; border: 0; border-radius: .80rem .80rem .23rem .80rem; background: #dce9ff; }
.message[data-role="operator"] { border-color: #a9d8c8; }
.message p { color: var(--ink); white-space: pre-wrap; }
.message-label { color: var(--muted); font-size: .79rem; font-weight: 650; margin-bottom: .12rem; }
.message .offer-list { display: grid; gap: .40rem; margin-top: .55rem; }
.offer { display: grid; gap: .23rem; padding: .55rem .60rem; border-radius: .44rem; border: 1px solid #d4e0f1; background: #f8fbff; }
.offer strong { line-height: 1.25; }
.offer p { font-size: .91rem; }
.offer .offer-note { color: var(--muted); font-size: .83rem; }
.offer .button { justify-self: start; margin-top: .20rem; }
.chat-composer { padding: .72rem 1rem .83rem; border-top: 1px solid var(--line); background: var(--surface); }
.composer-row { display: flex; align-items: end; gap: .65rem; }
.composer-row textarea { resize: vertical; flex: 1 1 auto; max-height: 9rem; min-width: 0; }
.composer-row .button { align-self: end; min-height: 2.8rem; }
.composer-status { margin-bottom: .44rem; font-size: .87rem; }
.composer-status[data-level="error"] { color: var(--danger); }
.suggestions, .voice-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .44rem; }
.suggestions { margin-bottom: .57rem; }
.suggestions button {
  color: #28549c;
  background: var(--pale);
  border: 1px solid #d4e1f5;
  border-radius: .42rem;
  font-size: .88rem;
  padding: .30rem .55rem;
}
.suggestions button:hover { background: #ddeaff; }
.voice-tools { margin-top: .51rem; }
.voice-tools .button[aria-pressed="true"] { color: var(--danger); border-color: #e6c1c9; }
.file-trigger { display: inline-flex; align-items: center; min-height: 2.25rem; padding: .20rem .26rem; font-weight: 600; font-size: .87rem; color: var(--primary); }
.file-trigger:hover { text-decoration: underline; }
.voice-tools:has(input:focus-visible) .file-trigger { outline: 3px solid #417cf5; outline-offset: 3px; }

@media (max-width: 740px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-top: 1rem; }
  .property-list { display: flex; overflow: auto; padding-bottom: .22rem; }
  .property-choice { min-width: 9.5rem; max-width: 14rem; flex: 0 0 auto; }
  .sidebar-heading { margin-bottom: .35rem; }
}
@media (max-width: 510px) {
  .home-content { margin-top: 1rem; }
  .demo-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .section-tabs button { padding: .45rem .35rem; font-size: .87rem; }
  .section-heading { align-items: flex-start; gap: .5rem; }
  .section-heading .button { min-height: 2.35rem; padding: .45rem .55rem; font-size: .86rem; }
  .chat-page { padding: 0; }
  .chat-shell { width: 100%; height: 100%; border: 0; border-radius: 0; }
  .chat-header, .chat-feed, .chat-composer { padding-inline: .68rem; }
  .chat-header { gap: .50rem; }
  .chat-header .chat-mark { display: none; }
  .chat-header .header-button { max-width: 8.8rem; }
  .composer-row { gap: .4rem; }
  .composer-row .button { padding-inline: .60rem; }
}
