/* ==========================================================================
   Gerege AI Nexus — console theme

   A gerege was the Mongol Empire's tablet of authority; the courier carrying
   one drew fresh horses at every relay station. The palette is that object:
   patinated bronze in shadow, struck gold where the light lands. Warm darks
   throughout — a blue-black ground would fight the gold rather than hold it.
   ========================================================================== */

:root {
  /* Ground and surfaces, warm rather than neutral */
  --ink:        #100E09;
  --surface:    #1A160E;
  --surface-2:  #221D13;
  --line:       #342C1B;
  --line-soft:  #262013;

  /* The metal itself, dark to bright */
  --bronze:     #8A6A32;
  --gold:       #E3BE72;
  --gold-bright:#F5DDA6;

  /* Type */
  --text:       #EFE7D5;
  --muted:      #A0937A;
  --faint:      #6F6650;

  /* Semantics, chosen to sit beside gold without clashing */
  --jade:       #6E9E7A;
  --lacquer:    #C05A4A;

  --font-display: 'Bitter', Georgia, 'Times New Roman', serif;
  --font-ui: 'Golos Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 264px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* The sprite is a definitions carrier, never rendered in flow. */
.sprite { display: none; }

/*
  Flaticon UICONS arrive as :before glyphs on <i>, so they scale with font-size
  and sit on a text baseline. Making each one a flex box centres it optically
  against its label instead of letting it ride that baseline.
*/
.fi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  font-size: 17px;
  line-height: 1;
}

/* The gerege mark is drawn, not borrowed — no icon library ships a paiza. */
.mark {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

a { color: var(--gold); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app-container {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 26px 18px;
  background: linear-gradient(180deg, #16120B, #100E09);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
}

/* --------------------------------------------------------------------------
   Brand — the plate is the one loud element; everything else stays quiet
   -------------------------------------------------------------------------- */

.brand-header {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line-soft);
}

.brand-logo { flex: none; }

.plate {
  width: 38px;
  height: 46px;
  display: block;
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.55));
}

.plate-edge   { fill: none; stroke: #6B4F22; stroke-width: 1.1; }
.plate-inner  { fill: none; stroke: rgba(72, 50, 16, 0.55); stroke-width: 0.9; }
.plate-script { stroke: rgba(72, 50, 16, 0.65); stroke-width: 1.5; stroke-linecap: round; }

/* Light crossing metal: one sweep on load, not a loop. */
.plate-sheen {
  fill: rgba(255, 255, 255, 0.5);
  transform: skewX(-18deg) translateX(0);
  animation: plate-sheen 1500ms ease-out 350ms 1 both;
}

@keyframes plate-sheen {
  from { transform: skewX(-18deg) translateX(0); }
  to   { transform: skewX(-18deg) translateX(78px); }
}

.brand-info { min-width: 0; }

.brand-info h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.2;
}

.badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--bronze);
}

/* --------------------------------------------------------------------------
   Navigation — active state is a struck gold rule, not a filled slab
   -------------------------------------------------------------------------- */

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.nav-item:hover { color: var(--text); background: rgba(227, 190, 114, 0.05); }

.nav-item.active {
  color: var(--gold);
  background: rgba(227, 190, 114, 0.09);
  border-left-color: var(--gold);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--muted);
}

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

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}

.dot.online {
  background: var(--jade);
  box-shadow: 0 0 0 0 rgba(110, 158, 122, 0.5);
  animation: pulse 2.6s ease-out infinite;
}

@keyframes pulse {
  70%  { box-shadow: 0 0 0 7px rgba(110, 158, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(110, 158, 122, 0); }
}

.footer-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.version-tag { font-family: var(--font-mono); color: var(--faint); }

/* Flaticon's free licence requires visible credit; it stays quiet but present. */
.attribution {
  font-size: 11px;
  color: var(--faint);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.attribution:hover { color: var(--bronze); border-bottom-color: var(--bronze); }

/* --------------------------------------------------------------------------
   Main
   -------------------------------------------------------------------------- */

.main-content { padding: 26px 30px 44px; min-width: 0; }

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line-soft);
}

.top-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.btn .fi { font-size: 16px; }

.btn-primary {
  background: linear-gradient(180deg, var(--gold), #C79A4E);
  color: #221806;
  border-color: #C79A4E;
  font-weight: 600;
}

.btn-primary:hover { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); }

.btn-outline {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn-outline:hover { border-color: var(--bronze); color: var(--gold); }

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */

.tab-content { display: none; }
.tab-content.active { display: block; animation: rise 260ms ease-out both; }

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

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.card h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
}

.card h3 .fi { color: var(--gold); font-size: 16px; }

.cards-layout { display: grid; gap: 18px; }
.grid-span-2 { grid-column: 1 / -1; }

/* Metrics ------------------------------------------------------------------ */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

/* A hairline of gold along the top edge — the light catching a struck plate. */
.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--bronze), transparent);
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--radius-sm);
  background: rgba(227, 190, 114, 0.09);
  border: 1px solid rgba(227, 190, 114, 0.16);
  color: var(--gold);
}

.metric-icon .fi { font-size: 19px; }

.metric-body { min-width: 0; flex: 1; }

.metric-label {
  display: block;
  font-size: 11.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-body h3 {
  margin: 5px 0 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.metric-sub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--faint);
  overflow-wrap: anywhere;
}

.progress-bar {
  margin-top: 9px;
  height: 5px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--bronze), var(--gold));
  transition: width 500ms ease;
}

/* Endpoints ---------------------------------------------------------------- */

.endpoints-list { display: flex; flex-direction: column; gap: 8px; }

.endpoint-item {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.endpoint-item code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.method {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  flex: none;
}

.method.get  { background: rgba(110, 158, 122, 0.14); color: var(--jade); }
.method.post { background: rgba(227, 190, 114, 0.14); color: var(--gold); }

.desc {
  margin-left: auto;
  font-size: 12px;
  color: var(--faint);
}

/* Tools -------------------------------------------------------------------- */

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 14px;
}

.tool-card {
  padding: 15px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  transition: border-color 140ms ease;
}

.tool-card:hover { border-color: var(--bronze); }

.tool-card h4 {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--gold);
  overflow-wrap: anywhere;
}

.tool-card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* Memory ------------------------------------------------------------------- */

.memory-search-bar { display: flex; gap: 10px; margin-bottom: 18px; }
.insights-list { display: flex; flex-direction: column; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

input[type="text"], select {
  width: 100%;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 140ms ease;
}

input[type="text"]::placeholder { color: var(--faint); }
input[type="text"]:focus, select:focus { border-color: var(--bronze); outline: none; }
input[type="text"]:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

.form-card { max-width: 560px; }
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Chat
   -------------------------------------------------------------------------- */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 165px);
  min-height: 380px;
  padding: 0;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message { display: flex; gap: 12px; max-width: 780px; }
.chat-message.user { flex-direction: row-reverse; margin-left: auto; }

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: rgba(227, 190, 114, 0.1);
  border: 1px solid rgba(227, 190, 114, 0.2);
  color: var(--gold);
}

.chat-message.user .avatar {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--muted);
}

.msg-content {
  padding: 12px 15px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.chat-message.user .msg-content { background: rgba(227, 190, 114, 0.07); border-color: rgba(227, 190, 114, 0.18); }

.msg-content strong { color: var(--gold); font-weight: 600; }
.chat-message.user .msg-content strong { color: var(--muted); }

.msg-content pre {
  margin: 9px 0 0;
  padding: 11px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.msg-content code { font-family: var(--font-mono); font-size: 12.5px; }

.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 15px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

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

  .sidebar {
    position: static;
    height: auto;
    gap: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-menu { flex-direction: row; flex-wrap: wrap; }

  .nav-item {
    width: auto;
    border-left: 0;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm);
  }

  .nav-item.active { border-left-color: transparent; border-bottom-color: var(--gold); }

  .main-content { padding: 20px 18px 36px; }
  .chat-container { height: auto; min-height: 460px; }
  .desc { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
