:root {
  --ink: #0b0d12;
  --muted: #6b7280;
  --line: rgba(11, 13, 18, 0.08);
  --line-strong: rgba(11, 13, 18, 0.14);
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --accent: #e11d1d;
  --accent-soft: rgba(225, 29, 29, 0.08);
  --ok: #0f9f6e;
  --warn: #b45309;
  --fail: #dc2626;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --display: "Space Grotesk", sans-serif;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(11, 13, 18, 0.04), 0 12px 40px rgba(11, 13, 18, 0.04);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: var(--display);
  background: var(--bg);
  line-height: 1.45;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #ffffff;
}

.laser-rule {
  height: 1px;
  border: 0;
  margin: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(225, 29, 29, 0.25) 18%,
    #ff2a2a 50%,
    rgba(225, 29, 29, 0.25) 82%,
    transparent 100%
  );
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem clamp(1.25rem, 3vw, 2.75rem) 0.85rem;
  border-bottom: none;
  animation: rise 0.45s ease both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  animation: float 5s ease-in-out infinite;
}

.brand-text h1 {
  margin: 0;
  font-size: clamp(2rem, 3.6vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
}

.brand-text p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.mast-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.65rem;
}

.key-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  max-width: min(280px, 48vw);
}

.key-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.key-toggle {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
}

.key-field input {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr);
  gap: 1.1rem;
  padding: 1.1rem clamp(1.25rem, 3vw, 2.75rem) 2rem;
  animation: rise 0.55s 0.05s ease both;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.4rem 1.5rem;
}

.panel h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}

.lede {
  margin: 0.3rem 0 1.15rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.lede code {
  font-family: var(--mono);
  font-size: 0.82em;
  color: var(--accent);
}

.page-meta {
  margin-top: 1.1rem;
}

.page-meta h3 {
  margin: 0.85rem 0 0.75rem;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.meta-grid div {
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.meta-grid dt {
  margin: 0 0 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta-grid dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.88rem;
}

.bhs-confirm {
  margin-top: 1.1rem;
}

.bhs-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.bhs-list li {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.bhs-top {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.45rem;
}

.bhs-ref {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
}

.bhs-score {
  margin-inline-start: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.bhs-ocr,
.bhs-text {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
}

.bhs-ocr {
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.bhs-text {
  color: var(--muted);
}

form {
  display: grid;
  gap: 0.85rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.optional {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  opacity: 0.8;
}

input[type="url"],
input[type="text"],
input[type="number"] {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.88rem;
  padding: 0.72rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

input:focus {
  outline: none;
  background: #ffffff;
  border-color: rgba(225, 29, 29, 0.45);
  box-shadow: 0 0 0 3px rgba(225, 29, 29, 0.1);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-top: 0.25rem;
}

button {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
}

button[type="submit"] {
  background: var(--ink);
  color: #ffffff;
  padding: 0.72rem 1.3rem;
  border-radius: 999px;
  letter-spacing: -0.01em;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

button[type="submit"]:hover:not(:disabled) {
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(225, 29, 29, 0.22);
  transform: translateY(-1px);
}

button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: wait;
  box-shadow: none;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}

.ghost:hover {
  color: var(--ink);
  border-color: rgba(11, 13, 18, 0.28);
}

.form-status {
  font-size: 0.88rem;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(225, 29, 29, 0.12);
}

.pill.muted {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line);
}

.pill.ok {
  background: rgba(15, 159, 110, 0.08);
  color: var(--ok);
  border-color: rgba(15, 159, 110, 0.16);
}

.pill.warn {
  background: rgba(180, 83, 9, 0.08);
  color: var(--warn);
  border-color: rgba(180, 83, 9, 0.16);
}

.pill.fail {
  background: rgba(220, 38, 38, 0.08);
  color: var(--fail);
  border-color: rgba(220, 38, 38, 0.16);
}

.result {
  margin-top: 1.25rem;
  padding-top: 1rem;
}

.result .laser-rule {
  margin: 0 0 1rem;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.result-head h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.strategy-panel {
  margin: 0 0 1rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.strategy-panel h4 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
}

.strategy-lede {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.strategy-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.strategy-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.strategy-item.primary {
  border-color: rgba(225, 29, 29, 0.35);
}

.strategy-meta {
  min-width: 0;
  flex: 1;
}

.strategy-meta strong {
  margin-right: 0.4rem;
}

.strategy-stats {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.strategy-desc {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.strategy-copy {
  flex-shrink: 0;
  white-space: nowrap;
}

.result pre {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.side {
  display: flex;
  flex-direction: column;
  min-height: 560px;
  padding-top: 1rem;
}

.side-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  padding: 0.25rem;
  width: fit-content;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-2);
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

.tab.active {
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(11, 13, 18, 0.04);
}

.side-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.tab-panel > .laser-rule {
  margin: 0 0 0.85rem;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* display:flex above would otherwise override the HTML hidden attribute */
.tab-panel[hidden],
.result[hidden],
.bhs-confirm[hidden],
.page-meta[hidden] {
  display: none !important;
}

.log-stream {
  flex: 1;
  min-height: 420px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding: 0.85rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: #374151;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.55;
}

.log-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  padding: 0.18rem 0;
  border-bottom: 1px solid rgba(11, 13, 18, 0.04);
}

.log-line:last-child {
  border-bottom: none;
}

.log-meta {
  color: #9ca3af;
  white-space: nowrap;
}

.log-line.INFO .log-level { color: #059669; }
.log-line.WARNING .log-level { color: #b45309; }
.log-line.ERROR .log-level,
.log-line.CRITICAL .log-level { color: #dc2626; }
.log-line.DEBUG .log-level { color: #6b7280; }

.scan-list {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0 0;
  display: grid;
  gap: 0.65rem;
  overflow: auto;
  max-height: calc(100vh - 260px);
  flex: 1;
  min-height: 280px;
}

.scan-list li {
  display: grid;
  gap: 0.35rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.scan-list li:hover {
  border-color: rgba(225, 29, 29, 0.35);
  box-shadow: 0 8px 24px rgba(11, 13, 18, 0.04);
  transform: translateY(-1px);
}

.scan-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.scan-id {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
}

.scan-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem 0.25rem;
}

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

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@media (max-width: 900px) {
  .masthead {
    flex-direction: column;
    align-items: flex-start;
  }

  .mast-meta {
    align-items: flex-start;
    width: 100%;
  }

  .key-field {
    max-width: none;
    width: 100%;
  }

  .key-field input {
    width: 100%;
  }

  .layout {
    grid-template-columns: 1fr;
  }

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

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .side {
    min-height: 0;
  }

  .log-stream,
  .scan-list {
    max-height: 420px;
  }
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}

.login-card {
  width: min(420px, 100%);
  padding: 1.5rem 1.5rem 1.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}

.login-brand {
  margin-bottom: 1rem;
}

.login-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.login-form label {
  display: grid;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.login-form input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
}

.login-form button {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.login-form button:hover {
  filter: brightness(0.95);
}

.login-error {
  margin-top: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: rgba(220, 38, 38, 0.08);
  color: var(--fail);
  font-size: 0.9rem;
}
