.tool-workshop-main {
  min-height: 70dvh;
}
.tool-workshop-shell {
  width: min(100%, 1040px);
  margin-inline: auto;
}
.tool-workshop-shell [hidden] {
  display: none !important;
}
.tool-workshop-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.tool-workshop-hero h1 {
  margin: 0;
  color: var(--ui-text);
  font-size: 1.6rem;
  line-height: 1.3;
  letter-spacing: -0.035em;
}
.tool-workshop-hero span {
  display: block;
  margin-top: 6px;
  color: var(--ui-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
body.tool-workshop-page .tool-laboratory-back {
  display: inline-block;
  margin-top: 10px;
  color: var(--ui-accent);
  font: 600 0.82rem/1.6 var(--font-ui);
  text-decoration: none;
}
.tool-laboratory-back:hover {
  text-decoration: underline;
}
.tool-laboratory-back:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 4px;
}
.tool-workshop-shell button,
.tool-viewer button {
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--action-fill, transparent);
  color: var(--action-foreground, var(--ui-text));
  font: 600 0.86rem/1.4 var(--font-ui);
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease;
}
.tool-workshop-shell button:hover,
.tool-viewer button:hover {
  background: var(--action-hover-fill, var(--ui-surface-soft));
}
.tool-workshop-shell button:active,
.tool-viewer button:active {
  transform: var(--action-target-transform, translateY(1px));
}
.tool-workshop-shell button:disabled {
  opacity: 0.55;
  cursor: wait;
}
#tool-create-toggle {
  flex-shrink: 0;
  color: var(--action-foreground, var(--ui-accent));
  border: 1px solid var(--ui-line-strong);
}
#tool-generate,
#tool-publish,
#tool-share-discussion {
  background: var(--action-fill, var(--ui-accent));
  color: var(--action-foreground, #fff);
}
#tool-generate:hover,
#tool-publish:hover,
#tool-share-discussion:hover {
  background: var(--action-hover-fill, color-mix(in srgb, var(--ui-accent) 85%, black));
}
.tool-studio {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  align-items: start;
  gap: 24px;
  border-top: 1px solid var(--ui-line);
  padding-top: 20px;
}
.tool-studio label {
  display: grid;
  gap: 8px;
  color: var(--ui-text);
  font-size: 0.86rem;
  font-weight: 600;
}
.tool-studio input,
.tool-studio textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--ui-line-strong);
  border-radius: 6px;
  background: var(--ui-input);
  color: var(--ui-text);
  font: 400 1rem/1.5 var(--font-ui);
  resize: vertical;
}
.tool-studio-fields {
  display: grid;
  gap: 16px;
  padding-block: 16px;
}
.tool-studio-fields > p,
.tool-sandbox-note {
  margin: 0;
  color: var(--ui-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}
.tool-studio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
#tool-studio-status {
  margin: 8px 0 0;
  color: var(--ui-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}
#tool-studio-status:empty,
#tool-reasoning:empty {
  display: none;
}
#tool-reasoning {
  margin-top: 10px;
}
#tool-reasoning .max-reasoning-content {
  max-height: 140px;
  overflow: auto;
  overflow-wrap: anywhere;
}
#tool-reasoning-note {
  color: var(--ui-muted);
  font-size: 0.75rem;
  line-height: 1.5;
  margin: 6px 0 0;
}
.tool-output {
  min-width: 0;
}
.tool-code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ui-muted);
  font-size: 0.75rem;
}
.tool-code-live {
  --code-tag: #7ee787;
  --code-string: #a5d6ff;
  --code-keyword: #ff7b72;
  --code-number: #79c0ff;
  --code-title: #d2a8ff;
  --code-comment: #8b949e;
  --code-meta: #ffa657;
  box-sizing: border-box;
  margin: 0;
  overflow: auto;
  background: #0d1117;
  border-radius: 6px;
}
.tool-code-live code.hljs {
  display: block;
  min-height: 100%;
  box-sizing: border-box;
  padding: 12px;
  background: #0d1117;
  color: #c9d1d9;
  font:
    400 0.82rem/1.6 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
  tab-size: 2;
}
body.theme-light .tool-code-live,
body.theme-light .tool-code-live code.hljs {
  --code-tag: #116329;
  --code-string: #0a3069;
  --code-keyword: #cf222e;
  --code-number: #0550ae;
  --code-title: #8250df;
  --code-comment: #57606a;
  --code-meta: #953800;
  background: #f6f8fa;
  color: #24292f;
}
/* The shared shell colors every span with !important; keep source tokens distinct. */
.tool-workshop-page #tool-code-highlight span {
  color: inherit !important;
}
.tool-workshop-page #tool-code-highlight :is(.hljs-name, .hljs-selector-tag) {
  color: var(--code-tag) !important;
}
.tool-workshop-page #tool-code-highlight :is(.hljs-string, .hljs-regexp) {
  color: var(--code-string) !important;
}
.tool-workshop-page #tool-code-highlight :is(.hljs-keyword, .hljs-selector-pseudo) {
  color: var(--code-keyword) !important;
}
.tool-workshop-page
  #tool-code-highlight
  :is(.hljs-attr, .hljs-number, .hljs-literal, .hljs-variable, .hljs-attribute) {
  color: var(--code-number) !important;
}
.tool-workshop-page #tool-code-highlight :is(.hljs-title, .hljs-built_in) {
  color: var(--code-title) !important;
}
.tool-workshop-page #tool-code-highlight :is(.hljs-comment, .hljs-quote) {
  color: var(--code-comment) !important;
}
.tool-workshop-page #tool-code-highlight .hljs-meta {
  color: var(--code-meta) !important;
}
.tool-output-tabs,
.tool-gallery-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--ui-line);
  margin-bottom: 12px;
}
.tool-output-tabs button,
.tool-gallery-toolbar button {
  border-radius: 0;
  border-bottom: 2px solid transparent;
  color: var(--action-foreground, var(--ui-muted));
}
.tool-output-tabs button[aria-pressed='true'],
.tool-gallery-toolbar button[aria-pressed='true'] {
  border-bottom-color: var(--ui-accent);
  color: var(--ui-accent);
}
#tool-preview {
  margin-left: auto;
  font-size: 0.78rem;
}
#tool-html,
.tool-preview-panel,
.tool-code-live {
  height: clamp(260px, 48dvh, 560px);
}
#tool-html {
  display: block;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  tab-size: 2;
}
.tool-preview-panel {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--ui-surface-soft);
}
#tool-preview-empty {
  margin: 0;
  padding: 20px;
  color: var(--ui-muted);
  text-align: center;
  font-size: 0.84rem;
  line-height: 1.9;
}
.tool-preview-panel iframe,
.tool-viewer iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.tool-sandbox-note {
  margin-top: 8px;
}
.tool-gallery-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 12px;
  margin-bottom: 0;
}
#tool-gallery-status {
  margin: 0;
  padding-block: 8px;
  color: var(--ui-muted);
  font-size: 0.78rem;
}
.tool-gallery {
  display: grid;
}
.tool-card {
  display: grid;
  grid-template-columns: 144px minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--ui-line);
  color: var(--ui-text);
  cursor: pointer;
  transition: background 160ms ease;
}
.tool-card:hover {
  background: var(--ui-surface-soft);
}
.tool-card-preview {
  position: relative;
  height: 90px;
  overflow: hidden;
  border-radius: 4px;
  background: #fff;
  isolation: isolate;
}
.tool-card iframe {
  position: relative;
  top: 0;
  left: 0;
  width: 576px;
  height: 360px;
  max-width: none;
  border: 0;
  background: #fff;
  transform: scale(0.25);
  transform-origin: top left;
  pointer-events: none;
}
.tool-card-copy {
  min-width: 0;
}
.tool-card-copy h2 {
  margin: 0;
  color: var(--ui-text);
  font-size: 1rem;
  line-height: 1.4;
}
.tool-card-copy h2,
.tool-card-copy p,
.tool-card-meta > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-card-copy p {
  margin: 5px 0 8px;
  color: var(--ui-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}
.tool-card-meta {
  display: flex;
  gap: 16px;
  color: var(--ui-muted);
  font-size: 0.72rem;
}
.tool-card-meta time {
  flex-shrink: 0;
}
.tool-gallery-empty {
  padding: 48px 16px;
  color: var(--ui-muted);
  text-align: center;
  line-height: 1.7;
}
.tool-viewer {
  box-sizing: border-box;
  width: min(1100px, calc(100vw - 28px));
  height: min(820px, calc(100dvh - 28px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ui-line);
  border-radius: 10px;
  background: var(--ui-surface);
  color: var(--ui-text);
}
.tool-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.tool-viewer::backdrop {
  background: rgba(3, 24, 30, 0.66);
}
.tool-viewer-surface {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--ui-surface-soft);
}
#tool-viewer-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--ui-text);
  background: var(--ui-surface-soft);
  text-align: center;
}
#tool-viewer-status[hidden] {
  display: none;
}
.tool-viewer header,
.tool-viewer footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ui-line);
}
.tool-viewer header > div {
  min-width: 0;
  overflow-wrap: anywhere;
}
.tool-viewer footer {
  justify-content: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid var(--ui-line);
  border-bottom: 0;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.tool-viewer h2,
.tool-viewer p {
  margin: 0;
}
.tool-viewer h2 {
  font-size: 1.1rem;
}
.tool-viewer p {
  margin-top: 3px;
  color: var(--ui-muted);
  font-size: 0.78rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tool-viewer header > button {
  flex-shrink: 0;
  width: 44px;
  font-size: 1.7rem;
}
.tool-workshop-page :focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ui-accent) 72%, white);
  outline-offset: 2px;
}
@media (min-width: 901px) {
  /* The desktop shell already displays the page title above the content. */
  .tool-workshop-hero h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (max-width: 900px) {
  .tool-workshop-hero {
    margin-bottom: 12px;
  }
  .tool-workshop-hero h1 {
    font-size: 1.25rem;
  }
  .tool-workshop-hero span {
    display: none;
  }
  .tool-studio {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding-top: 12px;
  }
  #tool-html,
  .tool-preview-panel,
  .tool-code-live {
    height: clamp(240px, 40dvh, 420px);
  }
  .tool-card {
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 12px;
    padding-block: 14px;
  }
  .tool-card-preview {
    height: 76px;
  }
  .tool-card iframe {
    width: 500px;
    height: 380px;
    transform: scale(0.2);
  }
  .tool-viewer {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tool-workshop-shell button,
  .tool-viewer button,
  .tool-card {
    transition: none;
  }
}
