body {
  margin: 0;
  background: linear-gradient(180deg, #0b1120 0%, #111827 100%);
  color: #e5e7eb;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

a { color: inherit; }

h1 { margin: 0 0 8px; font-size: 32px; }
h2, h3 { margin-top: 0; }

.panel {
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid #2f3b52;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

.app-shell {
  max-width: 1680px;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  min-height: 100vh;
  box-sizing: border-box;
}

.sidebar {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 22px;
  height: fit-content;
}

.brand-kicker {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #93c5fd;
  margin-bottom: 8px;
}

.sub, .muted {
  color: #9ca3af;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mini-panel {
  background: #0f172a;
  border: 1px solid #253147;
  border-radius: 16px;
  padding: 16px;
}

.mini-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.mini-panel-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.me-summary {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.status-grid div {
  background: #111827;
  border: 1px solid #283548;
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.status-grid span {
  color: #94a3b8;
  font-size: 12px;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-list.empty {
  color: #94a3b8;
  font-size: 14px;
}

.session-item-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.session-item-wrap.active .session-item {
  border-color: #3b82f6;
  background: #162033;
}

.session-item {
  width: 100%;
  text-align: left;
  background: #111827;
  border: 1px solid #253147;
  color: #e5e7eb;
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
}

.session-item:hover {
  border-color: #3b82f6;
  background: #162033;
}

.session-delete-btn {
  border: 1px solid #7f1d1d;
  background: rgba(127, 29, 29, 0.2);
  color: #fecaca;
  border-radius: 12px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.session-delete-btn:hover {
  background: rgba(127, 29, 29, 0.35);
}

.session-title {
  font-weight: 600;
}

.session-meta {
  margin-top: 4px;
  color: #94a3b8;
  font-size: 12px;
}

.main-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.hero-panel,
.chat-panel {
  padding: 22px;
}

.hero-copy ul {
  margin: 0;
  padding-left: 20px;
}

.hero-copy li {
  margin: 8px 0;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 90px);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.chat-messages {
  flex: 1;
  min-height: 560px;
  max-height: calc(100vh - 310px);
  overflow: auto;
  padding-right: 6px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-card {
  max-width: 420px;
  text-align: center;
  background: #0f172a;
  border: 1px dashed #334155;
  border-radius: 18px;
  padding: 28px;
}

.bubble {
  max-width: 92%;
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 14px;
  line-height: 1.72;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.bubble-user {
  margin-left: auto;
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
}

.bubble-assistant {
  margin-right: auto;
  background: #0f172a;
  border: 1px solid #253147;
}

.bubble-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.bubble-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bubble-role {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.82;
}

.bubble-time {
  font-size: 12px;
  color: #94a3b8;
}

.copy-btn {
  border: 1px solid #3b4a62;
  background: rgba(255,255,255,0.06);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.copy-btn:hover {
  background: rgba(255,255,255,0.12);
}

.danger-btn {
  border-color: #7f1d1d;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.22);
}

.danger-btn:hover {
  background: rgba(127, 29, 29, 0.35);
}

.bubble-text {
  white-space: normal;
  word-break: break-word;
  font-size: 15px;
}

.bubble-text h2,
.bubble-text h3,
.bubble-text h4 {
  margin: 10px 0 8px;
  line-height: 1.35;
}

.bubble-text h2 { font-size: 20px; }
.bubble-text h3 { font-size: 17px; }
.bubble-text h4 { font-size: 15px; }

.bubble-text p {
  margin: 8px 0;
}

.bubble-text ul {
  margin: 8px 0;
  padding-left: 20px;
}

.bubble-text li {
  margin: 6px 0;
}

.bubble-text code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 6px;
}

.msg-gap {
  height: 4px;
}

.typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 18px;
}

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #93c5fd;
  opacity: 0.45;
  animation: typingPulse 1s infinite ease-in-out;
}

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

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

.composer {
  margin-top: 14px;
  border-top: 1px solid #253147;
  padding-top: 16px;
}

textarea,
input,
select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid #3b4a62;
  background: #0b1220;
  color: #f9fafb;
  padding: 14px 16px;
  box-sizing: border-box;
  font: inherit;
}

textarea {
  min-height: 260px;
  resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.btn {
  background: #2563eb;
  color: white;
  border: 0;
  padding: 11px 15px;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-weight: 600;
  text-align: center;
}

.centered-btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary { background: #334155; }

.text-btn {
  border: 0;
  background: transparent;
  color: #93c5fd;
  cursor: pointer;
  padding: 0;
}

.hidden { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}

.modal-card {
  position: relative;
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  margin: 20px auto;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
}

.modal-card-narrow {
  width: min(760px, calc(100vw - 32px));
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid #374151;
  background: #0f172a;
}

.guide-body {
  padding: 20px;
  overflow: auto;
  max-height: calc(100vh - 120px);
  line-height: 1.6;
}

.guide-body section {
  margin-bottom: 22px;
}

.guide-body ul {
  margin: 8px 0;
  padding-left: 20px;
}

.guide-body code {
  background: #1f2937;
  padding: 2px 6px;
  border-radius: 6px;
}

.guide-pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #0b1220;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid #374151;
  font-size: 13px;
  line-height: 1.55;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.admin-actions-row {
  margin-top: 10px;
}

.small-gap {
  margin-top: 10px;
}

.admin-manage-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #253147;
}

.admin-user-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.admin-user-list-wide {
  gap: 8px;
}

.admin-user-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  background: #111827;
  border: 1px solid #253147;
  border-radius: 14px;
  padding: 12px;
}

.admin-user-item-wide {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.admin-user-item-blocked {
  opacity: 0.8;
}

.admin-user-main {
  min-width: 0;
}

.admin-user-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.admin-user-controls-wide {
  align-items: stretch;
}

.admin-user-name {
  font-weight: 700;
  margin-bottom: 4px;
}

.admin-user-email {
  font-weight: 500;
  color: #cbd5e1;
}

.admin-user-meta {
  color: #94a3b8;
  font-size: 12px;
  margin-top: 4px;
}

.admin-limit-row {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-limit-row-wide {
  flex-wrap: nowrap;
  justify-content: flex-start;
}

.admin-limit-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #94a3b8;
}

.admin-inline-input {
  width: 96px;
  padding: 8px 10px;
  border-radius: 10px;
}

.admin-user-buttons {
  display: flex;
  gap: 8px;
}

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

  .sidebar {
    position: static;
  }

  .chat-panel {
    min-height: auto;
  }

  .chat-messages {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  .chat-header,
  .composer-actions,
  .mini-panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-grid,
  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .admin-user-item,
  .admin-user-buttons,
  .admin-user-controls,
  .admin-limit-row {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-inline-input {
    width: 100%;
  }

  .bubble {
    max-width: 100%;
  }
}
