:root {
  --bg: #0A0A0A;
  --bg-raised: #131313;
  --ticket: #101010;
  --text: #EDEDED;
  --text-muted: #6E6E6E;
  --text-dim: #4A4A4A;
  --rule: #232323;
  --amber: #D6A75A;
  --teal: #6FA79A;
  --rust: #C1633F;
  --radius: 2px;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Work Sans', sans-serif;
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--rule);
  padding: 20px 16px 84px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar.hidden { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sidebar-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Hamburger toggle button (lives in topbar) */
.hamburger {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  padding: 4px;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-muted);
  border-radius: 1px;
  transition: transform 0.22s ease, opacity 0.22s ease, background 0.12s ease;
  transform-origin: center;
}

.hamburger:hover span { background: var(--text); }

/* Animate into an × when sidebar is open */
.hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.hamburger.is-open span { background: var(--amber); }

.app-main {
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.wordmark {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.wordmark-accent { color: var(--amber); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.entry-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border: 1px solid var(--rule);
  padding: 6px 10px;
}

.nav-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 7px 12px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.nav-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 72px 24px 100px;
}

.hero {
  margin-bottom: 48px;
}

.hero h1 {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  text-transform: uppercase;
}

.hero-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  line-height: 1.7;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0;
  text-transform: uppercase;
}

.ask-box {
  border: 1px dashed var(--rule);
  padding: 36px 28px;
  margin-bottom: 20px;
}

#ask-form {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ask-mark {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.4rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

#query {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: 10px 2px;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.95rem;
}

#query::placeholder { color: var(--text-dim); }

#query:focus {
  outline: none;
  border-bottom-color: var(--amber);
}

#ask-form button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 10px 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

#ask-form button:hover { border-color: var(--amber); color: var(--amber); }
#ask-form button:active { transform: scale(0.98); }

#ask-form button:focus-visible,
#query:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 56px;
}

.quick-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-right: 4px;
}

.quick-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  padding: 7px 11px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.quick-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 48px 20px;
  border: 1px dashed var(--rule);
}

.empty-state.hidden { display: none; }

.ticket-icon { font-size: 1.6rem; margin-bottom: 12px; color: var(--text-dim); }
.empty-sub { font-size: 0.82rem; margin-top: 8px; }
.empty-state p {
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.03em;
  font-size: 0.8rem;
  text-transform: uppercase;
}

#tickets {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.ticket {
  background: var(--ticket);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 24px 26px;
  animation: rise 0.3s ease;
}

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

.ticket-serial {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.ticket-serial-api {
  color: var(--rust);
}

.ticket-question {
  font-family: 'Work Sans', sans-serif;
  font-weight: 600;
  font-size: 1.08rem;
  margin: 0 0 14px;
  color: var(--text);
}

.ticket-answer {
  font-size: 0.94rem;
  line-height: 1.65;
  color: #C9C9C9;
}

.ticket-answer p {
  margin: 0 0 12px;
}

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

.ticket-answer strong {
  color: var(--text);
  font-weight: 600;
}

.ticket-answer em {
  font-style: italic;
  color: var(--text);
}

.ticket-answer ul,
.ticket-answer ol {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  counter-reset: ticket-li;
}

.ticket-answer ul:last-child,
.ticket-answer ol:last-child {
  margin-bottom: 0;
}

.ticket-answer li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 8px;
}

.ticket-answer li:last-child {
  margin-bottom: 0;
}

.ticket-answer ul li::before {
  content: "\2014";
  position: absolute;
  left: 0;
  color: var(--text-dim);
}

.ticket-answer ol li {
  counter-increment: ticket-li;
}

.ticket-answer ol li::before {
  content: counter(ticket-li) ".";
  position: absolute;
  left: 0;
  color: var(--text-dim);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
}

.ticket-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.stamp {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0;
}

.stamp::before { content: "[ "; }
.stamp::after { content: " ]"; }

.stamp.kb { color: var(--teal); }
.stamp.cache { color: var(--amber); }
.stamp.api { color: var(--rust); }

.ticket.loading .ticket-answer {
  color: var(--text-dim);
}

/* Pulsing text shown while a ticket is loading */
@keyframes pulse-opacity {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.loading-pulse {
  animation: pulse-opacity 1.4s ease-in-out infinite;
  display: inline-block;
}

/* Mobile sidebar backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sidebar-backdrop.visible {
  display: block;
}

.history-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.history-item {
  background: var(--ticket);
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 10px 12px;
  font-size: 0.86rem;
  cursor: pointer;
}

.history-item:hover { border-color: var(--text-muted); }

.terminal-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 46px;
  height: 46px;
  border-radius: 0;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--rule);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  transition: border-color 0.12s ease;
}

.terminal-fab:hover { border-color: var(--amber); color: var(--amber); }

.terminal-panel {
  position: fixed;
  bottom: 82px;
  right: 24px;
  width: 420px;
  height: 380px;
  min-width: 320px;
  min-height: 220px;
  max-width: 90vw;
  max-height: 80vh;
  background: #1E1E1E;
  border: 1px solid #000;
  border-radius: 8px;
  z-index: 55;
  display: flex;
  flex-direction: column;
  overflow: auto;
  resize: both;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
}

.terminal-panel.hidden { display: none; }

.terminal-panel::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 10px;
  height: 10px;
  pointer-events: none;
  background-image:
    linear-gradient(135deg, transparent 0 40%, #6A6A6A 40% 46%, transparent 46% 60%, #6A6A6A 60% 66%, transparent 66% 80%, #6A6A6A 80% 86%, transparent 86%);
  opacity: 0.7;
}

.terminal-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-bottom: 1px solid #000;
  background: linear-gradient(#3A3A3A, #2C2C2C);
  flex-shrink: 0;
}

.terminal-dots {
  position: absolute;
  left: 12px;
  display: flex;
  gap: 7px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.dot-red { background: #FF5F56; }
.dot-yellow { background: #FFBD2E; }
.dot-green { background: #27C93F; }

.terminal-title {
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: #B8B8B8;
}

.terminal-close {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: #8A8A8A;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.terminal-close:hover { color: #EDEDED; }

.terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  background: #1E1E1E;
}

.terminal-line {
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 4px;
}

.github-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    color: #fff;
    font-size: 1.4rem;
    text-decoration: none;
    border-radius: 50%;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.github-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.08);
}
.terminal-muted { color: #7A7A7A; }
.terminal-query { color: #F2F2F2; }
.terminal-kb { color: #6FD98E; }
.terminal-cache { color: #E8B95F; }
.terminal-api { color: #FF8368; }

/* ── Mobile & Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Terminal panel: near-fullscreen instead of tiny corner popup */
  .terminal-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 55vh;
    min-height: 260px;
    border-radius: 12px 12px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    resize: none;
  }

  /* Sidebar becomes a full-height overlay drawer above the backdrop */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70; /* above backdrop (65) */
    background: var(--bg);
    box-shadow: 0 0 40px rgba(0,0,0,0.6);
  }

  .terminal-fab {
    bottom: 20px;
    right: 16px;
  }
}

@media (max-width: 560px) {
  /* Topbar */
  .topbar {
    padding: 14px 16px;
  }

  /* When sidebar is collapsed the expand button sits top-left;
     don't shove the topbar content into the middle of the screen */
  body.sidebar-collapsed .topbar {
    padding-left: 16px;
  }

  /* Sidebar expand button: tuck it at bottom-left */
  .sidebar-expand {
    top: auto;
    bottom: 20px;
    left: 16px;
    font-size: 0.68rem;
    padding: 7px 10px;
  }

  /* Main content */
  main {
    padding: 32px 16px 100px;
  }

  /* Hero */
  .hero {
    margin-bottom: 32px;
  }

  /* Ask box */
  .ask-box {
    padding: 24px 16px;
    margin-bottom: 16px;
  }

  /* Form: stack vertically on very small screens */
  #ask-form {
    flex-wrap: wrap;
    gap: 12px;
  }

  #ask-form button {
    width: 100%;
    padding: 12px 20px;
  }

  /* Quick-row: larger tap targets */
  .quick-row {
    gap: 8px;
    margin-bottom: 40px;
  }

  .quick-btn {
    padding: 9px 12px;
    font-size: 0.68rem;
  }

  /* Tickets */
  .ticket {
    padding: 18px 16px;
  }

  .ticket-question {
    font-size: 1rem;
  }

  .ticket-answer {
    font-size: 0.88rem;
  }
}