/* Outrider theme: shared tokens, header and theme toggle. Each tool keeps its own copy. */
:root{
  --bg:#14181f; --surface:#1c222b; --surface-2:#232a35; --border:#333c49;
  --text:#e7e4db; --text-dim:#9aa4b2; --text-faint:#6b7684;
  --brand:#7000d6; --brand-hover:#8f00ff; --on-brand:#ffffff;
  --accent:#b98cff; --accent-soft:rgba(185,140,255,0.16);
  --green:#4c9a63; --green-text:#a8d6b6;
  --red:#c1503f; --red-text:#f0b3ab;
  --amber:#d4a24c; --amber-text:#f0d29b;
  --shadow:0 4px 14px rgba(0,0,0,0.35);
  --radius:8px;
  --mono:"SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans:-apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --head:"Cinzel", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  color-scheme:dark;
}
@media (prefers-color-scheme: light){
  :root:not([data-theme="dark"]){
    --bg:#e8eaef; --surface:#ffffff; --surface-2:#f1f2f6; --border:#cdd1db;
    --text:#22242c; --text-dim:#545a6b; --text-faint:#7f8598;
    --accent:#7000d6; --accent-soft:rgba(112,0,214,0.10);
    --green:#2f7a48; --green-text:#1f5533;
    --red:#a5372a; --red-text:#7a281e;
    --amber:#93701f; --amber-text:#6e5416;
    --shadow:0 4px 14px rgba(40,50,80,0.14);
    color-scheme:light;
  }
}
:root[data-theme="light"]{
  --bg:#e8eaef; --surface:#ffffff; --surface-2:#f1f2f6; --border:#cdd1db;
  --text:#22242c; --text-dim:#545a6b; --text-faint:#7f8598;
  --accent:#7000d6; --accent-soft:rgba(112,0,214,0.10);
  --green:#2f7a48; --green-text:#1f5533;
  --red:#a5372a; --red-text:#7a281e;
  --amber:#93701f; --amber-text:#6e5416;
  --shadow:0 4px 14px rgba(40,50,80,0.14);
  color-scheme:light;
}
*,*::before,*::after{ box-sizing:border-box; }
body{
  margin:0; background:var(--bg); color:var(--text); font-family:var(--sans);
  line-height:1.5;
}
a{ color:var(--accent); }
a:hover{ color:var(--brand-hover); }
:root[data-theme="dark"] a:hover{ color:#d3b8ff; }
h1,h2,h3{ font-family:var(--head); }
.site-header{
  display:flex; align-items:center; gap:16px; flex-wrap:wrap;
  max-width:1180px; margin:0 auto; padding:24px 24px 18px;
  border-bottom:1px solid var(--border);
}
.brand{ flex-shrink:0; display:block; line-height:0; border-radius:12px; }
.brand img{ width:56px; height:56px; object-fit:contain; }
.brand:focus-visible{ outline:2px solid var(--accent); outline-offset:3px; }
.head-text{ flex:1; min-width:200px; }
.site-header h1{
  font-size:1.5rem; font-weight:600; letter-spacing:0.05em; margin:0 0 4px;
  text-transform:uppercase; color:var(--text);
}
.site-header p{ margin:0; color:var(--text-dim); font-size:14.5px; max-width:640px; }
#themeToggle{
  flex-shrink:0; display:flex; align-items:center; gap:7px;
  background:var(--surface); border:1px solid var(--border); color:var(--text-dim);
  border-radius:20px; padding:7px 14px 7px 12px; font-size:13px; font-family:var(--sans);
  cursor:pointer;
}
#themeToggle:hover{ color:var(--text); border-color:var(--accent); }
#themeToggle:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
#themeToggle svg{ width:15px; height:15px; }
.btn{
  background:var(--brand); color:var(--on-brand); border:1px solid transparent;
  border-radius:6px; padding:8px 14px; font-size:14px; font-family:var(--sans);
  font-weight:600; cursor:pointer;
}
.btn:hover{ background:var(--brand-hover); }
.btn-secondary{
  background:transparent; color:var(--accent); border:1px solid var(--accent);
  border-radius:6px; padding:8px 14px; font-size:14px; font-family:var(--sans);
  font-weight:600; cursor:pointer;
}
.btn-secondary:hover{ background:var(--accent-soft); }

/* Downtime result colors (DC line) */
:root{
  --dc-default:var(--accent);
  --dc-crit-fail:#ff6b5e; --dc-fail:#ffa64d; --dc-success:#5cc46a; --dc-crit-success:#5cb3ff;
}
:root[data-theme="light"]{
  --dc-crit-fail:#b3261e; --dc-fail:#a85a00; --dc-success:#2f7a48; --dc-crit-success:#1f5fbf;
}
@media (prefers-color-scheme: light){
  :root:not([data-theme="dark"]){
    --dc-crit-fail:#b3261e; --dc-fail:#a85a00; --dc-success:#2f7a48; --dc-crit-success:#1f5fbf;
  }
}

/* App layout */
#app{ max-width:960px; margin:0 auto; padding:0 16px 24px; }
.site-header{ padding-left:0; padding-right:0; margin-bottom:20px; }

.card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:20px; margin-bottom:20px; box-shadow:var(--shadow);
}
.card h2{ font-size:1.05rem; font-weight:600; letter-spacing:0.04em; margin-top:0; }

.general-input-header{ display:flex; justify-content:space-between; align-items:center; margin-bottom:0.75rem; }
.general-input-header h2{ margin:0; }

/* System toggle (PF2 / SF2) */
.system-toggle-container{ display:flex; justify-content:flex-end; }
.system-toggle{
  display:inline-flex; border-radius:999px; overflow:hidden;
  border:1px solid var(--border); background:var(--surface-2);
}
.system-toggle label{ display:flex; align-items:center; cursor:pointer; }
.system-toggle input{ display:none; }
.system-toggle span{ padding:0.25rem 0.85rem; color:var(--text-dim); font-size:0.9rem; font-weight:600; }
.system-toggle input:checked + span{ background:var(--brand); color:var(--on-brand); border-radius:999px; }

/* Forms */
.form-row{ display:flex; flex-direction:column; margin-bottom:0.75rem; }
.form-row label{ margin-bottom:0.25rem; font-weight:600; font-size:0.9rem; color:var(--text-dim); }
input[type="text"], input[type="number"]{
  padding:0.45rem 0.6rem; border-radius:6px; border:1px solid var(--border);
  background:var(--surface-2); color:var(--text); font-family:var(--sans); font-size:14px;
}
input[type="text"]:focus, input[type="number"]:focus{ outline:2px solid var(--accent); outline-offset:1px; }
.level-input, .days-input{ width:3.6rem; }
.income-display{ width:6rem; }
.field-error{ color:var(--red-text); font-size:0.8rem; min-height:1em; }

/* Character cards */
.character-card{
  background:var(--surface-2); border:1px solid var(--border); border-radius:var(--radius);
  padding:0.85rem; margin-bottom:0.75rem;
}
.character-header{
  display:grid; grid-template-columns:auto auto auto auto;
  column-gap:1rem; row-gap:0.25rem; align-items:start;
}
.character-header .form-row, .character-footer .form-row{ margin-bottom:0; }
.character-middle{ display:flex; justify-content:center; margin:0.4rem 0 0.6rem; font-size:0.95rem; }
.character-middle span{
  display:inline-block; padding:0.3rem 0.7rem; border-radius:999px;
  background:var(--bg); border:1px solid var(--border);
  color:var(--dc-default); font-weight:600;
}
.character-footer{ display:grid; grid-template-columns:2fr 1fr 1fr; column-gap:1rem; align-items:center; }

/* Radio pills */
.radio-group{ display:flex; flex-wrap:wrap; gap:0.3rem; }
.radio-pill{
  position:relative; display:inline-flex; align-items:center; justify-content:center;
  padding:0.25rem 0.55rem; border-radius:999px; border:1px solid var(--border);
  background:var(--surface); color:var(--text-dim); cursor:pointer; font-size:0.85rem;
}
.radio-pill:hover{ border-color:var(--accent); }
.radio-pill input{ display:none; }
.radio-pill .x-mark{
  width:14px; height:14px; border-radius:3px; border:1px solid var(--text-faint);
  position:relative; margin-right:0.35rem;
}
.radio-pill input:checked ~ .x-mark{ background:var(--brand); border-color:var(--brand); }
.radio-pill input:checked ~ .x-mark::before,
.radio-pill input:checked ~ .x-mark::after{
  content:""; position:absolute; top:2px; left:6px; width:2px; height:8px;
  background:#ffffff; transform-origin:center;
}
.radio-pill input:checked ~ .x-mark::before{ transform:rotate(45deg); }
.radio-pill input:checked ~ .x-mark::after{ transform:rotate(-45deg); }
.radio-pill.disabled{ opacity:0.4; cursor:not-allowed; }

/* HHST checkbox */
.checkbox-row{ display:flex; align-items:center; gap:0.4rem; cursor:pointer; color:var(--text-dim); }
.checkbox-row input{ display:none; }
.checkbox-custom{ width:18px; height:18px; border-radius:3px; border:1px solid var(--text-faint); position:relative; }
.checkbox-row input:checked + .checkbox-custom{ background:var(--brand); border-color:var(--brand); }
.checkbox-row input:checked + .checkbox-custom::before,
.checkbox-row input:checked + .checkbox-custom::after{
  content:""; position:absolute; top:2px; left:8px; width:2px; height:10px;
  background:#ffffff; transform-origin:center;
}
.checkbox-row input:checked + .checkbox-custom::before{ transform:rotate(45deg); }
.checkbox-row input:checked + .checkbox-custom::after{ transform:rotate(-45deg); }

#appendix-toggle{ min-width:120px; text-align:center; }

/* Summary */
.summary-output{
  min-height:4rem; font-family:var(--mono); font-size:0.9rem; white-space:pre-wrap;
  background:var(--surface-2); border:1px solid var(--border); color:var(--text-dim);
  padding:0.6rem 0.75rem; border-radius:6px; margin:0 0 0.75rem;
}

/* Banners */
.banner{
  position:fixed; right:1rem; padding:0.6rem 1rem; border-radius:6px;
  font-size:0.9rem; z-index:20; opacity:0; pointer-events:none; transition:opacity 0.4s;
  color:#ffffff;
}
.banner-error{ top:1rem; background:#b00020; }
.banner-copy{ bottom:4.5rem; background:#2e7d32; }
.banner.visible{ opacity:1; pointer-events:auto; }
.hidden{ display:none; }

/* Appendix */
.appendix{ margin-top:0.75rem; }
.appendix-block{ margin-bottom:0.75rem; }
.appendix-block h3{ font-size:0.95rem; font-weight:600; letter-spacing:0.04em; margin-bottom:0.25rem; }
#downtime-table-container{ overflow:hidden; }
.downtime-table{ width:100%; border-collapse:collapse; font-size:0.85rem; }
.downtime-table th, .downtime-table td{
  text-align:center; padding:0.3rem 0.35rem; border-bottom:1px solid var(--border);
}
.downtime-table th{ font-weight:700; }

/* Mobile */
@media (max-width:640px){
  .character-header, .character-footer{ grid-template-columns:1fr !important; }
  .summary-output{ font-size:0.8rem; }
}

[hidden]{ display:none !important; }
#installBtn{
  flex-shrink:0; background:var(--brand); border:1px solid transparent; color:var(--on-brand);
  border-radius:20px; padding:7px 14px; font-size:13px; font-family:var(--sans);
  font-weight:600; cursor:pointer;
}
#installBtn:hover{ background:var(--brand-hover); }
#installBtn:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
