* { box-sizing: border-box; }
html { height: 100%; }
body { min-height: 100%; margin: 0; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; background: #eef3fb; color: #17243b; }
.hidden { display: none !important; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, rgba(47,128,237,.22), transparent 32%), linear-gradient(135deg,#f8fbff,#eef4ff); }
.login-card { width: min(430px, 100%); padding: 30px; border: 1px solid rgba(211,222,239,.9); border-radius: 28px; background: rgba(255,255,255,.9); box-shadow: 0 24px 60px rgba(30,58,95,.14); }
.login-logo { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 18px; color: #fff; font-weight: 900; background: linear-gradient(135deg,#2f80ed,#7c3aed); box-shadow: 0 14px 28px rgba(47,128,237,.28); }
.login-card h1 { margin: 18px 0 6px; font-size: 28px; letter-spacing: -.04em; }
.login-card p { margin: 0 0 22px; color: #61708a; line-height: 1.45; }
.login-card label, .profile-dialog label { display: grid; gap: 8px; margin: 13px 0; color: #41516d; font-weight: 700; }
.login-card input, .profile-dialog input { width: 100%; border: 1px solid #d7e1f4; border-radius: 14px; padding: 13px 14px; font: inherit; outline: none; background: #f9fbff; }
.login-card input:focus, .profile-dialog input:focus { border-color: #2f80ed; background: #fff; box-shadow: 0 0 0 4px rgba(47,128,237,.12); }
.remember-row { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 10px !important; font-weight: 600 !important; }
.remember-row input { width: auto; }
.login-card button, .profile-dialog button, .send-box button { border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 800; color: #fff; background: linear-gradient(135deg,#2f80ed,#1f6ed4); cursor: pointer; box-shadow: 0 10px 22px rgba(47,128,237,.25); }
.login-actions { display: grid; gap: 18px; margin-top: 22px; }
.login-actions button { width: 100%; min-height: 56px; font-size: 16px; }
.forgot-link { display: inline-flex; justify-self: center; align-items: center; min-height: 36px; padding: 6px 12px; color: #1d6fe8; font-weight: 800; text-decoration: none; border-radius: 12px; }
.forgot-link:hover { background: #edf5ff; text-decoration: none; }
.login-error { min-height: 20px; margin-top: 12px; color: #d72d47; font-weight: 700; }
.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; background: radial-gradient(circle at top left, rgba(47,128,237,.16), transparent 34%), linear-gradient(135deg,#f7faff 0%,#eef4ff 48%,#f8fbff 100%); }
.sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid rgba(137,158,190,.26); background: rgba(255,255,255,.82); backdrop-filter: blur(14px); box-shadow: 12px 0 32px rgba(25,45,85,.06); }
.sidebar-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 16px 14px; background: linear-gradient(180deg,#fff 0%,rgba(255,255,255,.9) 100%); border-bottom: 1px solid rgba(219,228,243,.75); }
.sidebar h1 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.ghost-btn { color: #1d6fe8 !important; background: #edf5ff !important; box-shadow: none !important; border: 1px solid #d7e7ff !important; padding: 10px 13px !important; }
.mobile-conversation-picker { display: none; }
#conversations { overflow-y: auto; padding: 12px; }
.conversation-item { margin-bottom: 10px; padding: 14px; border: 1px solid rgba(217,226,242,.92); border-radius: 18px; cursor: pointer; background: rgba(255,255,255,.78); box-shadow: 0 8px 22px rgba(30,58,95,.06); transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.conversation-item:hover { transform: translateY(-1px); border-color: rgba(47,128,237,.35); background: #fff; box-shadow: 0 12px 26px rgba(30,58,95,.1); }
.conversation-item.active { border-color: rgba(47,128,237,.45); background: linear-gradient(135deg,#eaf3ff 0%,#fff 100%); box-shadow: inset 4px 0 0 #2f80ed, 0 12px 28px rgba(47,128,237,.14); }
.conversation-item strong { display: inline-block; margin-bottom: 4px; font-size: 16px; letter-spacing: -.02em; }
.conversation-item small { color: #61708a; line-height: 1.45; }
.conversation-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 18px; }
.main-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; padding: 18px 20px; border: 1px solid rgba(211,222,239,.82); border-radius: 22px; background: rgba(255,255,255,.88); box-shadow: 0 14px 34px rgba(30,58,95,.08); }
.main-header strong { display: block; margin-bottom: 8px; font-size: 19px; letter-spacing: -.03em; }
#dialog-info { color: #41516d; font-size: 14px; line-height: 1.55; }
#dialog-info a { color: #1d6fe8; font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; border: 1px solid rgba(211,222,239,.76); border-radius: 24px; background: linear-gradient(rgba(255,255,255,.72),rgba(255,255,255,.72)), radial-gradient(circle at top right, rgba(47,128,237,.12), transparent 32%); box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 18px 40px rgba(30,58,95,.07); }
.bubble-wrap { max-width: min(760px, 76%); display: grid; gap: 5px; }
.bubble-wrap.user { align-self: flex-start; }
.bubble-wrap.operator { align-self: flex-end; justify-items: end; }
.bubble-meta { display: flex; align-items: center; gap: 8px; color: #6a7890; font-size: 12px; }
.operator-avatar { width: 24px; height: 24px; border-radius: 999px; object-fit: cover; background: #dfe9f8; }
.bubble { padding: 12px 14px; border-radius: 18px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; box-shadow: 0 8px 18px rgba(22,41,72,.08); }
.bubble.user { color: #1c2b45; background: #fff; border: 1px solid rgba(210,222,242,.95); border-bottom-left-radius: 6px; }
.bubble.operator { color: #fff; background: linear-gradient(135deg,#2f80ed 0%,#1f6ed4 100%); border-bottom-right-radius: 6px; }
.send-box { display: flex; gap: 10px; margin-top: 14px; padding: 12px; border: 1px solid rgba(211,222,239,.82); border-radius: 20px; background: rgba(255,255,255,.92); box-shadow: 0 14px 34px rgba(30,58,95,.08); }
.send-box input { flex: 1; min-width: 0; border: 1px solid #d7e1f4; border-radius: 14px; padding: 13px 14px; font: inherit; outline: none; background: #f9fbff; }
.profile-dialog { width: min(460px, calc(100vw - 32px)); border: 0; border-radius: 24px; padding: 0; box-shadow: 0 24px 70px rgba(15,31,61,.28); }
.profile-dialog::backdrop { background: rgba(10,20,40,.38); backdrop-filter: blur(4px); }
.profile-dialog form { padding: 24px; }
.profile-dialog h2 { margin: 0 0 6px; }
.profile-dialog p { margin: 0 0 18px; color: #61708a; }
.profile-preview { position: relative; width: 76px; height: 76px; display: grid; place-items: center; border-radius: 24px; overflow: hidden; background: linear-gradient(135deg,#e7f1ff,#f4ecff); color: #2f80ed; font-size: 26px; font-weight: 900; }
.profile-preview img { width: 100%; height: 100%; object-fit: cover; display: none; }
.profile-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 310px minmax(0, 1fr); }
  .conversation-main { padding: 14px; }
  .main-header { padding: 16px; }
  .bubble-wrap { max-width: min(680px, 82%); }
}
@media (max-width: 820px) {
  body { overflow: hidden; }
  .login-screen { min-height: 100vh; min-height: 100dvh; align-items: center; padding: clamp(14px, 4vw, 24px); overflow-y: auto; }
  .login-card { width: 100%; max-width: 480px; padding: clamp(22px, 6vw, 30px); border-radius: 24px; }
  .login-card h1 { font-size: clamp(28px, 7vw, 38px); line-height: 1.05; }
  .login-card p { font-size: 16px; }
  .login-card input, .profile-dialog input, .send-box input { min-height: 48px; font-size: 16px; }
  .login-actions button { min-height: 54px; }
  .layout { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
  .sidebar { flex: 0 0 auto; height: auto; min-height: auto; max-height: none; border-right: 0; border-bottom: 1px solid rgba(137,158,190,.26); box-shadow: 0 12px 28px rgba(25,45,85,.08); }
  .sidebar-head { padding: 12px; }
  .sidebar h1 { font-size: 20px; }
  .ghost-btn { min-height: 40px; padding: 9px 12px !important; }
  .mobile-conversation-picker { display: grid; gap: 8px; padding: 0 12px 12px; }
  .mobile-conversation-picker label { color: #41516d; font-size: 13px; font-weight: 800; }
  .mobile-conversation-picker select { width: 100%; min-height: 48px; border: 1px solid #d7e1f4; border-radius: 16px; padding: 0 42px 0 13px; color: #17243b; background: #fff; font: 700 15px/1.2 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; outline: none; box-shadow: 0 8px 20px rgba(30,58,95,.07); }
  .mobile-conversation-picker select:focus { border-color: #2f80ed; box-shadow: 0 0 0 4px rgba(47,128,237,.12); }
  .mobile-conversation-picker small { color: #61708a; font-size: 12px; }
  #conversations { display: none; }
  .conversation-item strong { font-size: 15px; }
  .conversation-item small { font-size: 12px; }
  .conversation-main { flex: 1 1 auto; min-height: 0; height: auto; padding: 10px; }
  .main-header { align-items: center; gap: 10px; margin-bottom: 10px; padding: 12px; border-radius: 18px; }
  .main-header > div { min-width: 0; }
  .main-header strong { margin-bottom: 5px; font-size: 16px; }
  #dialog-info { max-height: 58px; overflow-y: auto; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
  .messages { padding: 12px; gap: 8px; border-radius: 18px; }
  .bubble-wrap { max-width: 92%; }
  .bubble { padding: 10px 12px; border-radius: 16px; font-size: 14px; }
  .bubble-meta { font-size: 11px; }
  .send-box { align-items: center; gap: 8px; margin-top: 10px; padding: 8px; border-radius: 18px; }
  .send-box input { padding: 0 12px; }
  .send-box button { min-height: 48px; padding: 0 14px; }
  .profile-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); overflow: auto; border-radius: 22px; }
  .profile-dialog form { padding: 20px; }
  .profile-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .profile-actions button { width: 100%; min-height: 44px; }
}
@media (max-width: 520px) {
  .login-screen { place-items: stretch; padding: 12px; }
  .login-card { align-self: center; padding: 22px 18px; border-radius: 22px; }
  .login-logo { width: 58px; height: 58px; border-radius: 19px; }
  .login-card h1 { margin-top: 20px; font-size: clamp(30px, 9vw, 40px); }
  .login-card p { margin-bottom: 18px; }
  .login-card label, .profile-dialog label { margin: 11px 0; }
  .login-actions { gap: 14px; margin-top: 18px; }
  .sidebar { min-height: auto; max-height: none; }
  .sidebar-head { padding: 10px 10px 8px; }
  .sidebar h1 { font-size: 18px; }
  .mobile-conversation-picker { padding: 0 10px 10px; }
  .mobile-conversation-picker select { min-height: 46px; font-size: 14px; }
  .conversation-main { padding: 8px; }
  .main-header { flex-wrap: wrap; padding: 11px; }
  .main-header .ghost-btn { margin-left: auto; }
  #dialog-info { max-height: 46px; }
  .messages { padding: 10px; border-radius: 16px; }
  .bubble-wrap { max-width: 95%; }
  .send-box { gap: 7px; padding: 7px; border-radius: 16px; }
  .send-box button { min-width: 50px; padding: 0 12px; font-size: 0; }
  .send-box button::after { content: "➤"; font-size: 18px; line-height: 1; }
}
@media (max-width: 380px) {
  .login-card { padding: 20px 16px; }
  .forgot-link { font-size: 14px; }
  .sidebar { min-height: auto; }
  .main-header strong { font-size: 15px; }
  .bubble { font-size: 13px; }
}
