/* Define CSS variables for theming */
:root {
  --webdfu-primary: #363a48; /* Vibrant Orange */
  --webdfu-accent: #cc0000; /* Light Orange Accent */
  --webdfu-bg: #fdfcfb; /* Slightly off-white bg */
  --webdfu-text: #4a4a4a; /* Dark grey text */
  --webdfu-light-text: #686868; /* Lighter grey */
  --webdfu-border: #ececec; /* Light border */
  --webdfu-card-bg: #ffffff; /* White card background */
  --webdfu-code-bg: #f0f0f0; /* Code background */
  --webdfu-error: #d32f2f; /* Error red */
  --webdfu-success: #388e3c; /* Success green */
  --webdfu-warning-bg: #fff8e6; /* Warning/Note background */
  --webdfu-warning-border: var(--webdfu-accent);
  --font-family: "futura-pt", sans-serif; /* Primary font */
  --sticky-top-offset: 2rem; /* Offset for sticky column */
}

/* ---------- Base & Layout ---------- */
html {
  font-size: 62.5%; /* Base font size: 1rem = 10px */
  box-sizing: border-box; /* Include padding and border in element's total width and height */
}
*,
*:before,
*:after {
  box-sizing: inherit; /* Inherit box-sizing for all elements */
}

body {
  background: var(--webdfu-bg);
  color: var(--webdfu-text);
  font-family: var(--font-family);
  font-size: 1.6rem; /* Default font size (16px) */
  line-height: 1.6;
  max-width: none; /* Allow body to take full width */
  width: auto;
  margin: 0;
  padding: 0 0; /* Padding at the bottom */
}

/* Centering container for major content blocks */
.container {
  /* Increased max-width for desktop */
  max-width: 140rem; /* <<< CHANGE: Increased width */
  width: 95%; /* Use percentage width for responsiveness */
  margin: 0 auto; /* Center the container */
  padding: 0 1rem; /* Padding inside container */
}

/* Link styling */
a {
  color: var(--webdfu-primary);
  text-decoration: none;
  font-weight: 700;
}
a:hover {
  text-decoration: underline;
}

/* Heading styling */
h1,
h2,
h3,
h4 {
  font-weight: 700;
  color: var(--webdfu-text);
  line-height: 1.2;
}
h1 {
  font-size: 3.2rem;
  margin-bottom: 0.5rem;
  color: var(--webdfu-primary);
}
h2 {
  font-size: 2.4rem;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--webdfu-border);
  padding-bottom: 0.5rem;
}
h3 {
  font-size: 1.8rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--webdfu-primary);
}

/* ---------- Hero Section ---------- */
.hero {
  text-align: center;
  padding: 1.5rem 1rem 1.2rem;
  background-color: var(--webdfu-card-bg);
  border-bottom: 1px solid var(--webdfu-border);
  margin-bottom: 1.2rem;
}
.hero-actions {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}
.secondary-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1.4rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 126, 63, 0.25);
  background: rgba(255, 126, 63, 0.08);
  color: var(--webdfu-primary);
  font-size: 1.4rem;
  font-weight: 700;
}
.secondary-page-link:hover {
  text-decoration: none;
  background: rgba(255, 126, 63, 0.14);
}
.secondary-page-link.inline-link {
  padding: 0.9rem 1.6rem;
}
.hero .tagline {
  font-size: 1.8rem;
  color: var(--webdfu-light-text);
  max-width: 60ch; /* Limit line length for readability */
  margin: 0 auto;
}

/* ---------- Pink Warning Box (Moved Above Columns) ---------- */
#readFirstWarning {
  background-color: #ffebee; /* Light red background */
  border: 1px solid #f1b0b7; /* Add full border */
  border-left: 4px solid var(--webdfu-error); /* Keep prominent left border */
  color: #c62828; /* Darker red text */
  border-radius: 12px;
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
#readFirstWarning strong {
  color: var(--webdfu-error);
}
#readFirstWarning p::before {
  content: "⚠️ "; /* Add warning emoji */
  margin-right: 0.5rem;
}
/* Ensure the p tag inside has reasonable margin */
#readFirstWarning p {
  margin: 0;
}

/* ---------- Two Column Layout ---------- */
.layout-wrapper {
  display: flex;
  flex-wrap: wrap; /* Allow columns to wrap on smaller screens */
  gap: 1.5rem; /* Space between columns */
  align-items: flex-start; /* Align items to the top */
}

.column {
  flex: 1; /* Allow columns to grow and shrink */
  min-width: 320px; /* Minimum width before wrapping */
}

/* Sticky Flasher Column */
.flash-column {
  position: sticky; /* Make the column sticky */
  top: var(--sticky-top-offset); /* Stick below the desired offset */
  align-self: start; /* Ensure it aligns to the top for sticky to work correctly */
}

/* Scrollable Instructions Column */
.instructions-column {
  max-height: calc(
    100vh - var(--sticky-top-offset) - 4rem
  ); /* Adjust 4rem for margins/padding */
  overflow-y: auto; /* Add scrollbar only when needed */
  padding-right: 1rem;
  margin-right: -1rem;
}
.instructions-column::-webkit-scrollbar {
  width: 8px;
}
.instructions-column::-webkit-scrollbar-track {
  background: var(--webdfu-bg);
  border-radius: 4px;
}
.instructions-column::-webkit-scrollbar-thumb {
  background-color: var(--webdfu-accent);
  border-radius: 4px;
  border: 2px solid var(--webdfu-bg);
}
.instructions-column {
  scrollbar-width: thin;
  scrollbar-color: var(--webdfu-accent) var(--webdfu-bg);
}

/* ---------- Card Style for Sections ---------- */
.card {
  background: var(--webdfu-card-bg);
  border: 1px solid var(--webdfu-border);
  border-radius: 12px;
  padding: 1.5rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.card h2 {
  margin-top: 0;
  border: none;
  padding-bottom: 0;
  margin-bottom: 1rem;
  text-align: center;
}

.column > *:last-child {
  margin-bottom: 0;
}

/* ---------- Flash UI (Card in Left Column) ---------- */
#flashSection {
  margin-top: 0;
}
#flashSection h2 {
  text-align: center;
}
.flow-summary {
  background: linear-gradient(135deg, #fff8ef, #fff3da);
  border: 1px solid #ffe1bd;
  border-radius: 10px;
  padding: 1.4rem;
  margin-bottom: 1.5rem;
}
.flow-summary p {
  margin: 0.4rem 0;
}
.inline-tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.3rem;
  margin-top: 1.5rem;
  border: 1px solid var(--webdfu-border);
  border-radius: 10px;
  background: #fffaf2;
}
.inline-tool-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.8rem;
}
.support-copy {
  margin: 0.4rem 0 0;
  color: var(--webdfu-light-text);
  font-size: 1.4rem;
}
.secondary-page-card p {
  text-align: center;
}
.note-top-spacing {
  margin-top: 1em;
}
.centered-row {
  text-align: center;
}
.time-set-row {
  text-align: center;
  margin-top: 1.5em;
}
.version-changes {
  padding-left: 1.5em;
  list-style-type: disc;
}
.version-link-row {
  margin-top: 1.5em;
  text-align: center;
}
.bootloader-screen-preview {
  text-align: center;
  margin-top: 0.5em;
}
.compact-code {
  font-size: 1.1rem;
}
.danger-note-box {
  background-color: #ffebee;
  border-left-color: #d32f2f;
}
/* Reduce top margin for first paragraph on smaller screens */
#flashSection > p:first-of-type {
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

/* Connect Button */
button#connect {
  background: #cc0000;
  border: none;
  padding: 1.2rem 2.4rem;
  border-radius: 8px;
  font-size: 1.6rem;
  font-weight: 300;
  color: #fff;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.1s ease;
  display: inline-block; /* Keep inline-block for desktop */
  margin-top: 1rem;
  width: auto;
  font-family: "futura-pt", sans-serif;
}
button#connect:hover {
  background-color: #b30000;
}
button#connect:active {
  transform: translateY(0px);
}
button#connect:disabled {
  background-color: #d9edf7;
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Status Display */
#status {
  display: inline-block; /* Keep inline-block for desktop */
  vertical-align: middle;
  margin-left: 1.5rem; /* Keep margin for desktop */
  font-weight: 300;
  padding: 0.8rem 1.2rem;
  border-radius: 6px;
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease;
  font-size: 1.6rem;
  min-height: 2.4rem;
  line-height: 1.7;
  border: 1px solid transparent;
  text-align: left;
}
/* Status visual states */
#status.status-info {
  background-color: #eef1f5;
  color: #334;
  border-color: #d8dde4;
}
#status.status-prompt {
  background-color: var(--webdfu-warning-bg);
  color: #856404;
  border-color: var(--webdfu-warning-border);
}
#status.status-error {
  background-color: #ffebee;
  color: var(--webdfu-error);
  border-color: #f1b0b7;
}
#status.status-success {
  background-color: #e8f5e9;
  color: var(--webdfu-success);
  border-color: #a5d6a7;
}

/* USB Info Box */
#usbInfo {
  white-space: pre-wrap;
  font-size: 1.3rem;
  margin-top: 1.5rem;
  background: var(--webdfu-code-bg);
  padding: 1rem;
  border-radius: 6px;
  color: var(--webdfu-light-text);
}

/* Fieldset for progress */
fieldset {
  border: 1px solid var(--webdfu-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
}
legend {
  font-weight: 700;
  color: var(--webdfu-primary);
  font-size: 1.6rem;
  padding: 0 0.5rem;
  margin-left: 0.5rem;
}

/* Log Area */
.log {
  font-size: 1.4rem;
  max-height: 180px; /* Default height */
  overflow-y: auto;
  background: var(--webdfu-code-bg);
  padding: 1rem;
  border-radius: 6px;
  margin-top: 1rem;
  line-height: 1.4;
}
.log p {
  margin: 0.4rem 0;
}
.log p.error {
  color: var(--webdfu-error);
  font-weight: 700;
}
.log p.warning {
  color: #ffa000;
}
.log p.success {
  color: var(--webdfu-success);
  font-weight: 700;
}

/* <<< ADDED/MODIFIED Progress Bar Styling >>> */
.log progress {
  width: 100%;
  margin-top: 0.5rem;
  accent-color: var(--webdfu-primary); /* Main color */
  height: 1.2rem; /* Slightly thicker */
  border-radius: 6px;
  border: 1px solid var(--webdfu-border);
  background-color: var(--webdfu-border); /* Background track color */
  overflow: hidden; /* Ensure background fills properly */
}
/* Style progress bar appearance for Webkit browsers */
.log progress::-webkit-progress-bar {
  background-color: var(--webdfu-border); /* Track color */
  border-radius: 6px;
}
.log progress::-webkit-progress-value {
  background-color: var(--webdfu-primary); /* Filled color */
  border-radius: 0; /* Use parent's rounding via overflow:hidden */
  transition: width 0.2s ease;
}
/* Style progress bar appearance for Firefox */
.log progress::-moz-progress-bar {
  background-color: var(--webdfu-primary); /* Filled color */
  border-radius: 6px; /* Firefox needs radius here */
  transition: width 0.2s ease;
}
/* <<< END Progress Bar Styling >>> */

/* Input fields styling */
input[type="text"],
input[type="number"] {
  font-family: var(--font-family);
  font-size: 1.4rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--webdfu-border);
  border-radius: 6px;
  background-color: #fff;
  margin-left: 0.5rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--webdfu-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 126, 63, 0.2); /* Focus ring */
}

/* ---------- Instructions Styling (Cards in Right Column) ---------- */
.instructions {
  /* Base styles for instruction cards */
}
.instructions h2 {
  text-align: left;
  margin-bottom: 1.5rem;
  border: none;
  padding: 0;
}
.instructions h3 {
  font-size: 1.8rem;
  margin-top: 2.5rem;
}
.instructions ol,
.instructions ul {
  padding-left: 2em;
  margin-bottom: 1.5rem;
}
.instructions li {
  margin-bottom: 1em;
  line-height: 1.7;
}
.instructions strong {
  font-weight: 700;
  color: var(--webdfu-text);
}
.instructions em {
  font-style: italic;
  color: var(--webdfu-light-text);
}

/* Note/Warning Box Styling */
.note-box {
  background-color: var(--webdfu-warning-bg);
  padding: 1.5rem;
  border-radius: 8px;
  margin: 1.5rem 0;
  border-left: 4px solid var(--webdfu-warning-border);
  font-size: 1.5rem;
  line-height: 1.7;
}
.note-box p {
  margin: 0.5rem 0;
}
.note-box strong {
  color: var(--webdfu-primary);
}
.note-box code {
  background-color: rgba(0, 0, 0, 0.07);
}

/* ---------- OS toggle Card ---------- */
.os-toggle {
  text-align: center;
}
.os-toggle span {
  font-weight: 700;
  margin-right: 1rem;
  display: block;
  margin-bottom: 1rem;
  font-size: 1.6rem;
}
.os-toggle div {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}
.os-btn {
  background: none;
  border: 2px solid #b30000;
  color: var(--webdfu-primary);
  padding: 0.8rem 1.6rem;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
  font-size: 1.6rem;
  font-weight: 400;
  font-family: "futura-pt", sans-serif;
}
.os-btn.active,
.os-btn:hover {
  background: #cc0000;
  color: #fff;
}

/* ---------- Browser Notice (Above Columns) ---------- */
#browserNotice {
  background: #fff3cd;
  border: 1px solid #ffeeba;
  color: #856404;
  padding: 1.5rem;
  border-radius: 8px;
  margin: 0 auto 2rem auto;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 400;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  max-width: 80rem;
}
#browserNotice p {
  margin: 0.5rem 0;
}
#browserNotice strong {
  font-weight: 700;
}
#browserNotice .download-btn {
  display: inline-block;
  margin-top: 1rem;
  background: var(--webdfu-primary);
  color: #fff;
  padding: 0.8rem 1.6rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 1.4rem;
  transition: background-color 0.2s ease;
  font-weight: 700;
}
#browserNotice .download-btn:hover {
  background-color: #e66a2f;
  text-decoration: none;
}

/* ---------- Inline kbd & code ---------- */
kbd {
  background: #eee;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.2em 0.5em;
  font-size: 0.9em;
  font-family: monospace;
  box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);
  color: #333;
  margin: 0 0.1em;
  vertical-align: baseline;
}
code {
  font-family: monospace;
  background-color: var(--webdfu-code-bg);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}
pre {
  background-color: var(--webdfu-code-bg);
  padding: 1.5em;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1em 0;
}
pre code {
  background: none;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1.5;
}

/* ---------- Footer ---------- */
footer.container {
  margin: 0 auto 0;
  padding: 2rem;
  text-align: center;
  font-size: 1.4rem;
  color: #fff;
  max-width: 80rem;
}
footer p {
  margin: 0.5rem 0;
}

/* ---------- Responsiveness ---------- */

/* Tablet and Smaller Desktop Breakpoint */
@media (max-width: 850px) {
  .layout-wrapper {
    flex-direction: column; /* Stack columns vertically */
    gap: 0; /* Remove gap when stacking */
  }
  .column {
    flex-basis: 100%; /* Make columns full width */
    min-width: unset; /* Reset min-width */
    margin-bottom: 2.5rem; /* Add margin between stacked columns */
  }
  .column:last-child {
    margin-bottom: 0;
  }

  /* Reset sticky and scroll behavior when stacked */
  .flash-column {
    position: static;
    align-self: auto;
  }
  .instructions-column {
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
    margin-right: 0;
  }

  /* Adjust container width for tablets if needed */
  .container {
    max-width: 70rem;
    width: 92%;
  }
}

/* Mobile Breakpoint */
@media (max-width: 600px) {
  /* Adjust container width */
  .container {
    width: 95%;
  }
  h1 {
    font-size: 2.8rem;
  }
  h2 {
    font-size: 2.1rem;
  }
  h3 {
    font-size: 1.7rem;
  } /* Slightly smaller h3 */

  /* <<< CHANGE: Reduce vertical padding/margins >>> */
  .hero {
    padding: 2rem 1rem;
    margin-bottom: 1.5rem;
  }
  #readFirstWarning {
    padding: 1.5rem 1.5rem;
    margin-bottom: 1.5rem;
  }
  .card {
    padding: 2rem 1.5rem;
    margin-bottom: 1.5rem;
  } /* Reduce card margin */
  .column {
    margin-bottom: 1.5rem;
  } /* Reduce space between stacked columns */
  .inline-tool-row {
    flex-direction: column;
    align-items: stretch;
  }
  .inline-tool-actions {
    align-items: stretch;
  }
  .secondary-page-link {
    width: 100%;
  }

  /* Make connect button and status block-level for stacking */
  /* Target the specific paragraph containing button and status */
  #flashSection > p:nth-of-type(2) {
    /* Assuming it's the second <p> */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem; /* Space between button and status */
    margin-top: 0; /* Reset margin if needed */
    margin-bottom: 1.5rem; /* Space below */
  }
  button#connect {
    width: 100%; /* Make button full width */
    margin-top: 0; /* Remove top margin */
    padding: 1.1rem 2rem; /* Slightly adjust padding */
    font-size: 1.5rem; /* Slightly adjust font */
  }
  #status {
    /* <<< CHANGE: Make status block & centered >>> */
    display: block;
    width: 100%;
    margin-left: 0;
    margin-top: 0; /* Rely on gap */
    text-align: center;
    font-size: 1.3rem; /* Slightly smaller font */
    padding: 0.6rem 1rem; /* Adjust padding */
    line-height: 1.6; /* Adjust line height */
  }
  /* Reduce top margin for first paragraph in flash section */
  #flashSection > p:first-of-type {
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1.5rem; /* Slightly smaller text */
  }
  /* Reduce vertical height of log area */
  .log {
    max-height: 120px;
  }
}

/* ---------- Bootloader Step Tracker ---------- */
#bl-step-tracker {
  margin-top: 1.5rem;
}
.bl-step {
  opacity: 0.4;
  pointer-events: none;
  padding: 1.5rem;
  border-left: 3px solid var(--webdfu-border);
  margin-bottom: 1.5rem;
  transition:
    opacity 0.3s,
    border-left-color 0.3s;
}
.bl-step.active {
  opacity: 1;
  pointer-events: auto;
  border-left-color: var(--webdfu-primary);
}
.bl-step.completed {
  opacity: 0.7;
  pointer-events: none;
  border-left-color: var(--webdfu-success);
}
.bl-step.completed h3::after {
  content: " ✓";
  color: var(--webdfu-success);
}
.bl-step h3 {
  margin-top: 0;
  font-size: 1.6rem;
}
.bl-step p {
  margin: 0.5rem 0;
}
.bl-step button {
  background: var(--webdfu-primary);
  border: none;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.1s ease;
  margin-top: 0.5rem;
  font-family: var(--font-family);
}
.bl-step button:hover {
  background-color: #e66a2f;
  transform: translateY(-1px);
}
.bl-step button:active {
  transform: translateY(0px);
}
.bl-step button:disabled {
  background-color: #ffb15e;
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Serial Trigger Button ---------- */
.serial-trigger-btn {
  display: inline-block;
  margin-top: 0.5rem;
  background: var(--webdfu-accent);
  border: none;
  padding: 0.8rem 1.6rem;
  border-radius: 8px;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s;
  font-family: var(--font-family);
}
.serial-trigger-btn:hover {
  background-color: var(--webdfu-primary);
}
.serial-trigger-btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

/* ---------- Time Set Area ---------- */
#timeSetArea {
  border-top: 1px solid var(--webdfu-border);
  padding-top: 1rem;
  margin-top: 1.5rem;
}

.logo-container {
  background-color: #000000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 18rem;
  border-bottom: 5px solid #cc0000;
}

/* Override sakura.css border-bottom + global a:hover underline */
.logo-container a,
.logo-container a:focus {
  text-decoration: none;
  border-bottom: none;
  color: #ffffff;
  font-weight: 300;
  letter-spacing: 0.1em;
}
.logo-container a:hover {
  text-decoration: none;
  border-bottom: none;
  color: #cc0000;
}

.logo-image {
  height: 8rem !important;
  width: auto !important;
}
