:root {
  color-scheme: dark;
  --bg: #090a0f;
  --panel: #10131b;
  --panel-strong: #151a24;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f2f5f8;
  --muted: #93a0af;
  --accent: #5eead4;
  --user: #2563eb;
  --hermes: #1d2430;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(94, 234, 212, 0.14), transparent 34rem),
    linear-gradient(145deg, #090a0f 0%, #111827 48%, #0b0f17 100%);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.chat {
  width: min(880px, 100%);
  height: min(780px, calc(100vh - 48px));
  min-height: 520px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 19, 27, 0.88);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px);
  animation: rise 420ms ease-out both;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(21, 26, 36, 0.82);
}

.chat-header h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.chat-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.status {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(94, 234, 212, 0.12), 0 0 24px rgba(94, 234, 212, 0.55);
}

.messages {
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  margin: 0 0 14px;
  animation: fade-in 180ms ease-out both;
}

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

.message.hermes {
  justify-content: flex-start;
}

.bubble {
  max-width: min(680px, 82%);
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.48;
  font-size: 0.96rem;
}

.user .bubble {
  border-bottom-right-radius: 5px;
  background: linear-gradient(145deg, var(--user), #1d4ed8);
  color: white;
}

.hermes .bubble {
  border-bottom-left-radius: 5px;
  background: var(--hermes);
  color: var(--text);
}

.bubble.error {
  border-color: rgba(251, 113, 133, 0.45);
  color: #fecdd3;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: rgba(21, 26, 36, 0.92);
}

textarea {
  width: 100%;
  max-height: 150px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  background: #0b0f17;
  color: var(--text);
  line-height: 1.4;
}

textarea:focus {
  border-color: rgba(94, 234, 212, 0.58);
  box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.09);
}

button {
  min-width: 82px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  background: var(--accent);
  color: #042f2e;
  font-weight: 700;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 42px;
}

.dots span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted);
  animation: pulse 900ms infinite ease-in-out;
}

.dots span:nth-child(2) {
  animation-delay: 120ms;
}

.dots span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

  .chat {
    height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .messages {
    padding: 18px 14px;
  }

  .bubble {
    max-width: 88%;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  button {
    height: 44px;
  }
}

.dashboard-body {
  background:
    linear-gradient(160deg, rgba(94, 234, 212, 0.08), transparent 32rem),
    linear-gradient(145deg, #090a0f 0%, #10141c 48%, #090a0f 100%);
}

.dashboard-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 20px 46px;
}

.dashboard-topbar,
.dashboard-auth,
.dashboard-toolbar,
.dashboard-panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 19, 27, 0.88);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
}

.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
}

.dashboard-topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboard-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #fbbf24;
  box-shadow: 0 0 0 5px rgba(251, 191, 36, 0.12);
}

.status-dot[data-kind="ok"] {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(94, 234, 212, 0.12);
}

.status-dot[data-kind="error"] {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(251, 113, 133, 0.12);
}

.dashboard-auth {
  margin-top: 16px;
  padding: 16px;
}

.dashboard-auth label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.auth-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.auth-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  outline: none;
  background: #0b0f17;
  color: var(--text);
  font: inherit;
}

.auth-row input:focus {
  border-color: rgba(94, 234, 212, 0.58);
  box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.09);
}

.dashboard-auth p,
.dashboard-toolbar span {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.dashboard-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
}

.dashboard-toolbar button,
.auth-row button,
.toolbar-link {
  min-width: auto;
  height: 40px;
  border-radius: 8px;
  padding: 0 14px;
}

.dashboard-toolbar button:not(:first-child) {
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--line);
}

.toolbar-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(11, 15, 23, 0.72);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric-card {
  min-height: 92px;
  padding: 14px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 1.7rem;
  line-height: 1;
  letter-spacing: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.dashboard-panel {
  min-height: 260px;
  padding: 16px;
  overflow: hidden;
}

.dashboard-panel.wide {
  grid-column: 1 / -1;
}

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

.panel-heading h2 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.8rem;
}

.key-values {
  margin: 0;
}

.key-values div {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.key-values dt {
  color: var(--muted);
}

.key-values dd {
  margin: 0;
  color: var(--text);
  text-align: right;
  overflow-wrap: anywhere;
}

.item-list {
  display: grid;
  gap: 10px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.dash-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(11, 15, 23, 0.58);
}

.dash-item strong,
.dash-item span,
.dash-item p {
  display: block;
}

.dash-item strong {
  font-size: 0.9rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.dash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.dash-actions button {
  min-width: auto;
  height: 34px;
  border-radius: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font-size: 0.8rem;
}

.skill-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.skill-form input,
.skill-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
  background: #0b0f17;
  color: var(--text);
  font: inherit;
}

.skill-form textarea {
  grid-column: 1 / 3;
  min-height: 92px;
  resize: vertical;
}

.skill-form button {
  min-width: auto;
  height: auto;
  border-radius: 8px;
  padding: 0 14px;
}

.dash-item span {
  margin-top: 5px;
  color: var(--accent);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.dash-item p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .skill-form {
    grid-template-columns: 1fr;
  }

  .skill-form textarea {
    grid-column: auto;
  }
}

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

  .dashboard-topbar,
  .auth-row {
    grid-template-columns: 1fr;
  }

  .dashboard-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card strong {
    font-size: 1.45rem;
  }

  .dashboard-toolbar button,
  .auth-row button {
    width: 100%;
  }
}
