@import url("https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=Cormorant+Garamond:wght@500;600;700&display=swap");

:root {
  --bg: #0d0d0f;
  --ink: #f4ede3;
  --muted: #d0b79b;
  --muted-strong: #e1c6a7;
  --accent: #f28b25;
  --accent-strong: #ff6a00;
  --accent-warm: #ffb15c;
  --line: rgba(242, 139, 37, 0.22);
  --line-soft: rgba(242, 139, 37, 0.12);
  --card: rgba(22, 22, 26, 0.9);
  --card-soft: rgba(17, 17, 21, 0.82);
  --card-strong: rgba(10, 10, 14, 0.95);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --content-width: 1240px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 106, 0, 0.24), transparent 26%),
    radial-gradient(circle at top right, rgba(242, 139, 37, 0.16), transparent 32%),
    linear-gradient(180deg, #09090b 0%, #111114 52%, #18140f 100%);
  font-family: "Instrument Sans", "Segoe UI", sans-serif;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

a {
  color: var(--accent-warm);
}

button,
input,
textarea,
select {
  font: inherit;
}

.shell {
  width: min(var(--content-width), calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.shell-header,
.hero-card,
.panel-card,
.chat-panel,
.side-card,
.auth-card,
.auth-brand-panel,
.chat-form {
  backdrop-filter: blur(14px);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.shell-header {
  position: relative;
  z-index: 40;
  overflow: visible;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  border-radius: 30px;
  padding: 24px 28px;
  margin-bottom: 28px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.user-badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(242, 139, 37, 0.12);
  border: 1px solid rgba(242, 139, 37, 0.16);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.profile-menu {
  position: relative;
  z-index: 41;
}

.profile-menu[open] .profile-menu-trigger {
  border-color: rgba(255, 177, 92, 0.38);
  box-shadow: 0 18px 34px rgba(242, 139, 37, 0.18);
}

.profile-menu[open] .profile-menu-chevron {
  transform: rotate(180deg);
}

.profile-menu summary::-webkit-details-marker {
  display: none;
}

.profile-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(22, 22, 26, 0.88);
  color: #fff4e8;
  cursor: pointer;
  list-style: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.profile-menu-trigger:hover {
  transform: translateY(-1px);
}

.profile-menu-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.profile-menu-chevron {
  color: var(--accent-warm);
  transition: transform 160ms ease;
}

.profile-menu-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 60;
  min-width: 280px;
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(242, 139, 37, 0.16);
  background: rgba(14, 14, 18, 0.98);
  box-shadow: 0 28px 52px rgba(0, 0, 0, 0.42);
}

.profile-menu-panel strong {
  color: #fff4e8;
  font-size: 1rem;
}

.profile-menu-panel span {
  color: var(--muted);
  font-size: 0.92rem;
}

.profile-menu-label {
  margin: 0;
  color: var(--accent-warm);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.68rem;
  font-weight: 700;
}

.profile-menu-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 16px;
  border: 1px solid rgba(242, 139, 37, 0.18);
  background: rgba(242, 139, 37, 0.08);
  color: #fff1e0;
  text-decoration: none;
  font-weight: 600;
}

.profile-menu-button {
  width: 100%;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-warm);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  line-height: 0.98;
  font-family: "Cormorant Garamond", Georgia, serif;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.9rem, 5.6vw, 5.1rem);
}

h2 {
  font-size: clamp(2.2rem, 3.5vw, 3.35rem);
}

h3 {
  font-size: 1.82rem;
}

.lead,
.footnote,
.panel-card p,
.panel-card small,
.message p,
li,
span,
label span {
  color: var(--muted);
}

.lead {
  max-width: 62ch;
  font-size: 1.05rem;
  line-height: 1.85;
}

.footnote {
  font-size: 0.92rem;
  line-height: 1.65;
}

.shell-header h1,
.hero-card h2,
.panel-card h3,
.auth-card h2,
.auth-brand-panel h1 {
  color: #fff4e8;
}

.hero-card {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 28px;
  border-radius: 32px;
  padding: 36px;
  margin-bottom: 28px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.stat-grid article {
  display: grid;
  gap: 10px;
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(35, 35, 40, 0.95), rgba(23, 23, 27, 0.92));
  border: 1px solid rgba(242, 139, 37, 0.16);
}

.stat-grid strong {
  font-size: 2.2rem;
  color: #ffd3a0;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
  gap: 24px;
}

.chat-stack,
.side-rail {
  display: grid;
  gap: 20px;
}

.chat-panel {
  min-height: 540px;
  padding: 28px;
  border-radius: 32px;
  display: grid;
  gap: 20px;
}

.chat-panel-head,
.composer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.message-stream {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 360px;
  max-height: 68vh;
  overflow-y: auto;
  padding-right: 8px;
}

.message-stream::-webkit-scrollbar {
  width: 8px;
}

.message-stream::-webkit-scrollbar-thumb {
  background: rgba(242, 139, 37, 0.3);
  border-radius: 999px;
}

.side-card,
.panel-card {
  border-radius: 30px;
  padding: 28px;
}

.message {
  max-width: 86%;
  padding: 18px 20px;
  border-radius: 24px;
  display: grid;
  gap: 10px;
}

.message-meta {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted-strong);
}

.message p {
  margin: 0;
  font-size: 0.99rem;
  line-height: 1.78;
  color: #f2dfca;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(255, 106, 0, 0.28), rgba(242, 139, 37, 0.16));
  border: 1px solid rgba(255, 106, 0, 0.28);
}

.message.assistant {
  align-self: flex-start;
  background: rgba(27, 27, 31, 0.95);
  border: 1px solid rgba(242, 139, 37, 0.12);
}

.chat-form {
  padding: 24px;
  border-radius: 30px;
  background: rgba(18, 18, 22, 0.92);
}

.composer-panel {
  display: grid;
  gap: 18px;
}

.chat-form textarea,
.stack-form input,
.stack-form textarea,
.stack-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 18px;
  background: rgba(10, 10, 12, 0.92);
  color: #fff3e5;
  line-height: 1.65;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.chat-form textarea:focus,
.stack-form input:focus,
.stack-form textarea:focus,
.stack-form select:focus {
  outline: none;
  border-color: rgba(255, 177, 92, 0.6);
  box-shadow: 0 0 0 4px rgba(242, 139, 37, 0.12);
}

.chat-form textarea {
  min-height: 132px;
  resize: vertical;
}

.chat-form textarea::placeholder,
.stack-form input::placeholder,
.stack-form textarea::placeholder {
  color: rgba(208, 183, 155, 0.7);
}

.chat-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.primary-button,
.ghost-button,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  text-decoration: none;
  font: inherit;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.primary-button,
.ghost-button {
  cursor: pointer;
}

.primary-button:hover,
.ghost-button:hover,
.ghost-link:hover {
  transform: translateY(-1px);
}

.primary-button {
  padding: 14px 22px;
  min-height: 48px;
  border: none;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #17120d;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 16px 34px rgba(242, 139, 37, 0.22);
}

.ghost-button,
.ghost-link {
  padding: 11px 18px;
  border: 1px solid var(--line);
  background: rgba(22, 22, 26, 0.82);
  color: #ffe8cf;
}

.flash {
  border-radius: 20px;
  padding: 16px 18px;
  margin-bottom: 20px;
}

.flash-success {
  background: rgba(242, 139, 37, 0.14);
  border: 1px solid rgba(242, 139, 37, 0.22);
}

.flash-error {
  background: rgba(255, 106, 0, 0.12);
  border: 1px solid rgba(255, 106, 0, 0.26);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.wide-card {
  grid-column: span 2;
}

.panel-card-emphasis {
  background: linear-gradient(180deg, rgba(24, 24, 29, 0.96), rgba(16, 16, 20, 0.96));
}

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

.knowledge-list {
  display: grid;
  gap: 14px;
}

.knowledge-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(18, 18, 22, 0.84);
}

.knowledge-item input {
  accent-color: var(--accent);
  margin-top: 4px;
}

.knowledge-item span {
  display: grid;
  gap: 6px;
}

.stack-form {
  display: grid;
  gap: 16px;
}

.split-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.table-list {
  display: grid;
  gap: 12px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(180px, 0.7fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border-radius: 20px;
  background: rgba(18, 18, 22, 0.86);
  border: 1px solid rgba(242, 139, 37, 0.1);
}

.table-row-main,
.table-row-meta,
.table-row-actions {
  display: grid;
  gap: 8px;
}

.table-row-main strong {
  color: #fff4e8;
}

.table-row-meta {
  justify-items: start;
}

.table-row-actions {
  grid-auto-flow: column;
  align-items: center;
  justify-content: end;
}

.table-row-actions form {
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-pill-active {
  color: #ffe8cf;
  background: rgba(242, 139, 37, 0.14);
  border: 1px solid rgba(242, 139, 37, 0.22);
}

.status-pill-inactive {
  color: #f1c8b6;
  background: rgba(255, 106, 0, 0.1);
  border: 1px solid rgba(255, 106, 0, 0.2);
}

.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(560px, 100%);
}

.auth-shell-wide {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: 1.1fr minmax(360px, 0.82fr);
  gap: 24px;
  align-items: stretch;
}

.auth-brand-panel,
.auth-card {
  border-radius: 36px;
  padding: 42px;
}

.auth-brand-panel {
  display: grid;
  align-content: space-between;
  gap: 28px;
  background:
    linear-gradient(180deg, rgba(19, 19, 23, 0.94), rgba(11, 11, 14, 0.96)),
    radial-gradient(circle at top right, rgba(242, 139, 37, 0.12), transparent 32%);
}

.auth-brand-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.auth-brand-grid article {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.02);
}

.auth-brand-grid strong {
  color: #fff3e5;
  font-weight: 600;
}

.auth-card-login {
  display: grid;
  align-content: center;
  gap: 20px;
}

.login-button {
  width: 100%;
}

label {
  display: grid;
  gap: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

@media (max-width: 1100px) {
  .auth-shell-wide,
  .hero-card,
  .chat-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .wide-card {
    grid-column: auto;
  }

  .auth-brand-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .shell {
    width: min(var(--content-width), calc(100% - 24px));
    padding: 20px 0 36px;
  }

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

  .table-row {
    grid-template-columns: 1fr;
  }

  .split-fields,
  .table-row-actions {
    grid-template-columns: 1fr;
    grid-auto-flow: row;
    justify-content: stretch;
  }

  .message {
    max-width: 100%;
  }

  .hero-card,
  .chat-panel,
  .side-card,
  .panel-card,
  .auth-card,
  .auth-brand-panel,
  .chat-form,
  .shell-header {
    padding: 22px;
  }

  .profile-menu {
    width: 100%;
  }

  .profile-menu-trigger,
  .profile-menu-button {
    width: 100%;
  }

  .profile-menu-panel {
    position: static;
    min-width: 0;
    margin-top: 12px;
  }
}
