:root {
  color-scheme: dark;
  --bg: #111516;
  --surface: #1b2122;
  --ink: #f3f5f2;
  --muted: #99a5a6;
  --line: #303a3b;
  --lime: #ddf78b;
  --aqua: #83e1d0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }
html { background: #0b0e0f; }
body { margin: 0; color: var(--ink); background: #0b0e0f; overflow-x: clip; }
button { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
input, textarea, select { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid var(--aqua); outline-offset: 4px; }
button:disabled { cursor: default; }
p, h1 { margin-top: 0; }
img { display: block; }
.app-shell {
  width: min(100%, 600px); min-height: 100svh; margin: 0 auto;
  display: flex; flex-direction: column; background: var(--bg);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) 24px 18px;
}
.brand { display: flex; min-width: 0; gap: 12px; align-items: center; }
.brand-mark {
  display: grid; place-items: center; flex: 0 0 44px; height: 44px;
  background: var(--lime); border-radius: 8px;
}
.brand div { min-width: 0; }
.brand strong { display: block; font-size: 1.08rem; font-weight: 750; line-height: 1.3; }
.brand div span {
  display: block; margin-top: 3px; font-size: .78rem; color: var(--muted);
  max-width: 210px; overflow-wrap: anywhere;
}
.progress-copy { display: grid; gap: 3px; text-align: right; flex: 0 0 auto; }
.progress-copy strong { font-size: .94rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.progress-copy span { font-size: .75rem; color: var(--muted); }
.topics-button {
  flex: 0 0 38px; width: 38px; height: 38px; border: 1px solid var(--line);
  border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer;
  font-size: 1.25rem; line-height: 1;
}
.progress-track { height: 3px; margin: 0 24px; background: var(--line); overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--lime); width: 0; transition: width 350ms ease; }
.workspace { flex: 1; display: flex; flex-direction: column; }
.topics-view { flex: 1; padding: 28px 24px max(28px, env(safe-area-inset-bottom)); }
.topics-heading > span { color: var(--aqua); font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.topics-heading h1 { margin: 10px 0 8px; font-size: 2rem; line-height: 1.1; }
.topics-heading p { margin: 0 0 22px; color: var(--muted); font-size: 1rem; line-height: 1.5; }
.random-button {
  width: 100%; min-height: 76px; padding: 14px 16px; border: 1px solid var(--lime);
  border-radius: 8px; background: var(--lime); color: #172116; cursor: pointer;
  display: grid; grid-template-columns: 40px minmax(0,1fr) 24px; gap: 12px;
  align-items: center; text-align: left;
}
.random-button > span:nth-child(2) { min-width: 0; }
.random-button strong, .random-button small { display: block; overflow-wrap: anywhere; }
.random-button strong { font-size: 1rem; }
.random-button small { margin-top: 3px; color: #43503b; font-size: .78rem; }
.random-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: #172116; color: var(--lime); font-size: 1.3rem;
}
.topics-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-top: 16px; }
.topic-card {
  --topic-color: var(--aqua); position: relative; min-height: 116px; padding: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  cursor: pointer; text-align: left; display: flex; flex-direction: column; justify-content: space-between;
}
.topic-card:nth-child(3n+2) { --topic-color: var(--lime); }
.topic-card:nth-child(3n) { --topic-color: #ffb59e; }
.topic-card::before { content: ""; position: absolute; top: -1px; left: 14px; width: 34px; height: 3px; background: var(--topic-color); }
.topic-card strong { font-size: .98rem; line-height: 1.25; overflow-wrap: anywhere; }
.topic-card span { color: var(--muted); font-size: .76rem; line-height: 1.35; }
.topic-card span b { color: var(--topic-color); font-weight: 700; }
.topic-card:active, .random-button:active { transform: scale(.985); }
.panel-view { flex: 1; padding: 28px 24px 32px; }
.panel-heading > span { color: var(--aqua); font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.panel-heading h1 { margin: 10px 0 8px; font-size: 2rem; line-height: 1.1; }
.panel-heading p { margin: 0 0 24px; color: var(--muted); font-size: .94rem; line-height: 1.5; }
.case-form { display: grid; gap: 16px; }
.case-form label { display: grid; gap: 7px; min-width: 0; }
.case-form label > span { color: #cbd2d2; font-size: .82rem; font-weight: 650; }
.case-form input, .case-form textarea, .case-form select {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); padding: 12px 13px; font-size: 1rem; line-height: 1.4;
  outline: none; resize: vertical;
}
.case-form textarea { min-height: 126px; }
.case-form input:focus, .case-form textarea:focus, .case-form select:focus { border-color: var(--aqua); box-shadow: 0 0 0 2px #83e1d026; }
.case-form input::placeholder, .case-form textarea::placeholder { color: #6f7b7c; }
.sides-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-reward { margin: 0; color: var(--muted); font-size: .82rem; }
.form-reward strong { color: var(--lime); }
.publish-button {
  width: 100%; min-height: 54px; border: 1px solid var(--lime); border-radius: 8px;
  background: var(--lime); color: #172116; cursor: pointer; font-weight: 750;
}
.publish-button:disabled { opacity: .55; }
.publish-success { padding: 52px 0 20px; text-align: center; }
.publish-success > span {
  display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 18px;
  border-radius: 50%; background: var(--lime); color: #172116; font-size: 1.5rem; font-weight: 800;
}
.publish-success h2 { margin: 0 0 8px; font-size: 1.5rem; }
.publish-success p { margin: 0 0 24px; color: var(--muted); }
.profile-hero { padding: 20px 0 28px; border-bottom: 1px solid var(--line); }
.rank-label { color: var(--aqua); font-size: .82rem; font-weight: 700; text-transform: uppercase; }
.profile-hero h1 { margin: 10px 0 6px; font-size: 2.75rem; line-height: 1; }
.profile-hero p { margin: 0 0 16px; color: var(--muted); font-size: .88rem; }
.rank-track { height: 6px; overflow: hidden; background: var(--line); border-radius: 3px; }
.rank-track span { display: block; width: 0; height: 100%; background: var(--lime); transition: width 350ms ease; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.profile-stats div { padding: 22px 0; }
.profile-stats div + div { padding-left: 24px; border-left: 1px solid var(--line); }
.profile-stats strong, .profile-stats span { display: block; }
.profile-stats strong { font-size: 1.6rem; }
.profile-stats span { margin-top: 3px; color: var(--muted); font-size: .78rem; }
.own-cases { padding-top: 26px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 1.05rem; }
.section-heading span { color: var(--muted); font-size: .8rem; }
.own-cases-list { display: grid; gap: 8px; }
.own-case-item { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.own-case-item strong { display: block; font-size: .92rem; line-height: 1.35; }
.own-case-item span { display: block; margin-top: 6px; color: var(--muted); font-size: .76rem; }
.empty-list { padding: 22px 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.main-nav {
  position: sticky; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3,1fr);
  padding: 7px 18px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  background: #111516f5; backdrop-filter: blur(12px);
}
.main-nav button {
  min-height: 49px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; align-content: center; gap: 2px;
}
.main-nav button > span { font-size: 1.2rem; line-height: 1; }
.main-nav button small { font-size: .7rem; }
.main-nav button.is-active { color: var(--lime); }
.case-view { flex: 1; display: flex; flex-direction: column; }
.case-stage {
  flex: 1; display: flex; flex-direction: column; padding: 22px 24px 20px;
  touch-action: pan-y; transition: transform 180ms ease, opacity 180ms ease;
}
.case-stage.is-leaving { opacity: .25; transform: translateX(-20px); }
.case-stage.is-entering { animation: arrive 200ms ease; }
.case-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 24px; }
.case-tags { color: var(--aqua); font-size: .81rem; font-weight: 650; text-transform: uppercase; }
.case-number { font-size: .81rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.case-stage h1, .state-screen h1 {
  font-size: 1.75rem; font-weight: 730; line-height: 1.14; margin: 18px 0 20px;
  overflow-wrap: anywhere;
}
.case-file { padding: 18px 0 0; border-top: 1px solid var(--line); }
.file-label { display: block; color: var(--aqua); margin-bottom: 9px; font-size: .81rem; font-weight: 600; }
.case-file p { color: #c6cece; font-size: 1rem; line-height: 1.6; margin: 0; }
.decision { margin-top: auto; padding-top: 24px; }
.decision-heading { display: flex; gap: 14px; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.question { font-size: 1.12rem; font-weight: 650; line-height: 1.3; margin: 0; }
.decision-label { font-size: .75rem; color: var(--muted); flex: 0 0 auto; }
.options { display: grid; gap: 10px; }
.option-button {
  --color: var(--lime); --tint: #2d3823; --result: 0%;
  position: relative; isolation: isolate; overflow: hidden; cursor: pointer;
  width: 100%; min-height: 86px; border: 1px solid #3c4840; border-radius: 8px;
  padding: 16px; display: grid; grid-template-columns: 34px minmax(0,1fr) 54px;
  grid-template-rows: auto auto; gap: 3px 12px; align-items: center;
  text-align: left; background: var(--surface);
  transition: border-color 160ms ease, background 160ms ease, transform 100ms ease;
}
.option-2 { --color: var(--aqua); --tint: #193d39; border-color: #35484a; }
.option-button::before {
  position: absolute; z-index: -1; inset: 0 auto 0 0; width: var(--result);
  background: var(--tint); content: ""; transition: width 500ms cubic-bezier(.2,.7,.2,1);
  pointer-events: none;
}
.option-letter {
  grid-row: 1 / 3; display: grid; place-items: center; width: 34px; height: 34px;
  border: 1px solid #59634f; border-radius: 50%; color: var(--color); font-weight: 700; font-size: .875rem;
}
.option-2 .option-letter { border-color: #466764; }
.option-label { grid-column: 2; grid-row: 1; font-size: 1rem; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.option-note { grid-column: 2; grid-row: 2; font-size: .75rem; color: var(--muted); line-height: 1.35; }
.option-percent { grid-column: 3; grid-row: 1 / 3; color: var(--color); font-size: 1.25rem; font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; }
.option-button.is-picked { border-color: var(--color); }
.option-button.is-picked .option-letter { background: var(--color); color: #101615; border-color: var(--color); }
.option-button.is-picked .option-note { color: var(--color); }
.option-button.is-pending .option-letter { font-size: 0; }
.option-button.is-pending .option-letter::after {
  content: ""; width: 14px; height: 14px; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: spin 700ms linear infinite;
}
.option-button:active:not(:disabled) { transform: scale(.987); }
@media (hover: hover) {
  .option-button:hover:not(:disabled) { border-color: var(--color); background: #242d2e; }
  .next-button:hover:not(:disabled) { filter: brightness(1.1); }
  .topic-card:hover { border-color: var(--topic-color); background: #222a2b; }
  .random-button:hover { filter: brightness(1.06); }
}
.verdict-summary { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 12px 0 0; }
.verdict-summary strong { color: var(--lime); font-size: .875rem; font-weight: 650; }
.verdict-summary span { font-size: .81rem; color: var(--muted); }
.action-bar { padding: 0 24px max(20px, env(safe-area-inset-bottom)); background: var(--bg); }
.action-bar p { text-align: center; margin: 0 0 10px; font-size: .78rem; color: var(--muted); }
.next-button, .action-button {
  min-height: 54px; padding: 14px 18px; width: 100%; border: 1px solid var(--lime);
  border-radius: 8px; background: var(--lime); color: #172116; display: flex;
  align-items: center; justify-content: space-between; gap: 12px; cursor: pointer;
  font-weight: 700; line-height: 1.3;
}
.next-button img { flex: 0 0 22px; }
.next-button.is-secondary { background: transparent; color: #ced7d6; border-color: var(--line); }
.next-button.is-secondary img { filter: invert(1); }
.next-button:disabled { opacity: .5; }
.state-screen { flex: 1; min-height: 65svh; padding: 40px 24px; display: flex; flex-direction: column; justify-content: center; }
.state-screen p { color: var(--muted); font-size: 1rem; line-height: 1.6; }
.loading-seal { display: grid; place-items: center; width: 68px; height: 68px; background: var(--lime); border-radius: 8px; margin-bottom: 24px; animation: breathe 1.6s ease-in-out infinite; }
.error-code { color: #ffb1a0; font-size: .875rem; margin-bottom: 18px; }
.toast {
  position: fixed; z-index: 20; left: 16px; right: 16px; bottom: max(20px,env(safe-area-inset-bottom));
  margin: 0 auto; max-width: 552px; border: 1px solid #ac6960; border-radius: 8px;
  background: #422925; color: #ffe3df; padding: 16px; font-size: .94rem; line-height: 1.4;
  box-shadow: 0 8px 32px #0006;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes arrive { from { opacity: .25; transform: translateX(15px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 50% { opacity: .5; } }
@media (min-width: 700px) {
  .app-shell { border-left: 1px solid #20292a; border-right: 1px solid #20292a; }
  .topbar { padding-inline: 36px; padding-top: 28px; }
  .progress-track { margin-inline: 36px; }
  .case-stage { padding: 32px 36px 24px; }
  .case-stage h1 { font-size: 2.25rem; }
  .action-bar { padding-inline: 36px; }
  .topics-view { padding-inline: 36px; }
  .panel-view { padding-inline: 36px; }
}
@media (max-width: 360px) {
  .topbar { padding-inline: 16px; gap: 8px; }
  .brand { gap: 8px; }
  .brand strong { font-size: 1rem; }
  .brand div span { max-width: 145px; }
  .topbar:has(.topics-button:not([hidden])) .brand div span { display: none; }
  .progress-track { margin-inline: 16px; }
  .case-stage { padding: 22px 16px 20px; }
  .case-stage h1 { font-size: 1.625rem; }
  .option-button { padding: 13px; grid-template-columns: 30px minmax(0,1fr) 44px; gap: 3px 9px; }
  .option-letter { width: 30px; height: 30px; }
  .option-percent { font-size: 1.05rem; }
  .decision-heading { flex-wrap: wrap; gap: 6px; }
  .action-bar { padding-inline: 16px; }
  .topics-view { padding-inline: 16px; }
  .panel-view { padding-inline: 16px; }
  .topics-grid { gap: 8px; }
  .topic-card { min-height: 108px; padding: 12px; }
  .sides-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
