:root {
  --bg-top: #ffd9b2;
  --bg-bottom: #f7f3e9;
  --ink-strong: #173053;
  --ink-soft: #5c6d87;
  --surface: rgba(255, 252, 246, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --surface-dark: rgba(20, 34, 57, 0.94);
  --line: rgba(23, 48, 83, 0.12);
  --line-strong: rgba(255, 255, 255, 0.1);
  --accent: #ff7a59;
  --accent-deep: #da5632;
  --accent-soft: rgba(255, 122, 89, 0.16);
  --gold: #f6b73c;
  --teal: #238878;
  --shadow-lg: 0 24px 90px rgba(24, 33, 57, 0.16);
  --shadow-sm: 0 14px 28px rgba(24, 33, 57, 0.08);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --display-font: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
  --body-font: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

[hidden] {
  display: none !important;
}

body {
  font-family: var(--body-font);
  color: var(--ink-strong);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 24%),
    radial-gradient(circle at bottom right, rgba(246, 183, 60, 0.24), transparent 32%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  appearance: none;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
}

.topbar,
.rail-card,
.panel,
.home-panel,
.sheet-panel,
.coach-card {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-sm);
}

.topbar {
  border-radius: var(--radius-xl);
  padding: 9px 14px;
  display: block;
  position: sticky;
  top: 24px;
  z-index: 24;
  overflow: visible;
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: white;
  font-family: var(--display-font);
  font-size: 1.3rem;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(255, 122, 89, 0.3);
}

.brand-home-button {
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.brand-home-button:hover {
  transform: translateY(-1px);
}

.eyebrow,
.panel-kicker,
.section-label {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.title-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0;
  min-width: 0;
}

.mode-chip-button {
  border: 0;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}

.topbar-density {
  flex: 0 0 auto;
  gap: 4px;
}

.topbar-density .segment {
  padding: 6px 10px;
  font-size: 0.76rem;
}

.file-name {
  min-width: 0;
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  color: var(--ink-strong);
  font-family: var(--display-font);
  font-size: clamp(1.02rem, 1.6vw, 1.35rem);
  font-weight: 700;
  padding: 0;
  outline: none;
}

.mode-chip,
.status-pill {
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(23, 48, 83, 0.08);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-strong);
}

.status-pill {
  background: rgba(35, 136, 120, 0.14);
}

.topbar-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  position: relative;
  flex: 0 0 auto;
}

.menu-wrap {
  position: relative;
}

.menu-wrap-end .menu-panel {
  right: 0;
  left: auto;
}

.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;
}

.menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.menu-trigger.is-open {
  background: rgba(255, 122, 89, 0.14);
  box-shadow: 0 10px 24px rgba(24, 33, 57, 0.12);
}

.menu-meta {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(23, 48, 83, 0.08);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.menu-meta svg {
  display: block;
}

.menu-meta-icon {
  width: 16px;
  height: 16px;
}

.topbar-icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  position: relative;
}

.topbar-icon-button.active {
  background: linear-gradient(135deg, rgba(255, 122, 89, 0.98), rgba(246, 183, 60, 0.98));
  color: white;
  box-shadow: 0 12px 26px rgba(218, 86, 50, 0.22);
}

.topbar-icon-button.menu-trigger {
  gap: 0;
}

.topbar-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-icon-wrap {
  display: grid;
  place-items: center;
}

.topbar-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 12px;
  height: 12px;
}

.menu-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.82);
}

.menu-caret {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 220px;
  max-width: min(88vw, 420px);
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.985);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 60;
}

.menu-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.menu-panel .section-label {
  margin-bottom: 10px;
}

.menu-panel .field:first-of-type,
.menu-panel .field-compact {
  margin-top: 0;
}

.menu-tool-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.tools-panel {
  width: 210px;
}

.brush-panel {
  width: min(300px, 84vw);
}

.color-panel {
  width: min(300px, 84vw);
}

.add-panel {
  width: min(320px, 88vw);
}

.add-block {
  margin-top: 0;
}

.add-actions .button {
  flex: 1 1 100%;
}

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

.shape-grid .button {
  width: 100%;
}

.background-panel {
  width: min(220px, 72vw);
}

.layer-panel {
  width: min(620px, 94vw);
  overflow: visible;
}

.layer-panel-body {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(280px, 320px);
  align-items: start;
  gap: 14px;
}

.layer-stack-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(320px, 100%);
  margin-left: auto;
  margin-bottom: 12px;
}

.layer-stack {
  display: grid;
  gap: 10px;
  max-height: min(42vh, 340px);
  width: min(320px, 100%);
  margin-left: auto;
  overflow-y: auto;
  overflow-x: visible;
  padding-right: 4px;
  margin-bottom: 16px;
}

.layer-detail-sidebar {
  min-height: 100%;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}

.layer-row-item {
  position: relative;
  overflow: visible;
  padding: 0;
  border-radius: 20px;
  background: rgba(23, 48, 83, 0.06);
  cursor: grab;
}

.layer-row-item.active {
  background: rgba(255, 122, 89, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 122, 89, 0.14);
}

.layer-row-item.is-dragging {
  opacity: 0.56;
  cursor: grabbing;
}

.layer-row-item.drop-before {
  box-shadow: inset 0 3px 0 rgba(255, 122, 89, 0.9);
}

.layer-row-item.drop-after {
  box-shadow: inset 0 -3px 0 rgba(255, 122, 89, 0.9);
}

.layer-row-main {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 42px 42px;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: inherit;
  overflow: hidden;
  border-radius: 20px;
  transition: border-radius 160ms ease;
}

.layer-row-item.actions-open .layer-row-main {
  border-radius: 20px 20px 0 0;
}

.layer-row-actions {
  position: static;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 180ms ease, opacity 160ms ease;
}

.layer-row-item.actions-open .layer-row-actions {
  max-height: 84px;
  opacity: 1;
}

.layer-action-button {
  border: 0;
  color: white;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.1;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  background: #238878;
}

.layer-action-button:nth-child(2) {
  background: #da5632;
}

.layer-thumb-button {
  border: 0;
  padding: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  align-self: stretch;
}

.layer-detail-field {
  margin: 0;
}

.layer-detail-actions {
  margin-top: 10px;
}

.pattern-panel {
  width: min(380px, 92vw);
}

.layer-panel .mini-actions .button,
.layer-panel .transform-actions .button {
  flex: 1 1 130px;
}

.pattern-actions .button {
  flex: 1 1 138px;
}

.button,
.tool-button,
.segment,
.layer-select,
.layer-visibility,
.swatch-button {
  border: 0;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.button {
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
}

.button:hover,
.tool-button:hover,
.segment:hover,
.layer-select:hover,
.layer-visibility:hover,
.swatch-button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: white;
  box-shadow: 0 14px 28px rgba(218, 86, 50, 0.24);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink-strong);
}

.button-ghost {
  background: rgba(23, 48, 83, 0.08);
  color: var(--ink-strong);
}

.compact {
  padding: 10px 14px;
  font-size: 0.93rem;
}

.editor-frame {
  min-height: 0;
  display: block;
}

.rail-card,
.panel,
.home-panel,
.sheet-panel,
.coach-card {
  border-radius: var(--radius-xl);
}

.rail-card,
.panel,
.sheet-panel {
  padding: 18px;
}

.tool-stack,
.mini-actions,
.layer-row,
.segmented,
.hero-actions,
.hero-stats,
.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  font-weight: 600;
}

.field span {
  font-size: 0.95rem;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="color"] {
  appearance: none;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 16px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

select {
  width: 100%;
  border: 1px solid rgba(23, 48, 83, 0.12);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink-strong);
}

.field-note {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.45;
}

.swatch-value {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(23, 48, 83, 0.08);
  font-weight: 700;
}

.swatch-strip {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  background: var(--swatch);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.78);
}

.swatch-button.active {
  box-shadow:
    inset 0 0 0 3px white,
    0 0 0 3px rgba(255, 122, 89, 0.3);
}

.tool-button,
.segment,
.layer-select,
.layer-visibility {
  cursor: pointer;
}

.tool-button {
  min-width: 88px;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(23, 48, 83, 0.08);
  color: var(--ink-strong);
  font-weight: 700;
}

.tool-button.active,
.segment.active {
  background: linear-gradient(135deg, rgba(255, 122, 89, 0.98), rgba(246, 183, 60, 0.98));
  color: white;
}

.icon-tool-button {
  min-width: 0;
  width: 56px;
  height: 56px;
  padding: 0;
  display: grid;
  place-items: center;
}

.tool-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-card {
  background: linear-gradient(180deg, rgba(255, 122, 89, 0.14), rgba(255, 255, 255, 0.8));
}

.help-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.help-list p {
  margin: 0;
  line-height: 1.5;
  color: var(--ink-strong);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.58fr) minmax(220px, 0.42fr);
  gap: 16px;
}

.tile-panel {
  padding: 12px;
}

.preview-panel {
  align-self: start;
  gap: 2px;
  padding: 2px;
}

.preview-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.preview-panel .mode-chip {
  min-width: 0;
  padding: 5px 7px;
  font-size: 0.72rem;
}

.preview-panel .topbar-density {
  gap: 3px;
}

.preview-panel .topbar-density .segment {
  min-width: 26px;
  padding: 5px 0;
}

.preview-panel .canvas-stage {
  min-height: clamp(320px, 34vw, 430px);
  border-radius: 12px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.panel > .panel-header:first-child .panel-actions {
  width: 100%;
}

.preview-header-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.panel-actions {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.panel-header h2,
.sheet-header h2,
.home-hero h1,
.recents-header h2,
.coach-card h3 {
  margin: 2px 0 0;
  font-family: var(--display-font);
}

.panel-header h2 {
  font-size: clamp(1.35rem, 2vw, 1.95rem);
}

.panel-note {
  margin: 0;
  max-width: 250px;
  color: var(--ink-soft);
  font-size: 0.96rem;
  line-height: 1.45;
  text-align: right;
}

.view-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.zoom-chip {
  border: 0;
  border-radius: 999px;
  background: rgba(23, 48, 83, 0.08);
  color: var(--ink-strong);
  font-weight: 700;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.icon-button {
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1.2rem;
}

.zoom-chip {
  min-width: 86px;
  padding: 10px 16px;
  cursor: pointer;
}

.icon-button:hover,
.zoom-chip:hover {
  transform: translateY(-1px);
}

.icon-button:disabled,
.zoom-chip:disabled,
.swatch-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.canvas-stage {
  position: relative;
  flex: 1;
  min-height: clamp(440px, 56vh, 760px);
  border-radius: calc(var(--radius-xl) - 8px);
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.86), transparent 24%),
    linear-gradient(180deg, rgba(255, 250, 242, 0.98), rgba(247, 241, 230, 0.98));
}

.canvas-stage.is-drop-target {
  box-shadow: inset 0 0 0 3px rgba(255, 122, 89, 0.46);
}

.preview-stage {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.14), transparent 28%),
    linear-gradient(180deg, rgba(20, 34, 57, 0.98), rgba(29, 46, 74, 0.98));
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#tileCanvas {
  touch-action: none;
  cursor: crosshair;
}

#tileCanvas.is-pan-ready {
  cursor: grab;
}

#tileCanvas.is-panning {
  cursor: grabbing;
}

#tileCanvas.is-move-ready {
  cursor: grab;
}

#tileCanvas.is-moving {
  cursor: grabbing;
}

.canvas-hint,
.canvas-badge,
.preview-badge,
.drop-hint,
.sheet-callout,
.toast {
  box-shadow: var(--shadow-sm);
}

.canvas-hint,
.canvas-badge,
.preview-badge,
.drop-hint {
  position: absolute;
}

.canvas-hint,
.canvas-badge,
.preview-badge {
  border-radius: 18px;
  padding: 12px 14px;
}

.canvas-badge,
.preview-badge {
  top: 18px;
  right: 18px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  font-weight: 700;
}

.canvas-badge {
  top: auto;
  right: auto;
  left: 20px;
  bottom: 20px;
  background: rgba(23, 48, 83, 0.1);
  color: var(--ink-strong);
}

.drop-hint {
  inset: 18px;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: 24px;
  border: 2px dashed rgba(255, 122, 89, 0.5);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink-strong);
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 150ms ease, transform 150ms ease;
}

.canvas-stage.is-drop-target .drop-hint {
  opacity: 1;
  transform: scale(1);
}

.move-toolbar-panel {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}

.move-toolbar {
  display: grid;
  align-items: center;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.move-toolbar .button {
  min-width: 0;
}

.move-action-button {
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
}

.move-action-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.move-action-icon rect {
  fill: currentColor;
  stroke: none;
}

.move-action-button:disabled .move-action-icon {
  opacity: 0.45;
}

.dock-group {
  min-width: 0;
}

.dock-copy p:last-child {
  margin: 12px 0 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.transform-block {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.transform-actions .button {
  flex: 1 1 120px;
}

.layer-select,
.layer-visibility {
  background: transparent;
  color: var(--ink-strong);
  font-weight: 700;
}

.layer-select {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0;
  text-align: left;
  border-radius: 16px;
}

.layer-select.active {
  background: transparent;
}

.layer-visibility {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
  font-size: 0.88rem;
  padding: 0;
}

.layer-visibility.is-hidden {
  background: rgba(23, 48, 83, 0.12);
  color: var(--ink-strong);
}

.layer-visibility-wrap {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.layer-actions-trigger {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-strong);
  font-size: 1.25rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.layer-visibility-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.layer-visibility svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layer-thumb {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 1px solid rgba(23, 48, 83, 0.08);
  background: white;
}

.layer-info {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.layer-name,
.layer-meta {
  display: block;
}

.layer-name-input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink-strong);
  font-weight: 700;
  padding: 0;
  outline: none;
}

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

.segment {
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(23, 48, 83, 0.08);
  color: var(--ink-strong);
  font-weight: 700;
}

.home-view,
.sheet-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.home-view {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.84), transparent 28%),
    linear-gradient(180deg, rgba(255, 229, 200, 0.88), rgba(247, 243, 233, 0.94));
}

.home-view.is-visible,
.sheet-shell.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.home-panel {
  width: min(1200px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 1.2fr;
  gap: 20px;
}

.home-hero,
.home-recents {
  border-radius: calc(var(--radius-xl) - 8px);
  padding: 22px;
}

.home-hero {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 28%),
    linear-gradient(145deg, rgba(255, 122, 89, 0.18), rgba(246, 183, 60, 0.16), rgba(255, 255, 255, 0.76));
}

.home-hero h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.98;
  max-width: 10ch;
}

.hero-copy,
.recents-copy {
  color: var(--ink-soft);
  line-height: 1.6;
}

.hero-copy {
  margin: 16px 0 0;
  max-width: 48ch;
}

.hero-actions {
  margin-top: 24px;
}

.hero-stats {
  margin-top: 24px;
}

.starter-section {
  margin-top: 24px;
}

.starter-header {
  display: grid;
  gap: 8px;
}

.starter-copy {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.starter-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.starter-card {
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(23, 48, 83, 0.08);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.starter-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 28%),
    linear-gradient(180deg, rgba(248, 242, 230, 0.98), rgba(240, 232, 220, 0.98));
}

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

.starter-card h3 {
  margin: 0;
  font-family: var(--display-font);
  font-size: 1.02rem;
}

.starter-card p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
  font-size: 0.92rem;
}

.starter-variant {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(23, 48, 83, 0.08);
  color: var(--ink-strong);
  font-size: 0.8rem;
  font-weight: 700;
  justify-self: start;
}

.starter-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.starter-swatches span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.starter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.starter-actions .button {
  flex: 1 1 120px;
}

.stat-card {
  min-width: 140px;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
}

.stat-card strong {
  display: block;
  font-size: 1.05rem;
  font-family: var(--display-font);
}

.stat-card span {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.home-recents {
  background: rgba(255, 255, 255, 0.7);
}

.recents-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
}

.recents-header h2 {
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.recent-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.recent-card,
.empty-card {
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(23, 48, 83, 0.08);
  overflow: hidden;
}

.recent-thumb {
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.84), transparent 26%),
    linear-gradient(180deg, #f3ecdf, #ece1cf);
}

.recent-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.recent-body {
  padding: 14px;
}

.recent-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.recent-title-row h3,
.empty-card h3 {
  margin: 0;
  font-size: 1.02rem;
  font-family: var(--display-font);
}

.recent-meta,
.empty-card p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

.recent-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-actions .button {
  flex: 1 1 90px;
}

.empty-card {
  padding: 22px;
  display: grid;
  place-items: start;
  min-height: 220px;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 26, 44, 0.44);
}

.sheet-panel {
  position: relative;
  width: min(560px, 100%);
  z-index: 1;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.sheet-body {
  margin-top: 18px;
  display: grid;
  gap: 18px;
}

.sheet-section {
  display: grid;
  gap: 12px;
}

.sheet-callout {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 122, 89, 0.12);
}

.sheet-callout p {
  margin: 0;
  line-height: 1.5;
}

.sheet-callout p + p {
  margin-top: 8px;
}

.export-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--ink-strong);
}

.export-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.confirm-panel {
  width: min(480px, 100%);
}

.new-pattern-panel {
  width: min(760px, 100%);
}

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

.preset-card {
  border: 0;
  border-radius: 22px;
  padding: 16px;
  display: grid;
  gap: 8px;
  text-align: left;
  background: rgba(23, 48, 83, 0.06);
  color: var(--ink-strong);
  box-shadow: inset 0 0 0 1px rgba(23, 48, 83, 0.04);
}

.preset-card.active {
  background: rgba(255, 122, 89, 0.14);
  box-shadow: inset 0 0 0 2px rgba(255, 122, 89, 0.38);
}

.preset-card strong,
.preset-card span {
  display: block;
}

.preset-label {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.preset-meta {
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.45;
}

.confirm-callout {
  background: rgba(23, 48, 83, 0.08);
}

.confirm-callout p {
  color: var(--ink-strong);
}

@media (max-width: 700px) {
  .preset-grid {
    grid-template-columns: 1fr;
  }
}

.sheet-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

.coach-card {
  position: fixed;
  left: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 18px;
  z-index: 22;
  transition: opacity 180ms ease, transform 180ms ease;
}

.coach-card.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

.coach-card h3 {
  font-size: 1.25rem;
}

.coach-card p {
  line-height: 1.55;
  color: var(--ink-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(17, 26, 44, 0.92);
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1180px) and (min-width: 768px) {
  .app-shell {
    padding: 16px;
    gap: 14px;
  }

  .editor-frame {
    display: block;
  }

  .topbar {
    padding: 8px 12px;
  }

  .topbar-main {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .brand-lockup,
  .title-row {
    min-width: 0;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    font-size: 1.18rem;
  }

  .file-name {
    min-width: 0;
    font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  }

  .mode-chip,
  .status-pill {
    padding: 5px 9px;
    font-size: 0.72rem;
  }

  .topbar-actions {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    justify-content: stretch;
    gap: 8px;
  }

  .topbar-actions > * {
    min-width: 0;
  }

  .topbar-actions .button {
    padding: 10px 12px;
    font-size: 0.88rem;
  }

  .topbar-actions .button.topbar-icon-button {
    width: 100%;
    height: 40px;
    padding: 0;
  }

  .menu-wrap {
    position: static;
  }

  .menu-meta {
    padding: 4px 8px;
    font-size: 0.72rem;
  }

  .menu-swatch {
    width: 12px;
    height: 12px;
  }

  .dock-copy,
  .panel-note {
    display: none;
  }

  .menu-panel,
  .panel {
    padding: 12px;
  }

  .menu-panel {
    top: calc(100% + 8px);
    left: 50%;
    right: auto;
    max-width: min(92vw, 420px);
    max-height: min(68vh, 520px);
    overflow: auto;
    transform: translate(-50%, -8px) scale(0.985);
  }

  .menu-panel.is-open {
    transform: translate(-50%, 0) scale(1);
  }

  .tools-panel {
    width: 180px;
  }

  .brush-panel {
    width: min(260px, 72vw);
  }

  .layer-panel {
    width: min(620px, 96vw);
  }

  .layer-panel-body {
    grid-template-columns: minmax(176px, 220px) minmax(0, 1fr);
    gap: 12px;
  }

  .pattern-panel {
    width: min(340px, 84vw);
  }

  .menu-panel .section-label {
    font-size: 0.64rem;
    letter-spacing: 0.1em;
  }

  .tool-stack {
    gap: 6px;
  }

  .tool-button {
    min-width: 0;
    flex: 1 1 0;
    padding: 10px;
    border-radius: 14px;
    font-size: 0.82rem;
  }

  .icon-tool-button {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    padding: 0;
  }

  .tool-icon {
    width: 20px;
    height: 20px;
  }

  .field {
    gap: 4px;
    margin-top: 8px;
  }

  .field span {
    font-size: 0.8rem;
  }

  .color-row {
    gap: 6px;
  }

  input[type="color"] {
    width: 36px;
    height: 36px;
  }

  .swatch-value {
    padding: 5px 8px;
    font-size: 0.74rem;
  }

  .swatch-strip {
    margin-top: 8px;
    gap: 6px;
  }

  .swatch-button {
    width: 24px;
    height: 24px;
  }

  .mini-actions,
  .layer-row,
  .segmented,
  .transform-actions {
    gap: 6px;
  }

  .mini-actions .button,
  .transform-actions .button {
    flex: 1 1 80px;
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .transform-block {
    margin-top: 10px;
    gap: 8px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1.62fr) minmax(190px, 0.38fr);
    gap: 14px;
  }

  .panel-header {
    gap: 10px;
  }

  .panel-actions {
    justify-items: start;
  }

  .view-controls {
    width: 100%;
  }

  .canvas-stage {
    min-height: clamp(360px, 46vh, 560px);
  }

  .canvas-hint {
    left: 16px;
    bottom: 16px;
    max-width: 240px;
    padding: 10px 12px;
    font-size: 0.88rem;
  }

  .canvas-badge,
  .preview-badge {
    top: 14px;
    right: 14px;
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  .canvas-badge {
    top: auto;
    right: auto;
    left: 16px;
    bottom: 16px;
  }

  .move-toolbar {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 10px;
  }

  .dock-group .section-label {
    font-size: 0.68rem;
  }

  .segment,
  .layer-select,
  .layer-visibility {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .layer-pill {
    gap: 4px;
    padding: 3px;
  }

  .home-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) and (min-width: 768px) and (orientation: portrait) {
  .app-shell {
    min-height: 100dvh;
    padding: 12px;
    gap: 12px;
  }

  .topbar {
    padding: 8px 10px;
  }

  .topbar-main {
    display: grid;
    gap: 10px;
  }

  .brand-lockup {
    gap: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    font-size: 1.02rem;
  }

  .title-row {
    gap: 8px;
  }

  .file-name {
    font-size: clamp(0.98rem, 2.4vw, 1.2rem);
  }

  .mode-chip,
  .status-pill {
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
  }

  .topbar-actions > * {
    min-width: 0;
  }

  .topbar-actions .button {
    padding: 8px 11px;
    font-size: 0.82rem;
  }

  .topbar-actions .button.topbar-icon-button {
    width: 100%;
    height: 38px;
    padding: 0;
  }

  .menu-wrap {
    position: static;
  }

  .menu-trigger {
    gap: 6px;
  }

  .icon-tool-button {
    width: 44px;
    height: 44px;
  }

  .menu-meta {
    max-width: 58px;
    padding: 4px 7px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.68rem;
  }

  .menu-panel {
    top: calc(100% + 6px);
    left: 50%;
    right: auto;
    max-width: min(94vw, 400px);
    max-height: min(60dvh, 440px);
    overflow: auto;
    transform: translate(-50%, -8px) scale(0.985);
  }

  .menu-panel.is-open {
    transform: translate(-50%, 0) scale(1);
  }

  .tools-panel {
    width: 168px;
  }

  .brush-panel {
    width: min(244px, 62vw);
  }

  .layer-panel {
    width: min(620px, 96vw);
  }

  .layer-panel-body {
    grid-template-columns: minmax(168px, 208px) minmax(0, 1fr);
    gap: 10px;
  }

  .pattern-panel {
    width: min(312px, 78vw);
  }

  .workspace {
    grid-template-columns: minmax(0, 1.64fr) minmax(176px, 0.36fr);
    gap: 10px;
  }

  .panel {
    padding: 12px;
    gap: 12px;
  }

  .panel-header {
    gap: 8px;
  }

  .panel-kicker {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
  }

  .panel-header h2 {
    font-size: 1.12rem;
  }

  .view-controls {
    gap: 6px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }

  .zoom-chip {
    min-width: 74px;
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  .canvas-stage {
    min-height: clamp(280px, 34vh, 410px);
  }

  .canvas-hint {
    left: 14px;
    bottom: 14px;
    max-width: 176px;
    padding: 8px 10px;
    font-size: 0.74rem;
    line-height: 1.35;
  }

  .canvas-badge,
  .preview-badge {
    top: 12px;
    right: 12px;
    padding: 8px 10px;
    font-size: 0.72rem;
  }

  .canvas-badge {
    top: auto;
    right: auto;
    left: 14px;
    bottom: 14px;
  }

  .move-toolbar {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
  }

  .layer-row {
    margin: 6px 0 0;
  }

  .segment,
  .layer-select,
  .layer-visibility {
    padding: 7px 9px;
    font-size: 0.74rem;
  }

  .layer-pill {
    gap: 4px;
    padding: 3px;
  }

  .home-view,
  .sheet-shell {
    padding: 14px;
  }

  .home-panel,
  .sheet-panel {
    max-height: calc(100dvh - 28px);
    overflow: auto;
  }
}

@media (max-width: 767px) {
  .app-shell,
  .home-view,
  .sheet-shell {
    padding: 16px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar,
  .rail-card,
  .panel,
  .home-panel,
  .sheet-panel,
  .coach-card {
    border-radius: 24px;
  }

  .topbar-main,
  .panel-header,
  .recents-header,
  .sheet-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions,
  .panel-actions {
    width: 100%;
  }

  .panel-actions {
    justify-items: start;
  }

  .panel-note {
    max-width: none;
    text-align: left;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .topbar-actions .button.topbar-icon-button {
    width: 42px;
    height: 42px;
    padding: 0;
  }

  .menu-panel {
    max-width: min(86vw, 360px);
  }

  .canvas-stage {
    min-height: 320px;
  }

  .coach-card {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}
