:root {
  --bg: #0f1115;
  --panel: #262f42;
  --panel-2: #1f2430;
  --text: #e8ecf1;
  --muted: #aab4c0;
  --accent: #7cc4ff;
  --border: #2b3240;
  --ok: #8ee28e;
  --warn: #ffd27a;
  --danger: #ff9a9a;
}

* { box-sizing: border-box; }

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #2c3440;
  background: #161b22;
  color: #c9d1d9;
  font-size: 14px;
  cursor: pointer;
}

.tab:hover {
  background: #1f2630;
}

.tab.active {
  background: #3976a9;
  border-color: #326b9a;
  color: white;
}

.units {
  font-size: 13px;
  color: #8b949e;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.howto-content {
  padding: 16px;
}

.main-area {
  width: 100%;
  min-width: 0;
}

#app-ui,
#content {
  width: 100%;
  margin: 0;
}

#content {
  display: block;
  padding: 0;
  margin-top: 4px;
}

#content .howto-content {
  margin: 0;
}

.howto-content h1 {
  margin: 0 0 20px;
  font-size: 1.5rem;
  font-weight: 600;
}

.howto-steps {
  margin: 0 0 24px;
  padding-left: 1.4em;
  line-height: 1.6;
  color: var(--text);
}

.howto-steps li {
  margin-bottom: 8px;
}

.howto-section {
  margin-top: 28px;
  margin-bottom: 8px;
}

.info-card {
  background: rgb(27, 36, 38);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.info-card.warning {
  border-left: 3px solid #f0570b;
  background: rgb(32, 47, 47);
}

.info-label {
  font-weight: 600;
  color: #cfd8ff;
  display: inline-block;
  margin-bottom: 4px;
}

.info-card a {
  color: #7ab7ff;
  text-decoration: none;
}

.info-card a:hover {
  text-decoration: underline;
}

.info-card .line {
  display: block;
  margin-bottom: 6px;
}

.info-card .line:last-child {
  margin-bottom: 0;
}

.info-card.primary {
  border-left: 3px solid #ffd500;
  background: linear-gradient(
    90deg,
    rgba(77, 163, 255, 0.08),
    rgba(77, 163, 255, 0.02)
  );
}
.info-card.primary ol {
  margin-bottom: 6px;
}

.controls {
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}

.dimensions {
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.dimensions-label {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.dimensions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  flex: 1 1 100%;
}

.dimensions-row--xyz {
  flex-wrap: nowrap;
}

.dimensions-row--secondary {
  flex-wrap: wrap;
  gap: 10px 12px;
}

/* Wall with other inputs on the left; checkboxes on the right (all breakpoints) */
.dimensions-checkboxes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  min-width: 0;
  margin-left: auto;
}

.dimensions-wall-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
  cursor: text;
}

.dimensions-wall-label input {
  cursor: text;
}

.field.checkbox {
  display: inline-flex;
  align-items: center;
}

.field.checkbox label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.dimensions-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  cursor: text;
}

.dimensions-row label input {
  cursor: text;
}

.dimensions-row input[type="number"],
.dimensions-wall-label input[type="number"] {
  width: 4.5em;
  min-width: 56px;
}

input[type="number"],
input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
}

input[type="text"] {
  width: 100%;
}

.controls-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button, a.button-link {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  text-align: center;
}

button.primary {
  background: var(--accent);
  color: #081018;
  border-color: transparent;
  font-weight: 600;
}

button:disabled, a.button-link.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.viewer-container {
  position: relative;
  margin-bottom: 20px;
}

.viewer-overlay-btn {
  position: absolute;
  padding: 8px 14px;
  border-radius: 6px;
  background: #2a2f3a;
  color: white;
  font-size: 13px;
  z-index: 10;
  text-decoration: none;
  display: inline-block;
  border: none;
  cursor: pointer;
}

.viewer-overlay-btn:hover {
  background: #353b48;
}

.viewer-overlay-btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.download-view {
  top: 20px;
  left: 20px;
}

.fit-view {
  bottom: 20px;
  right: 20px;
}

.hidden {
  display: none;
}

.viewer {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: 500px;
  margin: 0 auto 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b0d12;
  overflow: hidden;
}

.viewer canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.viewer-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.model-info {
  font-size: 13px;
  color: var(--muted);
}

/* Short about (SEO / crawlers); hidden with #app-ui when About is open */
.site-about {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.2);
}

.site-about-heading {
  margin: 0 0 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  line-height: 1.3;
}

.site-about-text {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--muted);
  opacity: 0.92;
}

.site-about-points {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-about-points li {
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--muted);
  opacity: 0.85;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.site-about-links {
  margin-top: 10px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #6b7280;
}

.site-about-links a:any-link {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-about-links a:any-link:hover,
.site-about-links a:any-link:focus-visible {
  color: #9aa4b2;
}

.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  font-size: 0.8rem;
}

/* Support button (subtle but intentional) */
.support-button {
  color: #9aa4b2;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0.85;
}

.support-button:hover {
  color: #e6edf3;
  background: rgba(255, 255, 255, 0.06);
  opacity: 1;
}

/* kill ugly visited purple */
.support-button:visited {
  color: #9aa4b2;
}

/* Stats = even quieter */
.site-footer-stats {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-footer-stats:hover {
  color: #9aa4b2;
}

.status {
  min-height: 22px;
  font-size: 14px;
  color: var(--muted);
}

.status-inline {
  min-height: 22px;
}

.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.error { color: var(--danger); }

@media (max-width: 640px) {
  .dimensions-row--xyz {
    gap: 10px;
  }

  .dimensions-row--secondary {
    gap: 8px 10px;
  }

  .dimensions-checkboxes {
    gap: 8px 12px;
  }

  /* Let X/Y/H shrink slightly so the row stays single-line on narrow phones */
  .dimensions-row--xyz input[type="number"] {
    min-width: 52px;
    width: 4em;
    padding: 7px 8px;
    font-size: 14px;
  }

  .dimensions-wall-label input[type="number"] {
    min-width: 52px;
    width: 4em;
    padding: 7px 8px;
    font-size: 14px;
  }
}

@media (max-width: 768px) {
  .viewer {
    aspect-ratio: 1 / 1;
    height: auto;
    max-height: none;
  }
}

@media (min-width: 769px) {
  .tab {
    padding: 8px 18px;
    font-size: 16px;
  }

  .units {
    font-size: 15px;
  }

  .dimensions-row label,
  .dimensions-wall-label {
    font-size: 16px;
  }

  .dimensions-row input[type="number"],
  .dimensions-wall-label input[type="number"] {
    padding: 10px 12px;
    font-size: 17px;
    min-width: 60px;
  }

  button,
  a.button-link {
    padding: 12px 22px;
    font-size: 16px;
  }

  .viewer-overlay-btn {
    padding: 10px 18px;
    font-size: 14px;
  }

  .status {
    font-size: 16px;
    min-height: 24px;
  }

  .model-info {
    font-size: 14px;
  }
}


.howto-hero {
  text-align: center;
  margin: 16px 0 24px;
}

.howto-hero img {
  width: 100%;
  max-width: 600px;
  height: auto;
  border-radius: 8px;
}

.howto-section-img {
  text-align: center;
  margin: 12px 0 20px;
}

.howto-section-img img {
  width: 100%;
  max-width: 360px;
  height: auto;
  border-radius: 8px;
}