:root {
  --primary: #24439a;
  --primary-dark: #182d73;
  --primary-light: #dbe7ff;
  --blue-bright: #12a8dc;
  --accent: #ff7a2f;
  --accent-strong: #f45a25;
  --accent-soft: #fff1dc;
  --gold: #ffb43f;
  --bg-app: #f4f6fa;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --text-primary: #172033;
  --text-body: #344054;
  --text-muted: #667085;
  --border: #e4e7ec;
  --ai-bubble: #f7fbff;
  --user-bubble: #ffffff;
  --ok: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-panel: 0 18px 45px rgba(24, 45, 115, 0.09);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(18, 168, 220, 0.16), transparent 28%),
    linear-gradient(135deg, #f7f8fb 0%, var(--bg-app) 44%, #eef3fa 100%);
  color: var(--text-body);
  font-family: "IBM Plex Sans Thai", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  color: var(--text-body);
  padding: 18px;
  border-right: 1px solid var(--border);
}

.brand-block {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 4px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-dark), var(--blue-bright));
  color: #fff;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-block h1 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
  line-height: 1.25;
}

.brand-block p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: var(--text-body);
  text-align: left;
  font-weight: 600;
}

.nav-item.active {
  background: #eef4ff;
  color: var(--primary-dark);
  box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.status-pill,
.model-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-color: var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #f9fafb;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-card span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}

.model-card strong {
  display: block;
  margin-top: 4px;
  color: var(--text-primary);
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--text-muted);
}

.dot.ok {
  background: var(--ok);
}

.dot.warning {
  background: var(--warning);
}

.dot.danger {
  background: var(--danger);
}

.main-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100vh;
}

.topbar {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar::before,
.topbar::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 999px;
  transform: rotate(-9deg);
}

.topbar::before {
  right: -92px;
  top: -86px;
  width: 430px;
  height: 160px;
  border: 22px solid rgba(36, 67, 154, 0.11);
  border-left-color: rgba(18, 168, 220, 0.18);
}

.topbar::after {
  right: -70px;
  bottom: -112px;
  width: 360px;
  height: 124px;
  border: 16px solid rgba(255, 180, 63, 0.36);
  border-left-color: rgba(244, 90, 37, 0.24);
}

.topbar > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.topbar h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 20px;
  line-height: 1.25;
}

.topbar-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-muted);
  font-size: 22px;
  box-shadow: var(--shadow-card);
}

.notice-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin: 16px 28px 0;
  padding: 10px 14px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  border-radius: 8px;
}

.quick-actions {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 14px 28px 10px;
  background: transparent;
}

.quick-actions button {
  min-height: 38px;
  min-width: 132px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--text-body);
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-card);
}

.quick-actions button:hover {
  border-color: #b9dfff;
  background: linear-gradient(180deg, #ffffff, #eff7ff);
  color: var(--primary-dark);
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  margin: 0 28px 18px;
  padding: 18px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.76)),
    radial-gradient(circle at 0% 100%, rgba(255, 122, 47, 0.08), transparent 34%);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-panel);
}

.message {
  display: grid;
  gap: 6px;
  max-width: min(820px, 100%);
}

.message.user {
  align-self: flex-end;
}

.message.ai {
  align-self: flex-start;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.message.user .message-meta {
  justify-content: flex-end;
}

.message-meta strong {
  color: var(--text-primary);
  font-size: 13px;
}

.bubble {
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.message.ai .bubble {
  border: 1px solid #d7e6ff;
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  background: var(--ai-bubble);
  box-shadow: var(--shadow-card);
}

.message.user .bubble {
  background: var(--user-bubble);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.message.user .bubble {
  border-top: 2px solid rgba(255, 180, 63, 0.75);
}

.bubble p {
  margin: 0 0 10px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble pre {
  margin: 10px 0;
  max-width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  padding: 12px;
  background: #111827;
  color: #f9fafb;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

.result-card {
  margin-top: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.soft-note {
  color: var(--text-muted);
}

.result-card strong {
  color: var(--text-primary);
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.composer {
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 12px 28px 14px;
}

.attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: #f8fafc;
  color: var(--text-body);
  font-size: 12px;
}

.file-chip button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
}

.composer-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: end;
}

.attach-button,
.send-button {
  display: grid;
  place-items: center;
  min-height: 40px;
  border-radius: 8px;
}

.attach-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--primary-dark);
  font-size: 24px;
}

.attach-button input {
  display: none;
}

textarea {
  width: 100%;
  max-height: 120px;
  min-height: 40px;
  resize: none;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-primary);
  outline: none;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.12);
}

.send-button {
  border: 0;
  background: linear-gradient(135deg, var(--primary), var(--blue-bright));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(36, 67, 154, 0.22);
}

.send-button:hover {
  background: linear-gradient(135deg, var(--primary-dark), #0b91c4);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.composer-hint {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main-panel {
    height: 100vh;
  }

  .topbar,
  .notice-bar,
  .quick-actions,
  .composer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .notice-bar,
  .chat-window {
    margin-left: 14px;
    margin-right: 14px;
  }
}

@media (max-width: 560px) {
  .composer-row {
    grid-template-columns: 36px minmax(0, 1fr) 56px;
  }

  .send-button {
    font-size: 13px;
  }

  .topbar h2 {
    font-size: 18px;
  }
}
