body {
    font-family: Arial, sans-serif;
    background-color: #f5f0e6;
    background-image: url('images/backgrnd.jpg');
    color: #3b2f2f;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    margin: 0;
    padding: 0;
}
header {
  text-align: center; /* Center content horizontally */
  padding: 1px 0;
}

header img {
    filter: drop-shadow(20px 20px 6px rgba(0, 0, 0, 1.0));
}

header .logo {
  height: auto; /* adjust size as needed */
  width: 280px;
  display: inline-block;
}

/* Remove the transparent background from text containers */
header, section, div, p {
    background: none !important;
}

nav {
    background: rgba(0,0,0,0.55) !important;
    border-bottom: 1px solid rgba(244,225,193,0.35);

    
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.25rem;
}
nav a {
    color: #fff !important;
    padding: 0.75rem 1rem;
    text-decoration: none;
    font-weight: 700;
    border-radius: 6px;
}
nav a:hover { background: rgba(0,0,0,0.35) !important; color: #fff !important; }
main {
    max-width: 1000px;
    margin: 1.25rem auto;
    background: transparent;
    padding: 1.5rem;
    box-shadow: 0 0 10px rgba(0,0,0,0.12);
    border-radius: 8px;
}
h1, h2 { color: #2e4b3d; }
footer {
    background: rgba(0,0,0,0.55) !important;
    color: #f5f5dc;
    text-align: center;
    padding: 1rem;
    margin-top: 1.25rem;
}
label { display:block; margin-top:0.5rem; margin-bottom:0.25rem; }
input, select, textarea { width:100%; padding:0.5rem; margin-bottom:0.75rem; border:1px solid #ccc; border-radius:6px; }
button { background-color:#2e4b3d; color:#fff; padding:0.6rem 1rem; border:none; border-radius:6px; cursor:pointer; }
button:hover { background-color:#3f6b54; }
@media (max-width:600px){ nav { gap:0.25rem; } nav a{ padding:0.5rem 0.75rem; } main{ margin:1rem; padding:1rem; } }

/* === Enhanced form styles === */
#cb-form.form-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem 1.25rem;
  align-items:start;
}
.field { display:flex; flex-direction:column; }
.field.full { grid-column: 1 / -1; }

fieldset {
  border: 1px solid #d9cbbb;
  border-radius: 8px;
  padding: 0.75rem 1rem 1rem;
  background-image: url('images/form-bg.png'); background-size: cover; background-position: center; background-repeat: no-repeat;
}
legend {
  padding: 0 0.4rem;
  color: #2e4b3d;
  font-weight: bold;
}
.checkbox-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem 0.75rem;
  margin-top: 0.25rem;
}
.checkbox-grid label {
  position: relative;
  padding-left: 28px; /* space for the checkbox */
}

.checkbox-grid input[type="checkbox"] {
  position: absolute;
  left: 120px;  /* distance from the left edge of the box */
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}


.helper { color:#d7c08a; font-size:0.92rem; }

/* Inputs look/feel */
input, select, textarea { 
  background-image: url('images/form-bg.png'); background-size: cover; background-position: center; background-repeat: no-repeat; 
  transition: border-color 0.15s ease, box-shadow 0.15s ease; 
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2e4b3d;
  box-shadow: 0 0 0 3px rgba(46, 75, 61, 0.15);
}

/* Custom file input */
.custom-file { position: relative; display:flex; align-items:center; gap:0.5rem; }
.custom-file input[type="file"]{
  position:absolute; inset:0; opacity:0; cursor:pointer; width:100%; height:100%;
}
.custom-file .button {
  background-color:#2e4b3d; color:#fff; padding:0.6rem 1rem; border-radius:6px; border:none;
}
.custom-file .file-name { font-size:0.9rem; color:#3b2f2f; }

/* Controls */
.controls { display:flex; justify-content:flex-end; gap:0.75rem; }
.controls.full { grid-column: 1 / -1; }

/* Result box */
.result-box {
  background: rgba(0,0,0,0.03);
  border:1px dashed #c8b79f;
  padding: 1rem;
  border-radius: 8px;
  white-space: pre-line;
}

/* Minor typography tweak */
.small { color:#5a4f4f; }



/* === Contrast Boost for image background === */
main {
  background: rgba(0,0,0,0.70) !important;
  color: #fff;
  -webkit-border: 1px solid rgba(255,255,255,0.12);
}

h1, h2, label, legend, .helper, p, small {
  color: #fff !important;
}

a { color: #cfe8ff; }
a:hover { color: #fff; }

/* Inputs and controls on dark */
input, select, textarea {
  background: rgba(0,0,0,0.55) !important;
  color: #fff !important;
  border-color: rgba(244, 225, 193,0.35) !important;
}
input::placeholder, textarea::placeholder { color: rgba(255,255,255,0.75); }

.checkbox-grid label {
  background: rgba(0,0,0,0.55) !important;
  color: #fff !important;
  border-color: rgba(244, 225, 193,0.28) !important;
}

fieldset {
  background: transparent !important;
  border-color: rgba(244, 225, 193,0.28) !important;
}
legend { color: #fff !important; background: transparent !important; }

/* Buttons on dark */
button, .custom-file .button {
  background-color:#2e4b3d !important;
  color:#fff !important;
  border: none !important;
}
button:hover, .custom-file .button:hover { background-color:#3f6b54 !important; }

/* Result box */
.result-box {
  background: rgba(0,0,0,0.25) !important;
  border-color: rgba(244, 225, 193,0.2) !important;
  color:#fff !important;
}

/* Slight text shadow for readability on busy spots */
h1, h2, label, legend, p, small, .helper {
  text-shadow: 10px 10px 6px rgba(0,0,0,1.0);
}

select {
    background: rgba(0, 0, 0, 0.9) !important;
    color: #fff !important;
}

select option {
    background: rgba(0, 0, 0, 0.9) !important;
    color: #fff !important;
}

/* Wood preview tooltip */
.wood-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

.wood-item .info {
  width: 18px;
  height: 18px;
  line-height: 18px;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: .8;
}

.wood-item .info:hover,
.wood-item .info:focus {
  opacity: 1;
  outline: none;
}

.wood-item .preview {
  position: absolute;
  top: 50%;
  left: calc(100% + 8px);
  transform: translateY(-50%);
  display: none;
  z-index: 50;
  background: rgba(0,0,0,.85);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  padding: 6px;
  width: 200px; height: 150px; overflow: hidden;
}

.wood-item .preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }


.wood-item .info:hover + .preview,
.wood-item .info:focus + .preview,


/* If the preview might run off the right edge on small screens,
   stack under the label instead */
@media (max-width: 600px) {
  .wood-item .preview { height: 200px; }
  .wood-item .preview {
    left: 0;
    top: calc(100% + 6px);
    transform: none;
    width: min(80vw, 320px);
  }
}

/* Optional: keep the grid neat with the new content */
.checkbox-grid .wood-item {
  margin-right: .5rem;
  margin-bottom: .5rem;
}


/* Show class for JS toggle */
.wood-item .preview.show { display: block; }



/* Prevent right-column previews from going off-screen: open to the LEFT */
#grain-radios .wood-item .preview {
  left: auto;
  right: calc(100% + 8px);
  transform: translateY(-50%);
}


/* Uniform preview sizing for all wood/grain previews */
.wood-item .preview {
  width: 200px;
  height: 150px;
  overflow: hidden;
}
.wood-item .preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}


/* Make grain radio rows match wood checkbox row sizing */
#grain-radios .wood-item {
  width: 100%;
  justify-content: space-between;
}
#grain-radios .wood-item input[type="radio"] {
  margin-left: auto; /* pushes the radio to the right end like checkboxes styling */
}


@media (max-width: 600px) {
  #grain-radios .wood-item .preview {
    right: auto;
    left: 0;
    top: calc(100% + 6px);
    transform: none;
  }
}


/* === Ensure Wood Types and Grain Pattern columns match widths === */
.form-grid {
  grid-template-columns: 1fr 1fr; /* lock to two equal-width columns */
}

#wood-checkboxes, #grain-radios {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem 0.75rem;
}

#grain-radios .wood-item {
  width: 100%;
  justify-content: space-between;
}

#grain-radios .wood-item input[type="radio"] {
  margin-left: auto;
}

/* Uniform preview sizing */
.wood-item .preview {
  width: 200px;
  height: 150px;
  overflow: hidden;
}
.wood-item .preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

/* Grain previews open left to avoid overflow */
#grain-radios .wood-item .preview {
  left: auto;
  right: calc(100% + 8px);
  transform: translateY(-50%);
}

/* On small screens, drop previews below */
@media (max-width: 600px) {
  #grain-radios .wood-item .preview {
    right: auto;
    left: 0;
    top: calc(100% + 6px);
    transform: none;
  }
}



/* === Equalize the two main columns on the cutting board form === */
.form-grid {
  grid-template-columns: 1fr 1fr; /* lock to two equal columns */
}
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* Make fieldsets and fields fill their grid cell fully */
.field, .field fieldset, fieldset.field, fieldset.option-group {
  width: 100%;
  box-sizing: border-box;
}

/* Ensure consistent internal padding */
.field fieldset, fieldset.option-group {
  padding: 0.75rem 1rem 1rem;
}

/* Keep uniform preview sizes */
.wood-item .preview { width: 200px; height: 150px; overflow: hidden; }
.wood-item .preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }

/* Grain previews open to the left to avoid overflow */
#grain-radios .wood-item .preview {
  left: auto;
  right: calc(100% + 8px);
  transform: translateY(-50%);
}
@media (max-width: 600px) {
  #grain-radios .wood-item .preview {
    right: auto; left: 0; top: calc(100% + 6px); transform: none;
  }
}



/* Match Grain Pattern rows to Wood Types rows */
#grain-radios .wood-item {
  display: block;
  position: relative;
  padding: 0.45rem 44px 0.45rem 12px; /* room on right for radio */
  border-radius: 6px;
  background: rgba(0,0,0,0.55) !important;
  color: #fff !important;
  border: 1px solid rgba(244,225,193,0.28);
}

/* Place the radio on the right, vertically centered */
#grain-radios .wood-item input[type="radio"] {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}

/* Keep the ? button inline near the text */
#grain-radios .wood-item .info { margin-left: 6px; }



/* === Unify row styling for Wood & Grain lists === */
#grain-radios .wood-item { /* wood untouched; grain styled separately */ }

/* Place the controls on the right edge and center vertically */
#wood-checkboxes input[type="checkbox"],
#grain-radios .wood-item input[type="radio"] {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}

/* Keep the ? button right after the text with a little gap */
#wood-checkboxes .info,
#grain-radios .info { margin-left: 8px; }



/* === Make Grain Pattern rows match the smaller Wood Types rows === */
#grain-radios .wood-item {
  display: block;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 0.35rem 40px 0.35rem 12px; /* smaller vertical padding like wood rows */
  border-radius: 6px;
  background: rgba(0,0,0,0.55) !important;
  color: #fff !important;
}

/* Place radio at right, centered */
#grain-radios .wood-item input[type="radio"] {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}

/* Keep the ? button tucked after text */
#grain-radios .wood-item .info { margin-left: 6px; }



/* === Tighten Grain Pattern rows & keep ? clear of the radio === */
#grain-radios .wood-item {
  padding: 0.25rem 72px 0.25rem 12px; /* smaller height + extra right padding */
  border-radius: 6px;
}

/* Put the ? button just left of the radio so it never overlaps */
#grain-radios .wood-item .info {
  position: absolute;
  right: 44px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0; /* override any inline margin */
}

/* Radio stays at far right */
#grain-radios .wood-item input[type="radio"] {
  right: 12px;
}



/* === Make Wood Type rows match Grain Pattern styling === */
#wood-checkboxes label {
  display: block;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 0.25rem 72px 0.25rem 12px; /* match grain row padding */
  border-radius: 6px;
  background: rgba(0,0,0,0.55) !important;
  color: #fff !important;
  border: 1px solid rgba(244,225,193,0.28);
}

/* Place checkbox at far right */
#wood-checkboxes input[type="checkbox"] {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}

/* Place ? button just left of checkbox */
#wood-checkboxes .info {
  position: absolute;
  right: 44px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}



/* === Make WOOD rows match GRAIN row style === */
#wood-checkboxes label {
  display: block;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 0.25rem 72px 0.25rem 12px; /* same as grain rows */
  border-radius: 6px;
  background: rgba(0,0,0,0.55) !important;
  color: #fff !important;
  border: 1px solid rgba(244,225,193,0.28);
  /* override earlier padding-left from generic rule */
  padding-left: 12px !important;
}

/* Place checkbox at the far right, vertically centered (override earlier left:120px rule) */
#wood-checkboxes input[type="checkbox"] {
  position: absolute !important;
  right: 12px !important;
  left: auto !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  margin: 0 !important;
}

/* Put the ? button just to the left of the checkbox so it never overlaps text */
#wood-checkboxes .info {
  position: absolute;
  right: 44px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}



/* Match Board Size radios to wood/grain rows */
#size-radios .wood-item {
  display: block;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 0.25rem 44px 0.25rem 12px;
  border-radius: 6px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: 1px solid rgba(244,225,193,0.28);
}
#size-radios .wood-item input[type="radio"] {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}



/* === Prevent radios/checkboxes from overlapping label text === */

/* Wood Types: leave space for ? (at 44px) + checkbox (at 12px) */
#wood-checkboxes label {
  padding-right: 72px !important;  /* space for ? + checkbox */
  padding-left: 12px !important;   /* cancel earlier 28px */
  box-sizing: border-box;
}
#wood-checkboxes .info {
  position: absolute;
  right: 44px;
  top: 50%;
  transform: translateY(-50%);
}
#wood-checkboxes input[type="checkbox"] {
  position: absolute !important;
  right: 12px !important;
  left: auto !important;   /* override any global left:120px */
  top: 50% !important;
  transform: translateY(-50%) !important;
  margin: 0 !important;
}

/* Grain Pattern: same spacing for ? + radio */
#grain-radios .wood-item {
  padding-right: 72px !important;
  padding-left: 12px !important;
  box-sizing: border-box;
}
#grain-radios .wood-item .info {
  position: absolute;
  right: 44px;
  top: 50%;
  transform: translateY(-50%);
}
#grain-radios .wood-item input[type="radio"] {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}

/* Board Size radios: only a radio on the right */
#size-radios .wood-item {
  padding-right: 40px !important;
  padding-left: 12px !important;
  box-sizing: border-box;
}
#size-radios .wood-item input[type="radio"] {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}



/* === Prevent overlap in Board Size radios === */
#size-radios .wood-item {
  padding-right: 72px !important; /* reserve space for the radio */
  padding-left: 12px !important;
  box-sizing: border-box;
  line-height: 1.2;
}
#size-radios .wood-item input[type="radio"] {
  position: absolute !important;
  right: 12px !important;
  left: auto !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  margin: 0 !important;
}



/* === STRONG FIX: pin board size radios to far-right and reserve space === */
#size-radios label.wood-item {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  padding-right: 10px !important; /* extra space for radio */
  line-height: 1.25 !important;
}
#size-radios label.wood-item input[type="radio"] {
  position: absolute !important;
  right: 12px !important;
  left: auto !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  margin: 0 !important;
}

h1, h2, h3, li, p {
  text-align: center;
}