:root {
  color-scheme: light;
  font: 14px/1.5 "Segoe UI", system-ui, sans-serif;
  --ink:#202638; --muted:#58647b; --line:#e0e4ee; --paper:#fff; --background:#f3f5fa;
  --accent:#4a36bb; --accent-deep:#3b269e; --tint:#efeafd; --rail:#262045;
  color:var(--ink);
}
* { box-sizing:border-box }
body { margin:0; background:var(--background) }
[hidden] { display:none !important }
button,input,textarea { font:inherit }
button { cursor:pointer }
button:disabled { cursor:default; opacity:.48 }
button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible { outline:2px solid #7659e6; outline-offset:2px }
a { color:var(--accent-deep); text-underline-offset:3px }
small { color:var(--muted) }
h1,h2,p { margin:0 }
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%) }
.primary,.secondary { border:1px solid transparent; border-radius:9px; padding:8px 12px; white-space:nowrap; font-weight:650 }
.primary { color:white; background:var(--accent); border-color:var(--accent) }
.primary:hover:enabled { background:var(--accent-deep) }
.secondary { color:var(--ink); background:var(--paper); border-color:var(--line) }
.secondary:hover:enabled { background:var(--tint); border-color:#c9bbf4 }
.inbox-app {
  display:grid;
  grid-template-columns:70px minmax(0,1fr);
  grid-template-rows:64px minmax(0,1fr);
  height:100dvh;
  overflow:hidden;
}
.channel-rail { grid-row:1/-1; display:flex; flex-direction:column; align-items:center; gap:13px; padding:14px 0; background:var(--rail); color:white }
.rail-separator { width:32px; border-top:1px solid #ffffff25 }
.channel-current { position:relative; display:grid; place-items:center; width:43px; height:43px; border-radius:12px; color:#382368; background:#e0d5ff; font-weight:850; letter-spacing:-.025em }
.channel-current b { position:absolute; right:-5px; top:-5px; background:#ffdfa3; color:#462955; border:2px solid var(--rail); min-width:20px; text-align:center; border-radius:10px; padding:0 3px; font-size:10px }
.rail-settings { margin-top:auto; border:1px solid #ffffff32; border-radius:10px; width:40px; height:40px; color:#f3eafa; background:#ffffff08; font-size:19px }
.rail-settings:hover { background:#ffffff20 }
.inbox-top { display:flex; align-items:center; justify-content:space-between; padding:0 24px; border-bottom:1px solid var(--line); background:var(--paper); gap:12px; grid-column:2 }
.product-title,.top-actions,.room-actions { display:flex; align-items:center; gap:12px; min-width:0 }
.product-title strong { color:#3b2c68; font-size:13px; letter-spacing:.13em; font-weight:850 }
.product-title span { border-left:1px solid var(--line); padding-left:12px; font-size:15px; font-weight:700 }
.account-button { display:flex; align-items:center; gap:7px; max-width:185px; padding:8px 10px; border:1px solid var(--line); border-radius:9px; background:#f9f9fd; color:var(--ink) }
.account-button span { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-weight:650 }
.account-button i { flex:0 0 7px; height:7px; background:#9c7181; border-radius:50% }
.account-button[data-connected=true] i { background:#238968; box-shadow:0 0 0 3px #cef1e3 }
#chat-sync-time { white-space:nowrap; font-variant-numeric:tabular-nums }
.chat-workspace { display:grid; grid-template-columns:minmax(295px,330px) minmax(0,1fr); grid-column:2; min-height:0; min-width:0 }
.chat-inbox { display:flex; flex-direction:column; min-width:0; min-height:0; border-right:1px solid var(--line); background:#fcfcff }
.chat-inbox-head { padding:18px 14px 11px; border-bottom:1px solid var(--line) }
.chat-inbox-title { display:flex; align-items:center; justify-content:space-between; gap:6px; margin:0 2px 13px }
.chat-inbox-title h1 { font-size:23px; letter-spacing:-.04em; line-height:1.25 }
.chat-search { position:relative; display:block }
.chat-search span { position:absolute; left:13px; top:12px; width:12px; height:12px; border:1.6px solid #747e93; border-radius:50%; pointer-events:none }
.chat-search span::after { content:""; position:absolute; width:6px; height:1.6px; transform:rotate(44deg); background:#747e93; top:9px; left:8px }
.chat-search input { width:100%; height:38px; border:1px solid var(--line); border-radius:9px; background:#f6f6fd; padding:0 10px 0 34px; color:var(--ink) }
.chat-switch { display:flex; gap:4px; margin-top:10px }
.chat-switch button { border:0; border-radius:7px; color:var(--muted); background:transparent; padding:6px; white-space:nowrap; font-size:11.5px; font-weight:700 }
.chat-switch button[aria-pressed=true] { background:var(--tint); color:var(--accent-deep) }
.chat-switch button:hover { color:var(--accent-deep) }
.chat-inbox-list { min-height:0; overflow:auto; padding:5px 8px 12px; scrollbar-width:thin }
.chat-contact { width:100%; display:grid; grid-template-columns:38px minmax(0,1fr) auto; gap:9px; align-items:center; border:1px solid transparent; border-radius:10px; padding:9px 7px; margin-bottom:2px; text-align:left; background:transparent; color:var(--ink) }
.chat-contact:hover { background:#f2f1fa }
.chat-contact[aria-pressed=true] { border-color:#ded3fa; background:#eee8fb; box-shadow:inset 3px 0 #7855d7 }
.chat-contact-copy,.chat-contact-meta { display:grid; min-width:0; gap:2px }
.chat-contact-copy strong,.chat-preview { white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
.chat-preview { font-size:12px; color:var(--muted) }
.chat-contact-meta { justify-items:end; align-self:start; font-size:12px; white-space:nowrap }
.chat-unread-dot { width:7px; height:7px; border-radius:50%; background:var(--accent) }
.chat-pinned-mark { color:var(--accent-deep); font-size:8px }
.chat-list-state { color:var(--muted); padding:18px }
.chat-avatar { display:grid; flex:0 0 auto; place-items:center; width:38px; height:38px; border-radius:12px; color:#43317c; background:#e9defc; position:relative; overflow:hidden; font-weight:800 }
.chat-avatar[data-tint="1"] { color:#865024; background:#fae9d8 }
.chat-avatar[data-tint="2"] { color:#205c59; background:#dcefee }
.chat-avatar[data-tint="3"] { color:#42598a; background:#e0ebfc }
.chat-avatar img { position:absolute; width:100%; height:100%; object-fit:cover }
.chat-room { position:relative; display:grid; grid-template: auto minmax(0,1fr) auto / minmax(0,1fr); min-height:0; min-width:0; isolation:isolate }
.chat-room-head { grid-area:1/1; display:flex; align-items:center; gap:10px; padding:12px 20px; min-width:0; background:var(--paper); border-bottom:1px solid var(--line) }
.chat-peer { display:flex; align-items:center; gap:10px; min-width:0; margin-right:auto }
.chat-peer div,.customer-card div { display:grid; min-width:0 }
.chat-peer strong,.customer-card strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
#chat-back { display:none }
#chat-pin[aria-pressed=true],#chat-context-toggle[aria-expanded=true] { color:var(--accent-deep); background:var(--tint); border-color:#dccff7 }
.room-actions { gap:6px }
.chat-scroll { grid-area:2/1; min-height:0; overflow:auto; padding:16px clamp(16px,4vw,54px); background:#f5f6fc; scrollbar-width:thin }
#chat-older { display:block; margin:0 auto 14px }
.chat-timeline { width:min(100%,900px); margin:0 auto; display:grid; gap:8px }
.chat-date { justify-self:center; border:1px solid var(--line); background:#fff; color:var(--muted); padding:3px 10px; border-radius:20px; margin:5px 0; font-size:11px }
.chat-message { display:flex; min-width:0 }
.chat-message.own { justify-content:flex-end }
.chat-message.system { justify-content:center }
.chat-bubble { max-width:min(82%,600px); min-width:0; border:1px solid var(--line); background:white; padding:8px 11px; border-radius:4px 13px 13px; box-shadow:0 2px 5px #2f2a5210 }
.own .chat-bubble { background:#eae3fb; border-color:#dbcef4; border-radius:13px 4px 13px 13px }
.system .chat-bubble { color:#535870; background:#edf0f7; box-shadow:none; border-radius:10px; font-size:12px }
.chat-author-name { display:block; margin-bottom:3px; font-size:11px; font-weight:650; overflow-wrap:anywhere }
.chat-text { white-space:pre-wrap; overflow-wrap:anywhere }
.chat-message-time { display:block; text-align:right; font-size:10px; margin-top:3px; font-variant-numeric:tabular-nums }
.chat-image img { display:block; width:auto; height:auto; max-width:min(100%,360px); max-height:280px; border-radius:8px; object-fit:contain }
.chat-order-links { display:flex; flex-wrap:wrap; gap:6px; margin-top:4px }
.chat-composer { grid-area:3/1; display:grid; gap:7px; min-width:0; padding:12px clamp(12px,3vw,30px); border-top:1px solid var(--line); background:white }
.chat-form { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:end; gap:8px }
.chat-form:has(.chat-attach[hidden]) { grid-template-columns:minmax(0,1fr) auto }
.chat-form textarea { border:1px solid var(--line); border-radius:11px; background:#fafafe; color:var(--ink); display:block; min-height:49px; max-height:180px; min-width:0; resize:vertical; padding:8px 11px }
.chat-attach { display:grid; place-items:center; position:relative; width:36px; height:36px; overflow:hidden; border:1px solid var(--line); border-radius:9px; background:#f9f7ff; color:var(--accent-deep); cursor:pointer; font-size:18px }
.chat-attach:focus-within { outline:2px solid #7659e6; outline-offset:2px }
.chat-attach input { opacity:0; position:absolute; padding:0; inset:0; width:100%; cursor:pointer }
.chat-composer-note { font-size:11px }
.chat-attachment-preview,.chat-delivery { display:flex; flex-wrap:wrap; align-items:center; gap:6px; font-size:12px; overflow-wrap:anywhere }
.chat-attachment-preview img { width:38px; height:38px; object-fit:cover; border-radius:7px }
.chat-thread-sync { color:var(--muted);font-size:12px }
.chat-delivery[data-kind=error] { color:#942c4c }
.chat-delivery[data-kind=success] { color:#206f57 }
.chat-empty-room { grid-area:2/1; align-self:center; justify-self:center; text-align:center; padding:24px; color:var(--muted) }
.chat-empty-room h2 { color:var(--ink); font-size:22px; letter-spacing:-.025em }
.empty-illustration { display:grid; grid-auto-flow:column; place-content:center; gap:5px; width:82px; height:66px; margin:0 auto 17px; border:1px solid #ded1f9; border-radius:23px 23px 23px 7px; background:linear-gradient(145deg,#f3ebff,#e7e2fa); transform:rotate(-5deg) }
.empty-illustration i { width:7px; height:7px; border-radius:50%; background:#795bbf }
.empty-illustration i:nth-child(2) { margin-top:-4px; background:#a482ce }
.empty-illustration i:nth-child(3) { background:#b68750 }
.chat-context { z-index:2; grid-area:2/1; justify-self:end; align-self:start; display:flex; flex-direction:column; gap:12px; width:min(276px,100%); max-height:100%; overflow:auto; padding:16px; border-left:1px solid var(--line); border-bottom:1px solid var(--line); box-shadow:-8px 10px 20px #28204613; background:white }
.chat-context h2 { font-size:17px; letter-spacing:-.02em }
.customer-card { display:flex; align-items:center; gap:8px; border:1px solid var(--line); background:#fbfaff; border-radius:12px; padding:10px }
.chat-context-links,.chat-context-orders { display:grid; gap:6px; line-height:1.4 }
.chat-context-links a,.chat-context-orders>div { border:1px solid var(--line); padding:7px 9px; border-radius:8px }
.chat-context-orders small { display:block }
@media (min-width:1120px) {
  .chat-room:has(.chat-context:not([hidden])) { grid-template-columns:minmax(0,1fr) 260px }
  .chat-context { grid-area:1/2/4/3; width:100%; height:100%; border-bottom:0; box-shadow:none; padding:20px 16px }
}
dialog { width:min(460px,calc(100vw - 24px)); padding:20px; color:var(--ink); border:1px solid var(--line); border-radius:15px }
dialog::backdrop { background:#211c47a8 }
dialog header { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px }
dialog h2 { font-size:20px }
dialog form { display:grid; gap:10px; margin:12px 0 }
dialog label { display:grid; gap:4px }
dialog input { width:100%; padding:8px; border:1px solid var(--line); border-radius:8px }
@media (max-width:740px) {
  .inbox-app { grid-template-columns:44px minmax(0,1fr); grid-template-rows:52px minmax(0,1fr) }
  .channel-current,.rail-settings { width:33px; height:33px; border-radius:9px }
  .inbox-top { padding:0 8px }
  .product-title strong,#chat-sync-time { display:none }
  .product-title span { padding:0; border:0 }
  .top-actions { gap:4px }
  .account-button { max-width:130px }
  .top-actions .refresh { padding:6px }
  .chat-workspace { grid-template-columns:minmax(0,1fr) }
  .chat-workspace[data-thread=true] .chat-inbox,.chat-workspace[data-thread=false] .chat-room { display:none }
  .chat-room-head { padding:7px 6px; gap:5px }
  #chat-back { display:block; padding:4px 7px; font-size:17px }
  .room-actions button { font-size:11px; padding:5px }
  .chat-scroll { padding-inline:9px }
  .chat-composer { padding:8px }
  .chat-form { gap:4px }
  .chat-form button { padding:6px }
}
