/* 작업 (js/work.js): the start screen, and the studio around a work being made: its bar,
   its guidelines, the canvas (workcanvas.css) and the chat beside it (workchat.css), which on
   phones and narrow windows is a sheet at the bottom. Colours come from styles.css's tokens;
   the only colours of its own are the swatches of the slides' looks (the same table as the
   slides themselves, server/workformat.js). */

/* ====================================================================================
   The start screen: made like the 공부 page (library.js render, styles.css .library,
   .agent-bar). It shares that page's .hero / .analysis-hero, .composer, .send-btn,
   .home-label, .section-head, .exam-grid / .exam-card and the chat's .attach-tile, but its
   own frame and bar (.work-home, .work-bar*): the AI helper treats .agent-bar* as its own and
   leaves it out of what it sees (agent.js OWN), and calls .library "study home". The rules
   below are the 공부 page's own, kept to the same values.
   ==================================================================================== */

.work-home {
  max-width: 920px;
  margin: 0 auto;
  box-sizing: border-box;
  /* (on one screen, standing a little above the middle: one part of the free space over the
     heading, two under the last row, as the 공부 page does) */
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
  display: flex;
  flex-direction: column;
  padding: 0 24px;
  -webkit-user-select: none;
  user-select: none;
}
.work-home::before,
.work-home::after {
  content: "";
  flex: 1 1 0px;
}
.work-home::before {
  min-height: 6px;
  flex-grow: 1;
}
.work-home::after {
  order: 1;
  min-height: 16px;
  flex-grow: 2;
}
.work-home:has(> .site-footer) {
  padding-bottom: 14px;
}
.work-home:has(> .site-footer)::after {
  min-height: 24px;
}
.work-home > .site-footer {
  order: 2;
  margin-top: 0;
  gap: 3px;
  padding-top: 10px;
  font-size: 11px;
  line-height: 1.5;
}
.work-home > .site-footer .footer-links {
  gap: 12px;
}
.work-home > .site-footer .footer-info {
  gap: 2px 10px;
}
.work-home input,
.work-home textarea,
.work-home .site-footer {
  -webkit-user-select: text;
  user-select: text;
}
.work-home > .analysis-hero {
  margin-bottom: 6px;
}
.work-home .analysis-hero h1 {
  font-size: 38px;
}

/* The bar: the round ✦ mark and, beside it, the box (.agent-bar, .agent-bar-icon, .agent-bar-box). */
.work-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px 0 0;
}
.work-bar-icon {
  appearance: none;
  flex: none;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgb(90 80 240 / 0.34), 0 1px 3px rgb(0 0 0 / 0.18);
  transition: transform 0.12s ease, filter 0.15s;
}
.work-bar-icon:hover {
  transform: translateY(-1px) scale(1.04);
  filter: brightness(1.06);
}
.work-bar-icon .icon {
  width: 50%;
  height: 50%;
}
.work-bar-box {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 10px 10px 14px;
  border-radius: 22px;
}
.work-bar-box.composer:focus-within {
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong));
}
.work-bar-box .composer-input {
  flex: 1 1 0;
  min-width: 0;
  min-height: 38px;
  padding: 7px 4px;
  font-size: 16px;
}
.work-bar-box .composer-input:focus-visible {
  box-shadow: none;
}
.work-bar-box .composer-input::placeholder {
  color: var(--muted);
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* (the box sized to what is typed, never to the idea shown in it while it is empty: a long
   one on a narrow screen made the empty box three lines tall) */
.work-bar-box .composer-input:placeholder-shown {
  height: 38px;
  overflow: hidden;
}
.work-bar-mic {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--ink-2);
}
.work-bar-mic.on {
  color: var(--accent-text);
  background: var(--accent-soft);
  animation: work-mic 1.2s ease-in-out infinite;
}
@keyframes work-mic {
  50% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
  }
}
.work-bar-box .send-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
}
.work-bar-box .send-btn:disabled {
  opacity: 0.45;
}

/* With the AI helper (work.js drawStart, spec 25): its bar comes first, and its card opens at the
   top of the page in the bar's place, as on the 공부 page (styles.css .agent-bar, .agent-dock,
   .library.agent-open). The box for the work stands under it, named by a small label, with no
   mark of its own. */
.work-home.agent-open .agent-dock {
  display: block;
}
.work-home.agent-open .agent-bar {
  display: none;
}
/* (while it works on the page, the card stays at the top of the screen: its steps are followed there) */
.work-home.agent-open .agent-dock:has(.agent-panel.acting) {
  position: sticky;
  top: 62px;
  z-index: 6;
}
.work-home:has(.agent-dock) {
  scroll-margin-top: 70px;
}
.work-home .home-label + .work-bar {
  margin-top: 0;
}
/* (the box has no mark beside it then: the options under it start at its edge) */
.work-bar.no-mark ~ .work-options,
.work-bar.no-mark ~ .work-signin {
  margin-left: 4px;
}
/* (the card growing past the window and shrinking back: the scroll bar's room is kept, so nothing moves sideways) */
.page:has(> .work-home) {
  scrollbar-gutter: stable;
}

/* The material in the box: a row of tiles over the words (the chat's .attachments / .attach-tile). */
.work-tiles {
  flex: 1 0 100%;
  min-width: 0;
  padding: 0 4px 2px 0;
}
.work-tiles[hidden] {
  display: none;
}
/* (:root: over the chat's own sizes for tiles on phones, html.touch-ui .attach-tile / .file-card) */
:root .attach-tile.work-src {
  width: 212px;
  height: auto;
  min-height: 108px;
  gap: 6px;
}
.work-src-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.work-src-top .file-card-icon {
  flex: none;
}
.work-src .file-card-name {
  min-width: 0;
  -webkit-line-clamp: 2;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.work-src-range.seg {
  align-self: flex-start;
}
.work-src-range .seg-btn {
  padding: 3px 9px;
  font-size: 12px;
}
.work-src .work-pages-input {
  width: 100%;
  box-sizing: border-box;
  height: 30px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 13px;
  -webkit-user-select: text;
  user-select: text;
}
.work-src .work-pages-input[hidden] {
  display: none;
}
.work-src.bad {
  border-color: var(--bad);
}
.work-src.bad .work-pages-input {
  border-color: var(--bad);
}
.work-src.bad .file-card-meta {
  color: var(--bad);
}
.work-src-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.45;
}

/* A quiet row of options under the bar: smaller than the box, like the 공부 page's secondary controls. */
.work-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 12px 0 0 74px; /* (under the box, not the ✦ mark) */
}
.work-options .seg-btn {
  padding: 4px 10px;
  font-size: 12.5px;
}
.work-options .chip {
  font-size: 12.5px;
  padding: 5px 11px;
}
.work-options .seg-btn[hidden] {
  display: none;
}
.work-themes {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 3px;
}
.work-themes[hidden] {
  display: none;
}
/* A slide's look: its background with a stroke of its accent. */
.work-swatch {
  appearance: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  /* (its background may be a gradient: the accent's corner is laid over it) */
  background: linear-gradient(135deg, transparent 0 58%, var(--sw-accent) 58% 100%), var(--sw-bg);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
.work-swatch:hover {
  transform: translateY(-1px);
}
.work-swatch[aria-checked="true"] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
.work-swatch:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.work-review {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.work-review input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}
/* (a free account: what a work costs it) */
.work-cost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
}
.work-cost[hidden] {
  display: none;
}
.work-signin {
  margin: 10px 0 0 74px;
}

/* Starters: they fill the box (and the form); nothing is sent. */
.work-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
}
.work-starter {
  gap: 6px;
  font-size: 13px;
}
.work-starter .icon {
  color: var(--accent);
}
.work-empty {
  margin: 22px 4px 0;
}
.work-empty + .work-starters {
  margin-top: 8px;
}
.work-empty[hidden],
.work-add-files[hidden] {
  display: none;
}

/* (what making it is likely to cost, after the plan banner's words: spec 23.9, workcost.js) */
.work-banner-cost {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

/* While what was left on 자동 is chosen and pressed (work.js setUp, spec 26.12): said in a small
   label over the box's top edge, which takes no room, so nothing under it moves. */
.work-bar {
  position: relative;
}
.work-setup-note {
  position: absolute;
  right: 12px;
  top: -12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  background: var(--surface);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--shadow);
}
.work-setup-note[hidden] {
  display: none;
}
.work-setting-up .work-bar-box {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

/* "직접 파일 넣기" (work.js drawAddFiles): the 공부 page's box and cards (styles.css .study-slot,
   .file-slot), with two cards: 고칠 파일 and 붙여 넣은 글. Its own box class, not .home-box: that
   one glides between pages (view-transition-name), and only one box on a page may. */
.work-add-files {
  margin: 26px 0 0;
}
.work-add-files > .home-label {
  margin-top: 0;
}
.work-file-box {
  display: block;
  padding: 10px 10px 8px;
  border-radius: 22px;
}
.work-file-box .composer-input {
  width: 100%;
  min-height: 52px;
  font-size: 15px;
}
.work-file-box .composer-bar {
  gap: 8px;
}
.work-file-box .send-btn:disabled {
  opacity: 0.45;
}
.work-file-box.over {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--ring), var(--shadow);
}
.work-file-box.busy {
  opacity: 0.75;
}
.work-file-tiles .attach-row {
  margin: 0 0 4px;
}
:root .attach-tile.work-file-tile {
  width: 230px;
  max-width: 100%;
}
.work-file-slots {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
button.study-slot {
  appearance: none;
  font: inherit;
  color: inherit;
  width: 100%;
}
.work-file-slots .study-slot:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
/* (a file being opened as a work: its name, what is being done, and how far) */
.work-import {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 10px 2px 0;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 13px;
}
.work-import[hidden] {
  display: none;
}
.work-import.failed {
  background: color-mix(in srgb, var(--bad) 10%, var(--surface));
  color: var(--ink);
}
.work-import.failed .icon {
  color: var(--bad);
}
.work-import-text {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  min-width: 0;
  flex: 1 1 200px;
}
.work-import-name {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.work-import-line {
  color: var(--ink-2);
}
.work-import-bar {
  flex: 1 0 100%;
  height: 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  overflow: hidden;
}
.work-import-fill {
  display: block;
  width: 3%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}
/* (how far is not known while the server reads the file: the bar moves to and fro) */
.work-import-bar.loose .work-import-fill {
  width: 30% !important;
  animation: work-import-loose 1.2s ease-in-out infinite alternate;
}
@keyframes work-import-loose {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(233%);
  }
}
.work-paste-dialog {
  width: min(620px, calc(100vw - 32px));
}
.work-paste-text {
  width: 100%;
  min-height: 220px;
  margin-top: 10px;
  resize: vertical;
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
}
@media (max-width: 520px) {
  .work-file-slots {
    grid-template-columns: 1fr;
  }
}
@media (prefers-reduced-motion: reduce) {
  .work-import-bar.loose .work-import-fill {
    animation: none;
  }
}

/* 내 작업: the 공부 page's cards, as compact as there. */
/* (while the list is not known yet, its place is kept by three empty cards of the same size: work.js drawRecentWait) */
.work-card-wait {
  pointer-events: none;
  box-shadow: none;
}
.work-home .work-card-wait .exam-icon {
  background: var(--surface-2);
}
.work-wait-bar {
  display: inline-block;
  width: 62%;
  border-radius: 6px;
  background: var(--surface-2);
}
.work-wait-bar.short {
  width: 40%;
}
.work-home .section-head {
  margin: 18px 0 9px;
}
.work-home .exam-grid {
  gap: 12px;
}
.work-home .exam-card {
  gap: 2px;
  padding: 10px 13px;
  border-radius: 14px;
}
.work-home .exam-top {
  gap: 7px;
  margin-bottom: 2px;
}
.work-home .exam-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.work-home .exam-icon .icon {
  width: 15px;
  height: 15px;
}
.work-home .exam-card .tag {
  font-size: 11.5px;
  padding: 1px 8px;
}
.work-home .exam-card .exam-more {
  width: 26px;
  height: 26px;
}
.work-home .exam-card .exam-title {
  font-size: 14.5px;
  -webkit-line-clamp: 1;
  max-height: 1.4em;
}
.work-home .work-card-meta {
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 560px) {
  .work-home {
    padding: 0 16px;
  }
  /* (the 공부 page has no bar on a phone, which opens on the chat: here the mark is smaller,
     so the box keeps room for the words) */
  .work-bar {
    gap: 8px;
  }
  .work-bar-icon {
    width: 44px;
    height: 44px;
  }
  /* (the helper's bar here is the same: its mark as small as the box's would be) */
  .work-home .agent-bar {
    gap: 8px;
  }
  .work-home .agent-bar-icon {
    width: 44px;
    height: 44px;
  }
  .work-bar-box {
    padding: 8px 8px 8px 12px;
  }
  :root .attach-tile.work-src {
    width: 178px;
  }
  .work-options,
  .work-signin {
    margin-left: 0;
  }
  .work-home .exam-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The form of a work: PPT, Word or PDF. */
.work-kind {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.6;
}
.work-kind[hidden] {
  display: none;
}

/* ====================================================================================
   The studio
   ==================================================================================== */

.work-studio {
  container: work / inline-size;
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}
.work-studio.resizing {
  cursor: col-resize;
  user-select: none;
}

/* ---- the bar: name and progress · (the tabs) · pace, pause, download ---- */
.work-top {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  min-height: 56px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.work-top-left,
.work-top-right {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.work-top-right {
  justify-content: flex-end;
  flex-wrap: wrap;
}
/* The way back to the works (#/work): a chevron and 작업, the bar's first control; on a phone
   or a touch screen the chevron alone, in a square big enough for a thumb. */
.work-back {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  padding: 0 9px 0 5px;
  margin-left: -6px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.work-back:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.work-back:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.work-title {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15.5px;
  font-weight: 750;
  letter-spacing: -0.02em;
  padding: 4px 6px;
  margin-left: -6px;
  border-radius: 7px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
  flex: 0 1 auto;
}
.work-title:hover {
  background: var(--surface-2);
}
.work-title:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.work-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.work-progress-text {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.work-progress {
  position: relative;
  width: 72px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  flex: none;
}
.work-progress[hidden] {
  display: none;
}
.work-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--grad);
  transition: width 0.4s ease;
}
.work-error {
  flex-basis: 100%;
  font-size: 12.5px;
  color: var(--bad);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.work-error[hidden] {
  display: none;
}
.work-pace .seg-btn {
  padding: 5px 10px;
  font-size: 12.5px;
}
.work-pause[hidden],
.work-more[hidden],
.work-restore[hidden] {
  display: none;
}
.work-download .icon:last-child {
  color: var(--muted);
}

/* ---- the guidelines every part follows ---- */
.work-guides {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.work-guides::-webkit-scrollbar {
  display: none;
}
.work-guides-label {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-right: 2px;
}
.work-guide {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 320px;
  padding: 2px 2px 2px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 12.5px;
  color: var(--ink-2);
}
.work-guide-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* (a guideline the AI's hands are about to type in: it has a place on the screen before its first letter) */
.work-guide-text:empty {
  display: inline-block;
  min-width: 2px;
  min-height: 1.2em;
}
.work-guide .icon-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
/* one the AI took out, until its hands have pressed its × */
.work-guide.going {
  pointer-events: none;
}
.work-guide-add {
  flex: none;
  padding: 3px 10px;
  font-size: 12.5px;
}
.work-guide-add:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ---- the work, and the chat beside it ---- */
.work-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6px var(--work-chat-w, 380px);
}
.work-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.work-canvas-host {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.work-chat-host {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
}
.work-chat-host > * {
  flex: 1;
  min-height: 0;
}
/* The line between them, dragged to give the chat more or less room. */
.work-resize {
  position: relative;
  cursor: col-resize;
  touch-action: none;
  background: transparent;
}
.work-resize::after {
  content: "";
  position: absolute;
  inset: 0 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.15s;
}
.work-resize:hover::after,
.work-studio.resizing .work-resize::after {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}
.work-resize:focus-visible {
  outline: none;
}
.work-resize:focus-visible::after {
  background: var(--accent);
}

/* ---- banners over the work: the plan to check, stopped here, made in another window ---- */
.work-banners:empty {
  display: none;
}
.work-banners {
  flex: none;
  padding: 10px 14px 0;
}
.work-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  padding: 10px 12px 10px 16px;
  border-radius: var(--r);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
}

/* ---- the pause before the next part (차근차근), or "making it all at once" ---- */
.work-beat {
  position: relative;
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin: 10px 14px 0;
  padding: 7px 8px 9px 14px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.work-beat[hidden] {
  display: none;
}
.work-beat-text {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.work-beat-text .icon {
  color: var(--accent);
}
.work-beat-actions {
  display: inline-flex;
  gap: 6px;
  flex: none;
}
/* The line under it that runs down to the start of the next part. */
.work-beat-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--surface-3);
}
.work-beat-line {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--grad);
  transition: width 0.25s linear;
}
.work-beat.held .work-beat-line {
  opacity: 0.45;
}

/* ---- the plain list that stands in for the canvas until the plan says which form ---- */
.work-skeleton {
  list-style: none;
  margin: 0 auto;
  padding: 24px 18px;
  width: 100%;
  max-width: 640px;
  display: grid;
  gap: 8px;
}
.work-skel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  color: var(--muted);
  font-size: 14px;
  animation: work-rise 0.25s ease-out;
}
.work-skel-n {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
}
.work-skel-bar {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: work-shimmer 1.4s ease-in-out infinite;
}
.work-skel-row.empty:nth-child(2) .work-skel-bar {
  flex: 0 1 70%;
}
.work-skel-row.empty:nth-child(3) .work-skel-bar {
  flex: 0 1 82%;
}
.work-skel-row.empty:nth-child(4) .work-skel-bar {
  flex: 0 1 60%;
}
@keyframes work-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}
@keyframes work-rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* "Apply this to the parts already made too?" with its button, in a toast. */
.work-toast {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.work-toast-btn {
  appearance: none;
  border: 0;
  border-radius: 7px;
  padding: 4px 10px;
  background: color-mix(in srgb, var(--bg) 18%, transparent);
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.work-toast-btn:hover {
  background: color-mix(in srgb, var(--bg) 30%, transparent);
}

/* The AI helper (styles.css .agent) floats at the bottom left. In a narrow window the chat is
   the sheet at the bottom, whose box the helper would cover: it sits just above the folded
   sheet (work.js sets --work-sheet-room) and is out of the way while the sheet is open.
   (Touch screens keep it where styles.css puts it, already clear of the sheet.) */
html.work-sheet-on:not(.touch-ui) .agent {
  bottom: calc(var(--work-sheet-room, 120px) + 10px);
}
html.work-sheet-open .agent {
  display: none;
}

/* ---- the sheet the chat is in on phones and narrow windows ---- */
.work-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lg);
  transition: height 0.22s ease;
}
.work-sheet.open {
  height: min(70vh, calc(var(--app-h, 100dvh) * 0.7));
}
.work-sheet-handle {
  appearance: none;
  flex: none;
  height: 22px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.work-sheet-handle::before {
  content: "";
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
}
.work-sheet-handle:focus-visible {
  outline: none;
}
.work-sheet-handle:focus-visible::before {
  background: var(--accent);
}
.work-sheet .work-chat-host {
  flex: 1;
  border-left: 0;
  background: transparent;
}
/* Folded: the chat shows only its box and the AI's last line (workchat.js folds itself);
   should it not, only its bottom shows and what is above is cut off. */
.work-sheet .work-chat-host[data-sheet="collapsed"] {
  flex: none;
  max-height: 220px;
  justify-content: flex-end;
  overflow: hidden;
}
.work-sheet .work-chat-host[data-sheet="collapsed"] > * {
  flex: none;
}

/* ====================================================================================
   Narrower: the tabs take the bar's first row
   ==================================================================================== */

@container work (max-width: 1180px) {
  .work-top .tabs-space {
    order: -1;
    flex: 1 1 100%;
    height: 34px;
  }
  .work-top-left {
    flex: 1 1 260px;
  }
  .work-top-right {
    flex: 1 1 auto;
  }
}

/* Phones and narrow windows (and every touch screen): the chat folds into the sheet. */
@media (max-width: 860px) {
  .work-top {
    padding: 8px 10px;
  }
  .work-top .tabs-space {
    order: -1;
    flex: 1 1 100%;
    height: 40px;
  }
  .work-studio.compact .work-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .work-studio.compact .work-canvas-host {
    padding-bottom: var(--work-sheet-h, 120px);
  }
}
/* (phones and tablets: html.touch-ui, set by js/device.js) */
html.touch-ui .work-studio.compact .work-body {
  grid-template-columns: minmax(0, 1fr);
}
html.touch-ui .work-studio.compact .work-canvas-host {
  padding-bottom: var(--work-sheet-h, 120px);
}
/* (no tabs over the bar on a touch screen, styles.css: no empty row kept for them; the round
   panel button floats at the top left, styles.css .shell-menu, and the way back sits beside it,
   54 px from the edge: the first row only, a row of buttons wrapped under it keeps its width) */
html.touch-ui .work-top .tabs-space {
  display: none;
}
html.touch-ui .work-top-left {
  margin-left: calc(54px - 10px);
}
html.touch-ui .work-back {
  width: 40px;
  height: 40px;
  padding: 0;
  margin-left: 0;
  justify-content: center;
}
html.touch-ui .work-back-label {
  display: none;
}

@media (max-width: 560px) {
  .work-top-right {
    justify-content: flex-start;
  }
  .work-pace .seg-btn {
    padding: 5px 8px;
    font-size: 12px;
  }
  .work-download > span {
    display: none;
  }
  .work-progress {
    width: 48px;
  }
  .work-guides {
    padding: 6px 10px;
  }
  .work-beat {
    margin: 8px 10px 0;
  }
  .work-banners {
    padding: 8px 10px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .work-progress-fill,
  .work-beat-line,
  .work-sheet,
  .work-swatch,
  .work-bar-icon {
    transition: none;
  }
  .work-skel-row {
    animation: none;
  }
  .work-skel-bar {
    animation: none;
  }
  .work-swatch:hover,
  .work-bar-icon:hover {
    transform: none;
  }
  .work-bar-mic.on {
    animation: none;
  }
}

/* Phones: the top bar kept to two short rows under the tabs (the pause, restore and download
   buttons show their icons only; their names stay for screen readers, work.js). The buttons
   still wrap to a row of their own where they do not fit (a narrow phone, longer English
   names): the studio hides what overflows, and Download is the last of them. */
@media (max-width: 560px) {
  .work-top {
    gap: 4px 8px;
    min-height: 0;
    padding: 6px 10px;
  }
  .work-back {
    width: 40px;
    height: 40px;
    padding: 0;
    margin-left: -4px;
    justify-content: center;
  }
  .work-back-label {
    display: none;
  }
  .work-top-right {
    gap: 6px;
  }
  .work-pause > span,
  .work-restore > span {
    display: none;
  }
  .work-title {
    font-size: 14.5px;
  }
  .work-status {
    font-size: 12px;
    /* (the status keeps its own width and the title gives way with its …: a status squeezed
       instead ran past the screen's edge, "Done · 3 parts" cut off) */
    flex: 0 1 auto;
    max-width: 62%;
  }
  .work-progress-text {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .work-top-left .work-title {
    flex: 1 1 0;
  }
}

/* The work chat's ✦ in its head opens the helper's settings, as its gear does (workchat.js). */
button.wch-avatar {
  appearance: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s;
}
button.wch-avatar:hover {
  transform: scale(1.06);
  filter: brightness(1.06);
}
@media (prefers-reduced-motion: reduce) {
  button.wch-avatar {
    transition: none;
  }
  button.wch-avatar:hover {
    transform: none;
  }
}

/* ====================================================================================
   Spec 26: the themes' gallery (themegallery.js), the work chat's pictures (workchat.js),
   and the sheet's italics, page set-up and page breaks (worksheet.js)
   ==================================================================================== */

/* 더 보기 after the six swatches on the start page */
.work-theme-more {
  appearance: none;
  border: 0;
  background: none;
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--accent-text, var(--accent));
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.work-theme-more:hover {
  background: var(--accent-soft);
}
.work-theme-more:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
/* The gallery: every theme by group, each a little slide with "Aa" in its colours and its name. */
.work-gallery-dialog {
  width: min(640px, calc(100vw - 32px));
}
.work-gallery-dialog .dialog-body {
  max-height: min(78vh, 680px);
  overflow: auto;
}
.work-gallery-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.work-gallery-top h2 {
  margin: 0;
}
.work-gallery {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}
.work-gallery-head {
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
}
.work-gallery-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}
.work-swatch-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.work-swatch.big {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 9px;
  background: linear-gradient(135deg, transparent 0 78%, var(--sw-accent) 78% 100%), var(--sw-bg);
  display: grid;
  place-items: center;
}
.work-swatch-aa {
  color: var(--sw-title);
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.work-swatch-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--ink-2);
}

/* The work chat's "+" (the Study chat's round "+"), left of the box; the pictures over the box. */
.wch .wch-plus {
  order: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
}
.wch .wch-plus:hover {
  background: var(--surface-3);
  color: var(--ink);
}
body:has(.wch-plus-menu) .wch .wch-plus {
  background: var(--surface-3);
  color: var(--ink);
}
.wch .wch-plus:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.wch-attach {
  padding: 0 14px;
}
.wch-attach .attach-tile {
  height: 84px;
}
.wch-attach .attach-image img {
  max-width: 150px;
}
.wch-attach .chat-image-busy {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
/* (a picture dragged over the chat: it shows where it will go) */
.wch.wch-drop {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
}
/* the pictures a message carried, over its words */
.wch-pics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.wch-msg.has-pics {
  max-width: 82%;
}
.wch-pic {
  display: block;
  height: 96px;
  max-width: 180px;
  object-fit: cover;
  border-radius: 10px;
  background: #fff;
  cursor: zoom-in;
}
/* a change made that came out the same as before: said, not ticked */
.wch-card.is-unchanged .wch-card-state,
.wch-card.is-barely .wch-card-state {
  background: var(--surface-3);
  color: var(--ink-2);
}

/* The sheet: italics, the page button, the page breaks, the AI's note under it. */
.ws-c.ws-i {
  font-style: italic;
}
.ws-italic i {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 700;
}
.ws-page {
  gap: 6px;
  max-width: 100%;
}
.ws-page-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-pages {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.ws-break {
  position: absolute;
}
.ws-break-col {
  width: 0;
  border-left: 2px dashed #6366f1;
}
.ws-break-row {
  height: 0;
  border-top: 2px dashed #6366f1;
}
.ws-page-dialog {
  width: min(460px, calc(100vw - 32px));
}
.ws-page-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 10px 0;
}
.ws-page-label {
  min-width: 42px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.ws-page-center {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
  font-size: 13px;
  cursor: pointer;
}
.ws-page-info {
  margin: 8px 0 0;
}
.ws-notes-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ws-notes-row[hidden] {
  display: none;
}
.ws-notes-tag {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.ws-notes-row .ws-notes {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 12.5px;
}
@media (max-width: 560px) {
  .ws-page-name {
    max-width: 120px;
  }
}

/* (phones hide what a chat box's placeholder says, styles.css touch-ui: this one says what goes in it, so it shows) */
html.touch-ui .work-file-box .composer-input::placeholder {
  color: var(--muted);
}
