:root {
  --sans: 'Torimoony Sans', 'Dalbit Sans Core', 'Dalbit Sans', 'Apple SD Gothic Neo', sans-serif;
  --display: 'Torimoony Round', var(--sans);
  --paper: #f8f5f2;
  --surface: #fffdfb;
  --ink: #211b2d;
  --muted: #625969;
  --plum: #6845b8;
  --plum-dark: #50328f;
  --lavender: #f1eafb;
  --line: #e7e0e7;
  --studio-rail: 214px;
  --studio-night: #211833;
  --night-canvas: #201733;
  --night-surface: #302045;
  --night-ink: #fff3e6;
  --night-muted: #e2d3ee;
  --night-label: #dbc6f1;
  --night-line: #543d6b;
  --night-amber: #ffcf8d;
  --studio-width: 1180px;
  --studio-gutter: clamp(23px, 3.3vw, 54px);
}

body { background: var(--paper); }
body:has(.workspace:is([data-screen="home"], [data-screen="auto"], [data-screen="episodes"]), .studio-feature-guest) {
  background: radial-gradient(ellipse at 65% 0, #392751, transparent min(80vw, 740px)), var(--night-canvas);
}
:focus-visible { outline-color: #8958c9; }
::selection { background: #dfd1f6; color: #382662; }

.app-header {
  position: fixed;
  z-index: 5;
  inset: 0 auto 0 0;
  width: var(--studio-rail);
  border-right: 1px solid #3b3048;
  background: var(--studio-night);
  color: #fcf4ee;
}
.app-header :focus-visible { outline-color: #e6cbff; }
.app-bar {
  display: flex;
  height: 100%;
  flex-direction: column;
  gap: 33px;
  padding: 27px 15px 19px;
}
.app-header .brand {
  width: fit-content;
  min-height: 44px;
  gap: 11px;
  margin: 0 7px;
  padding: 0;
  color: #fff4e9;
}
.app-header .brand-mark {
  width: 38px;
  height: 38px;
  flex-basis: 38px;
  border-radius: 12px;
  box-shadow: 0 0 0 1px #f2c99b26;
}
.app-header .brand strong {
  font-family: var(--display);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.05em;
}
.app-header .nav { display: grid; align-items: stretch; gap: 6px; margin: 0; }
.app-header .nav:empty { display: none; }
.app-header .nav-item {
  justify-content: flex-start;
  min-height: 47px;
  gap: 11px;
  padding: 9px 13px;
  border-radius: 10px;
  color: #d0c5da;
  font-size: 14px;
}
.app-header .nav-item svg { width: 18px; height: 18px; }
.app-header .nav-item:hover { color: #fff7ff; background: #ffffff0d; }
.app-header .nav-item[aria-current="page"] { color: #f4e8ff; background: #4a3561; font-weight: 770; }
.app-header .nav-item[aria-current="page"] svg { color: var(--night-amber); }

.bar-family { display: flex; min-width: 0; align-items: center; gap: 5px; margin-top: auto; }
.bar-family:empty { display: none; }
.bar-profile, .bar-preview {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  color: #eadde9;
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
}
.bar-profile { max-width: 100%; min-height: 44px; padding: 3px 6px; }
.bar-profile:hover, .header-settings:hover { background: #ffffff16; }
.bar-sample { padding-inline: 5px 10px; border: 1px solid #674c85; border-radius: 22px; background: #3a2850; }
.bar-sample .portrait { width: 30px; height: 30px; border: 0; }
.bar-sample .portrait img { width: 100%; height: 100%; object-fit: cover; }
.bar-profile > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-preview { margin-inline-start: 6px; padding: 5px 10px; border: 1px solid #eab88152; color: #f7d6ae; }
.app-header .avatars > .portrait { border-color: #2a2035; background: #694d71; color: #fff0de; }
.header-settings { display: none; }

.workspace {
  width: min(var(--studio-width), calc(100% - var(--studio-rail) - 2 * var(--studio-gutter)));
  min-height: 100svh;
  margin-inline-start: max(calc(var(--studio-rail) + var(--studio-gutter)), calc((100% + var(--studio-rail) - var(--studio-width)) / 2));
  padding: clamp(38px, 5.3vw, 76px) 0 65px;
}
.studio-home-title {
  margin: 0 0 clamp(14px, 2vw, 24px);
  color: var(--night-ink);
  font-family: var(--display);
  font-size: clamp(23px, 3.3vw, 38px);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -.025em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.workspace .page-title {
  font-family: var(--serif);
  font-size: clamp(34px, 4.1vw, 55px);
  font-weight: 700;
  letter-spacing: -.045em;
}
.workspace .page-date { border-color: var(--line); background: var(--surface); color: var(--muted); }

.studio-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: clamp(19px, 2.45vw, 33px);
}
.studio-title { min-width: 0; }
.studio-title h1 {
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(36px, 4.65vw, 65px);
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -.06em;
}
.studio-title p { margin-top: 10px; color: var(--muted); font-size: clamp(14px, 1.25vw, 16px); line-height: 1.55; }
.studio-switch {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border: 1px solid #e9e0e9;
  border-radius: 12px;
  background: #efe9ee;
}
.studio-switch a {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 8px;
  color: #5f546b;
  font-size: 14px;
  font-weight: 680;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
}
.studio-switch .icon { width: 17px; height: 17px; }
.studio-switch a:hover { color: var(--plum-dark); background: #ffffff80; }
.studio-switch a[aria-current="page"] {
  background: var(--surface);
  color: #543394;
  font-weight: 760;
  box-shadow: 0 1px 4px #34204816;
}

.workspace:is([data-screen="home"], [data-screen="auto"], [data-screen="episodes"]) {
  color: var(--night-ink);
}
.workspace:is([data-screen="home"], [data-screen="auto"], [data-screen="episodes"]) :focus-visible {
  outline-color: var(--night-amber);
}

.studio-clue {
  margin-top: 12px;
  color: var(--night-label);
  font-size: 13px;
}
.studio-clue summary { width: fit-content; padding-block: 5px; cursor: pointer; }
.studio-clue p { margin-top: 4px; color: var(--night-muted); overflow-wrap: anywhere; }
.studio-actions { display: grid; gap: 8px; margin-top: 17px; }
.studio-actions:empty { display: none; }
.button.primary.studio-generate {
  width: 100%;
  min-height: 54px;
  gap: 9px;
  padding: 11px 17px;
  border-color: #ffd7a4;
  border-radius: 16px;
  background: #ffd7a4;
  color: #2c1e3b;
  font-size: 16px;
  font-weight: 800;
  text-align: left;
}
.button.primary.studio-generate > span { flex: 1; }
.button.primary.studio-generate:hover:not(:disabled) { border-color: #ffe5c5; background: #ffe5c5; }
.button.studio-generate .icon { width: 19px; height: 19px; }
.studio-own-action { display: flex; margin-top: 11px; }
.button.outline.studio-replay {
  min-height: 44px;
  border-color: #8b719f;
  border-radius: 13px;
  background: transparent;
  color: var(--night-ink);
  font-size: 14px;
}
.button.outline.studio-replay > .icon:last-child { margin-inline-start: auto; }
.button.outline.studio-replay:hover:not(:disabled) { background: #473559; color: var(--night-ink); }

.studio-feature {
  display: grid;
  grid-template-columns: minmax(0, 1.23fr) minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--night-line);
  border-radius: 25px;
  background: var(--night-surface);
  color: var(--night-ink);
  box-shadow: 0 12px 45px #100b1c42;
}
.studio-preview-image {
  position: relative;
  display: grid;
  min-height: clamp(315px, 34vw, 439px);
  place-items: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 40% 42%, #614671, #342147 74%);
  color: var(--night-amber);
}
.studio-preview-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 45%;
}
.studio-preview-image > .icon { width: 45px; height: 45px; }
.studio-preview-art::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(270deg, var(--night-surface), transparent 18%);
  content: '';
  pointer-events: none;
}
.studio-feature-content {
  min-width: 0;
  align-self: center;
  padding: clamp(20px, 3.5vw, 48px);
}
.studio-preview-caption { color: var(--night-amber); font-size: 14px; font-weight: 760; }
.studio-feature h2 {
  margin-top: 4px;
  font-family: var(--display);
  font-size: clamp(30px, 3.4vw, 52px);
  font-weight: 800;
  line-height: 1.21;
  letter-spacing: -.05em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.studio-feature-summary {
  margin-top: 8px;
  color: var(--night-muted);
  font-size: 15px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.studio-feature-guest + .studio-guest { margin-top: 17px; }
.studio-feature-guest :focus-visible { outline-color: var(--night-amber); }

.studio-tutorial-link {
  display: grid;
  width: min(100%, 410px);
  min-height: 60px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 8px 12px;
  border: 1px solid var(--night-line);
  border-radius: 14px;
  background: var(--night-surface);
  color: var(--night-ink);
  text-align: left;
}
.studio-tutorial-link:hover { border-color: #9d83bb; background: #3e2d54; }
.studio-tutorial-link img { border-radius: 50%; }
.studio-tutorial-link strong, .studio-tutorial-link small { display: block; }
.studio-tutorial-link small { margin-top: 2px; color: var(--night-label); font-size: 12px; }
.studio-tutorial-link .icon { width: 17px; height: 17px; color: var(--night-amber); }

.studio-starters, .studio-shelf { margin-top: clamp(21px, 3.15vw, 44px); }
:is(.studio-starters, .studio-shelf) .section-head { justify-content: space-between; gap: 10px; margin-bottom: 10px; }
:is(.studio-starters, .studio-shelf) .section-head h2 {
  color: var(--night-ink);
  font-family: var(--display);
  font-size: clamp(22px, 2.35vw, 32px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.045em;
  text-wrap: pretty;
}
:is(.studio-starters, .studio-shelf) .text-link { flex: 0 0 auto; color: var(--night-label); }
.studio-starter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.studio-starter {
  display: grid;
  min-height: 77px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--night-line);
  border-radius: 13px;
  background: var(--night-surface);
  color: var(--night-ink);
  text-align: left;
  transition: border-color 150ms ease, background-color 150ms ease;
}
.studio-starter:hover { border-color: #9d83bb; background: #3e2d54; }
.studio-starter-icon {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border-radius: 11px;
  background: #eee6fb;
  color: #5b4190;
}
.studio-starter-icon.sky { background: #e6eefb; color: #3d5684; }
.studio-starter-icon.rose { background: #f7e6ed; color: #8c4065; }
.studio-starter-icon.honey { background: #f9ecd5; color: #785622; }
.studio-starter-icon .icon { width: 21px; height: 21px; }
.studio-starter-copy { display: grid; gap: 3px; min-width: 0; }
.studio-starter-copy strong { overflow-wrap: anywhere; font-size: 14px; font-weight: 760; }
.studio-starter-copy small { color: var(--night-muted); font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.studio-starter > .icon { width: 16px; height: 16px; color: var(--night-label); }

.studio-feature + .job-panel { margin-top: 16px; }
.studio-guest,
.workspace[data-screen="account"] .settings-card,
.workspace > .empty-state,
.workspace .job-panel {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}
.studio-guest {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 16px;
  padding: 23px;
  border: 1px solid var(--line);
  border-radius: 13px;
}
.studio-guest h2 { margin-bottom: 4px; font-size: 22px; letter-spacing: -.035em; }
.studio-guest p, .workspace .job-panel .job-copy p { color: var(--muted); }
.workspace .job-panel .card-icon { background: var(--lavender); color: var(--plum-dark); }
.workspace .job-panel .progress-shell { background: #e7d9f2; }
.workspace .job-panel .progress-fill { background: var(--plum); }
.offline-note { border: 1px solid #e7dbe8; border-radius: 10px; background: #f1e8f2; color: #543f5c; }
.toast { border-color: #705587; background: #33243e; color: #fff7ed; }

@media (max-width: 960px) {
  :root { --studio-gutter: clamp(16px, 4.4vw, 40px); }
  .app-header { position: sticky; inset: 0 0 auto; width: auto; border-width: 0 0 1px; }
  .app-bar {
    width: calc(100% - 2 * var(--studio-gutter));
    height: auto;
    min-height: calc(62px + env(safe-area-inset-top));
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-inline: auto;
    padding: env(safe-area-inset-top) 0 0;
  }
  .app-header .nav {
    position: fixed;
    inset: auto 0 0;
    display: flex;
    gap: 5px;
    padding: 5px max(var(--studio-gutter), env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(var(--studio-gutter), env(safe-area-inset-left));
    border-top: 1px solid #4a3956;
    background: var(--studio-night);
  }
  .app-header .nav-item {
    min-height: 49px;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 2px;
    border-radius: 13px;
    font-size: 12px;
    line-height: 1.2;
  }
  .app-header .nav-item.settings-nav { display: none; }
  .app-header .brand { margin: 0; }
  .app-header .brand-mark { width: 35px; height: 35px; flex-basis: 35px; }
  .app-header .brand strong { font-size: 23px; }
  .bar-family { margin: 0; }
  .bar-profile > span:last-child { max-width: 115px; }
  .bar-profile:not(.bar-sample) { padding-inline: 4px 9px; border-radius: 22px; background: #38294c; }
  .header-settings {
    display: grid;
    width: 44px;
    min-height: 44px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 12px;
    color: var(--night-label);
  }
  .header-settings[aria-current="page"] { color: var(--night-amber); background: #4a3561; }
  .header-settings svg { width: 18px; height: 18px; }
  .workspace {
    width: min(var(--studio-width), calc(100% - 2 * var(--studio-gutter)));
    min-height: calc(100svh - 58px);
    margin-inline: auto;
    padding: 29px 0 calc(85px + env(safe-area-inset-bottom));
  }
  .toast { bottom: calc(70px + env(safe-area-inset-bottom)); }
}

@media (max-width: 680px) {
  .workspace { padding-top: 25px; }
  .workspace:is([data-screen="home"], [data-screen="auto"], [data-screen="episodes"], :has(.studio-feature-guest)) { padding-top: 11px; }
  .studio-heading { align-items: stretch; flex-direction: column; gap: 14px; margin-bottom: 13px; }
  .studio-title h1 { font-size: clamp(36px, 9vw, 48px); }
  .studio-title p { margin-top: 6px; }
  .studio-switch a { min-width: 0; min-height: 41px; flex: 1 1 0; padding-inline: 8px; }
  .studio-feature { grid-template-columns: minmax(0, 1fr); border-radius: 24px; }
  .studio-preview-image { min-height: 0; max-height: 365px; aspect-ratio: 1.28; }
  .studio-preview-art img { object-position: center 44%; }
  .studio-preview-art::after { background: linear-gradient(0deg, var(--night-surface), transparent 30%); }
  .studio-feature-content { padding: 11px 16px 15px; }
  .studio-feature h2 { font-size: clamp(29px, 8.2vw, 42px); }
  .studio-preview-caption { font-size: 13px; }
  .studio-feature-summary { margin-top: 7px; font-size: 14px; }
  .studio-actions { margin-top: 14px; }
  .button.primary.studio-generate { min-height: 50px; }
  .studio-own-action .button { width: 100%; }
  .studio-starter-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .studio-starter { min-height: 62px; padding-block: 8px; }
}

@media (max-width: 365px) {
  .app-header .brand { gap: 6px; }
  .app-header .brand strong { font-size: 21px; }
  .bar-profile > span:last-child { max-width: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  .studio-starter { transition: none; }
}
