:root {
  --bg: #050914;
  --panel: rgba(18, 28, 40, 0.86);
  --panel-deep: rgba(10, 16, 27, 0.94);
  --panel-soft: rgba(32, 48, 62, 0.68);
  --primary: #7fffd4;
  --primary-strong: #35f3ba;
  --primary-soft: rgba(127, 255, 212, 0.18);
  --accent: #ff6b73;
  --blue: #8fd7ff;
  --gold: #ffd681;
  --text: #f6fbff;
  --muted: #a9b7c7;
  --muted-strong: #c9d6e0;
  --border: rgba(176, 212, 230, 0.28);
  --border-bright: rgba(127, 255, 212, 0.72);
  --shadow: rgba(0, 0, 0, 0.42);
  --glow: rgba(127, 255, 212, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(127, 255, 212, 0.13), transparent 30%),
    radial-gradient(circle at 88% 8%, rgba(143, 215, 255, 0.1), transparent 34%),
    linear-gradient(135deg, #07101d 0%, #050914 54%, #02040a 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.95), transparent 78%);
  z-index: 0;
}

button,
textarea {
  font: inherit;
}

.matrix-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.1;
  z-index: 0;
}

.lab-shell {
  position: relative;
  z-index: 1;
  width: min(1530px, calc(100vw - 48px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  grid-template-areas:
    "chat mission"
    "footer footer";
  gap: 26px;
  align-content: center;
  padding: 38px 0 20px;
}

.chat-panel,
.mission-panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(24, 36, 50, 0.92), rgba(8, 14, 24, 0.92)),
    var(--panel);
  box-shadow:
    0 20px 60px var(--shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 34px rgba(127, 255, 212, 0.08);
  overflow: hidden;
}

.chat-panel {
  grid-area: chat;
  min-height: min(820px, calc(100vh - 118px));
  display: flex;
  flex-direction: column;
}

.chat-panel::after {
  content: "";
  position: absolute;
  right: 30px;
  bottom: 196px;
  width: 285px;
  aspect-ratio: 3 / 2;
  background: url("/assets/hackersir-peek-cat.png") center bottom / contain no-repeat;
  opacity: 0.46;
  filter: drop-shadow(0 0 22px var(--glow));
  pointer-events: none;
  z-index: 1;
}

.lab-header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 26px;
  align-items: center;
  padding: 26px 28px 20px;
  border-bottom: 1px solid rgba(176, 212, 230, 0.25);
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.brand-avatar {
  width: 112px;
  height: 112px;
  object-fit: contain;
  object-position: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 24px rgba(127, 255, 212, 0.22);
}

.brand {
  margin: 0 0 4px;
  color: var(--primary);
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #ffffff;
  font-size: 3.4rem;
  line-height: 1.06;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.18);
}

.subtitle {
  flex: 0 0 auto;
  max-width: 350px;
  padding: 14px 24px;
  border: 2px solid rgba(127, 255, 212, 0.74);
  border-radius: 999px;
  color: #f8ffff;
  background: rgba(16, 26, 37, 0.82);
  box-shadow: inset 0 0 22px rgba(127, 255, 212, 0.08);
  font-size: 1.08rem;
  line-height: 1.45;
  text-align: center;
}

.subtitle span,
.footer-slogan span {
  color: var(--accent);
}

.status-row {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px 8px;
  color: var(--primary);
}

.status-pill,
.connection-status {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border: 1px solid rgba(176, 212, 230, 0.26);
  border-radius: 999px;
  color: var(--muted-strong);
  background: rgba(10, 16, 27, 0.74);
  box-shadow: inset 0 0 16px rgba(255, 255, 255, 0.03);
}

.status-pill::before {
  content: "⛨";
  color: var(--primary);
}

.connection-status::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 14px var(--primary);
}

.capture-banner {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 7px;
  margin: 14px 28px 0;
  padding: 18px 20px;
  border: 1px solid rgba(127, 255, 212, 0.9);
  border-radius: 18px;
  color: #041910;
  background: linear-gradient(135deg, #8dffd9, #21f1a5);
  box-shadow: 0 0 26px rgba(127, 255, 212, 0.58);
  animation: pulseCapture 1s ease-in-out infinite alternate;
}

.capture-banner[hidden] {
  display: none;
}

.capture-banner strong {
  color: #00170e;
  font-size: 1.2rem;
}

.messages {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 360px;
  overflow-y: auto;
  padding: 34px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

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

.message-avatar {
  flex: 0 0 auto;
  width: 78px;
  height: 78px;
  object-fit: contain;
  object-position: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  filter: drop-shadow(0 0 15px rgba(127, 255, 212, 0.16));
}

.message {
  max-width: min(76%, 720px);
  padding: 24px 26px;
  border: 1px solid rgba(176, 212, 230, 0.28);
  border-radius: 24px;
  color: var(--text);
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  backdrop-filter: blur(10px);
}

.message .label {
  display: block;
  margin-bottom: 9px;
  color: var(--primary);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.2;
}

.message-content {
  display: block;
}

.message-highlight {
  font-family: Consolas, "Courier New", monospace;
  font-weight: 700;
}

.message-highlight.primary {
  color: var(--primary);
  text-shadow: 0 0 14px rgba(127, 255, 212, 0.28);
}

.message-highlight.danger {
  color: var(--accent);
  text-shadow: 0 0 14px rgba(255, 107, 115, 0.26);
}

.message.bot {
  background: linear-gradient(145deg, rgba(33, 47, 62, 0.9), rgba(17, 27, 40, 0.9));
  box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.035);
}

.message.user {
  max-width: min(44%, 420px);
  border-color: rgba(143, 215, 255, 0.56);
  background: rgba(37, 70, 96, 0.42);
}

.message.thinking {
  color: var(--gold);
  border-color: rgba(255, 214, 129, 0.42);
  background: rgba(255, 214, 129, 0.08);
}

.composer {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 14px;
  margin: 0 28px 22px;
  padding: 14px 16px 16px;
  border: 1px solid rgba(127, 255, 212, 0.34);
  border-radius: 26px;
  background: rgba(42, 75, 66, 0.36);
  box-shadow: inset 0 0 22px rgba(127, 255, 212, 0.08);
}

textarea {
  width: 100%;
  min-height: 94px;
  max-height: 190px;
  resize: vertical;
  border: 2px solid rgba(127, 255, 212, 0.78);
  border-radius: 20px;
  padding: 20px 64px 18px 24px;
  color: var(--text);
  background: rgba(4, 8, 14, 0.86);
  outline: none;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.26);
}

textarea::placeholder {
  color: rgba(201, 214, 224, 0.72);
}

textarea:focus {
  border-color: var(--primary);
  box-shadow:
    0 0 0 4px rgba(127, 255, 212, 0.12),
    inset 0 0 20px rgba(0, 0, 0, 0.24);
}

.composer::after {
  content: "";
  position: absolute;
  right: 36px;
  top: 48px;
  width: 34px;
  height: 30px;
  background: rgba(201, 214, 224, 0.34);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 56'%3E%3Cpath d='M12 48c-7-7-7-20-3-29L7 7l13 9a34 34 0 0 1 24 0L57 7l-2 12c4 9 4 22-3 29-8 8-32 8-40 0Z' fill='none' stroke='black' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 56'%3E%3Cpath d='M12 48c-7-7-7-20-3-29L7 7l13 9a34 34 0 0 1 24 0L57 7l-2 12c4 9 4 22-3 29-8 8-32 8-40 0Z' fill='none' stroke='black' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 192px;
  gap: 18px;
}

button {
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 2px solid var(--border-bright);
  border-radius: 18px;
  color: #032014;
  background: linear-gradient(135deg, #a0ffe0, #48e9ad);
  box-shadow: 0 10px 28px rgba(53, 243, 186, 0.18);
  cursor: pointer;
  font-weight: 700;
}

button:hover:not(:disabled) {
  filter: brightness(1.05);
  box-shadow: 0 0 22px rgba(127, 255, 212, 0.32);
}

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

#resetButton {
  color: var(--primary);
  background: rgba(9, 17, 28, 0.78);
}

.mission-panel {
  grid-area: mission;
  min-height: min(820px, calc(100vh - 118px));
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.mission-hero {
  position: relative;
  min-height: 230px;
  border: 1px solid rgba(176, 212, 230, 0.22);
  border-radius: 20px;
  background:
    linear-gradient(rgba(127, 255, 212, 0.05), rgba(127, 255, 212, 0.01)),
    rgba(8, 14, 24, 0.8);
  overflow: hidden;
}

.mission-hero::before {
  content: "100 010 110 001 101";
  position: absolute;
  left: 24px;
  top: 20px;
  width: 150px;
  color: rgba(127, 255, 212, 0.18);
  font-family: Consolas, "Courier New", monospace;
  font-size: 1rem;
  line-height: 1.3;
  word-spacing: 12px;
}

.mission-hero img {
  position: absolute;
  right: 10px;
  bottom: -42px;
  width: 255px;
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, 0.34));
}

.terminal-mark {
  position: absolute;
  left: 22px;
  bottom: 22px;
  min-width: 64px;
  min-height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(127, 255, 212, 0.32);
  border-radius: 8px;
  color: var(--primary);
  background: rgba(11, 22, 31, 0.75);
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.35rem;
}

.spark {
  position: absolute;
  color: var(--primary);
  text-shadow: 0 0 16px rgba(127, 255, 212, 0.55);
}

.spark-one {
  right: 92px;
  top: 44px;
}

.spark-two {
  left: 86px;
  top: 90px;
}

.mission-panel h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--primary);
  font-size: 2rem;
  line-height: 1.2;
}

.mission-panel h2 span {
  color: var(--gold);
  font-size: 1.25rem;
}

.mission-panel p {
  color: var(--muted-strong);
  line-height: 1.7;
}

.target {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: center;
  padding: 18px 20px;
  border: 1px dashed rgba(127, 255, 212, 0.75);
  border-radius: 16px;
  background: rgba(28, 58, 56, 0.42);
}

.target span:first-child {
  grid-column: 1 / -1;
  color: var(--muted-strong);
}

.target code {
  color: var(--primary);
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.3rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.lock {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--gold);
  background: rgba(255, 214, 129, 0.09);
}

.hints {
  display: grid;
  gap: 12px;
  margin-top: 2px;
}

details {
  border: 1px solid rgba(176, 212, 230, 0.35);
  border-radius: 14px;
  background: rgba(17, 27, 40, 0.74);
  overflow: hidden;
}

summary {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "⌄";
  margin-left: auto;
  color: var(--muted-strong);
}

details[open] summary::after {
  content: "⌃";
}

details p {
  padding: 0 20px 18px 54px;
  color: var(--muted);
}

.lab-footer {
  grid-area: footer;
  display: grid;
  grid-template-columns: auto auto minmax(120px, 1fr) auto;
  gap: 18px;
  align-items: center;
  color: rgba(201, 214, 224, 0.78);
  font-family: Consolas, "Courier New", monospace;
}

.level-chip,
.footer-slogan {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border: 1px solid rgba(127, 255, 212, 0.36);
  border-radius: 999px;
  color: var(--primary);
  background: rgba(13, 26, 34, 0.78);
}

.footer-dots {
  height: 2px;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.55) 1px, transparent 1px);
  background-size: 14px 2px;
}

.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;
}

@keyframes pulseCapture {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-2px);
  }
}

@media (max-width: 1420px) and (min-width: 1181px) {
  .lab-shell {
    width: min(100vw - 28px, 1340px);
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 22px;
  }

  .brand-avatar {
    width: 86px;
    height: 86px;
  }

  .brand-cluster {
    gap: 14px;
  }

  h1 {
    font-size: 2.55rem;
  }

  .subtitle {
    max-width: 270px;
    padding: 12px 16px;
    font-size: 0.96rem;
  }

  .message-avatar {
    width: 64px;
    height: 64px;
  }

  .message {
    max-width: min(74%, 660px);
  }

  .mission-hero img {
    width: 220px;
  }

  .chat-panel::after {
    right: 20px;
    bottom: 190px;
    width: 238px;
  }

  .target code {
    font-size: 1.1rem;
  }

  .button-row {
    grid-template-columns: 1fr 160px;
  }
}

@media (max-width: 1180px) {
  .lab-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "chat"
      "mission"
      "footer";
    align-content: start;
    padding-top: 20px;
  }

  .chat-panel,
  .mission-panel {
    min-height: auto;
  }

  .mission-panel {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
  }

  .mission-hero {
    grid-row: span 6;
  }
}

@media (max-width: 760px) {
  .lab-shell {
    width: min(100vw - 24px, 560px);
    gap: 16px;
    padding: 12px 0 18px;
  }

  .lab-header,
  .status-row {
    flex-direction: column;
    align-items: stretch;
  }

  .brand-cluster {
    gap: 14px;
  }

  .brand-avatar {
    width: 76px;
    height: 76px;
  }

  .brand {
    font-size: 1.1rem;
  }

  h1 {
    font-size: 2rem;
  }

  .subtitle {
    max-width: none;
    padding: 12px 16px;
  }

  .messages {
    padding: 22px 16px;
  }

  .message-avatar {
    width: 52px;
    height: 52px;
  }

  .message,
  .message.user {
    max-width: min(100%, 520px);
    padding: 18px;
    border-radius: 18px;
  }

  .chat-panel::after {
    right: -18px;
    bottom: 260px;
    width: 190px;
    opacity: 0.28;
  }

  .composer {
    margin: 0 14px 16px;
  }

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

  .mission-panel {
    display: flex;
    padding: 16px;
  }

  .mission-hero {
    min-height: 190px;
  }

  .mission-hero img {
    width: 210px;
  }

  .lab-footer {
    grid-template-columns: 1fr;
  }

  .footer-dots {
    display: none;
  }
}
