/* ------------------------------------------------------------------ */
/* Design tokens                                                       */
/* ------------------------------------------------------------------ */

:root {
  --paper: #f7f4ee;
  --surface: #ffffff;
  --ink: #1f2a33;
  --ink-soft: #5a6570;
  --accent: #2b4c73;
  --border: #e3ddd2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31, 42, 51, 0.06), 0 4px 16px rgba(31, 42, 51, 0.06);
  --danger: #a0453f;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: Georgia, "Times New Roman", Times, serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10161c;
    --surface: #1a232c;
    --ink: #e8e4da;
    --ink-soft: #a7b0b8;
    --accent: #7fa5d1;
    --border: #2a3540;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.35);
    --danger: #d98c8c;
  }
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must always win, even over components that set their
   own display (flex/grid) — several toggled panels rely on it. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 0.5em;
}

p {
  margin: 0 0 0.75em;
}

button {
  font: inherit;
  color: inherit;
}

input, select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------ */
/* Header                                                              */
/* ------------------------------------------------------------------ */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(16px, env(safe-area-inset-left)) 14px max(16px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-kanji {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.header-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
  transition: background-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--border);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

/* ------------------------------------------------------------------ */
/* Layout                                                              */
/* ------------------------------------------------------------------ */

.layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px;
  padding-bottom: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

.main-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.controls-column {
  min-width: 0;
}

@media (min-width: 900px) {
  .layout {
    flex-direction: row-reverse;
    align-items: flex-start;
    padding: 24px;
  }
  .main-column {
    flex: 1 1 auto;
    min-width: 0;
  }
  .controls-column {
    flex: 0 0 340px;
    min-width: 320px;
    position: sticky;
    top: 86px;
  }
}

/* ------------------------------------------------------------------ */
/* Cards (shared)                                                      */
/* ------------------------------------------------------------------ */

.preview-card,
.picker,
.info-panel,
.accordion-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------------ */
/* Preview                                                             */
/* ------------------------------------------------------------------ */

.preview-card {
  padding: 16px;
}

.preview-canvas {
  width: 100%;
  max-height: 48vh;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
}

.preview-canvas svg {
  display: block;
  width: 100%;
  height: 100%;
}

@media (min-width: 900px) {
  .preview-canvas {
    max-height: 62vh;
  }
}

.pass-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.legend-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Pattern picker strip                                                */
/* ------------------------------------------------------------------ */

.picker {
  padding: 14px 0;
}

.pattern-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 0 14px 4px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.pattern-strip::-webkit-scrollbar {
  height: 6px;
}

.pattern-strip::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.pattern-card {
  scroll-snap-align: start;
  flex: 0 0 128px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
  text-align: center;
}

.pattern-card:hover {
  border-color: var(--accent);
}

.pattern-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

.pattern-thumb {
  width: 76px;
  height: 76px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.pattern-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.pattern-name {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
}

.pattern-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.family-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  background: var(--border);
  padding: 2px 7px;
  border-radius: 999px;
}

/* ------------------------------------------------------------------ */
/* Difficulty dots                                                     */
/* ------------------------------------------------------------------ */

.difficulty-dots {
  display: inline-flex;
  gap: 4px;
}

.difficulty-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.difficulty-dots .dot.filled {
  background: var(--accent);
}

.difficulty-dots.compact .dot {
  width: 6px;
  height: 6px;
}

/* ------------------------------------------------------------------ */
/* Accordion (shared: info panel + controls)                           */
/* ------------------------------------------------------------------ */

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-display);
  text-align: left;
  min-height: 44px;
}

.chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  color: var(--ink-soft);
}

.accordion-header[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}

.accordion-body,
.info-body {
  padding: 0 16px 16px;
}

.accordion {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ------------------------------------------------------------------ */
/* Info panel                                                          */
/* ------------------------------------------------------------------ */

.info-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.info-heading h2 {
  font-size: 1.4rem;
}

.info-kanji {
  font-size: 1.1rem;
  color: var(--ink-soft);
}

.info-meaning {
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.info-body .difficulty-dots {
  margin-bottom: 12px;
}

.info-body .dot {
  width: 9px;
  height: 9px;
}

.info-description {
  margin-bottom: 14px;
}

.stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.stat-chip {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.info-body h3 {
  font-size: 0.95rem;
  margin-top: 18px;
}

.pass-list,
.tip-list {
  margin: 0;
  padding-left: 1.2em;
}

.pass-list li,
.tip-list li {
  margin-bottom: 4px;
}

/* ------------------------------------------------------------------ */
/* Form fields                                                         */
/* ------------------------------------------------------------------ */

.field {
  margin-bottom: 18px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.field-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.field-value {
  font-weight: 400;
  color: var(--ink-soft);
}

.field-note {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: -10px;
  margin-bottom: 18px;
}

.field-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.field-row .field {
  flex: 1 1 130px;
}

select,
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  min-height: 44px;
}

.unit {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-left: 6px;
}

/* Stepper */

.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}

.stepper input[type="number"] {
  border: none;
  border-radius: 0;
  text-align: center;
  min-width: 0;
  flex: 1;
  -moz-appearance: textfield;
}

.stepper input[type="number"]::-webkit-inner-spin-button,
.stepper input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-btn {
  flex: 0 0 40px;
  border: none;
  background: var(--paper);
  cursor: pointer;
  font-size: 1.1rem;
  min-height: 44px;
  color: var(--ink);
}

.stepper-btn:hover {
  background: var(--border);
}

/* Seed row */

.seed-row {
  display: flex;
  gap: 8px;
}

.seed-row input {
  flex: 1;
}

.dice-btn {
  flex: 0 0 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  cursor: pointer;
  font-size: 1.1rem;
}

.dice-btn:hover {
  background: var(--border);
}

/* Range inputs */

input[type="range"] {
  width: 100%;
  height: 44px;
  padding: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  margin-top: -8px;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Colour swatches                                                     */
/* ------------------------------------------------------------------ */

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

.swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  position: relative;
}

.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.swatch-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    conic-gradient(#e63946, #f1c453, #52b788, #4895ef, #b892ff, #e63946);
}

.swatch-custom.selected {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.swatch-custom input[type="color"] {
  width: 150%;
  height: 150%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: transparent;
  opacity: 0;
}

/* ------------------------------------------------------------------ */
/* Segmented control + switch                                          */
/* ------------------------------------------------------------------ */

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}

.segmented button {
  flex: 1;
  border: none;
  background: var(--paper);
  padding: 10px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-soft);
  border-right: 1px solid var(--border);
}

.segmented button:last-child {
  border-right: none;
}

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 0;
  min-height: 44px;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  width: 42px;
  height: 24px;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-label {
  font-size: 0.92rem;
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Action bar                                                          */
/* ------------------------------------------------------------------ */

.action-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + var(--safe-bottom)) max(8px, env(safe-area-inset-right));
  gap: 4px;
  z-index: 20;
}

.action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
  min-height: 52px;
  transition: background-color 0.15s ease;
}

.action-btn:hover {
  background: var(--paper);
}

.action-btn svg {
  width: 21px;
  height: 21px;
}

.action-btn span {
  font-size: 0.68rem;
  font-weight: 600;
}

@media (min-width: 900px) {
  .action-bar {
    position: static;
    border-top: none;
    justify-content: flex-start;
    padding: 0;
    gap: 10px;
  }
  .action-btn {
    flex: 0 0 auto;
    flex-direction: row;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .action-btn span {
    font-size: 0.85rem;
  }
}

/* ------------------------------------------------------------------ */
/* Toast                                                                */
/* ------------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  z-index: 60;
}

@media (min-width: 900px) {
  .toast {
    bottom: 24px;
  }
}

/* ------------------------------------------------------------------ */
/* Drawers                                                              */
/* ------------------------------------------------------------------ */

.drawer[hidden] {
  display: none;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 25, 0.45);
}

.drawer-panel {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 640px) {
  .drawer-panel {
    width: 420px;
    max-width: 90vw;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.drawer-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.learn-section {
  margin-bottom: 22px;
}

.learn-section h3 {
  font-size: 1rem;
  color: var(--accent);
}

.learn-section ul {
  padding-left: 1.2em;
  margin: 0;
}

.learn-section li {
  margin-bottom: 6px;
}

/* Save form */

.save-form {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.save-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.save-form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.save-form-row input {
  flex: 1 1 160px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  min-height: 44px;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--paper);
  border: 1px solid var(--border);
  color: var(--ink);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
}

.saved-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-wrap: wrap;
}

.saved-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.saved-name {
  font-weight: 600;
}

.saved-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.saved-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.saved-empty {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------------ */
/* Print                                                               */
/* ------------------------------------------------------------------ */

#print-sheet {
  display: none;
}

@media print {
  body > *:not(#print-sheet) {
    display: none !important;
  }
  #print-sheet {
    display: block !important;
  }
  #print-sheet h1 {
    font-size: 1.2rem;
    margin-bottom: 12px;
  }
  #print-sheet .print-canvas svg {
    width: auto;
    height: auto;
  }
  #print-sheet .print-calibration {
    margin: 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  #print-sheet .print-calibration p {
    font-size: 0.8rem;
    max-width: 320px;
  }
  #print-sheet ol {
    padding-left: 1.2em;
  }
}

/* ------------------------------------------------------------------ */
/* Picker header + Surprise me                                         */
/* ------------------------------------------------------------------ */

.picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px 10px;
}

.picker-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.surprise-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: border-color 0.15s ease;
}

.surprise-btn:hover {
  border-color: var(--accent);
}

.surprise-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Pattern strip "Design & mix" section break */

.pattern-strip-divider {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.pattern-strip-divider span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  border-left: 1px dashed var(--border);
  padding-left: 10px;
  height: 76px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Colour param + motif edit button                                    */
/* ------------------------------------------------------------------ */

.field-color input[type="color"] {
  width: 56px;
  height: 44px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  cursor: pointer;
}

.motif-edit-btn {
  width: 100%;
}

/* ------------------------------------------------------------------ */
/* Hitomezashi manual seed-bit editor                                  */
/* ------------------------------------------------------------------ */

.bit-strip-group {
  margin-top: 14px;
}

.bit-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 2px 12px;
  scrollbar-width: thin;
}

.bit-strip::-webkit-scrollbar {
  height: 5px;
}

.bit-strip::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.bit-chip {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  cursor: pointer;
}

.bit-chip[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Floating play button + stitch player controls                       */
/* ------------------------------------------------------------------ */

.preview-card {
  position: relative;
}

.play-fab[hidden] {
  display: none;
}

.play-fab {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  z-index: 5;
}

.play-fab:hover {
  filter: brightness(1.08);
}

.play-fab svg {
  width: 20px;
  height: 20px;
  margin-left: 2px;
}

.pass-legend.player-strip {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.player-btn {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-size: 1rem;
}

.player-btn:hover {
  background: var(--border);
}

.player-playpause {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.player-speed {
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.player-exit {
  margin-left: auto;
}

.player-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.player-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.08s linear;
}

.player-caption {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ */
/* Motif designer + photo mock-up drawers                              */
/* ------------------------------------------------------------------ */

.designer-panel,
.mockup-panel {
  width: 100%;
}

@media (min-width: 640px) {
  .designer-panel,
  .mockup-panel {
    width: min(94vw, 920px);
    max-width: 94vw;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
  }
}

.designer-body,
.mockup-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.designer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}

.designer-toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
}

.designer-toolbar-field select {
  min-height: 44px;
}

.designer-hint {
  margin: 0;
}

.designer-surface-wrap {
  width: 100%;
  flex-shrink: 0;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
  touch-action: none;
}

@media (min-width: 900px) {
  .designer-surface-wrap {
    max-width: 70vw;
  }
}

.designer-surface {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.designer-grid-line {
  stroke: var(--border);
  stroke-width: 0.4;
}

.designer-dot {
  fill: var(--ink-soft);
}

.designer-sym-line {
  stroke: var(--ink-soft);
  stroke-linecap: round;
  opacity: 0.45;
}

.designer-base-line {
  stroke: var(--accent);
  stroke-linecap: round;
}

.designer-drag-line {
  stroke: var(--accent);
  stroke-linecap: round;
  opacity: 0.7;
}

.designer-preview-label {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink-soft);
}

.designer-preview {
  height: 120px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.designer-preview svg {
  width: 100%;
  height: 100%;
  display: block;
}

.designer-done {
  width: 100%;
}

.mockup-privacy {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 0;
}

.mockup-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
}

.mockup-choose-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.mockup-stage-wrap {
  width: 100%;
  flex-shrink: 0;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
  touch-action: none;
}

.mockup-stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.mockup-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mockup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.mockup-actions button {
  flex: 1 1 140px;
}
