:root {
    --bg: #F3EEE1;
    --surface: #FBF8F0;
    --surface-2: #EAE2CD;
    --text: #241F18;
    --text-dim: #6B6153;
    --accent: #B23A2E;
    --accent-ink: #FBF8F0;
    --violet: #A98544;
    --mint: #3E7A5B;
    --border: rgba(36,31,24,0.16);
    --tape-a: #B23A2E;
    --tape-b: #241F18;
    --radius: 6px;
    --shadow: 0 1px 2px rgba(36,31,24,0.06), 0 10px 28px rgba(36,31,24,0.08);
  }
  html.dark {
    --bg: #171310;
    --surface: #1E1812;
    --surface-2: #29211A;
    --text: #EDE6D6;
    --text-dim: #A79C89;
    --accent: #E2665A;
    --accent-ink: #171310;
    --violet: #C9A356;
    --mint: #5FA986;
    --border: rgba(237,230,214,0.14);
    --tape-a: #E2665A;
    --tape-b: #171310;
    --shadow: 0 8px 30px rgba(0,0,0,0.35);
  }
  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    transition: background .3s ease, color .3s ease;
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3, .display { font-family: 'Instrument Serif', sans-serif; letter-spacing: -0.02em; }
  .mono { font-family: 'Space Mono', monospace; }
  a { color: inherit; }
  .container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

  /* ---- Ruler tick motif (signature element) ---- */
  .tape {
    height: 22px;
    width: 100%;
    background-image: repeating-linear-gradient(
      -45deg,
      var(--tape-a), var(--tape-a) 14px,
      var(--tape-b) 14px, var(--tape-b) 28px
    );
    opacity: 0.9;
  }
  .ruler-underline {
    position: relative;
    display: inline-block;
  }
  .ruler-underline::after {
    content: "";
    display: block;
    height: 8px;
    margin-top: 6px;
    background-image:
      repeating-linear-gradient(to right, var(--accent) 0, var(--accent) 2px, transparent 2px, transparent 10px);
    background-size: 100% 8px;
    background-position: bottom;
  }

  /* ---- Header ---- */
  header {
    position: sticky; top: 0; z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .nav-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 0;
  }
  .logo {
    font-family: 'Instrument Serif', sans-serif;
    font-weight: 700;
    font-size: 22px;
    display: flex; align-items: center; gap: 8px;
    text-decoration: none; color: var(--text); cursor: pointer;
  }
  .logo .dot { color: var(--accent); }
  nav.links { display: flex; gap: 28px; align-items: center; }
  nav.links a { text-decoration: none; font-weight: 500; font-size: 15px; color: var(--text-dim); cursor: pointer; }
  nav.links a:hover { color: var(--text); }
  .icon-btn {
    width: 40px; height: 40px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 18px;
  }
  .header-actions { display: flex; align-items: center; gap: 12px; }
  .hamburger { display: none; }

  /* ---- Hero ---- */
  .hero { padding: 80px 0 56px; }
  .eyebrow {
    font-family: 'Space Mono', monospace;
    font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--violet); font-weight: 700; margin-bottom: 18px; display: block;
  }
  .hero h1 { font-size: 56px; line-height: 1.05; margin: 0 0 20px; max-width: 780px; }
  .hero p.sub { font-size: 18px; color: var(--text-dim); max-width: 560px; margin: 0 0 32px; }
  .hero-cta { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 56px; }
  .btn-primary {
    background: var(--text); color: var(--bg);
    padding: 14px 26px; border-radius: 100px; border: none;
    font-weight: 600; font-size: 15px; cursor: pointer;
  }
  .btn-ghost {
    background: transparent; color: var(--text);
    padding: 14px 26px; border-radius: 100px; border: 1px solid var(--border);
    font-weight: 600; font-size: 15px; cursor: pointer;
  }

  /* ---- Live demo strip in hero ---- */
  .live-demo {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
  }
  .live-demo .field label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); font-weight: 700; }
  .live-demo input[type=range] { width: 100%; accent-color: var(--accent); }
  .live-demo .value { font-family: 'Space Mono'; font-size: 28px; font-weight: 700; }
  .live-demo .result {
    text-align: center;
  }
  .result-badge {
    position: relative;
    background: var(--accent); color: var(--accent-ink);
    font-family: 'Space Mono'; font-weight: 700; font-size: 32px;
    padding: 10px 22px 10px 30px; border-radius: 8px; display: inline-block;
    outline: 2px dashed color-mix(in srgb, var(--accent-ink) 35%, transparent);
    outline-offset: -6px;
  }
  .result-badge::before {
    content: '';
    position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--surface);
    border: 1.5px solid color-mix(in srgb, var(--accent-ink) 40%, transparent);
  }
  .result-sub { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

  /* ---- Category grid ---- */
  .section { padding: 60px 0; }
  .section-head { margin-bottom: 32px; }
  .section-head span.eyebrow { margin-bottom: 8px; }
  .section-head h2 { font-size: 34px; margin: 0 0 8px; }
  .section-head p { color: var(--text-dim); font-size: 16px; margin: 0; max-width: 560px; }

  .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  a.card { text-decoration: none; }
  .card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 28px 24px; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
  }
  .card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
  .card .emoji { font-size: 28px; margin-bottom: 16px; display: block; }
  .card h3 { font-size: 17px; margin: 0 0 8px; }
  .card p { font-size: 13px; color: var(--text-dim); margin: 0; line-height: 1.5; }

  /* ---- Calculator screens ---- */
  .screen { display: none; padding: 48px 0 80px; }
  .screen.active { display: block; }
  .back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); text-decoration: none; font-size: 14px; margin-bottom: 24px; cursor: pointer; font-weight: 600; }
  .calc-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
  .calc-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 32px; box-shadow: var(--shadow);
  }
  .unit-toggle { display: inline-flex; background: var(--surface-2); border-radius: 100px; padding: 4px; margin-bottom: 24px; }
  .unit-toggle button {
    border: none; background: transparent; padding: 8px 18px; border-radius: 100px;
    font-weight: 600; font-size: 13px; cursor: pointer; color: var(--text-dim);
  }
  .unit-toggle button.active { background: var(--text); color: var(--bg); }
  .field-group { margin-bottom: 20px; }
  .field-group label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em;}
  .field-group input[type=number] {
    width: 100%; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--bg); color: var(--text); font-size: 16px; font-family: 'Space Mono';
  }
  .measure-tip { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
  .calc-card .calc-btn {
    width: 100%;
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  .calc-card .calc-btn:active { transform: translateY(1px); }
  .result-panel.flash { animation: result-flash .5s ease; }
  @keyframes result-flash {
    0% { box-shadow: var(--shadow), 0 0 0 0 rgba(178,58,46,0.45); }
    40% { box-shadow: var(--shadow), 0 0 0 6px rgba(178,58,46,0.15); }
    100% { box-shadow: var(--shadow), 0 0 0 0 rgba(178,58,46,0); }
  }
  .gender-toggle { display: flex; gap: 10px; margin-bottom: 24px; }
  .gender-toggle button {
    flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
    font-weight: 600; cursor: pointer; color: var(--text-dim); font-size: 13px;
  }
  .gender-toggle button.active { background: var(--violet); color: white; border-color: var(--violet); }

  .result-panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 32px; text-align: center; box-shadow: var(--shadow);
  }
  .result-panel .big-size {
    position: relative;
    font-family: 'Space Mono'; font-weight: 700; font-size: 60px; color: var(--accent-ink);
    background: var(--accent); display: inline-block; padding: 16px 40px 16px 52px; border-radius: 8px; margin: 16px 0 20px;
    outline: 2px dashed color-mix(in srgb, var(--accent-ink) 35%, transparent);
    outline-offset: -8px;
  }
  .result-panel .big-size::before {
    content: '';
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--surface);
    border: 2px solid color-mix(in srgb, var(--accent-ink) 40%, transparent);
  }
  .result-panel .tag { font-size: 13px; color: var(--mint); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
  table.chart { width: 100%; border-collapse: collapse; margin-top: 24px; font-size: 13px; }
  table.chart th, table.chart td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: center; }
  table.chart th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; }
  table.chart tr.highlight td { background: var(--surface-2); font-weight: 700; }
  .disclaimer-note { font-size: 12px; color: var(--text-dim); margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--border); }

  /* ---- Result action buttons (copy/print/share) ---- */
  .result-actions { display: flex; gap: 8px; justify-content: center; margin: 2px 0 10px; flex-wrap: wrap; }
  .result-actions button {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 100px;
    padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text);
    display: inline-flex; align-items: center; gap: 6px; transition: background .15s ease;
  }
  .result-actions button:hover { background: var(--border); }

  /* ---- Toast notification ---- */
  #toastMsg {
    position: fixed; bottom: 90px; right: 28px; background: var(--text); color: var(--bg);
    padding: 10px 20px; border-radius: 8px; font-size: 13px; font-weight: 600;
    opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease;
    z-index: 70; pointer-events: none;
  }
  #toastMsg.show { opacity: 1; transform: translateY(0); }

  /* ---- Print: show only the active result panel ---- */
  @media print {
    header, footer, #scrollTop, .calc-card, .back-link, .result-actions, .tape { display: none !important; }
    body { background: #fff; }
    .screen:not(.active) { display: none !important; }
    .calc-layout { grid-template-columns: 1fr !important; }
    .result-panel { box-shadow: none !important; border: 1px solid #000 !important; }
    .result-panel::before { content: "7TShirts.com"; display: block; font-weight: 700; margin-bottom: 12px; }
    body.print-only-measurement .calc-layout:not(.tool-measurement) { display: none !important; }
    body.print-only-measurement .section-head { display: none !important; }
  }

  /* ---- FAQ accordion ---- */
  .faq-section details {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 20px; margin-bottom: 10px;
  }
  .faq-section summary {
    font-weight: 600; cursor: pointer; font-size: 15px; list-style: none;
    display: flex; justify-content: space-between; align-items: center;
  }
  .faq-section summary::after { content: '+'; font-size: 20px; color: var(--accent); font-weight: 400; margin-left: 12px; }
  .faq-section details[open] summary::after { content: '−'; }
  .faq-section summary::-webkit-details-marker { display: none; }
  .faq-section p { color: var(--text-dim); font-size: 14px; line-height: 1.6; margin: 12px 0 0; }
  .faq-section code.mono { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

  /* ---- Legal / footer ---- */
  footer { border-top: 1px solid var(--border); padding: 48px 0 32px; margin-top: 40px; }
  .footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr 1fr; gap: 28px; margin-bottom: 32px; }
  .footer-col h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin: 0 0 14px; }
  .footer-col a { display: block; font-size: 14px; margin-bottom: 10px; text-decoration: none; color: var(--text); cursor: pointer; }
  .footer-col a:hover { color: var(--violet); }
  .footer-bottom { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; gap: 12px; }
  .footer-bottom .copy { margin: 0; }
  .footer-company-line { display: block; margin-top: 4px; font-size: 12px; opacity: 0.85; }

  /* ---- Scroll to top ---- */
  #scrollTop {
    position: fixed; bottom: 28px; right: 28px; width: 48px; height: 48px; border-radius: 50%;
    background: var(--accent); color: var(--accent-ink); border: none; font-size: 20px; cursor: pointer;
    box-shadow: var(--shadow); display: none; align-items: center; justify-content: center; z-index: 60;
  }
  #scrollTop.show { display: flex; }

  /* ---- Standalone content pages (about, contact, legal) ---- */
  .page-hero { padding: 56px 0 32px; }
  .page-hero .eyebrow { margin-bottom: 14px; }
  .page-hero h1 { font-size: 40px; margin: 0 0 12px; }
  .page-hero .updated { font-size: 13px; color: var(--text-dim); }
  .content-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 40px; box-shadow: var(--shadow); margin-bottom: 64px;
  }
  .content-card h2 { font-size: 22px; margin: 32px 0 12px; }
  .content-card h2:first-child { margin-top: 0; }
  .content-card p { color: var(--text-dim); font-size: 15px; line-height: 1.75; margin: 0 0 14px; }
  .content-card ul { color: var(--text-dim); font-size: 15px; line-height: 1.75; padding-left: 20px; }
  .content-card a.inline-link { color: var(--accent); font-weight: 600; text-decoration: underline; }
  .content-card .lede { font-size: 17px; color: var(--text); }

  @media (max-width: 860px) {
    .hero { padding: 48px 0 36px; }
    .hero h1 { font-size: 36px; }
    .live-demo { grid-template-columns: 1fr; }
    .grid { grid-template-columns: repeat(2, 1fr); }
    .section { padding: 40px 0; }
    .section-head { margin-bottom: 22px; }
    .calc-layout { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    nav.links { display: none; }
  }