/*
 * GPSA app shell: mobile-first frame and components for GPSA tools (light + dark).
 * Adopt: <body class="shell">, link only this file plus Inter. Every rule is scoped
 * under .shell, so pages without that class are unaffected. Demo: shell.html.
 */

.shell {
  --bg: #e9edf6;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #111a30;
  --text-2: #3b4560;
  --muted: #59627a;
  --border: #d9e0ee;
  --border-strong: #c3cde3;
  --appbar: #002366;
  --appbar-border: transparent;
  --primary: #002366;
  --primary-hover: #001a4d;
  --on-primary: #ffffff;
  --brand-text: #002366;
  --step-current: #002366;
  --step-current-line: #002366;
  --link: #0033a0;
  --link-hover: #002366;
  --accent: #d9242b;
  --ok: #167a43;
  --ok-bg: #e6f4ec;
  --warn-title: #5c3d00;
  --warn-text: #5c3d00;
  --warn-bg: #fdf6e7;
  --warn-border: #f1dfb4;
  --warn-icon: #8a5a00;
  --error-text: #8f1d1d;
  --error-bg: #fdecec;
  --error-border: #f3c2c2;
  --info-text: #0b2a6b;
  --info-bg: #eaf0fb;
  --info-border: #c9d6f2;
  --focus: #3b66e0;
  --disabled-bg: #c3cde3;
  --disabled-text: #3b4560;
  --input-bg: var(--surface);
  --toast-error-bg: var(--error-text);
  --shadow: 0 1px 2px rgba(16, 26, 48, .06), 0 12px 30px -14px rgba(16, 26, 48, .22);
  --shadow-menu: 0 12px 40px -8px rgba(16, 26, 48, .35);
  --card-border: transparent;
  --radius: 14px;
  --radius-sm: 10px;

  color-scheme: light dark;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  .shell {
    --bg: #0c1222;
    --surface: #161f35;
    --surface-2: #0f1729;
    --text: #e8edf7;
    --text-2: #c4cde0;
    --muted: #a3aec4;
    --border: #243052;
    --border-strong: #36446a;
    --appbar: #0a1a3f;
    --appbar-border: #1f2c4d;
    --primary: #3b66e0;
    --primary-hover: #2f56c4;
    --brand-text: #c3d3ff;
    --step-current: #ffffff;
    --step-current-line: #9db8ff;
    --link: #9db8ff;
    --link-hover: #c3d3ff;
    --ok: #5fd49a;
    --ok-bg: #12301f;
    --warn-title: #f7dc9c;
    --warn-text: #f2e2bb;
    --warn-bg: #33270c;
    --warn-border: #5a4514;
    --warn-icon: #f2c96b;
    --error-text: #ffc9c9;
    --error-bg: #3a1416;
    --error-border: #6b2a2e;
    --info-text: #c9d8ff;
    --info-bg: #14213f;
    --info-border: #2c3d6b;
    --focus: #9db8ff;
    --disabled-bg: #2a3550;
    --disabled-text: #a3aec4;
    --input-bg: var(--surface-2);
    --toast-error-bg: #b3261e;
    --shadow: none;
    --shadow-menu: 0 12px 40px -8px rgba(0, 0, 0, .7);
    --card-border: var(--border);
  }
}

.shell *,
.shell *::before,
.shell *::after { box-sizing: border-box; }

.shell a { color: var(--link); text-underline-offset: 2px; }
.shell a:hover { color: var(--link-hover); }

.shell :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- helpers ---------- */

/* Components set display, which would otherwise beat the hidden attribute. */
.shell [hidden] { display: none !important; }

.shell .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.shell .kicker {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.shell .muted { color: var(--muted); }
.shell .lead { font-size: 16px; color: var(--text-2); }
.shell .small { font-size: 14px; }
.shell .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.shell .scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.shell dl.facts { margin: 0; }
.shell dl.facts dt {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.shell dl.facts dd { margin: 0 0 12px; font-size: 15px; }

/* On-pointer / on-touch hint text: pick by input device. */
.shell .on-pointer { display: none; }
@media (hover: hover) and (pointer: fine) {
  .shell .on-pointer { display: inline; }
  .shell .on-touch { display: none; }
}

/* ---------- page frame ---------- */

.shell .app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px;
}
.shell .app-main--wide { max-width: 1040px; }

.shell .app-footer {
  padding: 12px 16px 28px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- app bar + account ---------- */

.shell .app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 12px 0 16px;
  background: var(--appbar);
  border-bottom: 1px solid var(--appbar-border);
  color: #fff;
}
.shell .app-bar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: #fff;
  text-decoration: none;
}
.shell .app-bar__brand:hover { color: #fff; }
.shell .app-bar__logo {
  width: 32px;
  height: 32px;
  flex: none;
  padding: 2px;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
}
.shell .app-bar__title {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell .account { position: relative; margin-left: auto; }
.shell .account__button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
  list-style: none;
}
.shell .account__button::-webkit-details-marker { display: none; }
/* App bar is dark in both themes, so the ring must be light. */
.shell .app-bar :focus-visible { outline-color: #fff; }

.shell .avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px #fff;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}
.shell .avatar--lg { width: 40px; height: 40px; font-size: 17px; box-shadow: none; }

.shell .account__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  width: 264px;
  max-width: calc(100vw - 24px);
  padding: 8px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  color: var(--text);
}
.shell .account__who {
  display: flex;
  gap: 12px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
}
.shell .account__text { display: flex; flex-direction: column; min-width: 0; }
.shell .account__email { font-size: 15px; overflow-wrap: anywhere; }
.shell .account__note { display: block; font-size: 13px; color: var(--muted); }
.shell .account__menu form { margin: 0; }
.shell .account__item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.shell .account__item:hover,
.shell .account__item:focus-visible { background: var(--surface-2); }

/* ---------- stepper ---------- */

.shell .stepper {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.shell .stepper ol {
  display: flex;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
  list-style: none;
  counter-reset: step;
}
.shell .stepper--wide ol { max-width: 1040px; }
.shell .stepper__step {
  flex: 1;
  padding: 12px 0 10px;
  border-bottom: 3px solid transparent;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  counter-increment: step;
}
.shell .stepper__step::before { content: counter(step) " \00b7  "; }
.shell .stepper__step.is-current {
  border-bottom-color: var(--step-current-line);
  color: var(--step-current);
  font-weight: 700;
}
.shell .stepper__step.is-done { color: var(--ok); }
.shell .stepper__step.is-done::before { content: "\2713  "; }

/* ---------- card ---------- */

/* A form inside a card stacks its children like the card does. */
.shell .card > form { display: flex; flex-direction: column; gap: 12px; margin: 0; }

.shell .card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.shell .card > h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.shell .card > h2 { margin: 0; font-size: 17px; font-weight: 700; }
.shell .card > p { margin: 0; }
.shell .card--center { align-items: center; text-align: center; }

/* ---------- buttons ---------- */

.shell .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.shell .btn--primary { background: var(--primary); color: var(--on-primary); }
.shell .btn--primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.shell .btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--brand-text);
}
.shell .btn--secondary:hover { color: var(--brand-text); border-color: var(--brand-text); }
.shell .btn--link {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--link);
  font-size: 15px;
  font-weight: 600;
}
.shell .btn--link:hover { color: var(--link-hover); }
.shell .btn--block { width: 100%; }
.shell .btn:disabled,
.shell .btn[aria-disabled="true"] {
  background: var(--disabled-bg);
  border-color: transparent;
  color: var(--disabled-text);
  cursor: not-allowed;
}

/* ---------- notices ---------- */

.shell .notice {
  display: flex;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  background: var(--info-bg);
  color: var(--info-text);
  font-size: 15px;
  line-height: 1.45;
}
.shell .notice--info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.shell .notice--warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.shell .notice--error { background: var(--error-bg); border-color: var(--error-border); color: var(--error-text); }
.shell .notice--success { background: var(--ok-bg); border-color: var(--ok); color: var(--text); }
.shell .notice__icon { flex: none; width: 22px; height: 22px; }
.shell .notice--warn .notice__icon { color: var(--warn-icon); }
.shell .notice--success .notice__icon { color: var(--ok); }
.shell .notice__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.shell .notice__title { font-size: 15px; font-weight: 700; }
.shell .notice--warn .notice__title { color: var(--warn-title); }
.shell .notice--success .notice__title { color: var(--ok); }
.shell .notice ul,
.shell .notice ol { margin: 4px 0 0; padding-left: 20px; }
.shell .notice p { margin: 0; }

/* ---------- fields ---------- */

.shell .field { display: flex; flex-direction: column; gap: 6px; }
.shell .field label { font-size: 15px; font-weight: 600; }
.shell .field input[type="email"],
.shell .field input[type="text"],
.shell .field select {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 17px;
}
.shell .field .input--code {
  height: 60px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 26px;
  letter-spacing: .2em;
}
.shell .hint { margin: 0; font-size: 14px; color: var(--muted); }

.shell label.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0;
  font-size: 16px;
  line-height: 1.45;
  cursor: pointer;
}
.shell label.check input {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--primary);
}

/* ---------- file picker ---------- */

.shell label.picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 168px;
  padding: 20px;
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
}
.shell .picker__icon { width: 40px; height: 40px; color: var(--brand-text); }
.shell .picker__title { font-size: 18px; font-weight: 700; color: var(--brand-text); }
.shell .picker__sub { font-size: 14px; color: var(--muted); }
.shell .picker__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}
.shell .picker:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.shell .picker.is-dragging { border-color: var(--primary); background: var(--info-bg); }

/* ---------- disclosure ---------- */

.shell details.disclosure { color: var(--text-2); }
.shell details.disclosure > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--brand-text);
  cursor: pointer;
}

/* ---------- action bar ---------- */

.shell .action-bar {
  --frame: 608px;
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px max(16px, calc((100% - var(--frame)) / 2)) calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.shell .action-bar--wide { --frame: 1008px; }
.shell .action-bar__inner { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.shell .action-bar__hint { margin: 0; text-align: center; font-size: 14px; color: var(--muted); }

/* ---------- split ---------- */

.shell .split { display: grid; gap: 16px; }
.shell .split__aside,
.shell .split__main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- toast ---------- */

.shell .toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--surface);
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .45);
}
.shell .toast[hidden] { display: none; }
.shell .toast--error { background: var(--toast-error-bg); color: #fff; }

/* ---------- busy + done ---------- */

.shell .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: shell-spin .8s linear infinite;
}
@keyframes shell-spin { to { transform: rotate(360deg); } }

.shell .done-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ok-bg);
  color: var(--ok);
}
.shell .done-mark svg { width: 34px; height: 34px; stroke: currentColor; }
.shell .done-mark--bad { background: var(--error-bg); color: var(--error-text); }

/* ---------- desktop ---------- */

@media (min-width: 900px) {
  .shell .split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
  .shell .split__aside { position: sticky; top: 72px; }
  /* On desktop the action sits right under the content, at the end of the row, not pinned to the
     bottom of a tall window; main stops growing so the footer takes the slack instead. */
  .shell .app-main { flex: none; }
  .shell .app-footer { margin-top: auto; }
  .shell .action-bar {
    position: static;
    padding-top: 0;
    border-top: 0;
    background: transparent;
  }
  .shell .action-bar__inner { align-items: flex-end; }
  .shell .action-bar .btn--block { width: auto; min-width: 280px; }
  .shell .action-bar__hint { text-align: right; }
}

/* ---------- reduced motion ---------- */

/* The spinner keeps turning: it is the only sign that work is in progress. */
@media (prefers-reduced-motion: reduce) {
  .shell *,
  .shell *::before,
  .shell *::after { transition: none !important; scroll-behavior: auto !important; }
}
