.chat-image-button.attachment {
  display: block;
  min-height: 34px;
  max-width: 100%;
  margin: 4px 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: zoom-in;
  text-align: start;
}
.chat-image-button .chat-image-placeholder {
  display: block;
  padding: 5px 10px;
  border: 1px solid currentColor;
  border-radius: 6px;
  font-size: .88rem;
}
.chat-image-button img { pointer-events: none; }
.chat-image-button [hidden], .chat-image-dialog [hidden] { display: none !important; }
.chat-image-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  color: #f5f8ff;
  background: transparent;
}
.chat-image-dialog[open] { display: flex; flex-direction: column; }
.chat-image-dialog::backdrop { background: rgba(10, 15, 24, .86); }
.chat-image-stage {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.chat-image-pixels {
  position: relative;
  flex: none;
  line-height: 0;
}
.chat-image-pixels img, .chat-image-pixels canvas {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  display: block;
  object-fit: contain;
}
.chat-image-stage[data-zoomed="true"] .chat-image-pixels { cursor: grab; }
.chat-image-stage[data-zoomed="true"] .chat-image-pixels:active { cursor: grabbing; }
.chat-image-info {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 24px);
  width: max-content;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f5f8ff;
  background: #172334;
  border-radius: 8px;
}
.chat-image-toolbar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  background: #141e2d;
}
.chat-image-dialog button {
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid #73839c;
  border-radius: 6px;
  color: #f5f8ff;
  background: #243247;
  font: inherit;
  cursor: pointer;
}
.chat-image-dialog button:hover { background: #344963; }
.chat-image-dialog button:focus-visible, .chat-image-button:focus-visible {
  outline: 2px solid #7ab6ff;
  outline-offset: 3px;
}
.chat-image-dialog button:disabled { opacity: .58; cursor: default; }
.chat-image-scale { min-width: 3.1em; text-align: center; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) {
  .chat-image-dialog button { min-height: 44px; }
}

.chat-upload-panel[hidden], .chat-upload-panel [hidden], .chat-delivered-attachments[hidden] { display: none !important; }
.chat-upload-panel { display: grid; gap: .45rem; margin: .35rem 0; min-width: 0; }
.chat-upload-panel p { margin: 0; }
.chat-upload-list { display: grid; gap: .35rem; padding: 0; margin: 0; list-style: none; max-height: 15rem; overflow: auto; }
.chat-upload-item { display: grid; grid-template-columns: 2.8rem minmax(0, 1fr) auto; align-items: center; gap: .55rem; padding: .35rem .5rem; border: 1px solid var(--line, #bfcbd7); border-radius: .55rem; min-width: 0; }
.chat-upload-thumbnail, .chat-upload-kind { width: 2.8rem; height: 2.6rem; border-radius: .3rem; }
.chat-upload-thumbnail { display: block; object-fit: contain; background: rgba(128, 140, 150, .1); }
.chat-upload-kind { display: grid; place-items: center; background: rgba(128, 140, 150, .12); font-size: .7rem; text-align: center; overflow-wrap: anywhere; }
.chat-upload-information { display: grid; gap: .12rem; min-width: 0; }
.chat-upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.chat-upload-details, .chat-upload-summary, .chat-upload-notice { font-size: .8rem; overflow-wrap: anywhere; }
.chat-upload-notice, [data-upload-status="failed"] { color: var(--danger, #b32530); }
.chat-upload-progress { width: 100%; height: .5rem; }
.chat-upload-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .25rem; }
.chat-upload-action { border: 1px solid var(--line, #bfcbd7); background: transparent; color: inherit; border-radius: .4rem; font: inherit; font-size: .77rem; padding: .35rem .5rem; cursor: pointer; }
.chat-upload-action:disabled { cursor: default; opacity: .55; }
[data-upload-commit] { justify-self: start; }
.chat-delivered-attachments { display: grid; gap: .5rem; margin-top: .25rem; min-width: 0; }
.chat-delivered-attachment { display: grid; justify-items: start; gap: .2rem; min-width: 0; }
.chat-attachment-video { display: block; width: min(22rem, 100%); height: auto; max-height: 22rem; border-radius: .5rem; background: #101820; }
.chat-delivered-name, .chat-attachment-download { font-size: .8rem; overflow-wrap: anywhere; }
@media (max-width: 420px) {
  .chat-upload-item { grid-template-columns: 2.4rem minmax(0, 1fr); }
  .chat-upload-thumbnail, .chat-upload-kind { width: 2.4rem; }
  .chat-upload-actions { grid-column: 2; justify-content: flex-start; }
}

:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans Devanagari", "Segoe UI", system-ui, sans-serif;
  color: #20233a;
  background: #eef1fb;
  --accent: #3546a0;
  --accent-hover: #26367e;
  --accent-soft: #e9edfc;
  --canvas: #f6f7fc;
  --muted: #535b76;
  --border: #dadfed;
}

body[data-platform="shakti"] {
  --accent: #71365f;
  --accent-hover: #552548;
  --accent-soft: #f3e7ef;
  --canvas: #fcf7fa;
  --muted: #665063;
  --border: #eadce5;
  background: #f4eaf1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; display: grid; place-items: center; padding: 28px; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .62; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible, .timeline:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 690px);
  height: min(820px, calc(100dvh - 56px));
  min-height: 380px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: white;
  box-shadow: 0 20px 52px #242a4915;
}

.chat-header { flex: none; display: flex; gap: 12px; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.brand-mark { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 13px; background: var(--accent); color: white; font-weight: 800; font-size: 1.25rem; }
.brand-text { flex: 1; min-width: 0; }
.brand { margin: 0 0 2px; color: var(--accent); font-size: .78rem; font-weight: 800; letter-spacing: .06em; }
h1 { margin: 0; font-size: 1.16rem; line-height: 1.25; }
#language { min-height: 42px; max-width: 42%; padding: 6px 9px; border: 1px solid var(--border); border-radius: 9px; background: white; color: inherit; font-size: .9rem; }
.support-links { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 9px 22px; border-bottom: 1px solid var(--border); font-size: .88rem; }
.support-links a { color: var(--accent); text-underline-offset: .2em; }
.support-offline { max-height: 5.5em; overflow: auto; padding: 9px 22px; margin: 0; background: var(--accent-soft); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
#welcome-copy, #chat-state, #end-copy { white-space: pre-wrap; overflow-wrap: anywhere; }

.connection { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 22px; background: #fff4d9; color: #62470b; font-size: .9rem; }
.connection button, .selected-file button, .text-button { min-height: 34px; padding: 4px 8px; border: 0; border-radius: 6px; color: inherit; background: transparent; font-weight: 650; text-decoration: underline; text-underline-offset: .19em; }
.welcome { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; padding: 24px; background: var(--canvas); }
.welcome form { width: min(100%, 370px); padding: 24px 0; }
.welcome h2 { margin: 0 0 10px; line-height: 1.2; font-size: clamp(1.4rem, 5vw, 1.9rem); }
.welcome p { margin: 0 0 23px; color: var(--muted); }
.welcome label { display: block; margin-bottom: 7px; font-size: .92rem; font-weight: 650; }
.welcome input { display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: white; min-height: 44px; }
.welcome select, .welcome textarea { display: block; width: 100%; margin-bottom: 14px; padding: 10px 12px; color: inherit; border: 1px solid var(--border); border-radius: 8px; background: white; min-height: 44px; }
.welcome textarea { resize: vertical; }
#cancel-new-chat { margin-top: 8px; color: var(--accent); }
.welcome small { display: block; margin: 8px 0 19px; color: var(--muted); line-height: 1.4; }
.primary { border: 0; border-radius: 9px; padding: 10px 16px; color: white; background: var(--accent); font-weight: 700; min-height: 44px; }
.primary:hover:enabled { background: var(--accent-hover); }
.welcome .primary { width: 100%; }

.conversation { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.conversation-bar { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 46px; padding: 4px 22px; background: white; border-bottom: 1px solid var(--border); }
.conversation-bar p { margin: 0; color: var(--muted); font-size: .86rem; }
.conversation-bar button { color: var(--accent); font-size: .82rem; }
.conversation-topic { min-width: 0; overflow-wrap: anywhere; }
#chat-category { margin-top: 2px; color: var(--accent); font-weight: 650; }
.timeline-wrap { flex: 1; min-height: 0; position: relative; background: var(--canvas); }
.timeline { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 16px 22px 12px; }
.empty { margin: 30px auto; text-align: center; color: var(--muted); }
#messages { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; list-style: none; }
.message { width: fit-content; max-width: min(85%, 460px); }
.message.guest { align-self: flex-end; }
.bubble { padding: 10px 13px; border: 1px solid var(--border); border-radius: 13px 13px 13px 3px; background: white; line-height: 1.44; }
.guest .bubble { background: var(--accent-soft); border-color: transparent; border-radius: 13px 13px 3px 13px; }
.message[data-status="failed"] .bubble, .message[data-status="unconfirmed"] .bubble { border-color: #bf8a87; }
.message-text { overflow-wrap: anywhere; white-space: pre-wrap; margin: 0; }
.attachment { display: block; margin: 2px 0; }
.attachment img { display: block; max-width: 100%; width: 230px; height: auto; max-height: 220px; object-fit: contain; object-position: left; border-radius: 7px; }
.message-meta { display: flex; flex-wrap: wrap; gap: 5px 9px; align-items: center; margin: 4px 1px 0; color: var(--muted); font-size: .75rem; }
.guest .message-meta { justify-content: flex-end; }
.message-meta button { padding: 3px 7px; min-height: 30px; border: 1px solid var(--border); border-radius: 6px; color: var(--accent); background: white; }
.unread { position: absolute; z-index: 1; left: 50%; bottom: 10px; transform: translateX(-50%); max-width: 90%; white-space: nowrap; padding: 8px 14px; border: 0; border-radius: 22px; color: white; background: var(--accent); min-height: 40px; box-shadow: 0 3px 12px #242a4930; }

#composer { flex: none; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.composer-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.composer-row:has(.attach[hidden]) { grid-template-columns: minmax(0, 1fr) auto; }
.composer-row textarea { width: 100%; resize: none; min-height: 44px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 1rem; line-height: 1.35; }
.composer-shortcut { color: var(--muted); font-size: .77rem; margin: 5px 0 0; text-align: end; }
.attach { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 9px; color: var(--accent); font-size: .85rem; font-weight: 700; cursor: pointer; }
#image-input:focus-visible + .attach { outline: 3px solid var(--accent); outline-offset: 3px; }
.selected-file { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); font-size: .85rem; }
.selected-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error, .welcome .error { color: #9f2833; font-size: .87rem; margin: 0 0 8px; }
.closed-note { flex: none; padding: 8px 16px; border-top: 1px solid var(--border); color: var(--muted); }
.closed-note p { margin: 0 0 2px; }
.closed-note button { color: var(--accent); }
.closed-note:has(.guest-rating:not([hidden])) { max-height: 55dvh; overflow: auto; }
.guest-rating { margin: 9px 0; padding: 11px; border: 1px solid var(--border); border-radius: 9px; color: #20233a; background: white; }
.guest-rating h2 { margin: 0 0 8px; font-size: 1rem; }
.guest-rating fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.rating-choices { display: flex; flex-wrap: wrap; gap: 7px; }
.rating-choices label { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; }
.rating-choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.rating-field { display: grid; gap: 4px; margin-top: 8px; }
.rating-field :is(textarea,select) { width: 100%; padding: 5px 8px; min-width: 0; border: 1px solid var(--border); border-radius: 7px; background: white; }
.rating-field textarea { resize: vertical; }
.rating-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rating-actions .primary { color: white; }
.rating-receipt-comment { white-space: pre-wrap; overflow-wrap: anywhere; }
.guest-rating .rating-status { margin-top: 7px; }
.guest-rating .rating-status[data-error="true"] { color: #9f2833; }
.visually-hidden { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; padding: 0; overflow: hidden; white-space: nowrap; }

@media (max-width: 600px) {
  body { padding: 0; }
  .chat-shell { width: 100%; height: 100dvh; min-height: 300px; border: 0; border-radius: 0; }
  .chat-header { padding: 12px 14px; }
  .timeline, .conversation-bar { padding-left: 14px; padding-right: 14px; }
  .connection { padding-left: 14px; padding-right: 14px; }
  #composer { padding-left: 9px; padding-right: 9px; }
}
