.follow-pattern {
  max-width: 1280px;
  margin-inline: auto;
  padding-block: 20px 36px;
  color: var(--ink);
  font: 14px/1.55 var(--font);
}

.follow-pattern [hidden] { display: none !important; }
.follow-pattern .btn { min-height: 44px; box-shadow: none; }
.follow-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.follow-header h1 { font-size: 24px; }
.follow-header button { flex: none; }
#follow-favorite {
  display: inline-grid;
  place-items: center;
  margin-inline-start: auto;
  width: 44px;
  padding: 0;
}
#follow-favorite[aria-pressed=true] {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--studio-soft);
}
#follow-favorite[aria-pressed=true] svg { fill: currentColor; }
.follow-heading { min-width: 0; }
.follow-heading p {
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 13px;
}

.follow-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 330px);
  gap: 16px;
  align-items: start;
}
.follow-sheet, .follow-summary, .follow-palette, .follow-actions, .follow-message {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.follow-sheet { overflow: hidden; }
.follow-sheet-bar, .follow-sheet-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  padding: 9px 16px;
}
.follow-sheet-bar label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.follow-sheet-bar select {
  min-height: 44px;
  min-width: 88px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}
.follow-range {
  padding: 0 16px 9px;
  font-size: 12px;
  color: var(--muted);
}
.follow-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: min(65dvh, 660px);
  min-height: 280px;
  overflow: hidden;
  border-block: 1px solid var(--line);
  background-color: var(--bg);
  background-image: radial-gradient(var(--line) .8px, transparent .8px);
  background-size: 12px 12px;
  touch-action: none;
  user-select: none;
}
.follow-stage:focus-visible { outline-offset: -3px; }
.follow-stage canvas {
  display: block;
  flex: none;
  max-width: none;
  image-rendering: pixelated;
}
.follow-stage .follow-grid {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}
.follow-sheet-foot { justify-content: space-between; color: var(--muted); font-size: 12px; }
.follow-label-hint:not([hidden]) { display: block; margin-top: 2px; font-size: 11px; }
.follow-zoom { display: flex; align-items: center; gap: 4px; }
.follow-zoom button {
  min-height: 44px;
  min-width: 44px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.follow-zoom button:hover { background: var(--cream); }
.follow-zoom output {
  min-width: 42px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.follow-side { display: grid; gap: 12px; min-width: 0; }
.follow-summary, .follow-palette, .follow-actions, .follow-message { padding: 14px 16px; }
.follow-side h2 { font-size: 15px; }
.follow-summary-line { display: flex; align-items: center; gap: 10px; }
.follow-summary-line h2,
.follow-summary-line > span { flex: none; font-size: 13px; }
.follow-summary progress {
  display: block;
  flex: 1;
  min-width: 24px;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  accent-color: var(--primary);
  background: var(--cream);
}
.follow-summary progress::-webkit-progress-bar { background: var(--cream); }
.follow-summary progress::-webkit-progress-value { background: var(--primary); }
.follow-summary progress::-moz-progress-bar { background: var(--primary); }
.follow-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  cursor: pointer;
}
.follow-filter input { width: 18px; height: 18px; accent-color: var(--primary); }
#follow-quality, #follow-brand, .follow-empty {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}
.follow-colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  padding: 5px;
  margin: 4px -5px -5px;
  max-height: 224px;
  overflow: auto;
}
.follow-color {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0 5px;
  min-height: 46px;
  padding: 5px 7px;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.follow-color[aria-pressed=true] {
  background: var(--cream);
  border-color: var(--focus);
  color: var(--ink);
}
.follow-color-count {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
}
.follow-color[data-done=true] .follow-color-count { color: var(--ink); }
.follow-swatch {
  display: block;
  width: 17px;
  height: 17px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.follow-color .follow-swatch { grid-row: span 2; }
.follow-actions { display: grid; gap: 10px; }
.follow-current { display: flex; align-items: center; gap: 9px; min-width: 0; }
.follow-current-details { flex: 1; min-width: 0; }
.follow-current .follow-swatch { width: 34px; height: 34px; border-radius: 8px; flex: none; }
.follow-current strong { overflow-wrap: anywhere; }
.follow-current p { color: var(--muted); font-size: 12px; }
.follow-mobile-bar { display: none; }
.follow-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.follow-buttons .btn:not(.secondary) { flex: 1; min-width: 0; }
.follow-buttons #follow-undo { max-width: 50%; overflow-wrap: anywhere; }
.follow-save {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 8px;
  min-height: 19px;
  color: var(--muted);
  font-size: 12px;
}
#follow-board-progress { color: var(--ink); }
.follow-save [data-status=error] { color: var(--danger); }
.follow-save #follow-save-retry { min-height: 44px; }
.follow-message p { color: var(--muted); }
.follow-message button { margin-top: 10px; }
.follow-pick-dialog { display: grid; gap: 12px; overflow: hidden; }
.follow-pick-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.follow-pick-header #dialog-title { margin: 0; }
.follow-pick-dialog .follow-pick-header > button { min-height: 44px; padding: 8px 15px; }
.follow-pick-dialog .follow-colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  max-height: min(42dvh, 390px);
  margin: 0;
  overflow: auto;
}
.follow-pick-dialog .follow-color { min-width: 0; padding: 6px 8px; }
.follow-pick-dialog .follow-color strong { overflow-wrap: anywhere; }
.follow-pick-dialog .follow-color[aria-pressed=true] { outline: none; border-color: var(--focus); }
.follow-pick-dialog .follow-color:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.follow-pick-dialog [hidden] { display: none !important; }
#modal:has(#follow-controls-sheet) {
  width: min(100%, 560px);
  max-width: 100%;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 12px);
  inset: auto 0 0;
  margin: auto auto 0;
  padding: 0;
  border-radius: 24px 24px 0 0;
  overflow: hidden;
}
#follow-controls-sheet {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 14px);
}
#follow-controls-sheet .follow-pick-header { flex: none; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.follow-pick-body { overflow: auto; overscroll-behavior: contain; min-height: 0; padding: 14px 16px max(16px, env(safe-area-inset-bottom, 0px)); }
.follow-pick-body > div + div { margin-top: 14px; }
.follow-pick-body .follow-actions, .follow-pick-body .follow-palette, .follow-pick-body .follow-summary { padding: 0; border: 0; border-radius: 0; }
.follow-pick-body .follow-palette h2 { font-size: 15px; }
.follow-pick-body .follow-colors { max-height: min(32dvh, 280px); margin-top: 8px; }
.follow-pick-body .follow-summary { padding-block: 12px; }
.follow-pick-body .follow-buttons .btn { min-height: 44px; padding-inline: 12px; }
#follow-view-options { border-top: 1px solid var(--line); }
#follow-view-options > summary { min-height: 44px; padding-block: 12px; cursor: pointer; font-weight: 600; }
#follow-view-options .follow-sheet-bar, #follow-view-options .follow-sheet-foot, #follow-view-options .follow-range { padding-inline: 0; }
#follow-view-options .follow-sheet-foot { align-items: stretch; flex-direction: column; }
#follow-view-options .follow-zoom { justify-content: space-between; }
.follow-pick-body #follow-favorite { margin: 0; }

.follow-chart-frame {
  display: grid;
  grid-template: 22px auto / 28px minmax(0, 1fr);
  overflow: hidden;
  border-block: 1px solid var(--line);
  background: var(--surface);
}
.follow-chart-frame .follow-stage {
  grid-area: 2 / 2;
  border: 0;
  background: var(--bg);
}
.follow-ruler { display: block; box-sizing: border-box; min-width: 0; min-height: 0; width: 100%; height: 100%; pointer-events: none; }
.follow-ruler--top { grid-area: 1 / 2; border-bottom: 1px solid var(--line); }
.follow-ruler--left { grid-area: 2 / 1; border-right: 1px solid var(--line); }

@media (max-width: 740px), (pointer: coarse) and (max-height: 600px) {
  #main:has(.follow-workspace) {
    padding: 0;
    overflow: hidden;
    scrollbar-gutter: auto;
  }
  .follow-pattern:has(.follow-workspace) { position: relative; width: 100%; height: 100dvh; padding: 0; overflow: hidden; }
  .follow-pattern:not(:has(.follow-workspace)) { padding: 12px; }
  .follow-pattern:has(.follow-workspace) > .follow-header {
    position: absolute;
    z-index: 2;
    inset: calc(28px + env(safe-area-inset-top, 0px)) auto auto calc(32px + env(safe-area-inset-left, 0px));
    margin: 0;
    pointer-events: none;
  }
  .follow-pattern:has(.follow-workspace) > .follow-header .follow-heading,
  .follow-pattern:has(.follow-workspace) > .follow-header #follow-favorite { display: none; }
  .follow-header #follow-back { pointer-events: auto; min-height: 44px; padding-inline: 14px; font-size: 13px; background: var(--surface); box-shadow: var(--shadow); }
  .follow-workspace, .follow-sheet, .follow-chart-frame { display: block; position: absolute; inset: 0; border: 0; border-radius: 0; }
  .follow-sheet > .follow-sheet-bar, .follow-sheet > .follow-range, .follow-sheet > .follow-sheet-foot, .follow-side { display: none; }
  .follow-chart-frame .follow-stage { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; }
  .follow-ruler { position: absolute; z-index: 1; opacity: .82; }
  .follow-ruler--top { top: 0; left: 24px; width: calc(100% - 24px); height: 20px; }
  .follow-ruler--left { top: 20px; left: 0; width: 24px; height: calc(100% - 20px); }
  .follow-grid [data-grid-line=cell] { stroke: var(--muted); opacity: .26; }
  .follow-grid [data-grid-line=half] { stroke: var(--muted); opacity: .44; }
  .follow-grid [data-grid-line=major] { stroke: var(--muted); opacity: .66; }
  .follow-mobile-bar {
    display: grid;
    justify-items: center;
    gap: 8px;
    position: absolute;
    z-index: 2;
    inset: auto 20px calc(16px + env(safe-area-inset-bottom, 0px));
    pointer-events: none;
  }
  #follow-change-color { pointer-events: auto; min-height: 52px; min-width: 156px; max-width: 100%; padding-inline: 20px; gap: 10px; box-shadow: var(--shadow); }
  #follow-mobile-color { font-size: 12px; color: inherit; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
  #follow-mobile-swatch { width: 22px; height: 22px; flex: none; border-color: var(--surface); }
  #follow-mobile-status { max-width: 100%; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--danger); font-size: 12px; }
}

@media (max-width: 340px) {
  .follow-summary-line { gap: 6px; }
}
