:root {
  font-family: Inter, "Noto Sans Thai", system-ui, sans-serif;
  color: #e8edf6;
  background: #080b12;
  font-size: 16px;
  --panel: #111722;
  --panel2: #161e2c;
  --line: #253047;
  --muted: #8d9bb1;
  --accent: #3dd9c4;
  --accent2: #1b8b80;
  --danger: #fb7185;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 70% -20%, #12344a 0, transparent 38%), #080b12;
  color: #e8edf6;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
a {
  transition: 0.18s ease;
}
a {
  color: #83e9dc;
  text-decoration: none;
}
.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100vh;
}
.sidebar {
  border-right: 1px solid var(--line);
  background: #0c111b;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.logo {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 8px 24px;
}
.logo span,
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #2d75ff);
  color: #071018;
  font-weight: 900;
}
.new-chat,
.primary {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #04110f;
  font-weight: 800;
  padding: 12px 16px;
  cursor: pointer;
}
.new-chat {
  width: 100%;
  text-align: left;
}
.sidebar nav {
  overflow: auto;
  margin-top: 18px;
  display: grid;
  gap: 5px;
}
.chat-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #abb6c8;
  padding: 10px 12px;
  border-radius: 10px;
}
.chat-link.active,
.chat-link:hover {
  background: #172235;
  color: #fff;
}
.chat-link span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.retention {
  font-size: 0.75rem;
  color: #6f7f97;
  line-height: 1.55;
  margin-top: auto;
  padding: 15px 8px;
}
.sidebar-bottom {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 4px;
}
.sidebar-bottom > a,
.link-button {
  padding: 9px 8px;
  color: #aebbd0;
  background: none;
  border: 0;
  text-align: left;
}
.sidebar-bottom b {
  float: right;
  color: var(--accent);
}
.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}
.workspace > * {
  min-width: 0;
  max-width: 100%;
}
.workspace > header {
  height: 76px;
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.workspace h1 {
  font-size: 1.1rem;
  margin: 0;
}
.workspace header small {
  color: var(--muted);
}
#mobileChats {
  display: none;
}
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.credit-pill {
  background: #142336;
  color: #90f5e8;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: #fff;
  border-radius: 10px;
}
.icon-btn.danger {
  color: var(--danger);
}
.messages {
  overflow: auto;
  padding: 30px max(24px, calc((100% - 900px) / 2));
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.message {
  min-width: 0;
  max-width: min(680px, 85%);
  background: var(--panel2);
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 5px;
  align-self: flex-start;
}
.message.user {
  align-self: flex-end;
  background: #203f55;
  border-color: #285774;
  border-radius: 18px 18px 5px 18px;
}
.message p {
  white-space: pre-wrap;
  margin: 8px 0;
  line-height: 1.55;
}
.message small {
  color: #a2b0c4;
}
.message img {
  display: block;
  max-width: 100%;
  max-height: 430px;
  border-radius: 12px;
}
.image-open {
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}
.tag {
  border: 0;
  border-radius: 7px;
  background: #203743;
  color: #8ff4e5;
  padding: 4px 8px;
  font-size: 0.8rem;
}
.download {
  margin-left: 8px;
}
.pending {
  color: #9cabc1;
  margin-top: 8px;
}
.pending span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.25;
    transform: scale(0.7);
  }
}
.composer {
  min-width: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: #0c111bf2;
  padding: 12px max(24px, calc((100% - 900px) / 2)) 16px;
}
.quick-head,
.compose-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 8px;
}
.text-btn {
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
}
.quick-buttons {
  display: flex;
  min-width: 0;
  width: 100%;
  gap: 8px;
  overflow: auto;
  scrollbar-width: none;
  padding-bottom: 9px;
}
.quick-buttons::-webkit-scrollbar {
  display: none;
}
.quick {
  min-width: 150px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  text-align: left;
  border: 1px solid var(--line);
  background: #121a27;
  color: #f3f6fa;
  border-radius: 12px;
  padding: 9px 11px;
  cursor: pointer;
}
.quick:hover {
  border-color: #3b8f8a;
  background: #162b33;
}
.quick i {
  grid-row: 1/3;
  color: var(--accent);
  font-size: 1.25rem;
  align-self: center;
}
.quick small {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compose-row {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  background: #151e2c;
  border: 1px solid #324159;
  border-radius: 16px;
  padding: 7px;
}
.compose-row:focus-within {
  border-color: var(--accent2);
}
textarea,
input,
select {
  background: #0e1520;
  color: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px;
}
.compose-row textarea {
  resize: none;
  border: 0;
  background: transparent;
  outline: 0;
  max-height: 130px;
}
.upload,
.send {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
}
.upload {
  background: #202b3c;
}
.upload input {
  display: none;
}
.send {
  background: var(--accent);
  color: #06211d;
}
.compose-meta {
  margin: 7px 4px 0;
}
.selected-images {
  display: flex;
  gap: 6px;
}
.error {
  padding: 9px 12px;
  background: #3a1520;
  color: #fda4af;
  border-radius: 9px;
  margin: 8px 0;
}
.hidden {
  display: none !important;
}
.empty {
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  color: var(--muted);
  padding: 32px;
}
.empty > i {
  font-size: 3rem;
  color: var(--accent);
}
.empty h2 {
  color: #fff;
  margin-bottom: 0;
}
.empty.compact {
  margin: auto;
}
.login-page,
.page {
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card,
.panel {
  width: min(430px, 100%);
  background: #101722;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px;
  box-shadow: 0 30px 80px #0008;
}
.login-card .brand-mark {
  margin-bottom: 25px;
}
.login-card h1 {
  margin: 0;
}
.login-card p {
  color: var(--muted);
}
label {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  color: #aeb9c9;
}
.login-card .primary {
  width: 100%;
  margin-top: 8px;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 20px 0 14px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}
.google-button {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #46546b;
  border-radius: 12px;
  background: #fff;
  color: #172033;
  font-weight: 700;
  cursor: pointer;
}
.google-button:hover {
  background: #f3f6fa;
}
.google-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.google-g {
  color: #4285f4;
  font-size: 1.2rem;
  font-weight: 900;
}
.auth-note {
  margin: 12px 0 0 !important;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.5;
}
.field-help {
  display: block;
  margin: -7px 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}
.auth-switch {
  margin: 18px 0 0 !important;
  text-align: center;
  font-size: 0.86rem;
}
.panel.wide {
  width: min(1180px, 100%);
  align-self: start;
  margin: 30px auto;
}
.balance-card {
  background: linear-gradient(120deg, #153d48, #1c2851);
  border-radius: 18px;
  padding: 25px;
  display: grid;
  width: min(350px, 100%);
}
.balance-card strong {
  font-size: 3rem;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  color: #8f9db3;
}
.positive {
  color: #6ee7b7;
}
.negative {
  color: #fda4af;
}
.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.secondary {
  border: 1px solid var(--line);
  background: #151e2c;
  color: #fff;
  border-radius: 10px;
  padding: 9px 13px;
}
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.card {
  background: #0c121c;
  border: 1px solid var(--line);
  padding: 20px;
  border-radius: 16px;
}
.button-list > div {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.button-list span {
  color: var(--muted);
}
.status {
  padding: 4px 8px;
  border-radius: 99px;
  background: #263148;
}
.status.done {
  color: #6ee7b7;
}
.status.refunded,
.status.failed {
  color: #fda4af;
}
dialog {
  border: 1px solid #39475d;
  border-radius: 18px;
  background: #101722;
  color: #fff;
  padding: 28px;
  max-width: min(620px, 92vw);
}
dialog::backdrop {
  background: #02050acd;
  backdrop-filter: blur(8px);
}
.dialog-close {
  position: absolute;
  right: 12px;
  top: 10px;
  background: none;
  border: 0;
  color: #fff;
  font-size: 1.6rem;
}
#viewer img {
  max-width: 82vw;
  max-height: 75vh;
  display: block;
  margin-bottom: 14px;
  border-radius: 10px;
}
#viewer > div {
  display: flex;
  gap: 8px;
  justify-content: center;
}
@media (max-width: 760px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    display: none;
  }
  .workspace > header {
    padding: 12px 15px;
  }
  #mobileChats {
    display: block;
    max-width: 180px;
    padding: 5px;
    margin-bottom: 4px;
  }
  .workspace h1 {
    display: none;
  }
  .credit-pill {
    font-size: 0.78rem;
  }
  .messages {
    padding: 18px 12px;
  }
  .message {
    max-width: 92%;
  }
  .composer {
    padding: 10px 10px 12px;
  }
  .quick {
    min-width: 128px;
  }
  .quick small {
    display: none;
  }
  .quick-head span {
    max-width: 75%;
  }
  .compose-meta {
    font-size: 0.7rem;
  }
  .panel.wide {
    padding: 20px;
    margin: 0;
  }
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .page-title {
    align-items: flex-start;
    gap: 12px;
  }
  .page-title p {
    display: none;
  }
}
