:root {
  --ink: #211b18;
  --muted: #6f625b;
  --paper: #fbf7f1;
  --paper-2: #f2e9dd;
  --line: #d9cabc;
  --accent: #9f1f2d;
  --accent-dark: #68131d;
  --gold: #b1883f;
  --good: #2d6b4f;
  --warn: #8a5a15;
  --bad: #9d2734;
  --shadow: 0 12px 32px rgba(53, 35, 27, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #e9dfd4;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: linear-gradient(180deg, #efe7de 0, #e7ddd2 100%); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.site-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 22px clamp(18px, 4vw, 54px);
  color: white;
  background:
    radial-gradient(circle at 12% 20%, rgba(255,255,255,.10), transparent 28%),
    linear-gradient(135deg, #451018, #8f1c29 62%, #54111a);
  border-bottom: 4px solid var(--gold);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 2px solid rgba(255,255,255,.75);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: .08em;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.09);
}
.eyebrow { margin: 0 0 3px; text-transform: uppercase; letter-spacing: .14em; font-size: .73rem; font-weight: 800; opacity: .8; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.65rem, 3vw, 2.65rem); line-height: 1.05; }
.subtitle { margin: 6px 0 0; opacity: .85; }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 750;
  color: white;
  background: var(--gold);
  box-shadow: 0 3px 10px rgba(0,0,0,.15);
}
.button:hover { filter: brightness(1.06); }
.button.secondary { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.35); }

.section-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px clamp(14px, 4vw, 54px);
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.section-nav a { padding: 8px 11px; border-radius: 7px; text-decoration: none; font-weight: 700; color: var(--accent-dark); white-space: nowrap; }
.section-nav a:hover { background: var(--paper-2); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(275px, 350px);
  gap: 24px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 38px) 64px;
}
.builder-column { min-width: 0; }
.notice {
  margin-bottom: 18px;
  padding: 13px 16px;
  border: 1px solid #d5bd91;
  border-left: 5px solid var(--gold);
  border-radius: 10px;
  background: #fff8e9;
  line-height: 1.45;
}
.panel {
  scroll-margin-top: 66px;
  margin-bottom: 22px;
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.section-heading, .subsection-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.section-heading { margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.step { margin: 0 0 3px; color: var(--accent); font-size: .73rem; text-transform: uppercase; letter-spacing: .14em; font-weight: 850; }
h2, h3 { font-family: Georgia, "Times New Roman", serif; }
h2 { margin: 0; font-size: clamp(1.35rem, 2.2vw, 1.8rem); }
h3 { margin: 0 0 8px; }
.section-note { color: var(--muted); font-size: .83rem; text-align: right; }
.subsection-heading { margin: 24px 0 13px; }
.subsection-heading p { margin: 5px 0 0; color: var(--muted); }
.attribute-total { flex: 0 0 auto; padding: 8px 12px; border-radius: 8px; background: var(--paper-2); font-weight: 800; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 15px; }
.form-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact-top { margin-top: 15px; }
label, legend { font-weight: 750; font-size: .9rem; }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #c9b9aa;
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: white;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(159,31,45,.12); }
textarea { resize: vertical; line-height: 1.42; }
small { display: block; margin-top: 5px; color: var(--muted); font-weight: 500; line-height: 1.3; }
.full-width-label { display: block; margin-top: 15px; }

.split-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.detail-card { min-height: 126px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.detail-card p { margin: 7px 0; line-height: 1.45; }
.muted { color: var(--muted); }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: var(--paper-2); font-size: .78rem; line-height: 1.2; }

.stats-inputs input { font-size: 1.1rem; font-weight: 750; }
.attribute-grid { display: grid; grid-template-columns: repeat(5, minmax(95px, 1fr)); gap: 10px; }
.attribute-grid label { padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: white; text-align: center; }
.attribute-grid span { display: block; color: var(--accent-dark); font-size: 1.05rem; }
.attribute-grid small { min-height: 31px; font-size: .7rem; }
.attribute-grid input { text-align: center; font-weight: 850; }

.empty-state { padding: 22px; border: 1px dashed #bda999; border-radius: 10px; color: var(--muted); text-align: center; background: rgba(255,255,255,.55); }
.mobility-choice { display: flex; align-items: center; gap: 20px; margin: 0 0 16px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 9px; }
.mobility-choice legend { padding: 0 7px; }
.mobility-choice label { display: flex; align-items: center; gap: 7px; }
.mobility-choice input { width: auto; margin: 0; }
.required-skill-list { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.required-skill { display: flex; justify-content: space-between; gap: 8px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: white; font-size: .86rem; }
.required-skill strong { color: var(--accent-dark); }

.skill-toolbar { display: grid; grid-template-columns: 2fr 1fr 1.4fr auto; align-items: end; gap: 10px; margin-bottom: 13px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.checkbox-label input { width: auto; margin: 0; }
.skill-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 12px; padding: 10px 12px; border-radius: 8px; background: var(--paper-2); color: var(--muted); font-size: .8rem; }
.skill-list { display: grid; gap: 8px; max-height: 780px; overflow: auto; padding-right: 4px; }
.skill-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}
.skill-row:hover { border-color: #b49b89; }
.skill-row.disabled { opacity: .58; background: #f3eee8; }
.skill-row input { width: 18px; height: 18px; margin: 0; }
.skill-name { font-weight: 780; }
.skill-meta { display: flex; flex-wrap: wrap; gap: 5px 10px; margin-top: 3px; color: var(--muted); font-size: .74rem; }
.skill-cost { min-width: 62px; text-align: right; font-weight: 850; color: var(--accent-dark); }
.skill-empty { padding: 25px; text-align: center; color: var(--muted); }

.summary-column { min-width: 0; }
.sticky-card { position: sticky; top: 60px; }
.summary-card { padding: 20px; border: 1px solid #cbb8a6; border-top: 5px solid var(--accent); border-radius: 13px; background: #fffdf9; box-shadow: var(--shadow); }
.summary-card .eyebrow { color: var(--accent); }
.summary-card h2 { overflow-wrap: anywhere; }
.summary-list { margin: 16px 0 10px; }
.summary-list div { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid #eadfd4; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; font-weight: 800; text-align: right; }
.summary-total { margin-top: 4px; border-bottom: 0 !important; font-size: 1.05rem; }
.summary-total dd { color: var(--accent-dark); }
.meter { height: 9px; overflow: hidden; border-radius: 999px; background: #e6ddd4; }
.meter div { width: 0; height: 100%; background: var(--accent); transition: width .2s ease; }
.validation-messages { display: grid; gap: 7px; margin-top: 14px; }
.validation-message { padding: 8px 10px; border-radius: 7px; font-size: .79rem; line-height: 1.35; }
.validation-message.good { color: #174a34; background: #e6f4ec; }
.validation-message.warn { color: #6f470e; background: #fff1d5; }
.validation-message.bad { color: #7f1c29; background: #fde8eb; }
.selected-summary { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.selected-summary h3 { display: flex; justify-content: space-between; font-size: 1rem; }
.selected-summary h3 span { display: inline-grid; place-items: center; min-width: 25px; height: 25px; border-radius: 50%; color: white; background: var(--accent); font-family: system-ui, sans-serif; font-size: .74rem; }
.selected-skill-summary { display: flex; flex-wrap: wrap; gap: 6px; max-height: 230px; overflow: auto; }
.selected-chip { padding: 5px 7px; border-radius: 6px; background: var(--paper-2); font-size: .72rem; }

.site-footer { padding: 22px; color: #76665c; text-align: center; font-size: .82rem; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; transform: translateY(20px); opacity: 0; pointer-events: none; padding: 10px 14px; border-radius: 8px; color: white; background: #2a2421; box-shadow: var(--shadow); transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.print-sheet { display: none; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .summary-column { order: -1; }
  .sticky-card { position: static; }
  .summary-card { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(300px, 1.2fr); gap: 18px 28px; }
  .summary-card > .eyebrow, .summary-card > h2 { grid-column: 1; }
  .summary-list { grid-column: 1; }
  .meter, .validation-messages, .selected-summary { grid-column: 2; }
  .meter { align-self: end; }
}

@media (max-width: 760px) {
  .site-header { grid-template-columns: auto 1fr; }
  .header-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .form-grid.two-columns, .form-grid.three-columns, .split-cards { grid-template-columns: 1fr; }
  .attribute-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .required-skill-list { grid-template-columns: 1fr 1fr; }
  .skill-toolbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .summary-card { display: block; }
  .mobility-choice { align-items: flex-start; flex-direction: column; gap: 10px; }
}

@media (max-width: 480px) {
  .brand-mark { width: 48px; height: 48px; }
  .panel { padding: 16px; border-radius: 10px; }
  .section-heading { display: block; }
  .section-note { display: block; margin-top: 6px; text-align: left; }
  .required-skill-list, .skill-toolbar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
}

@media print {
  @page { size: letter; margin: .45in; }
  body { background: white; font-size: 10pt; }
  .no-print, .layout, .site-header, .site-footer, .toast { display: none !important; }
  .print-sheet { display: block; }
  .print-header { display: flex; justify-content: space-between; align-items: end; border-bottom: 3px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  .print-header h1 { color: #000; font-size: 22pt; }
  .print-header p { margin: 0; }
  .print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .print-section { break-inside: avoid; border: 1px solid #777; padding: 8px; margin-bottom: 8px; }
  .print-section h2 { margin: -8px -8px 7px; padding: 5px 8px; color: white; background: #333; font-size: 12pt; }
  .print-section h3 { font-size: 10pt; margin: 7px 0 3px; }
  .print-section p { margin: 3px 0; white-space: pre-wrap; }
  .print-stats { width: 100%; border-collapse: collapse; text-align: center; }
  .print-stats th, .print-stats td { border: 1px solid #777; padding: 4px; }
  .print-skills { columns: 2; column-gap: 18px; margin: 0; padding-left: 18px; }
  .print-skills li { break-inside: avoid; margin-bottom: 2px; }
}
