/* ─── TOKENS (mirrors site tokens exactly) ──────────── */
:root {
  --ink:          #0D1117;
  --ink-dim:      #6B7280;
  --surface:      #FFFFFF;
  --panel:        #F4F5F6;
  --panel-mid:    #ECEEF0;
  --dark:         #0F1B2D;
  --navy:         #1A3A5C;
  --blue:         #2563AE;
  --sky:          #5BA8D9;
  --lime:         #C8E84A;
  --lime-dark:    #A8C832;
  --border-l:     #E5E7EB;
  --radius:       12px;
  --radius-lg:    18px;
  --nav-h:        56px;

  --sysuse-col:    #2563AE;
  --infoqual-col:  #0D9488;
  --interqual-col: #7C3AED;

  --error:         #DC2626;
  --error-bg:      #FEF2F2;
  --error-border:  #FECACA;
  --success:       #16A34A;
  --success-bg:    #F0FDF4;
}

/* ─── RESET ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Noto Sans', sans-serif;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
img, video { display: block; width: 100%; }
ul { list-style: none; }

/* ─── TOAST (H1: system status feedback) ────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 99px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  transition: opacity .25s, transform .25s;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
}
.toast.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.toast--success { background: var(--success); }
.toast.toast--error   { background: var(--error); }

/* ─── NAV ────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: var(--nav-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-l);
  transition: box-shadow .3s;
}
.nav-left {
  display: flex;
  align-items: center;
  gap: 20px;
}
.nav-logo {
  font-family: 'Noto Sans', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.3px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-logo span {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--ink);
  border-radius: 4px;
}
.nav-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-dim);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22C55E;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}
.nav-links a {
  font-size: 14px;
  color: var(--ink);
  transition: color .2s;
}
.nav-links a:hover { color: var(--blue); }
.nav-active { font-weight: 600; color: var(--ink) !important; }
.nav-cta {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  background: #d0d0d0;
  color: #fff;
  border-radius: 8px;
  transition: background .2s, transform .15s;
}
.nav-cta:hover { background: #bbb; transform: translateY(-1px); }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
  background: none;
  border: none;
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--ink);
  border-radius: 2px;
}
.mobile-menu {
  display: none;
  position: fixed;
  top: var(--nav-h); left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border-l);
  padding: 20px 32px 24px;
  z-index: 99;
  flex-direction: column;
  gap: 4px;
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
  font-size: 16px;
  color: var(--ink-dim);
  padding: 12px 0;
  border-bottom: 1px solid var(--border-l);
}
.mobile-menu a:last-child { border-bottom: none; }

/* ─── PAGE LAYOUT ────────────────────────────────────── */
.pssuq-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  min-height: 100vh;
  padding-top: var(--nav-h);
  align-items: start;
}

/* ─── LEFT: CALCULATOR ───────────────────────────────── */
.calc-panel {
  background: var(--surface);
  border-right: 1px solid var(--border-l);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--nav-h));
}
.calc-inner {
  flex: 1;
  padding: 48px 48px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Heading */
.calc-heading {
  font-family: 'Noto Sans', sans-serif;
  font-weight: 700;
  font-size: clamp(26px, 3vw, 40px);
  letter-spacing: -1px;
  color: var(--ink);
  line-height: 1.1;
  margin-bottom: 6px;
}
.calc-sub {
  font-size: 14px;
  color: var(--ink-dim);
  line-height: 1.6;
}
.calc-sub strong { color: var(--ink); }

/* Results block */
.results-block {
  background: var(--panel);
  border: 1px solid var(--border-l);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-l);
  font-size: 14px;
  gap: 12px;
}
.result-row:last-child { border-bottom: none; }
.result-label {
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.result-range {
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-dim);
  opacity: .7;
}
.result-value {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}
.result-overall { background: var(--navy); }
.result-overall .result-label  { color: rgba(255,255,255,.75); font-weight: 600; }
.result-overall .result-range  { color: rgba(255,255,255,.45); }
.result-overall .result-value  { color: var(--lime); font-size: 17px; }

/* H9: inline error banner */
.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius);
  color: var(--error);
  font-size: 13px;
  line-height: 1.55;
}
.error-banner[hidden] { display: none; }
.error-banner svg { flex-shrink: 0; margin-top: 1px; }

/* Controls bar */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
}
.control-group--right { margin-left: auto; }
.ctrl-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.ctrl-input {
  width: 54px;
  padding: 5px 8px;
  border: 1px solid var(--border-l);
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
  color: var(--ink);
  background: var(--surface);
  text-align: center;
}
.ctrl-input::placeholder { color: var(--ink-dim); font-size: 11px; }
.ctrl-input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

.btn-ctrl {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Noto Sans', sans-serif;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: background .18s, transform .12s;
  white-space: nowrap;
}
.btn-ctrl:hover:not(:disabled) { background: var(--navy); transform: translateY(-1px); }
.btn-ctrl:disabled { opacity: .35; pointer-events: none; cursor: not-allowed; }
.btn-ctrl--ghost {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--border-l);
}
.btn-ctrl--ghost:hover:not(:disabled) { background: var(--panel); color: var(--ink); transform: none; }

/* H2/H6: scale reminder strip */
.scale-reminder {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.scale-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-dim);
  background: var(--panel);
  border: 1px solid var(--border-l);
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
}
.scale-pill--good { color: #16A34A; background: #F0FDF4; border-color: #BBF7D0; }
.scale-pill--bad  { color: #DC2626; background: #FEF2F2; border-color: #FECACA; }
.scale-divider { font-size: 11px; color: var(--border-l); }

/* Table */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
}
.table-wrap::-webkit-scrollbar { height: 5px; }
.table-wrap::-webkit-scrollbar-track { background: var(--panel); }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border-l); border-radius: 4px; }

#pssuq-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
}

/* H2: subscale header row */
#pssuq-table thead tr:first-child th {
  padding: 10px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #fff;
  text-align: center;
  white-space: nowrap;
}
#pssuq-table thead tr:first-child .th-participant {
  background: var(--dark);
  color: rgba(255,255,255,.6);
  font-size: 11px;
  width: 44px;
  min-width: 44px;
}
.th-sysuse    { background: var(--sysuse-col); }
.th-infoqual  { background: var(--infoqual-col); }
.th-interqual { background: var(--interqual-col); }

/* H2: Q# row with SA/SD labels */
#pssuq-table thead tr:last-child th {
  background: var(--panel);
  color: var(--ink-dim);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 8px;
  text-align: center;
  border-bottom: 2px solid var(--border-l);
  min-width: 36px;
  line-height: 1.3;
}
.th-sa { display: block; font-size: 9px; font-weight: 700; color: #16A34A; letter-spacing: .3px; }
.th-sd { display: block; font-size: 9px; font-weight: 700; color: #DC2626; letter-spacing: .3px; }

#pssuq-table tbody tr { transition: background .12s; }
#pssuq-table tbody tr:hover { background: #F0F4FF; }
#pssuq-table tbody tr:nth-child(even) { background: #FAFAFA; }
#pssuq-table tbody tr:nth-child(even):hover { background: #EEF2FF; }

#pssuq-table tbody td {
  border: 1px solid var(--border-l);
  padding: 0;
  text-align: center;
  min-width: 36px;
  height: 34px;
  color: var(--ink);
  font-size: 13px;
}
#pssuq-table tbody td:first-child {
  background: var(--panel);
  color: var(--ink-dim);
  font-weight: 600;
  font-size: 12px;
  pointer-events: none;
  padding: 8px 10px;
}
#pssuq-table tbody td[contenteditable="true"]:focus {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: #EFF6FF;
  position: relative;
  z-index: 1;
}

/* H5/H9: invalid cell highlight */
#pssuq-table tbody td.cell-invalid {
  background: var(--error-bg) !important;
  color: var(--error) !important;
  outline: 1.5px solid var(--error-border) !important;
}

/* H6: table hint */
.table-hint {
  font-size: 12px;
  color: var(--ink-dim);
  margin-top: -8px;
  line-height: 1.5;
}

/* Action buttons */
.calc-action {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.btn-calculate {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: var(--lime);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  font-family: 'Noto Sans', sans-serif;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s, transform .15s, opacity .15s;
  letter-spacing: -.2px;
}
.btn-calculate:hover { background: var(--lime-dark); transform: translateY(-1px); }
/* H1: calculating state */
.btn-calculate.is-loading { opacity: .6; pointer-events: none; }
.btn-calculate.is-done    { background: var(--lime-dark); }

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Noto Sans', sans-serif;
  border: 1.5px solid var(--border-l);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
  white-space: nowrap;
}
.btn-download:hover {
  background: var(--panel);
  border-color: var(--ink-dim);
  transform: translateY(-1px);
}

/* Footer */
.calc-footer {
  padding: 24px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid var(--border-l);
}
.footer-copy { font-size: 12px; color: var(--ink-dim); }
.footer-links { display: flex; gap: 20px; }
.footer-links a { font-size: 12px; color: var(--ink-dim); transition: color .2s; }
.footer-links a:hover { color: var(--ink); }

/* ─── RIGHT: EXPLANATION PANEL ───────────────────────── */
.explain-panel {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--border-l);
  -webkit-overflow-scrolling: touch;
}
.explain-panel::-webkit-scrollbar { width: 4px; }
.explain-panel::-webkit-scrollbar-track { background: transparent; }
.explain-panel::-webkit-scrollbar-thumb { background: var(--border-l); border-radius: 4px; }

.explain-inner {
  padding: 52px 44px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* H10: PDF download card */
.pdf-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
  background: var(--surface);
  border: 1.5px solid var(--border-l);
  border-radius: var(--radius-lg);
  transition: box-shadow .2s, transform .2s;
}
.pdf-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,.07);
  transform: translateY(-1px);
}
.pdf-card-icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  background: var(--panel);
  border: 1px solid var(--border-l);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  margin-top: 2px;
}
.pdf-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pdf-card-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.pdf-card-text {
  font-size: 12.5px;
  color: var(--ink-dim);
  line-height: 1.65;
}
.btn-pdf-download {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  padding: 8px 16px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Noto Sans', sans-serif;
  border-radius: 8px;
  cursor: pointer;
  transition: background .18s, transform .12s;
  width: fit-content;
}
.btn-pdf-download:hover { background: var(--navy); transform: translateY(-1px); }

/* Divider */
.explain-divider {
  height: 1px;
  background: var(--border-l);
  margin: 2px 0;
}

/* Badge */
.explain-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--blue);
  background: rgba(37,99,174,.08);
  border: 1px solid rgba(37,99,174,.2);
  padding: 5px 12px;
  border-radius: 20px;
  width: fit-content;
}

/* Headings */
.explain-heading {
  font-family: 'Noto Sans', sans-serif;
  font-weight: 700;
  font-size: clamp(20px, 2.5vw, 30px);
  color: var(--ink);
  letter-spacing: -.5px;
  line-height: 1.2;
}
.explain-body { font-size: 15px; line-height: 1.8; color: var(--ink); }
.explain-body strong { font-weight: 700; }

.explain-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink-dim);
}

/* Subscale list */
.subscale-list { display: flex; flex-direction: column; }
.subscale-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-l);
}
.subscale-item:first-child { border-top: 1px solid var(--border-l); }
.subscale-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.subscale-dot--sysuse    { background: var(--sysuse-col); }
.subscale-dot--infoqual  { background: var(--infoqual-col); }
.subscale-dot--interqual { background: var(--interqual-col); }
.subscale-body { display: flex; flex-direction: column; gap: 3px; }
.subscale-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.subscale-name em { font-style: normal; font-weight: 400; color: var(--ink-dim); font-size: 12px; }
.subscale-desc { font-size: 13px; color: var(--ink-dim); line-height: 1.5; }

/* How-to steps */
.how-list { display: flex; flex-direction: column; gap: 13px; }
.how-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.65;
}
.how-item strong { font-weight: 700; }
.how-num {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--panel-mid);
  border: 1px solid var(--border-l);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-dim);
  margin-top: 2px;
}

/* Score scale */
.interpret-block { display: flex; flex-direction: column; gap: 14px; }
.score-scale { display: flex; flex-direction: column; gap: 10px; }
.scale-bar {
  position: relative;
  height: 10px;
  border-radius: 99px;
  background: var(--border-l);
}
.scale-fill {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #22C55E 0%, #F59E0B 50%, #EF4444 100%);
}
.scale-marker {
  position: absolute;
  top: -4px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.scale-marker span {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-l);
  padding: 1px 5px;
  border-radius: 4px;
  margin-top: 16px;
}
.scale-labels { display: flex; justify-content: space-between; margin-top: 4px; }
.scale-good { font-size: 12px; font-weight: 700; color: #16A34A; }
.scale-bad  { font-size: 12px; font-weight: 700; color: #DC2626; }
.explain-hint { font-size: 13px; color: var(--ink-dim); line-height: 1.7; }
.explain-hint strong { color: var(--ink); }

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 1100px) {
  .calc-inner    { padding: 40px 36px 28px; }
  .explain-inner { padding: 44px 32px; }
}

@media (max-width: 960px) {
  .pssuq-layout { grid-template-columns: 1fr; }

  /* Explanation below calculator on mobile (calc is first in DOM) */
  .explain-panel {
    position: relative;
    top: auto;
    height: auto;
    overflow-y: visible;
    border-left: none;
    border-top: 1px solid var(--border-l);
  }
  .explain-inner { padding: 40px 36px; }
  .calc-panel    { border-right: none; min-height: auto; }
  .calc-inner    { padding: 40px 36px 24px; }
  .calc-footer   { padding: 24px 36px; }
  .controls-bar  { gap: 10px; }
  .control-group--right { margin-left: 0; }
}

@media (max-width: 768px) {
  nav { padding: 0 20px; }
  .nav-links, .nav-status, .nav-cta { display: none; }
  .hamburger { display: flex; }

  .explain-inner { padding: 32px 24px; }
  .calc-inner    { padding: 32px 20px 24px; }
  .calc-footer   { padding: 20px 24px; flex-direction: column; align-items: flex-start; }

  #pssuq-table { font-size: 12px; }
  #pssuq-table thead tr:first-child th { padding: 8px 5px; font-size: 9.5px; }
  #pssuq-table thead tr:last-child th  { min-width: 30px; padding: 5px; }
  #pssuq-table tbody td { min-width: 30px; height: 32px; }

  .controls-bar { flex-direction: column; align-items: stretch; }
  .control-group { width: 100%; flex-wrap: wrap; }
  .control-group--right { margin-left: 0; }

  .calc-action { flex-direction: column; }
  .btn-calculate, .btn-download { width: 100%; justify-content: center; }

  .scale-reminder { gap: 6px; }

  .pdf-card { flex-direction: column; }
}

@media (max-width: 480px) {
  .explain-inner   { padding: 28px 20px; }
  .explain-heading { font-size: 20px; }
}
