:root {
    /* --- Minty theme --- */
    --mint: #3EDCB3;
    --mint-dark: #2AB897;
    --mint-light: #C9F7EE;

    --neutral-dark: #222B2B;
    --neutral-light: #F9FAF9;

    --text-dark: #003322;
    --text-light: #ffffff;
}

body {
    font: 16px system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial
}

/* --- Sticky footer layout (non-intrusive) --- */
html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Instead of flexing .wrap (which breaks inner layouts), we use a spacer */
.page-content {
  flex: 1 0 auto; /* fill remaining space, but don't shrink content */
}

/* Footer always sits at the bottom */
footer {
  flex-shrink: 0;
  text-align: center;
  font-size: 0.85rem;
  color: #888;
  padding: 1rem 0;
  margin-top: auto; /* ensures sticky behavior */
}

.grid2 {
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: 0.5rem;
}

.grid {
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: 1rem
}

textarea, input {
    width: 100%
}

/* Base card uses CSS vars so variants can override locally */
.card {
    --card-bg: #fff;
    --card-border: #ddd;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.2rem 1rem;
    margin-bottom: 0.5rem; /* reduces space between cards */
    overflow: hidden;            /* keeps child elements contained */
}

/* Mint variant (very light background + slightly stronger border) */
.card[data-variant="mint"] {
    --card-bg: color-mix(in srgb, var(--mint) 4%, #fff);
    --card-border: var(--mint-dark);
}

.btn-row {
    display: flex;
    gap: .5rem;
    align-items: center
}

.small {
    font-size: .9rem;
    color: #666
}

input {
    width: 95%;
    /*font: inherit;*/
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #ccc;
    /*background: #fafafa;*/
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    height: 8px;
    margin-bottom: 5px; /* gap between input fields */
}

input:focus {
    outline: none;
    border-color: var(--mint-dark);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint-light) 40%, transparent);
    background: #fff;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: -0.5rem;
    color: #222;
}

input::placeholder {
    color: #aaa;
    font-style: italic;
}


button,
a.button {
    display: inline-block;
    font: inherit;
    padding: .6rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--mint-dark);
    background: var(--mint);
    color: var(--text-dark);
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s ease, transform 0.1s ease;
}

button:hover,
a.button:hover {
    background: var(--mint-dark);
    transform: translateY(-1px);
}

button:active,
a.button:active {
    transform: translateY(0);
}

a.button[aria-disabled="true"] {
    opacity: .55;
    pointer-events: none; /* blocks clicks/hover */
    filter: grayscale(10%);
}

a.button:not([aria-disabled="true"]) {
    border-width: 2px;
    box-shadow: 0 0 6px rgba(42, 184, 151, 0.4);
    font-weight: bold;;
    /*transform: scale(1.02);*/
}

h3 {
    text-align: center;
    margin-top: 0.9rem;
    margin-bottom: 2rem;
}

h3 span {
    border-bottom: 3px solid var(--mint);
    /*border-top: 2px solid var(--mint);*/
    padding-bottom: 0.1em;
}

h1 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--neutral-dark);
    text-decoration: underline;
    text-underline-color: var(--neutral-dark);

    text-align: center;
    margin-bottom: 1rem;
}

h1 .mint-accent {
    color: var(--mint-dark);
    text-decoration: underline;
    text-underline-color: var(--mint-dark);
}

/* Segmented control container */
.segmented {
  display: flex;
  gap: .5rem;
  justify-content: center;
  flex-wrap: wrap;
  border: 0;
  padding: 0;
  margin: .25rem 0 1rem;
  width: 100%;
  box-sizing: border-box;
  min-inline-size: 0; /* ← prevents overflow on tiny screens */
}

/* Hide the native radios but keep them accessible */
.segmented .seg {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Unselected buttons: outline style */
.segmented label.button {
  background: #fff;
  color: var(--neutral-dark);
  border: 1px solid var(--mint-dark);
  flex: 1 1 0;
  min-width: 0;            /* ← critical: allows buttons to shrink */
  text-align: center;
  padding: 0.25rem 0.55rem;
  font-size: 0.9rem;
  border-radius: 8px;
  white-space: nowrap;
}

/* Selected state: looks “active” */
.segmented .seg:checked + label.button {
  background: var(--mint);
  color: var(--text-dark);
  font-weight: bold;
  border-width: 2px;
  box-shadow: 0 0 6px rgba(42, 184, 151, .35);
}

/* Keyboard focus ring for accessibility */
.segmented .seg:focus + label.button {
  outline: 3px solid color-mix(in srgb, var(--mint) 40%, transparent);
  outline-offset: 2px;
}

/* --- MOBILE --- */
@media (max-width: 480px) {
  .segmented {
    flex-wrap: nowrap;        /* keep in one row */
    gap: .35rem;
  }
  .segmented .button {
    flex: 1 1 0;
    padding: .4rem 0;
    font-size: .9rem;
    min-width: 0;            /* ← ensure it can shrink */
  }
}


/* Each row: number + input side by side */
.fen-grid .row {
    display: flex;
    grid-template-columns: auto 1fr; /* number + flexible input */
    align-items: center;
    /*margin: 0.25rem 0; DEAD CODE? */
}

/* Number style */
.fen-grid .n {
    width: 1.8rem;
    height: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--mint-dark);
    border-radius: 8px;
    background: #fff;
    color: var(--neutral-dark);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Inputs fill the rest of the row */
.fen-grid input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    border: 1px solid #ccc;
    font: inherit;
}

/* Greyed-out look for disabled inputs */
.fen-grid input:disabled {
    /*background:#f3f4f4;*/
    color: #666666;
    /*border-color:#e0e3e2;*/
    border-color: crimson;
    /*cursor:not-allowed;*/
    text-decoration: line-through;
    background: #666666;
}

/* dim the number badge for disabled rows */
.fen-grid .row.is-disabled .n {
    opacity: .45;
}

.fen-grid .row.is-disabled {
    position: relative;
}

.fen-grid .row.is-disabled::after {
    content: "";
    position: absolute;
    left: 2.5rem; /* leave space for the number badge */
    right: 0.5rem;
    top: 50%;
    height: 1px;
    background: #b4b8b7; /* match grey tone */
    pointer-events: none; /* allow clicking again when re-enabled */
}

/* Tabs */
.tabs {
    display: flex;
    gap: .5rem;
    justify-content: center;
    margin-bottom: .6rem
}

/* Tab look (reuse your .button style base) */
.tabs .tab {
    background: #fff;
    color: var(--neutral-dark);
    border: 1px solid var(--mint-dark);
    padding: .35rem .8rem;
    border-radius: 10px;
    cursor: pointer
}

.tab-radio:checked + .tab {
    background: var(--mint);
    color: var(--text-dark);
    font-weight: bold;
    border-width: 2px;
}

/* Panels: hide all by default; show by checked tab */
#tab-fen:checked ~ .panels #panel-fen {
    display: block
}

#tab-cap:checked ~ .panels #panel-cap {
    display: block
}


/* Tabs container (keep) */
.tabs-wrapper {
    display: flex;
    gap: .5rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: .6rem;
}

/* Radios hidden (keep) */
.tab-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Reset generic label rules just inside tabs */
.tabs-wrapper label {
    display: inline-flex; /* instead of block */
    align-items: center;
    justify-content: center;
    margin: 0; /* kill the big bottom margin */
}

/* Tab look */
.tabs-wrapper .tab {
    flex: 0 0 auto; /* don’t stretch full width */
    background: #fff;
    color: var(--neutral-dark);
    border: 1px solid var(--mint-dark);
    padding: .35rem .8rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background .2s ease, transform .1s ease;
}

/* Selected tab */
.tab-radio:checked + .tab {
    background: var(--mint);
    color: var(--text-dark);
    font-weight: bold;
    border-width: 2px;
}

/* Panels */
.tab-panel {
    display: none;
    margin-top: .5rem;
}

#tab-fen:checked ~ .panels #panel-fen {
    display: block;
}

#tab-cap:checked ~ .panels #panel-cap {
    display: block;
}

/* wrapper is block so panels drop underneath */
.tabs-wrapper {
    display: block;
}

/* the row that holds the tabs */
.tab-bar {
    display: flex;
    gap: .5rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: .6rem;
}

/* hide native radios */
.tab-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* neutralize any global label styles just here */
.tab-bar label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

/* tab look (reuses your button style idea) */
.tab-bar .tab {
    background: #fff;
    color: var(--neutral-dark);
    border: 1px solid var(--mint-dark);
    padding: .35rem .8rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background .2s ease, transform .1s ease;
}

/* selected tab styling */
#tab-fen:checked + label[for="tab-fen"],
#tab-cap:checked + label[for="tab-cap"] {
    background: var(--mint);
    color: var(--text-dark);
    font-weight: bold;
    border-width: 2px;
}

/* panels hidden by default */
.tab-panel {
    display: none;
    margin-top: .5rem;
}

/* show the active panel — uses :has() on the parent */
.tabs-wrapper:has(#tab-fen:checked) #panel-fen {
    display: block;
}

.tabs-wrapper:has(#tab-cap:checked) #panel-cap {
    display: block;
}

/* Source tabs row (Manual / Auto) */
.source-tabs{
  display:flex; gap:.5rem; justify-content:center; align-items:center;
  margin-bottom:.6rem;
}
.source-radio{ position:absolute; opacity:0; width:0; height:0; }

/* Show the right panel using :has() */
.source-panels .source-panel{ display:none; }
.card:has(#source-manual:checked) #panel-manual{ display:block; }
.card:has(#source-auto:checked)   #panel-auto{   display:block; }

/* Optional: keep the “tab” look consistent */
.source-tabs .tab{
  background:#fff;
  color:var(--neutral-dark);
  border:1px solid var(--mint-dark);
  padding:.35rem .9rem;
  border-radius:10px;
  cursor:pointer;
}
#source-manual:checked + label[for="source-manual"],
#source-auto:checked   + label[for="source-auto"]{
  background:var(--mint);
  color:var(--text-dark);
  font-weight:bold;
  border-width:2px;
}

/* Always reserve space for scrollbar to avoid lateral shift */
html {
  overflow-y: scroll;
}





.clear-diagrams { text-align: center; margin-top: .5rem; }

.button.secondary{
  background: #fff;
  color: var(--neutral-dark);
  border: 1px solid var(--mint-dark);
}
.button.secondary:hover{
  background: var(--mint-light);
}

.btn-row .spacer{ flex:1; }              /* pushes Clear all to the right */

.button.danger{
  background:#fff;
  color:#b00020;
  border:1px solid #e0a4ab;
}
.button.danger:hover{
  background:#fdecec;
}

/* --- Top navigation --- */
.topnav{
  display:flex;
  justify-content:center;
  gap:.5rem;
  flex-wrap:wrap;
  margin:-.25rem 0 1.25rem; /* tucks closer to the h1 */
}
.topnav-link{
  display:inline-block;
  padding:.5rem .9rem;
  border-radius:.75rem;
  text-decoration:none;
  line-height:1;
  border:1px solid #e6e6e6;
  background:#fff;
  color:#111;
  font-size:.95rem;
  box-shadow:0 1px 2px rgba(0,0,0,.06);
  transition:transform .05s ease, box-shadow .15s ease, background .2s ease, border-color .2s ease;
}
.topnav-link:hover{
  transform:translateY(-1px);
  box-shadow:0 3px 10px rgba(0,0,0,.08);
}
.topnav-link.is-active{
  border-color:#00b894;
  background:linear-gradient(180deg,#eafff8,#ffffff);
  color:#00b894;
  font-weight:600;
}

/* --- Mobile: scrollable one-line menu --- */
@media (max-width: 480px) {
  .topnav {
    flex-wrap: nowrap;               /* single line */
    overflow-x: auto;                /* horizontal scroll */
    -webkit-overflow-scrolling: touch; /* smooth iOS scroll */
    justify-content: flex-start;     /* left aligned */
    gap: .4rem;
    padding: 0 .5rem;
    scrollbar-width: none;           /* hide scrollbar on Firefox */
  }

  .topnav::-webkit-scrollbar {
    display: none;                   /* hide scrollbar on WebKit */
  }

  .topnav a {
    flex: 0 0 auto;                  /* keep natural width */
    font-size: .9rem;
    padding: .45rem .75rem;
  }
}


/* make the menu stick at the top while scrolling */
.topnav { position:sticky; top:0; z-index:10; background:#fff; padding:.5rem; }

select {
  border: 1px solid #ccc;
  border-radius: .5rem;
  padding: .3rem .4rem;
  font-size: .95rem;
  width: 100%;
  max-width: 15rem;
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Collapse to a single column on mobile */
@media (max-width: 900px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}

/* Optional: slightly tighter spacing on very small screens */
@media (max-width: 420px) {
  .grid2 {
    gap: 0.75rem;
  }
}

/* --- PDF preview frame --- */
#preview {
  width: 100%;
  border: 1px solid #e5e5e5;
  border-radius: 0.75rem;
  display: block;
  aspect-ratio: 8.5 / 11; /* match letter/A4 ratio roughly */
  max-height: 100vh;       /* prevent it from being enormous */
  height: auto;
}

/* On phones, give the preview most of the viewport height */
@media (max-width: 900px) {
  #preview {
    min-height: 80vh;
  }
}

/* If the screen is *very* narrow, prefer opening the PDF in a new tab.
   We show the helper button and can optionally hide the iframe. */
.mobile-only { display: none; }

@media (max-width: 480px) {
  .mobile-only { display: block; }
  /* Option A: keep the iframe but it will be tall;
     Option B (harsher): comment-in the next line to hide it completely */
  /* #preview { display: none; } */
}

/* --- Utility styles for disabled links/buttons (optional polish) --- */
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input[type="range"] {
  accent-color: #3cd3ad; /* your mint color */
}

/* Header container always centered and aligned */
.site-header {
  position: relative;
  text-align: center;
  margin: 1rem auto 1.25rem; /* consistent spacing */
  width: 100%;
  max-width: 900px;          /* aligns with .wrap if desired */
}

/* Make sure .wrap starts right after the header */
.wrap {
  max-width: 1100px;         /* wider workspace for two columns */
  margin: 0 auto 2rem;       /* keep centered and consistent */
  padding: 0 1rem;
}


/* --- Site title / heading styles --- */
.site-title a {
  color: black;
  text-decoration: none;
}

.site-title .mint-accent {
  color: var(--mint-dark);
}

.brand-link {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease-in-out;
}
.brand-link:hover {
  opacity: 0.75;
}
