:root {
  --bg: #09090d;
  --panel: #101016;
  --panel-2: #0d0d12;
  --border: rgba(104, 75, 222, 0.28);
  --border-soft: rgba(104, 75, 222, 0.14);

  --accent: #684bde;
  --accent-bright: #8b6bff;
  --accent-soft: rgba(104, 75, 222, 0.15);

  --green: #4ade80;
  --amber: #fbbf24;
  --cyan: #38bdf8;
  --red: #ff5f56;

  --text: #e7e7ee;
  --text-dim: #8a8a99;
  --text-faint: #55555f;

  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
}

.page {
  display: flex;
  height: 100vh;
}

/* ---------- Preloader ---------- */

.preloader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  cursor: pointer;
  transition: opacity 0.35s ease;
}

.preloader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.preloader-inner {
  width: 280px;
  text-align: left;
}

.preloader-glyph {
  font-size: 13px;
  color: var(--accent-bright);
  font-weight: 600;
  margin-bottom: 18px;
  white-space: nowrap;
}

.preloader-status {
  font-size: 12.5px;
  color: var(--text-dim);
  min-height: 1.4em;
  margin-bottom: 14px;
}

.preloader-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--border-soft);
  overflow: hidden;
  margin-bottom: 8px;
}

.preloader-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  transition: width 0.12s linear;
}

.preloader-pct {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 20px;
}

.preloader-hint {
  font-size: 11px;
  color: var(--text-faint);
  opacity: 0.7;
}

/* ---------- Terminal pane ---------- */

.terminal-pane {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.matrix-canvas {
  position: fixed;
  z-index: 50;
  cursor: pointer;
}

.terminal-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border-soft);
}

.tb-dots {
  display: flex;
  gap: 6px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
  opacity: 0.85;
}
.dot-red { background: var(--red); }
.dot-yellow { background: var(--amber); }
.dot-green { background: var(--green); }

.tb-title {
  flex: 1 1 auto;
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
  letter-spacing: 0.02em;
}

.mode-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 auto;
}

.mode-btn {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 4px 12px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.mode-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.mode-btn:not([aria-pressed="true"]):hover {
  color: var(--text);
}

.terminal-output {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.terminal-output::-webkit-scrollbar {
  width: 8px;
}
.terminal-output::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.line {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.6em;
}

.line.echo {
  color: var(--text);
}
.line.echo .prompt-echo {
  color: var(--accent-bright);
  margin-right: 6px;
}

.line.blank { min-height: 1.6em; }

.hl   { color: var(--accent-bright); font-weight: 600; }
.ok   { color: var(--green); }
.warn { color: var(--amber); }
.link { color: var(--cyan); }
.dim  { color: var(--text-dim); }

a.term-link {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px dashed rgba(56, 189, 248, 0.5);
}
a.term-link:hover {
  color: var(--accent-bright);
  border-bottom-color: var(--accent-bright);
}

.badge {
  display: inline-block;
  padding: 0 6px;
  margin-right: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent-bright);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  vertical-align: 1px;
}

.exp-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 6px;
}

.exp-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 4px;
}

.company-logo-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 64px;
  height: 36px;
}

.company-logo {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.gopher-img {
  display: block;
  width: 140px;
  height: auto;
  margin: 6px 0 10px;
}

.cursor-tail {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: var(--accent-bright);
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* Preset buttons */

.presets-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 20px 14px;
}

.preset-btn {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 6px 14px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.preset-btn:hover {
  background: var(--accent);
  color: #fff;
}
.preset-btn:active {
  transform: scale(0.96);
}

/* Input line */

.input-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 18px;
  border-top: 1px solid var(--border-soft);
}

.prompt {
  color: var(--accent-bright);
  font-weight: 600;
  flex: 0 0 auto;
}

.cmd-input {
  flex: 1 1 auto;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  caret-color: var(--accent-bright);
}

.cmd-input::placeholder {
  color: var(--text-faint);
}

.stop-btn {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  padding: 5px 10px;
  background: transparent;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.stop-btn:hover {
  opacity: 1;
  color: var(--red);
  border-color: var(--red);
}

.stop-btn.is-active {
  opacity: 1;
  color: var(--red);
  border-color: var(--red);
  background: rgba(255, 95, 86, 0.12);
}

/* ---------- Profile pane ---------- */

.profile-pane {
  flex: 0 0 320px;
  min-height: 0;
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px -16px rgba(104, 75, 222, 0.6) inset;
  background: var(--panel-2);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.profile-card {
  width: 100%;
  padding: 28px 24px;
  text-align: left;
}

.profile-links {
  display: flex;
  gap: 10px;
  padding: 0 24px 24px;
  flex: 0 0 auto;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent-bright);
  background: var(--accent-soft);
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.icon-btn:hover {
  background: var(--accent);
  color: #fff;
}

.icon-btn:active {
  transform: scale(0.94);
}

.profile-photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 12px 32px -12px rgba(104, 75, 222, 0.5);
  margin-bottom: 18px;
}

.profile-name {
  font-size: 18px;
  margin: 0 0 4px;
  color: var(--text);
  text-align: left;
}

.profile-role {
  margin: 0 0 14px;
  color: var(--accent-bright);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.profile-desc {
  margin: 0;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.7;
  text-align: left;
}

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

@media (max-width: 860px) {
  .page {
    flex-direction: column;
  }

  .terminal-topbar {
    padding: 8px 12px;
  }

  .tb-title {
    font-size: 11px;
  }

  .profile-pane {
    order: -1;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    overflow: visible;
    border-left: none;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 24px -16px rgba(104, 75, 222, 0.6) inset;
  }

  .profile-card {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .profile-photo {
    width: 44px;
    height: 44px;
    aspect-ratio: auto;
    border-radius: 8px;
    margin-bottom: 0;
    flex: 0 0 auto;
  }

  .profile-text {
    flex: 1 1 auto;
    min-width: 0;
  }

  .profile-name {
    font-size: 13.5px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .profile-role {
    font-size: 11px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .profile-desc {
    display: none;
  }

  .profile-links {
    flex: 0 0 auto;
    padding: 0;
    gap: 6px;
  }

  .icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
  }

  .icon-btn svg {
    width: 15px;
    height: 15px;
  }

  .terminal-output {
    padding: 12px 14px 4px;
  }

  .presets-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 14px 10px;
  }

  .input-line {
    padding: 10px 14px 14px;
  }
}
