/* ============================================================
   BlindSizer — Styles
   Palette: warm timber tones · cream · white
   Approach: mobile-first, max-width 480px column
   ============================================================ */

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }
button { font-family: inherit; cursor: pointer; }

/* ===== DESIGN TOKENS ===== */
:root {
  /* Colour */
  --c-bg:          #FAF7F3;
  --c-card:        #FFFFFF;
  --c-border:      #E4D8C8;
  --c-border-focus:#8B5E3C;

  --c-t-dark:   #3E2008;   /* darkest timber */
  --c-t-mid:    #6E3E1A;   /* primary timber */
  --c-t-warm:   #8B5E3C;   /* buttons, accents */
  --c-t-tan:    #C4956A;   /* light timber */
  --c-t-pale:   #DDB98A;   /* very light tan */
  --c-t-cream:  #F5EDE0;   /* warm cream */
  --c-t-mist:   #FAF0E6;   /* near-white cream */

  --c-text:     #2C1A0E;
  --c-text-mid: #5A3820;
  --c-text-muted: #9B7558;

  --c-success:  #4A8C5C;
  --c-warn:     #B06820;
  --c-warn-bg:  #FFF4E5;
  --c-warn-bd:  #E8A84A;
  --c-error:    #B03030;

  --c-white: #FFFFFF;

  /* Radii */
  --r-card: 16px;
  --r-md:   10px;
  --r-sm:    7px;

  /* Shadows */
  --shadow-card: 0 2px 16px rgba(62,32,8,0.10), 0 1px 4px rgba(62,32,8,0.06);
  --shadow-btn:  0 2px 8px rgba(62,32,8,0.22);

  /* Transitions */
  --t-fast: 0.15s ease;
  --t-mid:  0.25s ease;
}

/* ===== BASE ===== */
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== HEADER ===== */
header {
  background: var(--c-t-dark);
  padding: 16px 16px 18px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 12px rgba(0,0,0,0.20);
}

.header-inner {
  max-width: 480px;
  margin: 0 auto;
}

/* Logo shown white on dark header — invert the black logo */
.header-logo {
  display: block;
  height: 72px;
  width: auto;
  filter: brightness(0) invert(1);
  margin-bottom: 3px;
}

.header-sub {
  font-size: 12px;
  color: var(--c-t-tan);
  letter-spacing: 0.15px;
  padding-left: 2px;
}

/* ===== FOOTER ===== */
footer {
  background: var(--c-t-cream);
  border-top: 2px solid var(--c-border);
  padding: 28px 16px 36px;
  text-align: center;
}

.footer-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Footer logo — black on cream, reduce opacity slightly for refinement */
.footer-logo {
  height: 88px;
  width: auto;
  opacity: 0.75;
}

.footer-by {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-muted);
  letter-spacing: 0.2px;
}

/* ===== MAIN LAYOUT ===== */
main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 14px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== CARD ===== */
.card {
  background: var(--c-card);
  border-radius: var(--r-card);
  padding: 20px 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--c-border);
}

.section-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--c-t-mid);
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--c-t-cream);
  letter-spacing: -0.2px;
}

/* ===== FIELD GROUP ===== */
.field-group { margin-bottom: 16px; }
.field-group:last-child { margin-bottom: 0; }

.label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text-mid);
  margin-bottom: 6px;
  letter-spacing: 0.05px;
}

.label em {
  font-style: normal;
  font-weight: 400;
  color: var(--c-text-muted);
}

.field-hint {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-top: 5px;
  line-height: 1.4;
}

/* ===== INPUTS ===== */
.input {
  width: 100%;
  padding: 11px 13px;
  background: var(--c-t-mist);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 15px;
  color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

.input:focus {
  border-color: var(--c-border-focus);
  background: var(--c-white);
  box-shadow: 0 0 0 3px rgba(139,94,60,0.14);
}

.input::placeholder { color: var(--c-t-pale); }

/* ===== SELECT ===== */
.select-wrap { position: relative; }

.select {
  width: 100%;
  padding: 11px 36px 11px 13px;
  background: var(--c-t-mist);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 15px;
  color: var(--c-text);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.select:focus {
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 3px rgba(139,94,60,0.14);
}

.select-arrow {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--c-t-warm);
  pointer-events: none;
}

/* ===== TOGGLE GROUP ===== */
.toggle-group {
  display: flex;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--c-t-mist);
}

.toggle-btn {
  flex: 1;
  padding: 11px 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--c-text-muted);
  background: transparent;
  border: none;
  transition: background var(--t-fast), color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.1px;
}

.toggle-btn + .toggle-btn {
  border-left: 1.5px solid var(--c-border);
}

.toggle-btn.active {
  background: var(--c-t-mid);
  color: var(--c-white);
}

/* ===== MOUNT PANEL ===== */
.mount-panel {
  padding-top: 18px;
  margin-top: 4px;
  border-top: 1.5px solid var(--c-t-cream);
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header h3 {
  font-size: 15px;
  font-weight: 800;
  color: var(--c-t-dark);
  margin-bottom: 4px;
}

.panel-hint {
  font-size: 12.5px;
  color: var(--c-text-muted);
  line-height: 1.4;
}

/* ===== MEASUREMENTS GRID ===== */
.measurements-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.measure-col-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-t-warm);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 10px;
}

.col-icon {
  width: 14px;
  height: 14px;
  color: var(--c-t-warm);
  flex-shrink: 0;
}

.unit-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-muted);
  background: var(--c-t-cream);
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
}

/* ===== LOGIC CALLOUT ===== */
.logic-callout {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #F0F7FF;
  border: 1.5px solid #B8D4F0;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
}

.callout-icon {
  width: 15px;
  height: 15px;
  color: #4A7AB0;
  flex-shrink: 0;
  margin-top: 1px;
}

.logic-callout p {
  font-size: 12.5px;
  color: #2A4A70;
  line-height: 1.4;
}

.logic-callout strong {
  font-weight: 700;
}

/* ===== OBSTRUCTION CHECKLIST ===== */
.obstruction-section {
  background: var(--c-t-cream);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 14px;
}

.obstruction-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--c-t-dark);
  margin-bottom: 3px;
}

.obstruction-sub {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.obstruction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.obs-item-static {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px 9px;
  background: var(--c-white);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  text-align: center;
  pointer-events: none;
  user-select: none;
}

.obs-item-static span {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-mid);
  line-height: 1.2;
}

.obs-icon {
  width: 22px;
  height: 22px;
  color: var(--c-t-warm);
}

/* Confirm row */
.confirm-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 10px 10px;
  border-radius: var(--r-sm);
  border: 1.5px solid transparent;
  transition: border-color var(--t-fast), background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.confirm-row:has(#insideConfirm:checked) {
  border-color: var(--c-success);
  background: #EDF7F1;
}

#insideConfirm {
  width: 18px;
  height: 18px;
  accent-color: var(--c-success);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
}

.confirm-text {
  font-size: 13px;
  color: var(--c-text-mid);
  font-weight: 500;
  line-height: 1.4;
}

/* ===== OUTSIDE MOUNT ROW ===== */
.outside-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

/* ===== SLIDERS ===== */
.sliders-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 18px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.slider-readout {
  font-size: 17px;
  font-weight: 800;
  color: var(--c-t-warm);
  min-width: 40px;
  text-align: right;
  letter-spacing: -0.3px;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--c-t-cream);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

/* Track fill via CSS gradient (updated by JS) */
.slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--c-t-mid);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(62,32,8,0.28);
  transition: transform var(--t-fast), background var(--t-fast);
  margin-top: -10px;
}

.slider::-webkit-slider-thumb:active {
  transform: scale(1.12);
  background: var(--c-t-dark);
}

.slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: var(--c-t-mid);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(62,32,8,0.28);
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}

.slider-ticks span {
  font-size: 11px;
  color: var(--c-text-muted);
  font-weight: 600;
}

/* ===== ILLUSTRATION ===== */
.illus-card {
  background: var(--c-t-cream);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 14px 14px 10px;
  text-align: center;
}

.illus-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--c-text-muted);
  margin-bottom: 8px;
}

.illus-wrap {
  max-width: 240px;
  margin: 0 auto;
}

#windowSvg {
  width: 100%;
  height: auto;
  display: block;
}

/* ===== RESULT PILL ===== */
.result-pill {
  background: linear-gradient(135deg, var(--c-t-dark) 0%, var(--c-t-mid) 100%);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-top: 16px;
  margin-bottom: 4px;
  animation: slideUp 0.28s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.result-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--c-t-tan);
}

.result-mount {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-t-pale);
  background: rgba(255,255,255,0.12);
  padding: 2px 8px;
  border-radius: 10px;
}

.result-size {
  font-size: 26px;
  font-weight: 800;
  color: var(--c-white);
  letter-spacing: -0.6px;
  line-height: 1.15;
}

/* ===== SAVE ERROR ===== */
.save-error {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-error);
  text-align: center;
  min-height: 20px;
  margin-top: 6px;
  line-height: 1.4;
}

/* ===== BUTTONS ===== */
.btn-primary, .btn-copy {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 15px 16px;
  font-size: 16px;
  font-weight: 800;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.2px;
}

.btn-primary {
  background: var(--c-t-mid);
  color: var(--c-white);
  box-shadow: var(--shadow-btn);
  margin-top: 16px;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(62,32,8,0.18);
}

.btn-copy {
  background: var(--c-t-warm);
  color: var(--c-white);
  box-shadow: var(--shadow-btn);
  margin-top: 14px;
}

.btn-copy:active {
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(62,32,8,0.18);
}

.btn-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ===== SAVED LIST ===== */
.saved-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.saved-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--c-t-mist);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 12px 13px;
  animation: slideUp 0.25s ease;
}

.saved-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c-t-mid);
  color: var(--c-white);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.saved-info {
  flex: 1;
  min-width: 0;
}

.saved-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--c-t-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-size {
  font-size: 13px;
  color: var(--c-text-mid);
  margin-top: 1px;
  font-weight: 500;
}

.saved-mount {
  font-size: 11px;
  color: var(--c-text-muted);
  margin-top: 2px;
}

.saved-del {
  background: none;
  border: none;
  padding: 7px;
  border-radius: var(--r-sm);
  color: var(--c-text-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.saved-del:active {
  background: #FCEAEA;
  color: var(--c-error);
}

.saved-del svg {
  width: 16px;
  height: 16px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(90px);
  background: var(--c-t-dark);
  color: var(--c-white);
  padding: 11px 22px 11px 16px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 6px 24px rgba(0,0,0,0.28);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 340px) {
  .measurements-grid { grid-template-columns: 1fr; }
  .outside-row        { grid-template-columns: 1fr; }
  .obstruction-grid   { grid-template-columns: 1fr; }
  .result-size        { font-size: 21px; }
}

@media (min-width: 420px) {
  main { padding: 20px 18px 60px; }
  .card { padding: 22px 20px; }
}

@media (min-width: 600px) {
  header { padding: 20px 24px 22px; }
  main   { padding: 24px 20px 60px; }
}
