/* Peg-Loom Knitting & Four-Shaft Weaving Draft Studio — Carbie-Slate & Starlight-Cerulean AA Theme */
:root {
  --bg-page: #080e1c;
  --bg-panel: #0f172a;
  --bg-card: #162036;
  --bg-canvas: #0b1324;
  --border-subtle: #334155;
  --border-bright: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --accent-blue: #0369a1;      /* #ffffff on #0369a1 = 5.93:1 WCAG AA */
  --accent-blue-hi: #0284c7;
  --accent-amber: #c2410c;     /* #ffffff on #c2410c = 5.18:1 WCAG AA */
  --accent-green: #15803d;     /* #ffffff on #15803d = 5.02:1 WCAG AA */
  --accent-slate: #1e293b;     /* #f8fafc on #1e293b = 13.5:1 WCAG AAA */
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-main);
  font-family: "DejaVu Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.38;
  overflow-x: hidden;
}

a {
  color: #7dd3fc;
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover, a:focus-visible {
  color: #bae6fd;
}

.app-shell {
  max-width: 1012px;
  margin: 0 auto;
  padding: 6px 10px 14px;
}

.top-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}

.header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.top-header h1 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.lede {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.action-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

button {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  padding: 5px 7px;
  border-radius: 5px;
  border: 1px solid #475569;
  background: var(--accent-slate);
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

button:hover {
  background: #283548;
  border-color: #94a3b8;
}

button:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 1px;
}

button.btn-primary,
button.active-mode {
  background: var(--accent-amber);
  border-color: #fb923c;
  color: #ffffff;
}

button.btn-blue,
button.active-sub {
  background: var(--accent-blue);
  border-color: #38bdf8;
  color: #ffffff;
}

button.btn-green {
  background: var(--accent-green);
  border-color: #4ade80;
  color: #ffffff;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 294px;
  gap: 8px;
  align-items: start;
}

.stage-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.canvas-wrap {
  position: relative;
  isolation: isolate;
  width: 100%;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  overflow: hidden;
}

#loomCanvas {
  display: block;
  width: 100%;
  height: 394px;
  touch-action: none;
  cursor: pointer;
}

.hud-pill {
  position: absolute;
  z-index: 2;
  bottom: 6px;
  right: 8px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid #475569;
  color: #f8fafc;
  font-size: 0.70rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  pointer-events: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.metric-card {
  min-width: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 7px;
}

.metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.metric-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
}

.side-panel {
  min-width: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid #1e293b;
}

.panel-section:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.section-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: #7dd3fc;
  letter-spacing: 0.01em;
}

.btn-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.btn-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.btn-grid-3 button,
.btn-grid-2 button {
  padding: 4px 4px;
  font-size: 0.69rem;
  text-align: center;
  min-width: 0;
}

.yarn-swatch-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 4px 5px !important;
  font-size: 0.68rem !important;
}

.swatch-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  flex-shrink: 0;
}

.helper-note {
  margin: 0;
  font-size: 0.71rem;
  color: var(--text-muted);
}

.challenge-banner {
  background: var(--bg-card);
  border: 1px solid #475569;
  border-radius: 5px;
  padding: 5px 6px;
  font-size: 0.71rem;
  color: var(--text-main);
}

.info-footer {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.71rem;
  color: var(--text-muted);
}

kbd {
  display: inline-block;
  padding: 0 4px;
  font-size: 0.67rem;
  font-family: "DejaVu Sans Mono", monospace;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 3px;
  color: #f8fafc;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 4px 6px 10px;
  }
  .top-header {
    margin-bottom: 4px;
    padding-bottom: 3px;
  }
  .top-header h1 {
    font-size: 0.88rem;
  }
  .lede {
    font-size: 0.68rem;
    line-height: 1.24;
  }
  .action-strip {
    gap: 3px;
    margin-bottom: 4px;
  }
  .action-strip button {
    font-size: 0.64rem;
    padding: 3px 5px;
  }
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
  #loomCanvas {
    height: 252px;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;
  }
}
