:root {
  color-scheme: dark;
  --background: #0a0a0a;
  --surface: #151515;
  --border: #313131;
  --text: #f6f5f2;
  --muted: #aaa8a2;
  --accent: #d9f995;
  --yes: #a7ee9a;
  --no: #ffa7a3;
  font-family: system-ui, sans-serif;
  background: var(--background);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .38; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.home {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.5rem;
  padding: 2rem;
  text-align: center;
}

.home h1 { font-size: clamp(2.45rem, 9vw, 6.7rem); line-height: 1.04; font-weight: 660; letter-spacing: -.085em; }
.start { text-decoration: none; }
.start span { color: var(--accent); font-size: .57em; display: inline-block; margin-left: .24em; vertical-align: top; }
.start:hover, .quiet-link:hover, .clue-button:hover { color: var(--accent); }

.screen { width: min(100%, 46rem); margin-inline: auto; padding: 2rem 1.25rem 4rem; }
.top-nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: clamp(2.5rem, 8vh, 5.5rem); }
.quiet-link { color: var(--muted); font-size: .875rem; text-decoration: none; background: none; border: 0; padding: 0; }
.case-navigation { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .65rem; }
#case-position, .case-status { color: var(--muted); font-size: .8rem; }
.arrow {
  width: 2.5rem;
  height: 2.5rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 50%;
}
.arrow:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.flashcard {
  min-height: 13rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: clamp(1.3rem, 5vw, 2.7rem);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: var(--surface);
}
.flashcard h1, #history-title { font-size: clamp(1.85rem, 5vw, 3.2rem); line-height: 1.1; letter-spacing: -.06em; }
.flashcard p { color: #cfcdc7; font-size: clamp(.99rem, 2.4vw, 1.13rem); line-height: 1.65; max-width: 57ch; }
#case-scenario { white-space: pre-line; }

.question-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .65rem; margin-top: 1rem; }
input, textarea {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: .7rem;
  padding: .75rem .9rem;
  line-height: 1.45;
}
textarea { resize: vertical; min-height: 4.7rem; }
input::placeholder, textarea::placeholder { color: #a19f9a; }
.primary {
  color: #151a0e;
  background: var(--accent);
  border: 0;
  border-radius: .7rem;
  font-weight: 650;
  padding: .65rem 1rem;
}
.primary:hover:not(:disabled) { background: #e8ffbe; }

.question-log, .history-list { list-style: none; padding: 0; margin: 0; }
.question-log { margin-top: .65rem; max-height: 9rem; overflow-y: auto; }
.question-log li { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: .6rem .1rem; border-bottom: 1px solid var(--border); }
.question-log li span { min-width: 0; overflow-wrap: anywhere; color: var(--muted); }
.verdict { flex: none; font-size: .8rem; }
[data-verdict="yes"] { color: var(--yes); }
[data-verdict="no"] { color: var(--no); }

.clue-button { margin-top: 1rem; padding: .3rem 0; border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: .2em; }
.theory-form { display: grid; justify-items: start; gap: .65rem; margin-top: 1.65rem; padding-top: 1.4rem; border-top: 1px solid var(--border); }
.theory-form label, .solution h2 { font-size: 1rem; font-weight: 650; }
.theory-result { margin-top: 1rem; font-weight: 650; }
.solution { margin-top: 1rem; display: grid; gap: .4rem; line-height: 1.55; }
.solution p, #history-empty { color: var(--muted); }
.case-status { display: flex; justify-content: space-between; gap: .75rem; min-height: 1.2rem; margin-top: 1rem; }
#inference-badge { margin-left: auto; flex: none; font-size: .72rem; }

#history-title { margin-bottom: 1.5rem; }
.history-list li { border-bottom: 1px solid var(--border); }
.history-list button { display: flex; justify-content: space-between; gap: .75rem; width: 100%; text-align: left; background: transparent; color: var(--text); border: 0; padding: .9rem 0; }
.history-list button:hover { color: var(--accent); }
.history-list button span:last-child { color: var(--accent); }

#clue-dialog { width: min(calc(100% - 2rem), 28rem); padding: 1.5rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); color: var(--text); }
#clue-dialog::backdrop { background: #000b; }
#clue-dialog h2 { font-size: 1.1rem; }
#clue-text { margin-block: .8rem 1.25rem; color: #cfcdc7; line-height: 1.55; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; }
.dialog-actions form { margin: 0; }
