@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  --bg: #0a0d12;
  --panel: #11161e;
  --panel-2: #161d27;
  --border: #232d3b;
  --text: #eef3f8;
  --muted: #9aa8b8;
  --blue: #58a6ff;
  --green: #3fd8a4;
  --amber: #f5b74e;
  --red: #ff6b81;
  --mono: "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
.hidden { display: none !important; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  padding: 0 28px;
  background: rgba(10, 13, 18, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  gap: 40px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 38px; height: 38px; border-radius: 8px; }
.brand-text {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .03em;
  color: #fff;
}
.brand-text b { color: var(--green); font-weight: 600; }

.nav { display: flex; gap: 6px; }
.nav-link {
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.nav-link:hover { color: var(--text); background: var(--panel-2); }
.nav-link.active { color: var(--text); background: var(--panel-2); }

.reset-link {
  position: absolute;
  right: 28px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.reset-link:hover { color: var(--red); }

.view { display: none; padding: 40px 0 80px; }
.view.active { display: block; }

.hero, .stats-row, .list-controls { max-width: 1000px; margin-left: auto; margin-right: auto; }
.hero { margin-bottom: 36px; }
.hero h1 { margin: 0 0 12px; font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.hero p { margin: 0; max-width: 720px; color: var(--muted); font-size: 17px; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 36px; }
.stat-card {
  padding: 22px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.stat-value { display: block; font-family: var(--mono); font-size: 32px; font-weight: 500; }
.stat-value.green { color: var(--green); }
.stat-value.blue { color: var(--blue); }
.stat-label { color: var(--muted); font-size: 15px; }

.list-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-tabs button {
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.filter-tabs button:hover { color: var(--text); }
.filter-tabs button.active { background: var(--blue); border-color: var(--blue); color: #08111d; font-weight: 600; }

.search-input {
  width: 300px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.search-input:focus { border-color: var(--blue); }
.search-input::placeholder { color: var(--muted); }

.incident-grid { 
  display: grid; 
  grid-template-columns: repeat(2, 1fr); 
  gap: 20px; 
  max-width: 1000px;
  margin: 0 auto;
}

.incident-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  min-height: 220px;
}
.incident-card:hover { 
  border-color: var(--blue); 
  transform: translateY(-4px); 
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.incident-card h3 { margin: 0; font-size: 18px; font-weight: 600; color: var(--text); }
.incident-card p { margin: 0; color: var(--muted); font-size: 15px; }
.card-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-row .inc-id { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.difficulty { font-size: 14px; font-weight: 600; }
.difficulty.beginner { color: var(--green); }
.difficulty.intermediate { color: var(--amber); }
.difficulty.advanced { color: var(--red); }

.done-mark { color: var(--green); font-size: 14px; font-weight: 600; }
.empty-note { color: var(--muted); text-align: center; padding: 48px 0; font-size: 16px; }

.case-toolbar {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  margin: -40px 0 32px;
}
.case-toolbar-inner { display: flex; align-items: center; gap: 16px; height: 60px; flex-wrap: wrap; }
.back-link { border: 0; background: transparent; color: var(--muted); font-size: 15px; cursor: pointer; }
.back-link:hover { color: var(--text); }
.case-id { font-family: var(--mono); font-size: 15px; color: var(--muted); }

.severity {
  padding: 4px 10px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}
.severity.critical { background: rgba(255,107,129,.15); color: var(--red); }
.severity.high { background: rgba(245,183,78,.15); color: var(--amber); }

.case-timer { font-family: var(--mono); font-size: 15px; color: var(--muted); }
.case-actions { display: flex; gap: 10px; margin-left: auto; }

.btn {
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #08111d; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }

.case-intro { margin-bottom: 28px; }
.case-intro h1 { margin: 0 0 10px; font-size: 28px; }
.case-intro > p { margin: 0 0 14px; max-width: 860px; color: var(--muted); font-size: 16px; }
.case-meta { display: flex; gap: 24px; flex-wrap: wrap; font-size: 15px; color: var(--muted); }
.case-meta a { font-weight: 600; }

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.panel-heading {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.files-panel, .answers-panel {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

#artifactList + .panel-heading { margin-top: 24px; }

.artifact-button {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.artifact-button:hover { border-color: var(--border); }
.artifact-button.active { border-color: var(--blue); background: rgba(88,166,255,.1); color: var(--blue); }

.ioc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ioc-chip {
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  word-break: break-all;
  cursor: pointer;
}
.ioc-chip:hover { color: var(--text); border-color: var(--blue); }

.viewer {
  background: #0c1016;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.viewer-head strong { font-family: var(--mono); font-size: 15px; }
.viewer-search {
  width: 240px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c1016;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.viewer-search:focus { border-color: var(--blue); }

.viewer-body {
  min-height: 420px;
  max-height: 640px;
  overflow: auto;
  padding: 18px 22px;
  font-family: var(--mono);
  font-size: 14.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c9d5e1;
}
.tk-ip { color: var(--amber); }
.tk-domain { color: var(--blue); }
.tk-bad { color: var(--red); }
.tk-good { color: var(--green); }
mark.hit { background: rgba(245,183,78,.35); color: #ffe3ae; border-radius: 3px; padding: 0 2px; }

.field { display: block; margin-bottom: 20px; }
.field > span { display: block; margin-bottom: 8px; font-size: 15px; font-weight: 600; }
.field-help {
  display: block;
  margin: -3px 0 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c1016;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }
.field select {
  appearance: none;
  padding-right: 48px;
  background-color: #0c1016;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa8b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 14px;
  cursor: pointer;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #5c6a7a; }

.tag-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c1016;
}
.tag-box:focus-within { border-color: var(--blue); }
.tag-box input {
  width: auto;
  min-width: 110px;
  min-height: 32px;
  flex: 1 1 110px;
  border: 0;
  background: transparent;
  padding: 4px 6px;
  outline: none;
  font-size: 14px;
}
#iocTags { display: contents; }
.ioc-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 9px;
  border-radius: 6px;
  background: rgba(88,166,255,.12);
  border: 1px solid rgba(88,166,255,.35);
  color: var(--blue);
  font-family: var(--mono);
  font-size: 13px;
}
.ioc-tag button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0; }
.ioc-tag button:hover { color: var(--red); }

.choice-row { display: flex; gap: 10px; }
.choice-row label { flex: 1; }
.choice-row input { position: absolute; opacity: 0; }
.choice-row span {
  display: block;
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c1016;
  font-size: 15px;
  cursor: pointer;
}
.choice-row input:checked + span { border-color: var(--blue); background: rgba(88,166,255,.12); color: var(--blue); font-weight: 600; }

.feedback { display: none; margin-top: 8px; font-size: 14px; font-style: normal; }
.feedback.show { display: block; }
.feedback.ok { color: var(--green); }
.feedback.bad { color: var(--red); }

.submit-btn { width: 100%; padding: 14px; font-size: 16px; }

.history-block {
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.history-head h2 { margin: 0; font-size: 20px; }

.history-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
}
.history-item:first-of-type { border-top: 0; }
.history-score {
  min-width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(63,216,164,.12);
  border: 1px solid rgba(63,216,164,.4);
  color: var(--green);
  font-family: var(--mono);
  font-size: 15px;
}
.history-item h3 { margin: 0 0 4px; font-size: 16px; }
.history-item p { margin: 0; color: var(--muted); font-size: 14px; }
.history-item .right { margin-left: auto; text-align: right; color: var(--muted); font-size: 14px; }
.no-history { color: var(--muted); padding: 32px 0; text-align: center; font-size: 16px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(4,6,10,.8);
  backdrop-filter: blur(6px);
}
.modal-backdrop.open { display: grid; }

.modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 60px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }

.playbook-step { display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.playbook-step:last-child { border: 0; }
.playbook-step .num {
  min-width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--blue);
  color: var(--blue);
  font-family: var(--mono);
  font-size: 14px;
}
.playbook-step h3 { margin: 0 0 6px; font-size: 16px; }
.playbook-step p { margin: 0; color: var(--muted); font-size: 15px; }

.result-summary { text-align: center; padding: 8px 0 20px; }
.result-summary .big { font-size: 44px; font-family: var(--mono); }
.result-summary .big.ok { color: var(--green); }
.result-summary .big.mid { color: var(--amber); }
.result-summary p { color: var(--muted); font-size: 16px; margin: 8px 0 0; }
.result-lines { border-top: 1px solid var(--border); padding-top: 16px; font-size: 15px; }
.result-lines div { padding: 6px 0; }
.result-lines .ok { color: var(--green); }
.result-lines .bad { color: var(--red); }

.report-preview {
  margin: 0 0 20px;
  padding: 16px;
  background: #0c1016;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--muted);
  white-space: pre-wrap;
}

.toast-container {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 150;
  display: grid;
  gap: 10px;
  width: min(400px, calc(100vw - 48px));
}
.toast {
  padding: 14px 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  font-size: 15px;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
}

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .answers-panel { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .container { padding: 0 16px; }
  .view { padding: 28px 0 60px; }

  .header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand reset"
      "nav nav";
    gap: 10px 12px;
    height: auto;
    min-height: 108px;
    padding: 12px 16px;
    justify-content: initial;
  }
  .brand { grid-area: brand; min-width: 0; }
  .brand img { width: 34px; height: 34px; }
  .brand-text {
    display: inline;
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nav {
    grid-area: nav;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .nav-link { width: 100%; padding: 9px 10px; font-size: 14px; }
  .reset-link {
    position: static;
    grid-area: reset;
    justify-self: end;
    padding: 7px 4px;
    font-size: 13px;
  }

  .incident-grid { grid-template-columns: 1fr; }
  .incident-card { min-height: 0; padding: 22px; }
  .stats-row { grid-template-columns: 1fr; }
  .stat-card { padding: 18px 20px; }
  .list-controls { align-items: stretch; flex-direction: column; }
  .search-input { width: 100%; }
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 15px; }

  .case-toolbar { margin: -28px 0 24px; }
  .case-toolbar-inner {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 10px 12px;
    height: auto;
    min-height: 0;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .back-link {
    grid-column: 1 / -1;
    justify-self: start;
    padding: 0;
  }
  .case-timer { justify-self: end; }
  .case-actions {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    margin-left: 0;
  }
  .case-actions .btn { min-width: 0; padding: 10px 6px; font-size: 13px; }

  .case-intro h1 { font-size: 25px; line-height: 1.25; }
  .case-intro > p { font-size: 15px; }
  .case-meta { align-items: flex-start; flex-direction: column; gap: 8px; font-size: 14px; }

  .workspace { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .files-panel, .answers-panel { padding: 16px; }
  .viewer-head { align-items: stretch; flex-wrap: wrap; padding: 14px 16px; }
  .viewer-head strong {
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .viewer-search { width: 100%; }
  .viewer-body {
    min-height: 320px;
    max-height: 520px;
    padding: 16px;
    font-size: 13.5px;
    line-height: 1.7;
  }

  .history-block { padding: 18px; }
  .history-item { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .history-item > div:nth-child(2) { min-width: 0; flex: 1; }
  .history-item .right { width: 100%; margin-left: 68px; text-align: left; }

  .modal-backdrop { padding: 12px; }
  .modal { max-height: calc(100vh - 24px); }
  .modal-head { padding: 17px 18px; }
  .modal-head h2 { font-size: 18px; }
  .modal-body { padding: 18px; }

  .toast-container {
    right: 16px;
    bottom: 16px;
    width: calc(100vw - 32px);
  }
}

@media (max-width: 380px) {
  .brand-text { font-size: 13px; }
  .case-id, .case-timer { font-size: 13px; }
  .severity { padding: 4px 8px; font-size: 12px; }
  .choice-row { gap: 8px; }
}
