:root {
  --bg: #0b0d10;
  --surface: #14181d;
  --surface-2: #1c2128;
  --border: #262d36;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #4ea3ff;
  --accent-strong: #2f7ee0;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --chip-bg: #1f6feb33;
  --chip-fg: #79c0ff;
  --radius: 14px;
  --pad: 16px;
}

* { box-sizing: border-box; }

/* El atributo HTML `hidden` debe ganarle a `display: flex` de .screen */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  overscroll-behavior-y: contain;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

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

.brand {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.iconbtn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.iconbtn:active { background: var(--surface-2); }

main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 900px) {
  main { max-width: 820px; padding: 24px; }
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 10px; flex-wrap: wrap; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.h2 { margin: 0; font-size: 18px; }

button {
  font-family: inherit;
  font-size: 16px;
}

.primary {
  background: var(--accent);
  color: #06121f;
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-weight: 700;
  cursor: pointer;
}
.primary:active { background: var(--accent-strong); }
.primary.big { padding: 18px; font-size: 18px; }

.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
}
.ghost.small { padding: 6px 10px; font-size: 13px; }
.ghost:active { background: var(--surface-2); }

.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-fg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.empty { color: var(--muted); }

.last-decision { gap: 10px; }
.verdict-line {
  font-size: 18px;
  font-weight: 600;
}

.imgwrap {
  background: var(--surface-2);
  border-radius: 10px;
  overflow: hidden;
  max-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.imgwrap img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.status {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.verdict {
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14.5px;
  line-height: 1.5;
  margin: 0;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.error {
  background: #3a1414;
  border: 1px solid #7a1d1d;
  color: #ffb3b3;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history li {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.history li:active { background: #232a33; }
.history .h-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.history .h-verdict {
  margin-top: 4px;
  font-weight: 600;
}
.history .h-cost {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.footer {
  text-align: center;
  padding: 10px;
  border-top: 1px solid var(--border);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
