/* ============================================================================
   HCS Fitness Reporter — Apple-style UI
   Photography-first design language adapted to a configuration form:
   alternating tiles, single blue accent, pill CTAs, near-invisible chrome.
   ============================================================================ */

:root {
  /* Brand & accent */
  --ap-primary: #0066cc;
  --ap-primary-focus: #0071e3;
  --ap-primary-on-dark: #2997ff;

  /* Surfaces */
  --ap-canvas: #ffffff;
  --ap-parchment: #f5f5f7;
  --ap-pearl: #fafafc;
  --ap-tile-1: #272729;
  --ap-tile-2: #2a2a2c;
  --ap-tile-3: #252527;
  --ap-black: #000000;

  /* Text */
  --ap-ink: #1d1d1f;
  --ap-on-dark: #ffffff;
  --ap-body-muted: #cccccc;
  --ap-ink-80: #333333;
  --ap-ink-48: #7a7a7a;
  --ap-ink-on-dark-muted: #a1a1a6;

  /* Borders */
  --ap-divider-soft: #f0f0f0;
  --ap-hairline: #e0e0e0;
  --ap-hairline-strong: rgba(0, 0, 0, 0.08);
  --ap-hairline-on-dark: rgba(255, 255, 255, 0.16);

  /* Radii */
  --ap-r-none: 0;
  --ap-r-xs: 5px;
  --ap-r-sm: 8px;
  --ap-r-md: 11px;
  --ap-r-lg: 18px;
  --ap-r-pill: 9999px;

  /* Spacing */
  --ap-x4: 4px;
  --ap-x8: 8px;
  --ap-x12: 12px;
  --ap-x17: 17px;
  --ap-x24: 24px;
  --ap-x32: 32px;
  --ap-x48: 48px;
  --ap-section: 80px;

  /* Single product-shadow — used only on hero illustration if present */
  --ap-product-shadow: 3px 5px 30px 0 rgba(0, 0, 0, 0.22);

  /* Type stacks */
  --ap-display: "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ap-text: "SF Pro Text", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---------------------------------------------------------------------------
   Reset & base
   --------------------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background: var(--ap-canvas);
  color: var(--ap-ink);
  font-family: var(--ap-text);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.47;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--ap-primary);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button {
  font-family: inherit;
  cursor: pointer;
}

/* The container is a vertical stack of edge-to-edge tiles */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

/* ---------------------------------------------------------------------------
   Global nav (slim black bar)
   --------------------------------------------------------------------------- */

.ap-global-nav {
  background: var(--ap-black);
  color: var(--ap-on-dark);
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 9000;
  font-family: var(--ap-text);
  font-size: 12px;
  letter-spacing: -0.01em;
}

.ap-global-nav .ap-gnav-left,
.ap-global-nav .ap-gnav-right {
  display: flex;
  align-items: center;
  gap: 22px;
}

.ap-global-nav a,
.ap-global-nav button {
  color: var(--ap-on-dark);
  background: transparent;
  border: none;
  padding: 0;
  font-size: 12px;
  letter-spacing: -0.01em;
  opacity: 0.88;
  text-decoration: none;
}

.ap-global-nav a:hover,
.ap-global-nav button:hover {
  opacity: 1;
  text-decoration: none;
}

.ap-gnav-brand {
  font-weight: 600;
  letter-spacing: -0.01em;
  opacity: 1 !important;
}

.ap-gnav-brand .ap-gnav-mark {
  color: var(--ap-primary-on-dark);
}

/* ---------------------------------------------------------------------------
   Sub-nav (frosted parchment)
   --------------------------------------------------------------------------- */

.ap-sub-nav {
  position: sticky;
  top: 44px;
  z-index: 8500;
  background: rgba(245, 245, 247, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--ap-hairline-strong);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.ap-sub-nav .ap-subnav-title {
  font-family: var(--ap-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.011em;
  color: var(--ap-ink);
}

.ap-sub-nav .ap-subnav-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 14px;
  letter-spacing: -0.016em;
}

.ap-sub-nav .ap-subnav-actions a {
  color: var(--ap-ink);
  font-weight: 400;
}

/* ---------------------------------------------------------------------------
   Tiles — the core layout primitive
   --------------------------------------------------------------------------- */

.ap-tile {
  width: 100%;
  padding: var(--ap-section) 32px;
  border-radius: 0;
  border: 0;
  position: relative;
}

.ap-tile-light    { background: var(--ap-canvas); color: var(--ap-ink); }
.ap-tile-parch    { background: var(--ap-parchment); color: var(--ap-ink); }
.ap-tile-dark     { background: var(--ap-tile-1); color: var(--ap-on-dark); }
.ap-tile-dark-2   { background: var(--ap-tile-2); color: var(--ap-on-dark); }

.ap-tile-inner {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}

.ap-tile-narrow .ap-tile-inner { max-width: 720px; }

/* Hero tile content stack */
.ap-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.ap-hero h1 {
  font-family: var(--ap-display);
  font-size: 56px;
  font-weight: 600;
  line-height: 1.07;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--ap-ink);
}

.ap-hero .ap-tagline {
  font-family: var(--ap-display);
  font-size: 28px;
  font-weight: 400;
  line-height: 1.14;
  letter-spacing: 0.007em;
  color: var(--ap-ink);
  margin: 0;
  max-width: 720px;
}

.ap-hero .ap-eyebrow {
  font-family: var(--ap-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.016em;
  color: var(--ap-primary);
  text-transform: none;
  margin: 0;
}

.ap-hero .ap-cta-row {
  display: flex;
  gap: 18px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.ap-hero .ap-hcs-mark {
  height: 64px;
  width: auto;
  margin-bottom: 8px;
}

/* Section heads inside form tiles */
.ap-section-head {
  text-align: center;
  margin-bottom: 48px;
}

.ap-section-head h2 {
  font-family: var(--ap-display);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.10;
  letter-spacing: 0;
  margin: 0 0 12px 0;
  color: var(--ap-ink);
}

.ap-section-head p {
  font-family: var(--ap-display);
  font-size: 21px;
  font-weight: 400;
  line-height: 1.33;
  letter-spacing: 0.011em;
  color: var(--ap-ink-80);
  margin: 0 auto;
  max-width: 640px;
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */

.ap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--ap-text);
  font-size: 17px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.022em;
  border: 0;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.ap-btn:active { transform: scale(0.95); }
.ap-btn:focus-visible { outline: 2px solid var(--ap-primary-focus); outline-offset: 3px; }

.ap-btn-primary {
  background: var(--ap-primary);
  color: var(--ap-on-dark);
  border-radius: var(--ap-r-pill);
  padding: 11px 22px;
  min-height: 44px;
}

.ap-btn-primary:hover { background: #0077ed; color: var(--ap-on-dark); text-decoration: none; }

.ap-btn-secondary {
  background: transparent;
  color: var(--ap-primary);
  border: 1px solid var(--ap-primary);
  border-radius: var(--ap-r-pill);
  padding: 10px 21px;
  min-height: 44px;
}

.ap-btn-secondary:hover {
  background: rgba(0, 102, 204, 0.06);
  text-decoration: none;
}

.ap-btn-dark {
  background: var(--ap-ink);
  color: var(--ap-on-dark);
  border-radius: var(--ap-r-sm);
  padding: 8px 15px;
  font-size: 14px;
  letter-spacing: -0.016em;
  min-height: 32px;
}

.ap-btn-dark:hover { background: #2a2a2c; color: var(--ap-on-dark); text-decoration: none; }

.ap-btn-pearl {
  background: var(--ap-pearl);
  color: var(--ap-ink-80);
  border: 1px solid var(--ap-divider-soft);
  border-radius: var(--ap-r-md);
  padding: 8px 14px;
  font-size: 14px;
  letter-spacing: -0.016em;
  min-height: 36px;
}

.ap-btn-pearl:hover { background: #f0f0f3; color: var(--ap-ink); text-decoration: none; }

.ap-btn-large {
  font-size: 18px;
  font-weight: 300;
  padding: 14px 28px;
  min-height: 48px;
}

.ap-btn[disabled],
.ap-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ap-btn[disabled]:active,
.ap-btn:disabled:active { transform: none; }

/* ---------------------------------------------------------------------------
   Form: tile-based sections, no card chrome
   The classic .form-section becomes a tile-inner block.
   --------------------------------------------------------------------------- */

.form-section {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  margin: 0;
  box-shadow: none;
}

.form-section h2 {
  font-family: var(--ap-display);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.10;
  letter-spacing: 0;
  text-align: center;
  margin: 0 0 48px 0;
  color: var(--ap-ink);
}

.form-section h3 {
  font-family: var(--ap-display);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.21;
  letter-spacing: 0.007em;
  margin: 0 0 16px 0;
  color: var(--ap-ink);
}

.form-section h4 {
  font-family: var(--ap-text);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -0.022em;
  margin: 0 0 12px 0;
  color: var(--ap-ink);
}

/* ---------------------------------------------------------------------------
   Form groups — labels above inputs, generous breathing room
   --------------------------------------------------------------------------- */

.form-group {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-family: var(--ap-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.016em;
  color: var(--ap-ink);
  margin: 0;
}

.form-group small {
  font-family: var(--ap-text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--ap-ink-48);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group select,
.form-group textarea,
input[type="text"]:not(.ap-bare),
input[type="email"]:not(.ap-bare),
input[type="password"]:not(.ap-bare),
select:not(.ap-bare),
textarea:not(.ap-bare) {
  font-family: var(--ap-text);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.47;
  letter-spacing: -0.022em;
  color: var(--ap-ink);
  background-color: var(--ap-canvas);
  border: 1px solid var(--ap-hairline);
  border-radius: var(--ap-r-md);
  padding: 12px 16px;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

/* Native option list — must be explicitly themed; otherwise dropdown
   inherits OS defaults and reads white-on-white in dark mode. */
.form-group select option,
select:not(.ap-bare) option {
  background-color: var(--ap-canvas);
  color: var(--ap-ink);
}

.form-group textarea,
textarea:not(.ap-bare) {
  border-radius: var(--ap-r-lg);
  min-height: 84px;
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ap-primary-focus);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}

.form-group select,
select:not(.ap-bare) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%231d1d1f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  padding-right: 44px;
}

::placeholder { color: var(--ap-ink-48); opacity: 1; }

/* Label + button row (e.g., upload alongside label) */
.label-with-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.label-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  font-size: 18px;
  line-height: 1;
}

.upload-btn-small {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ap-pearl);
  color: var(--ap-ink-80);
  border: 1px solid var(--ap-divider-soft);
  border-radius: var(--ap-r-pill);
  padding: 8px 16px;
  font-family: var(--ap-text);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -0.016em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.upload-btn-small:hover { background: #f0f0f3; color: var(--ap-ink); }
.upload-btn-small:active { transform: scale(0.95); }
.upload-btn-small.uploaded { background: rgba(0, 102, 204, 0.08); color: var(--ap-primary); border-color: rgba(0, 102, 204, 0.24); }

.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.file-status {
  font-family: var(--ap-text);
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--ap-ink-48);
  margin-top: 4px;
  min-height: 18px;
}

.file-status:not(:empty) { color: var(--ap-primary); }

/* Toggle-secret eye button inside password field row */
.credential-field {
  position: relative;
  margin-bottom: 16px;
}

.credential-field label {
  display: block;
  font-family: var(--ap-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.016em;
  color: var(--ap-ink);
  margin-bottom: 8px;
}

.credential-field input { padding-right: 44px; }

.toggle-secret {
  position: absolute;
  right: 8px;
  bottom: 6px;
  background: transparent;
  border: 0;
  font-size: 16px;
  color: var(--ap-ink-48);
  padding: 8px;
  cursor: pointer;
  border-radius: var(--ap-r-pill);
  transition: background 0.15s ease;
}

.toggle-secret:hover { background: rgba(0, 0, 0, 0.04); }

.required-note {
  font-family: var(--ap-text);
  font-size: 12px;
  letter-spacing: -0.01em;
  color: var(--ap-ink-48);
  margin-top: 24px;
  text-align: right;
}

/* Checkbox label rows */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--ap-text);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -0.016em;
  color: var(--ap-ink);
  padding: 8px 0;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--ap-primary);
  cursor: pointer;
}

/* ---------------------------------------------------------------------------
   Workflow tabs (top-level: New Report / From Cache)
   Pill-chip grammar; transparent → Action Blue when active.
   --------------------------------------------------------------------------- */

.workflow-tabs {
  display: inline-flex;
  gap: 6px;
  background: var(--ap-pearl);
  border: 1px solid var(--ap-divider-soft);
  border-radius: var(--ap-r-pill);
  padding: 4px;
  margin: 0 auto 32px auto;
}

.workflow-tabs {
  display: flex;
  width: fit-content;
}

.workflow-tab-btn {
  background: transparent;
  border: 0;
  font-family: var(--ap-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.016em;
  color: var(--ap-ink-80);
  padding: 8px 18px;
  border-radius: var(--ap-r-pill);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.workflow-tab-btn:hover { color: var(--ap-ink); }
.workflow-tab-btn:active { transform: scale(0.95); }
.workflow-tab-btn.active {
  background: var(--ap-ink);
  color: var(--ap-on-dark);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Wrap the workflow-tabs in a centered row */
.ap-tab-row {
  display: flex;
  justify-content: center;
  margin-top: -32px;
  margin-bottom: 32px;
}

/* ---------------------------------------------------------------------------
   Credential tabs (inside the form)
   --------------------------------------------------------------------------- */

.credential-tabs {
  display: flex;
  gap: 4px;
  background: var(--ap-pearl);
  border: 1px solid var(--ap-divider-soft);
  border-radius: var(--ap-r-pill);
  padding: 4px;
  width: fit-content;
  margin: 8px 0 12px 0;
}

.credential-tab {
  background: transparent;
  border: 0;
  font-family: var(--ap-text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.016em;
  color: var(--ap-ink-80);
  padding: 6px 14px;
  border-radius: var(--ap-r-pill);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.credential-tab.active {
  background: var(--ap-canvas);
  color: var(--ap-ink);
  box-shadow: 0 0 0 1px var(--ap-divider-soft);
}

.credential-tab-content { margin-top: 8px; }

.credentials-parsed {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(0, 102, 204, 0.06);
  border: 1px solid rgba(0, 102, 204, 0.18);
  border-radius: var(--ap-r-md);
  padding: 14px 16px;
  margin-top: 12px;
}

.credentials-parsed strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ap-ink);
  margin-bottom: 4px;
}

.credentials-parsed p {
  margin: 0;
  font-size: 13px;
  color: var(--ap-ink-80);
  font-family: var(--ap-text);
}

.success-icon { font-size: 18px; }

/* ---------------------------------------------------------------------------
   Collapsible sections — quiet hairline, no card chrome
   --------------------------------------------------------------------------- */

.collapsible-section {
  border-top: 1px solid var(--ap-hairline);
  margin: 0;
  padding: 0;
}

.collapsible-section:last-of-type {
  border-bottom: 1px solid var(--ap-hairline);
}

.collapsible-header {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-family: var(--ap-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.011em;
  color: var(--ap-ink);
  transition: color 0.15s ease;
}

.collapsible-header:hover { color: var(--ap-primary); }

.collapse-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--ap-r-pill);
  background: var(--ap-pearl);
  border: 1px solid var(--ap-divider-soft);
  color: var(--ap-ink);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  transition: transform 0.2s ease, background 0.15s ease;
}

.collapsible-section.open .collapse-icon { transform: rotate(45deg); }

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.collapsible-section.open .collapsible-content { max-height: 4000px; }

.collapsible-content-inner {
  padding: 8px 8px 28px 8px;
}

/* ---------------------------------------------------------------------------
   Info banners (Pro Tip / Warning)
   --------------------------------------------------------------------------- */

.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(0, 102, 204, 0.05);
  border: 1px solid rgba(0, 102, 204, 0.16);
  border-radius: var(--ap-r-md);
  padding: 16px 18px;
  margin-bottom: 20px;
}

.info-banner.warning {
  background: rgba(245, 166, 35, 0.08);
  border-color: rgba(245, 166, 35, 0.28);
}

.info-banner .info-icon {
  font-size: 20px;
  line-height: 1;
}

.info-banner strong {
  display: block;
  font-family: var(--ap-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.016em;
  color: var(--ap-ink);
  margin-bottom: 4px;
}

.info-banner p {
  font-family: var(--ap-text);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ap-ink-80);
  margin: 0;
}

/* ---------------------------------------------------------------------------
   Divider
   --------------------------------------------------------------------------- */

.divider {
  height: 1px;
  background: var(--ap-hairline);
  border: 0;
  margin: 32px 0;
}

/* ---------------------------------------------------------------------------
   Submit / form actions
   --------------------------------------------------------------------------- */

.form-actions {
  display: flex;
  justify-content: center;
  padding: 0;
  margin-top: 32px;
  background: transparent;
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--ap-primary);
  color: var(--ap-on-dark);
  border: 0;
  border-radius: var(--ap-r-pill);
  padding: 14px 32px;
  font-family: var(--ap-text);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.022em;
  cursor: pointer;
  min-height: 48px;
  min-width: 220px;
  transition: background 0.15s ease, transform 0.12s ease;
}

.submit-btn:hover { background: #0077ed; }
.submit-btn:active { transform: scale(0.95); }
.submit-btn:focus-visible { outline: 2px solid var(--ap-primary-focus); outline-offset: 3px; }
.submit-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.submit-btn[disabled]:active { transform: none; }

.submit-btn .btn-icon { font-size: 18px; line-height: 1; }

/* ---------------------------------------------------------------------------
   Progress bar
   --------------------------------------------------------------------------- */

.progress-container {
  background: var(--ap-parchment);
  border: 1px solid var(--ap-hairline);
  border-radius: var(--ap-r-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--ap-divider-soft);
  border-radius: var(--ap-r-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--ap-primary);
  border-radius: var(--ap-r-pill);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-family: var(--ap-text);
  font-size: 14px;
  letter-spacing: -0.016em;
  color: var(--ap-ink-80);
  margin: 12px 0 0 0;
  text-align: center;
}

/* ---------------------------------------------------------------------------
   Message container (toast-style alerts)
   --------------------------------------------------------------------------- */

.message-container { margin-bottom: 16px; }

.message-container .message {
  padding: 14px 18px;
  border-radius: var(--ap-r-md);
  font-family: var(--ap-text);
  font-size: 14px;
  letter-spacing: -0.016em;
  margin-bottom: 8px;
  border: 1px solid transparent;
}

.message-container .message.success {
  background: rgba(40, 167, 69, 0.06);
  border-color: rgba(40, 167, 69, 0.22);
  color: #1d6f3f;
}

.message-container .message.error {
  background: rgba(220, 53, 69, 0.06);
  border-color: rgba(220, 53, 69, 0.22);
  color: #a01928;
}

.message-container .message.info {
  background: rgba(0, 102, 204, 0.06);
  border-color: rgba(0, 102, 204, 0.22);
  color: var(--ap-primary);
}

/* ---------------------------------------------------------------------------
   Footer (parchment, dense links)
   --------------------------------------------------------------------------- */

.ap-footer {
  background: var(--ap-parchment);
  color: var(--ap-ink-80);
  padding: 48px 32px 32px 32px;
  border-top: 1px solid var(--ap-hairline);
  text-align: center;
}

.ap-footer p {
  font-family: var(--ap-text);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--ap-ink-48);
  margin: 0;
}

.ap-footer a {
  color: var(--ap-ink-80);
  text-decoration: none;
}

.ap-footer a:hover { color: var(--ap-primary); text-decoration: underline; }

/* Hide classic footer if it leaks through */
footer:not(.ap-footer) { display: none; }

/* ---------------------------------------------------------------------------
   Modal (What's New)
   --------------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 24px;
}

.modal-content {
  background: var(--ap-canvas);
  border-radius: var(--ap-r-lg);
  max-width: 720px;
  width: 100%;
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--ap-hairline);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 16px 28px;
  border-bottom: 1px solid var(--ap-hairline);
}

.modal-header h2 {
  font-family: var(--ap-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.007em;
  color: var(--ap-ink);
  margin: 0;
}

.modal-close {
  background: var(--ap-pearl);
  border: 1px solid var(--ap-divider-soft);
  border-radius: var(--ap-r-pill);
  width: 36px;
  height: 36px;
  font-size: 20px;
  color: var(--ap-ink);
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.12s ease;
}

.modal-close:hover { background: #f0f0f3; }
.modal-close:active { transform: scale(0.95); }

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 28px 24px 28px;
  border-top: 1px solid var(--ap-hairline);
}

.modal-btn-primary {
  background: var(--ap-primary);
  color: var(--ap-on-dark);
  border: 0;
  border-radius: var(--ap-r-pill);
  padding: 11px 22px;
  font-family: var(--ap-text);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.016em;
  cursor: pointer;
  min-height: 40px;
  transition: background 0.15s ease, transform 0.12s ease;
}

.modal-btn-primary:hover { background: #0077ed; }
.modal-btn-primary:active { transform: scale(0.95); }

.changelog-version {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--ap-hairline);
}

.changelog-version:last-child { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }

.changelog-version h3 {
  font-family: var(--ap-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.011em;
  color: var(--ap-ink);
  margin: 0 0 12px 0;
}

.changelog-section { margin-top: 16px; }

.changelog-section h4 {
  font-family: var(--ap-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.016em;
  color: var(--ap-primary);
  margin: 0 0 8px 0;
}

.changelog-section ul {
  margin: 0;
  padding-left: 22px;
}

.changelog-section li {
  font-family: var(--ap-text);
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -0.016em;
  color: var(--ap-ink-80);
  margin-bottom: 4px;
}

.changelog-section li strong { color: var(--ap-ink); font-weight: 600; }

/* ---------------------------------------------------------------------------
   Blueprint builder rows (JS-generated; keep it quiet)
   --------------------------------------------------------------------------- */

.blueprint-item,
.cache-blueprint-item {
  border: 1px solid var(--ap-hairline);
  border-radius: var(--ap-r-md);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--ap-canvas);
}

.blueprint-item input,
.blueprint-item textarea,
.cache-blueprint-item input,
.cache-blueprint-item textarea {
  font-size: 14px;
  padding: 8px 12px;
  border-radius: var(--ap-r-sm);
}

/* ---------------------------------------------------------------------------
   Inline JS-styled buttons (e.g., "+ Add Blueprint")
   These were inline-styled in classic; rein them in here.
   --------------------------------------------------------------------------- */

button[onclick*="addBlueprint"],
button[onclick*="addCacheBlueprint"] {
  background: var(--ap-primary) !important;
  color: var(--ap-on-dark) !important;
  border: 0 !important;
  border-radius: var(--ap-r-pill) !important;
  padding: 8px 16px !important;
  font-family: var(--ap-text) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  letter-spacing: -0.016em !important;
  min-height: 36px;
  transition: background 0.15s ease, transform 0.12s ease;
}

button[onclick*="addBlueprint"]:hover,
button[onclick*="addCacheBlueprint"]:hover { background: #0077ed !important; }
button[onclick*="addBlueprint"]:active,
button[onclick*="addCacheBlueprint"]:active { transform: scale(0.95); }

/* Cache regenerate is a primary action — strip the classic gradient override */
#regenerate-btn {
  background: var(--ap-primary) !important;
}

#regenerate-btn:hover { background: #0077ed !important; }

/* ---------------------------------------------------------------------------
   Hide elements specific to the classic skin
   (theme toggle, classic user-info chrome — replaced by global nav)
   --------------------------------------------------------------------------- */

.theme-toggle-btn,
.whats-new-btn-classic { display: none; }

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 1068px) {
  .ap-hero h1 { font-size: 48px; }
  .form-section h2,
  .ap-section-head h2 { font-size: 34px; }
}

@media (max-width: 833px) {
  .ap-tile { padding: 56px 22px; }
  .ap-hero h1 { font-size: 40px; }
  .ap-hero .ap-tagline { font-size: 22px; }
  .form-section h2,
  .ap-section-head h2 { font-size: 28px; }
  .ap-sub-nav { padding: 0 18px; }
  .ap-sub-nav .ap-subnav-actions { gap: 12px; }
  .ap-global-nav { padding: 0 16px; }
  .ap-global-nav .ap-gnav-left,
  .ap-global-nav .ap-gnav-right { gap: 14px; }
}

@media (max-width: 640px) {
  .ap-tile { padding: 48px 18px; }
  .ap-hero h1 { font-size: 34px; }
  .ap-hero .ap-tagline { font-size: 19px; }
  .form-section h2,
  .ap-section-head h2 { font-size: 24px; }
  .label-with-button { flex-direction: column; align-items: flex-start; }
  .upload-row { flex-direction: column; align-items: flex-start; }
  .submit-btn { width: 100%; }
  .ap-footer { padding: 32px 18px 24px 18px; }
}

@media (max-width: 480px) {
  .ap-hero h1 { font-size: 28px; line-height: 1.1; }
  .form-section h2,
  .ap-section-head h2 { font-size: 22px; }
}

/* ===========================================================================
   Dark mode — tokens redefine, the whole system flips automatically.
   Apple's dark surfaces use the same near-black tile palette as the dark
   product tiles. Action Blue (#0066cc) reads cleanly on tile-1 already,
   so the primary CTA does not need a swap.
   =========================================================================== */

[data-theme="dark"] {
  /* Surfaces flip to the tile palette; canvas becomes tile-1 */
  --ap-canvas: #1d1d1f;       /* near-black ink, used as page surface */
  --ap-parchment: #161617;    /* one micro-step darker for alternation */
  --ap-pearl: #2a2a2c;        /* lifted secondary surface (was near-white) */

  /* Text inverts */
  --ap-ink: #f5f5f7;
  --ap-ink-80: #d2d2d7;
  --ap-ink-48: #86868b;

  /* Hairlines on dark */
  --ap-hairline: rgba(255, 255, 255, 0.10);
  --ap-divider-soft: rgba(255, 255, 255, 0.06);
  --ap-hairline-strong: rgba(255, 255, 255, 0.14);
}

/* Body background */
[data-theme="dark"] body { background: var(--ap-canvas); }

/* Sub-nav frosted parchment → frosted near-black */
[data-theme="dark"] .ap-sub-nav {
  background: rgba(22, 22, 23, 0.78);
  border-bottom-color: var(--ap-hairline-strong);
}

/* Inline button hovers that hard-coded a light hex */
[data-theme="dark"] .ap-btn-pearl:hover,
[data-theme="dark"] .upload-btn-small:hover,
[data-theme="dark"] .modal-close:hover { background: #3a3a3c; color: var(--ap-ink); }

[data-theme="dark"] .ap-btn-dark { background: var(--ap-pearl); }
[data-theme="dark"] .ap-btn-dark:hover { background: #3a3a3c; }

/* Inputs: dark surface needs a lifted, slightly lighter input fill */
[data-theme="dark"] .form-group input[type="text"],
[data-theme="dark"] .form-group input[type="email"],
[data-theme="dark"] .form-group input[type="password"],
[data-theme="dark"] .form-group input[type="number"],
[data-theme="dark"] .form-group input[type="url"],
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] input[type="text"]:not(.ap-bare),
[data-theme="dark"] input[type="email"]:not(.ap-bare),
[data-theme="dark"] input[type="password"]:not(.ap-bare),
[data-theme="dark"] select:not(.ap-bare),
[data-theme="dark"] textarea:not(.ap-bare) {
  background-color: #2a2a2c;
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--ap-ink);
}

[data-theme="dark"] .form-group select option,
[data-theme="dark"] select:not(.ap-bare) option {
  background-color: #2a2a2c;
  color: var(--ap-ink);
}

[data-theme="dark"] ::placeholder { color: #86868b; }

/* Select chevron needs a light stroke on dark */
[data-theme="dark"] .form-group select,
[data-theme="dark"] select:not(.ap-bare) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23f5f5f7' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Workflow tabs container becomes a dark pearl with light divider */
[data-theme="dark"] .workflow-tabs,
[data-theme="dark"] .credential-tabs {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .workflow-tab-btn { color: var(--ap-ink-80); }
[data-theme="dark"] .workflow-tab-btn:hover { color: var(--ap-ink); }
[data-theme="dark"] .workflow-tab-btn.active { background: var(--ap-ink); color: var(--ap-canvas); }

[data-theme="dark"] .credential-tab.active {
  background: rgba(255, 255, 255, 0.10);
  color: var(--ap-ink);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* Info banners — preserve hue, soften on dark */
[data-theme="dark"] .info-banner {
  background: rgba(41, 151, 255, 0.08);
  border-color: rgba(41, 151, 255, 0.24);
}

[data-theme="dark"] .info-banner.warning {
  background: rgba(245, 166, 35, 0.10);
  border-color: rgba(245, 166, 35, 0.32);
}

/* Inline links inside body text on dark */
[data-theme="dark"] a { color: var(--ap-primary-on-dark); }
[data-theme="dark"] .ap-footer a { color: var(--ap-ink-80); }
[data-theme="dark"] .ap-footer a:hover { color: var(--ap-primary-on-dark); }

/* Credentials-parsed info card */
[data-theme="dark"] .credentials-parsed {
  background: rgba(41, 151, 255, 0.10);
  border-color: rgba(41, 151, 255, 0.28);
}
[data-theme="dark"] .credentials-parsed strong { color: var(--ap-ink); }
[data-theme="dark"] .credentials-parsed p { color: var(--ap-ink-80); }

/* Toast messages */
[data-theme="dark"] .message-container .message.success {
  background: rgba(48, 209, 88, 0.10);
  border-color: rgba(48, 209, 88, 0.30);
  color: #4ade80;
}
[data-theme="dark"] .message-container .message.error {
  background: rgba(255, 69, 58, 0.10);
  border-color: rgba(255, 69, 58, 0.30);
  color: #ff6b6b;
}
[data-theme="dark"] .message-container .message.info {
  background: rgba(41, 151, 255, 0.10);
  border-color: rgba(41, 151, 255, 0.28);
  color: var(--ap-primary-on-dark);
}

/* Modal */
[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, 0.66); }
[data-theme="dark"] .modal-content { background: var(--ap-pearl); border-color: var(--ap-hairline-strong); }
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--ap-hairline); }

/* Blueprint builder cards */
[data-theme="dark"] .blueprint-item,
[data-theme="dark"] .cache-blueprint-item {
  background: var(--ap-pearl);
  border-color: var(--ap-hairline);
}

/* Progress bar track */
[data-theme="dark"] .progress-container {
  background: var(--ap-pearl);
  border-color: var(--ap-hairline);
}
[data-theme="dark"] .progress-bar { background: rgba(255, 255, 255, 0.10); }

/* Theme toggle button — small pill in the global nav, state-reflective */
.ap-theme-toggle {
  background: rgba(255, 255, 255, 0.12);
  border: 0;
  color: var(--ap-on-dark);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--ap-r-pill);
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.12s ease;
}
.ap-theme-toggle:hover { background: rgba(255, 255, 255, 0.22); }
.ap-theme-toggle:active { transform: scale(0.95); }
.ap-theme-toggle .ap-theme-icon { display: inline-block; }

/* In dark mode, swap to a sun-glow pill so the active state is obvious */
[data-theme="dark"] .ap-theme-toggle {
  background: rgba(255, 204, 0, 0.18);
  color: #ffd60a;
}
[data-theme="dark"] .ap-theme-toggle:hover { background: rgba(255, 204, 0, 0.30); }

