:root {
  --ink: #16221c;
  --muted: #68766e;
  --paper: #f2f6ef;
  --panel: rgba(255, 255, 252, 0.94);
  --line: #d5dfd7;
  --sage: #789a82;
  --teal: #3e958e;
  --blue: #547fb7;
  --amber: #c6903f;
  --danger: #b25858;
  --shadow: 0 22px 60px rgba(30, 51, 39, 0.13);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% 12%, rgba(120, 154, 130, 0.24), transparent 27rem),
    radial-gradient(circle at 92% 86%, rgba(84, 127, 183, 0.18), transparent 32rem),
    linear-gradient(145deg, #f8faf5, var(--paper));
}

a { color: inherit; }
h1, h2, p { margin: 0; }
button { font: inherit; }
.eyebrow { color: var(--teal); font-size: 12px; font-weight: 750; letter-spacing: 0.14em; text-transform: uppercase; }

.home-shell {
  width: min(1240px, calc(100vw - 40px));
  min-height: 100vh;
  margin: auto;
  padding: clamp(42px, 8vh, 96px) 0 34px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 42px;
}

.home-hero { max-width: 880px; }
.home-hero h1 { margin-top: 14px; max-width: 820px; font-family: Georgia, serif; font-size: clamp(44px, 7vw, 86px); font-weight: 500; line-height: 0.98; letter-spacing: -0.045em; }
.home-hero p { margin-top: 22px; max-width: 720px; color: var(--muted); font-size: clamp(16px, 2vw, 20px); line-height: 1.55; }

.entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-self: center; }
.entry-card {
  min-width: 0;
  min-height: 360px;
  padding: 28px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 32px;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 180ms ease, box-shadow 180ms ease;
  overflow: hidden;
}
.entry-card:hover { transform: translateY(-5px); box-shadow: 0 28px 68px rgba(30, 51, 39, 0.19); }
.predict-card { background: linear-gradient(150deg, rgba(246, 251, 245, 0.98), rgba(204, 225, 210, 0.95)); }
.atlas-card { background: linear-gradient(150deg, rgba(249, 249, 242, 0.98), rgba(211, 224, 237, 0.96)); }
.card-index { font-family: Georgia, serif; color: rgba(22, 34, 28, 0.42); font-size: 18px; }
.card-kicker { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.entry-card h2 { margin-top: 12px; font-family: Georgia, serif; font-size: clamp(32px, 4vw, 50px); font-weight: 500; line-height: 1.04; }
.entry-card h2 { overflow-wrap: anywhere; }
.entry-card p { margin-top: 16px; max-width: 520px; color: #4f5f56; line-height: 1.55; }
.card-action { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid rgba(22, 34, 28, 0.15); padding-top: 18px; font-weight: 750; }
.card-action b { font-size: 24px; font-weight: 400; }
.home-footer { display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12px; }
.home-footer .ready { color: #26724a; font-weight: 700; }

.result-shell { width: min(1760px, calc(100vw - 32px)); margin: auto; padding: 16px 0 30px; }
.top-nav { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.top-nav a { text-decoration: none; }
.top-nav > div { display: flex; gap: 18px; color: var(--muted); font-size: 13px; }
.portal-mark { font-family: Georgia, serif; font-size: 20px; font-weight: 600; }

.state-card, .result-header, .probability-strip, .review-chooser, .workspace-card, .technical-details {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.state-card { max-width: 680px; margin: 16vh auto; padding: 24px; border-radius: 18px; display: flex; align-items: center; gap: 18px; }
.state-card p { margin-top: 5px; color: var(--muted); }
.loader { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card { border-color: rgba(178, 88, 88, 0.45); }

.result-header { margin-top: 18px; padding: 22px 24px; border-radius: 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.result-header h1 { margin-top: 6px; font-family: Georgia, serif; font-size: clamp(30px, 4vw, 52px); font-weight: 500; letter-spacing: -0.025em; }
.result-header p { margin-top: 8px; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.button, .decision-pill { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; border-radius: 999px; text-decoration: none; font-size: 13px; font-weight: 700; }
.button.secondary { border: 1px solid var(--line); background: white; }
.decision-pill { border: 1px solid var(--line); color: var(--muted); }
.decision-pill.auto { color: #246a45; border-color: rgba(36, 106, 69, 0.32); background: rgba(62, 149, 142, 0.1); }
.decision-pill.review { color: #815619; border-color: rgba(198, 144, 63, 0.4); background: rgba(198, 144, 63, 0.12); }

.probability-strip { margin-top: 14px; padding: 16px; border-radius: 16px; display: grid; grid-template-columns: 1fr 1fr minmax(260px, 0.75fr); gap: 14px; }
.probability-strip article { min-width: 0; padding: 13px; border-radius: 12px; background: rgba(120, 154, 130, 0.07); }
.probability-strip article > span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.probability-bars { display: grid; gap: 8px; }
.probability-row { display: grid; grid-template-columns: 72px 1fr 54px; align-items: center; gap: 8px; font-size: 12px; }
.probability-row i { height: 8px; overflow: hidden; border-radius: 999px; background: #e3ebe5; }
.probability-row i b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--blue)); }
.probability-row strong { text-align: right; }
.result-facts { display: grid; gap: 8px; }
.result-facts div { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.result-facts div span { margin: 0; color: var(--muted); text-transform: none; letter-spacing: normal; }

.review-chooser { margin-top: 14px; padding: 20px; border-radius: 16px; border-color: rgba(198, 144, 63, 0.45); background: linear-gradient(135deg, rgba(255, 249, 233, 0.97), rgba(255, 255, 252, 0.97)); }
.review-chooser h2 { margin-top: 5px; font-family: Georgia, serif; font-weight: 500; }
.review-chooser p { margin-top: 7px; color: var(--muted); font-size: 13px; }
.candidate-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.candidate-button { min-height: 54px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); cursor: pointer; text-align: left; }
.candidate-button:hover { border-color: var(--amber); background: #fffdf7; }
.review-reason { padding-top: 7px; overflow-wrap: anywhere; }

.workspace-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.workspace-card { min-width: 0; overflow: hidden; border-radius: 16px; }
.workspace-card > header { min-height: 68px; padding: 12px 14px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); }
.workspace-card > header > span { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; font-size: 11px; }
.workspace-card h2 { font-size: 16px; }
.workspace-card header p { margin-top: 3px; color: var(--muted); font-size: 11px; }
.media-stage { position: relative; height: clamp(340px, 42vw, 650px); overflow: hidden; display: grid; place-items: center; background: #050706; }
.media-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.alignment-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.alignment-media .aligned-mask-layer { opacity: 0.28; filter: sepia(1) saturate(5) hue-rotate(115deg); mix-blend-mode: screen; }
.alignment-media .aligned-mask-layer.mask-only { opacity: 1; filter: none; mix-blend-mode: normal; }
.segmented-control { margin-left: auto; display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #f3f6f2; }
.segmented-control button { min-height: 28px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.segmented-control button.active { background: white; color: var(--ink); box-shadow: 0 2px 7px rgba(30, 51, 39, 0.12); }
.atlas-card-panel { min-height: 620px; }
.atlas-card-panel iframe { display: block; width: 100%; height: clamp(540px, 58vw, 820px); border: 0; background: #eef3ed; }
.atlas-placeholder { min-height: 540px; display: grid; place-content: center; gap: 7px; padding: 24px; text-align: center; color: var(--muted); }
.text-link { margin-left: auto; color: var(--teal); font-size: 12px; font-weight: 750; text-decoration: none; }
.technical-details { margin-top: 14px; padding: 15px; border-radius: 14px; }
.technical-details summary { cursor: pointer; font-weight: 700; }
.technical-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.technical-grid div { padding: 10px; border: 1px solid var(--line); border-radius: 9px; display: grid; gap: 5px; }
.technical-grid span { color: var(--muted); font-size: 11px; }
.technical-grid strong { font-size: 12px; overflow-wrap: anywhere; }

[hidden] { display: none !important; }

@media (max-width: 1000px) {
  .entry-grid, .workspace-grid, .probability-strip { grid-template-columns: 1fr; }
  .entry-card { min-height: 300px; }
  .candidate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .technical-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
  .home-shell, .result-shell { width: min(100% - 20px, 1240px); }
  .home-hero h1 { font-size: 44px; }
  .home-footer, .result-header, .top-nav { align-items: flex-start; flex-direction: column; }
  .candidate-grid, .technical-grid { grid-template-columns: 1fr; }
  .header-actions { width: 100%; flex-wrap: wrap; }
  .workspace-card > header { flex-wrap: wrap; }
  .segmented-control { width: 100%; margin-left: 41px; }
}
