/* Studio chrome and route layouts. The editor and its dialogs retain their own controls. */
html:has(.studio-shell) {
  --studio-header-height: 64px;
  --studio-nav-height: 0px;
  --studio-gutter: clamp(24px, 4vw, 58px);
  --studio-screen-space: clamp(29px, 4vw, 52px);
  --studio-surface: #f8f4f0;
  --studio-linen: #ede3dc;
  --studio-selection: #eadbe5;
  scroll-padding-block: calc(var(--studio-header-height) + 12px) calc(var(--studio-nav-height) + 12px);
}

.studio-shell {
  min-block-size: 100vh;
  background: var(--studio-surface);
}

.studio-loading {
  margin: var(--studio-screen-space) 0 0;
  color: var(--quiet);
  font-size: 14px;
}

.studio-shell > .app-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 6;
  padding-block-start: env(safe-area-inset-top);
  background: var(--paper);
}

.studio-shell > main,
.studio-shell .header-inner {
  width: min(100% - var(--studio-gutter) * 2, 1256px);
}

.studio-shell .header-inner {
  min-height: calc(var(--studio-header-height) - 1px);
  padding: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
}

.studio-shell .brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  width: fit-content;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.studio-shell .brand img {
  width: 34px;
  height: 34px;
}

.studio-shell .header-actions {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.studio-shell .account-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  color: var(--accent);
  text-decoration: none;
}

.studio-shell .account-button:is(:hover, [aria-current="page"]) {
  background: var(--studio-selection);
}

.studio-shell #account-label {
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.studio-shell .studio-nav {
  grid-column: 2;
  grid-row: 1;
  justify-content: center;
  gap: 2px;
  padding: 0;
}

.studio-nav > :is(a, button),
.mobile-studio-nav > :is(a, button) {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--quiet);
  text-decoration: none;
  white-space: nowrap;
  touch-action: manipulation;
}

.studio-nav > :is(a, button) {
  gap: 6px;
  padding-inline: 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 575;
}

.studio-nav > :is(a, button):is(:hover, [aria-current="page"], [aria-expanded="true"]) {
  background: var(--accent-soft);
  color: var(--accent);
}

.studio-nav > :is(a, button)[aria-current="page"] {
  background: var(--studio-selection);
  font-weight: 665;
}

@media (max-width: 1110px) {
  html:has(.studio-shell) { --studio-header-height: 102px; }
  .studio-shell .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 52px 49px;
    gap: 0 8px;
  }
  .studio-shell .header-actions { grid-column: 2; }
  .studio-shell .studio-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: start;
    align-items: center;
    padding-block-end: 4px;
  }
}

.studio-shell > main > [id$="-page"] {
  --screen-heading-gap: clamp(16px, 2.25vw, 26px);
  width: 100%;
  max-width: none;
  margin: 0;
  padding-block: var(--studio-screen-space) clamp(30px, 5vw, 65px);
}

.studio-shell :is(.screen-heading, .quick-preview-heading, .shop-heading, .library-heading, .plans-heading) {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 20px;
  margin: 0 0 var(--screen-heading-gap);
  padding: 0;
}

.studio-shell :is(.screen-heading, .quick-preview-heading, .shop-heading, .library-heading, .plans-heading, .diagnostics-heading) h1 {
  font-size: clamp(31px, 4vw, 48px);
  line-height: 1.04;
  font-weight: 615;
  letter-spacing: -.052em;
  color: var(--accent);
}

.studio-shell > main h1[tabindex="-1"]:focus { outline: none; }

.studio-shell :is(.screen-heading, .quick-preview-heading, .shop-heading, .library-heading, .plans-heading, .diagnostics-heading) p {
  max-width: 56ch;
  margin: 8px 0 0;
  color: var(--quiet);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.studio-shell :is(.screen-actions, .shop-heading-actions) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Home pairs the first task with an actual stitched example. */
.studio-shell .quick-hero {
  grid-template-columns: minmax(300px, .84fr) minmax(0, 1.16fr);
  align-items: center;
  gap: clamp(26px, 6.5vw, 90px);
}

.studio-shell .quick-intro { padding: 0; }

.studio-shell .quick-intro h1 {
  font-size: clamp(49px, 6.1vw, 83px);
  font-weight: 615;
  letter-spacing: -.064em;
}

.studio-shell .quick-intro > p:not(.quick-error) {
  max-width: 34ch;
  margin-block-start: 16px;
  font-size: clamp(15px, 1.55vw, 18px);
  line-height: 1.5;
}

.studio-shell .quick-start-actions {
  margin-block-start: 24px;
  gap: 8px;
}

.studio-shell .quick-start-actions > button { min-height: 48px; }

.studio-shell .quick-color-example { margin-inline-start: -10px; }

.studio-shell .quick-hero-art {
  position: relative;
  border-radius: 19px;
  background: var(--studio-linen);
  box-shadow: none;
}

.studio-shell .quick-hero-art img {
  height: auto;
  min-height: 0;
  aspect-ratio: 1.5;
  object-position: 54% 54%;
}

.studio-shell .shop-shortcuts {
  margin-block-start: clamp(22px, 4vw, 46px);
  padding-block: 5px;
  gap: 0;
  border-block: 1px solid var(--line);
}

.studio-shell .shop-shortcut {
  position: relative;
  min-height: 68px;
  padding-inline: 13px;
  border: 0;
  border-radius: 9px;
  background: transparent;
}

.studio-shell .shop-shortcut:hover { background: var(--accent-soft); }
.studio-shell .shop-shortcut + .shop-shortcut::before {
  content: '';
  position: absolute;
  inset: 11px auto 11px 0;
  width: 1px;
  background: var(--line);
}
.studio-shell .shop-shortcut small { margin-block-start: 3px; }
.studio-shell .shop-tool-icon { width: 38px; height: 38px; }
.studio-shell .quick-recent { border-top: 0; padding: 0; }

/* Work surface and order queue keep tools close to the active task. */
.studio-shell #editor-page { padding-block-start: clamp(18px, 2.5vw, 32px); }
.studio-shell .project-bar { padding-block: 0 16px; }
.studio-shell .workshop { margin-block-end: 0; }
.studio-shell .workspace, .studio-shell .workshop .assistant { border-radius: 16px; }
.studio-shell .shop-order-list { padding: clamp(12px, 2vw, 22px); }
.studio-shell .shop-board-tools { padding: 15px; }
.studio-shell .shop-order-list, .studio-shell .shop-board-tools { border-radius: 14px; }
.studio-shell .shop-board-tools button { font-size: 13px; }
.studio-shell .shop-queues { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.studio-shell #diagnostics-page > .diagnostics { padding-block: 0; }
.studio-shell #plans-page .plans-grid { max-width: 960px; }

.studio-shell .order-back {
  padding-inline: 8px;
  margin-inline-start: -8px;
  border-radius: 8px;
  font-size: 14px;
  text-decoration: none;
}

.studio-shell .order-back:hover { background: var(--accent-soft); }

/* Saved work. Thumbnails use the same fabric tone as the editor preview. */
.studio-shell .project-search-section { margin-block-end: 18px; }

.project-search-section :is(input[type="search"], input[type="text"]),
.account-form :is(input[type="email"], input[type="text"], input[type="password"]) {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
}

.project-search-section #projects-search { max-width: 420px; }
.project-search-section #projects-status { margin: 6px 0 0; color: var(--quiet); font-size: 13px; }
.project-search-section #projects-status:empty { display: none; }

.project-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 14px;
}

.workspace-project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
}

.workspace-project-card:is(:hover, :focus-within, .workspace-project-current) { border-color: #c8aebc; }

.workspace-project-thumb {
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 2.6;
  padding: 0;
  overflow: hidden;
  border-radius: 14px 14px 0 0;
  background: var(--studio-linen);
  color: var(--accent);
}

.workspace-project-thumb[data-kind="stitches"] { background: #eadde3; }
.workspace-project-thumb:has(img) { aspect-ratio: 1.85; }

.workspace-project-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.workspace-project-thumb:not(:has(img)) > [data-icon] {
  display: grid;
  width: clamp(45px, 7vw, 64px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px dashed #b996a8;
  border-radius: 50%;
}

.workspace-project-thumb .icon { width: 23px; height: 23px; }

.workspace-project-content {
  display: grid;
  gap: 4px;
  align-content: start;
  min-width: 0;
  padding: 12px 15px;
  overflow-wrap: anywhere;
}

.workspace-project-content :is(h2, h3, p) { margin: 0; }
.workspace-project-content :is(h2, h3) { font-size: 16px; font-weight: 655; line-height: 1.3; }
.workspace-project-content :is(p, small, time) { color: var(--quiet); font-size: 12px; }

.workspace-project-link {
  color: inherit;
  text-decoration: none;
}

.workspace-project-link::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
}

.workspace-project-link:focus-visible {
  outline: none;
}

.workspace-project-link:focus-visible::after {
  outline: 2px solid #97567a;
  outline-offset: 3px;
}

.workspace-project-card:hover .workspace-project-link {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.workspace-project-footer {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  margin-block-start: auto;
  padding: 3px 8px;
  border-block-start: 1px solid var(--line);
}

.workspace-project-footer :is(button, a) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  padding-inline: 8px;
  border-radius: 7px;
  color: var(--accent);
  text-decoration: none;
}

.workspace-project-footer :is(button, a):hover { background: var(--accent-soft); }
.workspace-project-footer .icon { width: 16px; height: 16px; }

.project-open-label {
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 575;
}

.workspace-empty {
  display: grid;
  grid-column: 1 / -1;
  justify-items: start;
  align-content: center;
  gap: 8px;
  min-height: 184px;
  margin: 0;
  padding: clamp(18px, 3vw, 38px);
  border: 1px dashed #c7aeb9;
  border-radius: 15px;
  background: var(--paper);
}

.workspace-empty :is(h2, h3, p) { margin: 0; }
.workspace-empty :is(h2, h3) { color: var(--ink); font-size: 19px; line-height: 1.3; }
.workspace-empty p { max-width: 44ch; color: var(--quiet); font-size: 14px; }
.workspace-empty :is(button, a) { margin-top: 4px; }

/* Account and status sit in separate settings groups. */
.account-workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  align-items: start;
  gap: 15px;
  max-width: 925px;
}

.account-workspace-card {
  min-width: 0;
  padding: clamp(17px, 2.7vw, 28px);
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  overflow-wrap: anywhere;
}

.account-workspace-card h2 {
  margin: 0 0 7px;
  font-size: clamp(18px, 2.2vw, 23px);
  line-height: 1.2;
  letter-spacing: -.024em;
}

.account-workspace-card p {
  margin: 0 0 13px;
  color: var(--quiet);
  font-size: 14px;
}

.account-workspace-card > :last-child { margin-block-end: 0; }
.account-workspace-card .account-state:empty { display: none; }

.account-form {
  display: grid;
  gap: 11px;
}

.account-form label {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-size: 13px;
  font-weight: 575;
}

.account-form small { color: var(--quiet); }
.account-workspace-card .form-error { color: #892f30; }
.account-workspace-card .form-error:empty { display: none; }

.account-state {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-block: 12px 10px;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.account-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-block: 10px;
}

.account-form .account-links { margin: 3px 0 0; }

.account-links > :is(a, button) {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  min-height: 44px;
  text-align: start;
  text-decoration: none;
}

.account-links > :is(a, button):not(.primary) { color: var(--accent); }
.account-links > .quiet:hover { background: var(--accent-soft); }

@media (max-width: 940px) {
  .studio-shell .shop-queues { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 760px) {
  html:has(.studio-shell) {
    --studio-header-height: calc(55px + env(safe-area-inset-top));
    --studio-nav-height: calc(62px + env(safe-area-inset-bottom));
    --studio-gutter: clamp(13px, 4.1vw, 23px);
    --studio-screen-space: 21px;
  }

  .studio-shell .header-inner {
    min-height: 54px;
    grid-template-rows: minmax(54px, auto);
  }

  .studio-shell .brand img { width: 31px; height: 31px; }
  .studio-shell :is(.studio-nav, .account-button) { display: none; }

  .studio-shell .mobile-studio-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1px;
    padding: 2px max(5px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(5px, env(safe-area-inset-left));
    box-shadow: 0 -5px 20px #5730470a;
  }

  .mobile-studio-nav > :is(a, button) {
    flex-direction: column;
    align-self: stretch;
    gap: 1px;
    min-width: 0;
    padding: 3px 0 4px;
    border-radius: 8px;
    font-size: clamp(10px, 2.65vw, 11px);
    font-weight: 560;
    line-height: 1.25;
    letter-spacing: -.02em;
  }

  .mobile-studio-nav > :is(a, button):focus-visible { outline-offset: -3px; }
  .mobile-studio-nav .mobile-nav-icon { width: 39px; height: 27px; border-radius: 9px; }

  .mobile-studio-nav > :is(a, button):is([aria-current="page"], .current-section, [aria-expanded="true"]) {
    color: var(--accent);
    font-weight: 700;
  }

  .mobile-studio-nav > :is(a, button):is([aria-current="page"], .current-section, [aria-expanded="true"]) .mobile-nav-icon {
    background: var(--studio-selection);
  }

  #studio-menu .studio-menu-links > :is(a, button) {
    display: grid;
    grid-template-columns: 27px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 49px;
    padding: 6px 8px;
    border-block-end: 1px solid var(--line);
    color: var(--ink);
    font-weight: 560;
    text-align: start;
    text-decoration: none;
  }

  #studio-menu .studio-menu-links > :is(a, button):is([aria-current="page"], :hover) {
    color: var(--accent);
    background: var(--accent-soft);
  }

  #studio-menu .studio-menu-links > a > [data-icon] { color: var(--accent); }
  #studio-menu .studio-menu-links > a > [data-icon]:last-child .icon { width: 13px; }

  .studio-shell > main > [id$="-page"] { padding-block-end: 24px; }

  .studio-shell :is(.screen-heading, .quick-preview-heading, .shop-heading, .library-heading, .plans-heading) {
    align-items: flex-start;
  }

  .studio-shell :is(.quick-preview-heading, .shop-heading) > div { display: block; }
  .studio-shell .shop-heading .primary { padding-inline: 12px; }
  .studio-shell :is(.library-heading, .plans-heading) .secondary { min-height: 44px; }
  .studio-shell .project-bar { padding-block-end: 11px; }
  .studio-shell .shop-shortcuts { grid-template-columns: 1fr; }
  .studio-shell .shop-shortcut { min-height: 58px; padding-inline: 7px; }
  .studio-shell .shop-shortcut + .shop-shortcut::before { inset: 0 0 auto; width: auto; height: 1px; }
  .studio-shell .shop-tool-icon { width: 34px; height: 34px; }
  .account-workspace-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
}

@media (max-width: 680px) {
  .studio-shell .quick-hero { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .studio-shell .quick-intro h1 { font-size: clamp(40px, 10.8vw, 56px); line-height: 1; }
  .studio-shell .quick-intro > p:not(.quick-error) { margin-block-start: 11px; }
  .studio-shell .quick-start-actions { margin-block-start: 15px; }
  .studio-shell .quick-start-actions > button { min-height: 46px; }
  .studio-shell .quick-hero-art { border-radius: 14px; }
  .studio-shell .quick-hero-art img { height: clamp(158px, 42vw, 246px); }
  .studio-shell .shop-shortcuts { margin-block-start: 19px; }
  .project-card-grid { gap: 9px; }
  .workspace-project-content { padding-inline: 10px; }
}

@media (max-width: 480px) {
  .project-card-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace-project-card:has(> .workspace-project-content):has(> .workspace-project-thumb) {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    align-items: stretch;
  }
  .workspace-project-card > .workspace-project-thumb {
    min-height: 80px;
    aspect-ratio: auto;
    border-radius: 14px 0 0;
  }
  .workspace-project-card > .workspace-project-content { padding: 10px 11px; align-content: center; }
  .workspace-project-card > .workspace-project-footer { grid-column: 1 / -1; }
}

@media print {
  .studio-shell > .app-header { position: static; }
}
