:root {
  color-scheme: light;
  --ink: #152c40;
  --muted: #536979;
  --line: #d7e3eb;
  --page: #f1f6fa;
  --blue: #075b95;
  --dark-blue: #073b65;
  --pale-blue: #e8f4fb;
  --white: #fff;
  --red: #952c27;
  --green: #116451;
  --shadow: 0 13px 37px #123b5c12;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 100%;
  line-height: 1.5;
  background: var(--page);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -.035em; }
h2 { font-size: 1.125rem; line-height: 1.3; }
a { color: var(--blue); }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: default; opacity: .62; }
:focus-visible { outline: 3px solid #1983c8; outline-offset: 3px; }

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

.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.site-bar {
  max-width: 88rem;
  min-height: 4.5rem;
  margin: 0 auto;
  padding: .75rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.brand { display: inline-flex; gap: .625rem; align-items: center; text-decoration: none; color: var(--ink); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.625rem;
  height: 2.625rem;
  border-radius: .75rem;
  background: var(--dark-blue);
  color: white;
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -.07em;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.125rem; line-height: 1.25; letter-spacing: -.025em; }
.brand small, .header-link, .staff-account { font-size: .875rem; }
.brand small { color: var(--muted); }
.header-link { font-weight: 650; text-underline-offset: .2em; }
.header-actions, .staff-account { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }
.header-actions { justify-content: end; }
.staff-account { border-left: 1px solid var(--line); padding-left: .75rem; font-weight: 650; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); }
.primary, .secondary {
  padding: .64rem 1rem;
  border: 1px solid transparent;
  border-radius: .55rem;
  font-weight: 680;
  line-height: 1.25;
  min-height: 2.75rem;
}
.primary { background: var(--blue); color: var(--white); }
.primary:hover:not(:disabled) { background: var(--dark-blue); }
.secondary { background: var(--white); color: var(--dark-blue); border-color: #b8cddb; }
.secondary:hover:not(:disabled) { background: var(--pale-blue); }
.small { font-size: .875rem; padding: .45rem .75rem; min-height: 2.5rem; }

label, legend { font-weight: 650; font-size: .9375rem; }
input:not([type='checkbox']), textarea, select {
  width: 100%;
  min-width: 0;
  border: 1px solid #aebfcd;
  border-radius: .5rem;
  background-color: var(--white);
  color: var(--ink);
  padding: .625rem .75rem;
}
input::placeholder, textarea::placeholder { color: #5f7281; }
textarea { resize: vertical; }
select {
  appearance: none;
  padding-right: 1.9rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right .89rem center, right .59rem center;
  background-size: .3rem .3rem;
  background-repeat: no-repeat;
}
.notice { font-size: .9375rem; color: var(--green); padding: .55rem .75rem; border-radius: .5rem; background: #e8f6f1; }
.notice.error { color: var(--red); background: #fdf0ee; }

.visitor-page { background: linear-gradient(120deg, #e5f1f7, #f4f8fb 58%, #ebf3f9); }
.visitor-layout {
  width: min(100%, 75rem);
  margin: 0 auto;
  padding: clamp(2.5rem, 8vh, 6rem) clamp(1rem, 5vw, 3rem);
  display: grid;
  grid-template-columns: 1fr minmax(24rem, 1.02fr);
  gap: clamp(2rem, 8vw, 6.25rem);
  align-items: start;
}
.visitor-intro { padding-top: clamp(1rem, 6vw, 4.375rem); }
.visitor-intro h1 { font-size: clamp(2.5rem, 5.7vw, 4.6rem); line-height: 1.02; letter-spacing: -.065em; color: var(--dark-blue); }
.visitor-intro p { margin-top: 1.1rem; max-width: 25rem; color: var(--muted); font-size: clamp(1rem, 2.2vw, 1.2rem); }
.chat-card { overflow: hidden; }
.chat-card-header {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(110deg, #073b65, #105f91);
  color: var(--white);
}
.chat-card-header h2 { font-size: 1.25rem; }
.chat-card-header p { color: #e6f1fa; font-size: .875rem; margin-top: .12rem; }
.chat-symbol {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 2.625rem;
  height: 2.125rem;
  border: 2px solid currentColor;
  border-radius: .8rem;
}
.chat-symbol::before {
  content: '';
  position: absolute;
  left: .42rem;
  bottom: -.29rem;
  width: .48rem;
  height: .48rem;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: skewY(-35deg);
}
.chat-symbol::after {
  content: '';
  position: absolute;
  top: .84rem;
  left: .57rem;
  width: .2rem;
  height: .2rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: .46rem 0 0 currentColor, .92rem 0 0 currentColor;
}
.start-form, .auth-card form, .form-stack { display: grid; gap: .65rem; }
.start-form, .auth-card { padding: 1.5rem; }
.start-form label:not(:first-child), .auth-card form label:not(:first-child) { margin-top: .3rem; }
.start-form .primary, .auth-card .primary { margin-top: .45rem; }
.chat-card > .notice { margin: .65rem 1rem 1rem; }
.visitor-thread .messages { min-height: 13.5rem; max-height: min(48vh, 25rem); }
.closed-notice { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .9rem 1rem; border-top: 1px solid var(--line); }
.closed-notice p { color: var(--muted); font-size: .9375rem; }

.auth-layout { padding: clamp(2rem, 8vh, 5rem) 1rem; }
.auth-card { width: min(100%, 27rem); margin: auto; }
.auth-card > p { margin-top: .7rem; }
.auth-card > p:not(.notice), .settings-card > p { color: var(--muted); }
.auth-card form { margin-top: 1.4rem; }
.office { width: min(100%, 88rem); padding: 1.25rem clamp(1rem, 4vw, 2.5rem) 2rem; margin: 0 auto; }
.office-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.125rem; }
.agent-presence { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .85rem; }
.presence-status { font-size: .875rem; font-weight: 650; color: var(--muted); }
.presence-status[data-ready='true'] { color: var(--green); }
.office-nav { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem; }
.office-nav button, .queue-filters button {
  border: 1px solid transparent;
  border-radius: .5rem;
  padding: .55rem .75rem;
  background: transparent;
  color: var(--muted);
  font-size: .9375rem;
  font-weight: 650;
}
.office-nav button:hover, .queue-filters button:hover { color: var(--dark-blue); background: var(--pale-blue); }
.office-nav button[aria-current='page'], .queue-filters button[aria-pressed='true'] { background: #dcecf8; color: var(--dark-blue); }
.office > .notice { margin-bottom: .75rem; }
.desk-grid {
  display: grid;
  grid-template-columns: minmax(17rem, 1fr) minmax(0, 2.12fr);
  gap: 1rem;
  height: clamp(32rem, calc(100dvh - 10.75rem), 54rem);
}
.queue, .desk-thread { min-height: 0; overflow: hidden; }
.queue { display: flex; flex-direction: column; }
.queue-head { padding: 1rem 1rem .65rem; border-bottom: 1px solid var(--line); }
.queue-head h1 { font-size: 1.375rem; margin: .1rem 0 .7rem; }
.queue-filters { display: flex; flex-wrap: wrap; gap: .2rem; }
.queue-filters button { padding: .345rem .55rem; font-size: .875rem; }
.queue-filters span { margin-left: .2rem; font-variant-numeric: tabular-nums; }
.queue-list { overflow: auto; }
.queue-empty { color: var(--muted); padding: 1.15rem 1rem; }
.queue-item {
  display: grid;
  gap: .18rem;
  width: 100%;
  padding: .8rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: .22rem solid transparent;
  background: var(--white);
  color: var(--ink);
  text-align: left;
}
.queue-item:hover, .queue-item[aria-current='true'] { background: #edf6fc; }
.queue-item[aria-current='true'] { border-left-color: var(--blue); }
.queue-item:focus-visible { outline-offset: -3px; }
.queue-item-top { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.queue-item strong, .queue-preview { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.queue-preview { display: block; font-size: .875rem; color: var(--muted); }
.queue-item time { flex: 0 0 auto; font-size: .8125rem; color: var(--muted); }
.queue-meta { font-size: .8125rem; color: var(--blue); overflow-wrap: anywhere; }

.thread-empty { display: grid; place-content: center; justify-items: center; gap: .8rem; height: 100%; color: var(--muted); padding: 2rem; text-align: center; }
.thread-empty .chat-symbol { color: var(--blue); }
.thread-view { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.thread-header {
  padding: 1rem 1.125rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .625rem;
  border-bottom: 1px solid var(--line);
}
.thread-header h2 { overflow-wrap: anywhere; }
.thread-header p { font-size: .875rem; color: var(--muted); margin-top: .16rem; }
.thread-tools { display: flex; align-items: center; gap: .5rem; }
.thread-tools select { font-size: .875rem; min-height: 2.5rem; width: auto; max-width: 12rem; }
.assignment-history { flex-basis: 100%; font-size: .875rem; color: var(--muted); }
.assignment-history summary { width: fit-content; cursor: pointer; font-weight: 650; color: var(--blue); }
.assignment-history ol { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 6.5rem; overflow: auto; }
.assignment-history li { display: flex; flex-wrap: wrap; gap: .45rem .75rem; padding: .2rem 0; }
.assignment-history time { color: var(--muted); }

.messages {
  padding: 1.125rem;
  margin: 0;
  list-style: none;
  background: #f5f9fc;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  overflow: auto;
}
.message {
  align-self: flex-start;
  max-width: min(88%, 38rem);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: .75rem .75rem .75rem .2rem;
  padding: .55rem .75rem;
  overflow-wrap: anywhere;
}
.message.own { align-self: flex-end; background: #deedf8; border-color: #c9e0f2; border-radius: .75rem .75rem .2rem .75rem; }
.message.auto { background: #e6f3ef; border-color: #cce5dc; }
.message-info { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .2rem .55rem; margin-bottom: .15rem; }
.message-info strong { font-size: .875rem; }
.message-info time { font-size: .8125rem; color: var(--muted); }
.message p { white-space: pre-wrap; }
.composer { display: flex; align-items: end; gap: .65rem; padding: .85rem 1rem; border-top: 1px solid var(--line); }
.composer textarea { min-height: 3.375rem; max-height: 10rem; }

.settings-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; gap: 1rem; }
.settings-card { padding: 1.25rem; }
.settings-card h1 + p { margin-top: .6rem; }
.settings-card .primary, .settings-card .secondary:not(.small) { justify-self: start; }
.agent-list { list-style: none; padding: 0; margin: .9rem 0 0; }
.agent-row { border-top: 1px solid var(--line); display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .85rem; padding: .7rem 0; }
.agent-row strong, .agent-row small { display: block; overflow-wrap: anywhere; }
.agent-row small { font-size: .875rem; color: var(--muted); }
.agent-info { flex: 1 1 8rem; }
.routing-form { margin-top: 1rem; padding: .85rem; border-radius: .65rem; background: var(--pale-blue); }
.routing-form p { color: var(--muted); font-size: .875rem; margin: .35rem 0 .65rem; }
.capacity-form { display: flex; align-items: end; gap: .35rem; }
.capacity-form input { width: 4.4rem; display: block; padding: .4rem .5rem; }
.capacity-form label { font-size: .875rem; }
.rules-layout { max-width: 60rem; }
.rules-layout form { display: grid; gap: 1rem; margin-top: 1rem; }
.rules-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; }
.check { display: inline-flex; align-items: center; gap: .37rem; width: fit-content; }
.check input { margin: 0; width: 1rem; height: 1rem; accent-color: var(--blue); }
.days { border: 1px solid var(--line); border-radius: .5rem; padding: .65rem; display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin: .25rem 0; }
.days legend { padding: 0 .3rem; }
.times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.times input, .keyword-row input, .keyword-row textarea { display: block; margin-top: .25rem; }
.keywords { display: grid; gap: .65rem; }
.keyword-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: .75rem; align-items: end; border-top: 1px solid var(--line); padding-top: .75rem; }
.password-dialog { padding: 1.4rem; width: min(calc(100% - 2rem), 28rem); color: var(--ink); }
.password-dialog::backdrop { background: #09264185; }
.password-dialog > p { margin-top: .6rem; }
.password-dialog dl { margin: 1rem 0; }
.password-dialog dt { font-size: .875rem; color: var(--muted); }
.password-dialog dd { margin: 0 0 .5rem; overflow-wrap: anywhere; font-weight: 650; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .85rem; }

@media (max-width: 51rem) {
  .visitor-layout { grid-template-columns: 1fr; gap: 1.5rem; max-width: 37rem; padding-top: 1.9rem; }
  .visitor-intro { padding-top: 0; }
  .desktop-break { display: none; }
  .desk-grid, .settings-layout { grid-template-columns: 1fr; height: auto; }
  .queue-list { max-height: 17rem; }
  .desk-thread { height: min(39rem, 78dvh); min-height: 23rem; }
}

@media (max-width: 33rem) {
  .site-bar { min-height: 4rem; }
  .brand-mark { width: 2.3rem; height: 2.3rem; }
  .header-actions, .staff-account { gap: .5rem; }
  .staff-account { border: 0; padding-left: 0; }
  #account-name { display: none; }
  .start-form, .chat-card-header, .settings-card { padding: 1rem; }
  .keyword-row { grid-template-columns: 1fr; }
  .keyword-row button { justify-self: start; }
  .closed-notice { flex-wrap: wrap; }
}
