/* Workspace controls size to the available pane. Header rows grow with their content. */
.app {
  grid-template-rows: auto minmax(0, 1fr);
}
.workspace-content {
  grid-template-rows: minmax(0, 1fr);
}
.topbar {
  min-height: 60px;
  gap: 12px;
}
.brand {
  font-size: 22px;
  gap: 5px;
  letter-spacing: -0.7px;
  color: var(--ink);
}
.brand-resume,
.brand-studio {
  color: inherit;
}
.brand-wrap,
.top-actions,
.secondary-actions,
.project-links {
  display: flex;
  align-items: center;
}
.brand-wrap {
  gap: 12px;
  min-width: 0;
}
.top-actions {
  gap: 8px;
  flex-shrink: 0;
}
.secondary-actions {
  gap: 6px;
  order: 0;
}
.compile-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  order: 1;
  flex: 0 0 auto;
}
.compile-actions .compile-guide {
  display: block;
  margin: 0;
  order: 1;
  flex: 0 0 auto;
}
.compile-actions .compile-guide-summary {
  width: 32px;
  height: 36px;
}
.top-actions .compile-actions #compileButton {
  margin: 0;
  order: 0;
}
.compile-actions #reportBugButton {
  order: 2;
  flex: 0 0 auto;
}
.secondary-actions #appearanceCycle {
  order: 0;
}
.secondary-actions #editTemplateButton {
  order: 1;
  margin: 0;
}
.secondary-actions #whyJsonButton {
  order: 2;
}

.top-actions #headerImportButton {
  order: 2;
}
.top-actions .export-wrap {
  margin-left: 0;
  order: 3;
}
.top-actions #moreActionsButton {
  order: 4;
}
#compileButton {
  padding: 6px;
  width: 36px;
  min-width: 36px;
}
.compile-label.visually-hidden {
  position: absolute !important;
}
a.button {
  text-decoration: none;
}
.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.project-links {
  gap: 2px;
}
.project-links .icon-button svg path[fill] {
  stroke: none;
}
.more-actions,
.mobile-workspace-bar {
  display: none;
}
.header-import,
.export-main {
  gap: 6px;
}
#exportButton .material-symbols-rounded {
  font-size: 17px;
}
.output-controls {
  container-type: inline-size;
  flex: 0 0 auto;
  min-width: 0;
  width: 100%;
}
.document-topbar {
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px 10px;
  min-height: 44px;
  height: auto;
  padding: 6px 8px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--ui-surface);
}
.document-primary-controls {
  display: contents;
}
.document-topbar .button,
.document-topbar summary {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 11px;
}
.document-topbar .workspace-layout {
  display: flex;
  flex-wrap: wrap;
  width: auto;
  min-width: 0;
  max-width: 100%;
  gap: 2px;
  margin: 0;
}
.document-topbar .layout-choice {
  min-width: 0;
  white-space: normal;
  padding: 5px 7px;
}
.layout-short-label {
  display: none;
}
@container (max-width: 640px) {
  .layout-full-label {
    display: none;
  }
  .layout-short-label {
    display: inline;
  }
}
@container (max-width: 450px) {
  .document-topbar #inspectPdfButton .action-label {
    display: none;
  }
  .document-topbar {
    gap: 6px;
  }
}
.editor-pane > .resume-tabs {
  flex: 0 0 38px;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
}
.pane-head-actions {
  min-width: 0;
}
.input-tabs {
  min-width: 0;
  overflow-x: auto;
}
@container (max-width: 400px) {
  .pane-title {
    display: none;
  }
  .pane-head-actions {
    width: 100%;
    margin: 0;
  }
}
.document-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 40px;
  padding: 4px 8px;
  overflow: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--line);
  background: var(--ui-surface);
}
.document-toolbar .button {
  min-height: 29px;
  padding: 4px 6px;
  font-size: 10px;
}
.document-toolbar .icon-button {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 4px;
}
.document-toolbar .material-symbols-rounded {
  font-size: 18px;
}
.document-edit-actions,
.document-view-actions,
.document-toolbar .page-navigator {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  margin: 0;
}
.document-toolbar #documentStats {
  flex: 0 0 auto;
  margin: 0;
  font-size: 10px;
  color: var(--ui-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
@container (max-width: 640px) {
  .document-toolbar #documentStats {
    display: none;
  }
}
#xmlEditor {
  box-sizing: border-box;
  resize: none;
  tab-size: 2;
  padding: 16px;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: var(--editor);
  color: var(--editor-ink);
  font:
    12px/1.8 Consolas,
    "Liberation Mono",
    monospace;
  white-space: pre-wrap;
  overflow: auto;
}
#panelXml .editor-foot {
  flex-wrap: wrap;
}
#xmlStatus {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
#panelXml .editor-foot.has-error #xmlStatus {
  color: #c5221f;
}
.why-content {
  max-width: 1280px;
}
.why-lede {
  max-width: none;
  width: 100%;
  text-wrap: wrap;
}
.walkthrough-forms {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: visible;
}
.walkthrough-form {
  min-width: 0;
}
.why-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 24px 0 4px;
  font-size: 12px;
  color: var(--ui-muted);
}
.why-footer a {
  color: var(--ui-primary);
}
@media (min-width: 901px) and (max-width: 1100px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .brand {
    font-size: 19px;
  }
  .brand-wrap {
    gap: 4px;
  }
  .secondary-actions {
    gap: 2px;
  }
  .top-actions {
    gap: 5px;
  }
  #editTemplateButton,
  #whyJsonButton {
    padding: 6px 8px;
    font-size: 11px;
  }
  .header-import .action-label {
    display: none;
  }
  .header-import {
    width: 34px;
    padding: 6px;
  }
}
@media (max-width: 900px) {
  html,
  body {
    height: 100%;
    width: 100%;
    overflow: hidden;
  }
  .app {
    min-height: 0;
    height: var(--app-height, 100dvh);
    width: 100%;
    overflow: hidden;
  }
  .topbar {
    min-height: 60px;
    height: 60px;
    padding: 6px 10px;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .brand {
    font-size: 18px;
    gap: 4px;
  }
  .brand-wrap {
    flex: 1 1 auto;
    gap: 0;
  }
  .desktop-project-links {
    display: flex;
    gap: 0;
  }
  .desktop-project-links .icon-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 10px;
  }
  .top-actions {
    gap: 3px;
  }
  .top-actions > .button,
  .top-actions > #compileButton,
  .top-actions .export-main {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 10px;
  }
  .action-label {
    display: none;
  }
  .export-caret {
    display: none;
    min-width: 24px;
    width: 24px;
    height: 44px;
    padding: 4px;
  }
  .top-actions .material-symbols-rounded {
    font-size: 20px;
  }
  .more-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
  }
  .secondary-actions {
    display: none;
    position: fixed;
    z-index: 65;
    right: 10px;
    top: 62px;
    width: min(300px, calc(100vw - 20px));
    box-sizing: border-box;
    padding: 12px;
    background: var(--ui-surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--chrome-shadow);
    flex-wrap: wrap;
    max-height: 75dvh;
    overflow: auto;
  }
  .secondary-actions.is-open {
    display: flex;
  }
  .secondary-actions .button {
    display: inline-flex !important;
    min-height: 44px;
    min-width: 44px;
    align-items: center;
    justify-content: center;
  }

  .compile-actions .compile-guide {
    display: block;
  }
  .compile-actions .compile-guide-summary {
    min-height: 44px;
    min-width: 44px;
  }
  .compile-actions .compile-guide-popover {
    position: fixed;
    top: 120px;
    right: 20px;
    left: auto;
    max-width: calc(100vw - 40px);
  }
  .main,
  .main.files-hidden {
    padding: 6px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    height: 100%;
    width: 100%;
    gap: 0;
    min-height: 0;
  }
  .workspace-sidebar,
  .main > .workspace-sidebar-resizer {
    display: none;
  }
  .main:not(.files-hidden) .workspace-sidebar {
    display: flex;
    position: absolute;
    background: var(--ui-surface);
    border: 1px solid var(--line);
    box-shadow: var(--chrome-shadow);
    width: min(280px, calc(100vw - 32px));
    max-width: none;
    z-index: 45;
    top: 6px;
    bottom: 6px;
    left: 6px;
  }
  .workspace-content {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    gap: 0;
  }
  .mobile-workspace-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 2px 6px;
    min-width: 0;
  }
  .mobile-workspace-bar > .button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }
  .mobile-workspace-bar .segmented {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
  }
  .mobile-workspace-bar .layout-choice {
    min-height: 44px;
    min-width: 0;
    padding: 7px 10px;
  }
  .document-topbar {
    padding: 8px;
    gap: 8px;
  }

  .document-primary-controls .mode-tab,
  .document-primary-controls .button,
  .document-primary-controls summary,
  .document-primary-controls select {
    min-height: 44px;
    min-width: 44px;
  }
  .document-topbar .workspace-layout {
    display: none;
  }
  #inspectPdfButton {
    margin-left: 0;
  }
  .workspace-panels,
  .workspace-panels.document-only {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    grid-template-rows: minmax(0, 1fr) !important;
  }
  .workspace-panels > .pane {
    height: 100%;
    min-height: 0;
    border-radius: 0 0 8px 8px;
  }
  .pane-head {
    min-height: 50px;
    padding: 5px 7px;
    gap: 4px;
  }
  .pane-title {
    display: none;
  }
  .pane-head-actions {
    width: 100%;
    display: flex;
    justify-content: space-between;
    min-width: 0;
    gap: 4px;
  }
  .input-tabs {
    min-width: 0;
    display: flex;
  }
  .input-tab {
    padding: 6px 8px;
    min-height: 44px;
    font-size: 11px;
  }
  .pane-head-actions .button {
    min-height: 44px;
  }
  .pane-head-actions .icon-button {
    min-width: 44px;
    width: 44px;
    padding: 4px;
  }
  .wrap-toggle {
    font-size: 10px;
    padding: 4px;
  }
  .document-toolbar {
    min-height: 52px;
    padding: 4px;
    gap: 4px;
  }
  .document-edit-actions > .button {
    display: none;
  }
  .insert-label {
    display: none;
  }
  .insert-menu > .button {
    box-sizing: border-box;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }
  .document-toolbar .page-navigator {
    gap: 0;
  }
  .document-toolbar .page-navigator button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 8px;
  }
  .document-toolbar .page-number {
    width: 40px;
    min-height: 44px;
  }
  .document-toolbar .page-total {
    min-width: 22px;
  }
  .document-toolbar .zoom-select {
    min-height: 44px;
    width: 78px;
    padding: 4px;
  }
  .document-toolbar #documentStats {
    display: none;
  }
  .preview-body {
    min-height: 0;
    padding: 12px 8px 24px;
    overscroll-behavior: contain;
  }
  .word-toolbar {
    padding: 5px 7px;
    gap: 5px;
    flex-wrap: nowrap;
    max-height: 58px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
  }
  .word-toolbar > * {
    flex-shrink: 0;
  }
  .word-toolbar .button,
  .word-toolbar select,
  #wordColor {
    min-height: 44px;
    height: 44px;
  }
  .word-toolbar .icon-button {
    min-width: 44px;
    width: 44px;
  }
  .workspace-side-head .button.icon-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  .workspace-side-head {
    min-height: 52px;
  }
  .file-entry,
  .file-entry .file-row {
    min-height: 44px;
  }
  .file-menu-button {
    min-height: 44px;
  }
  .why-content {
    padding: 22px 16px 32px;
  }
  .why-lede {
    font-size: 14px;
    line-height: 1.65;
  }
  .modal {
    max-height: calc(100dvh - 32px);
    overflow: auto;
  }
  .pdf-proof-head {
    flex-wrap: wrap;
    padding: 8px;
  }
  .pdf-proof-head h2 {
    font-size: 17px;
  }
  .proof-navigation {
    flex-wrap: wrap;
  }
  .pdf-proof-head .button {
    min-height: 44px;
  }

  .pane-head-actions .wrap-toggle,
  .input-tab {
    min-width: 44px;
  }
  .editor-foot .button,
  .folder-row,
  .outline-item,
  .file-action-menu button {
    min-height: 44px;
  }
  .paper-size-select,
  .page-navigator .icon-button {
    min-height: 44px;
    min-width: 44px;
  }
  .main.files-hidden .workspace-sidebar {
    display: none;
  }
  .top-actions .export-main {
    border-radius: 22px;
  }
  body[data-appearance="apple"] .top-actions .export-main {
    border-radius: 8px;
  }
}
@media (max-width: 420px) {
  .topbar {
    padding: 6px;
    gap: 3px;
  }
  .brand {
    font-size: 16px;
  }
  .top-actions {
    gap: 1px;
  }
  .export-caret {
    width: 20px;
    min-width: 20px;
  }

  #inspectPdfButton {
    font-size: 10px;
    padding: 4px 6px;
    margin-left: 0;
  }
  .input-tab {
    padding: 6px;
    font-size: 10px;
  }

  .walkthrough-forms {
    grid-template-columns: minmax(0, 1fr);
  }
  .player-heading,
  .walkthrough-stage {
    padding: 12px;
  }
  .player-controls {
    flex-wrap: wrap;
    gap: 8px;
  }
}
@media print {
  .mobile-workspace-bar,
  .secondary-actions,
  .topbar {
    display: none !important;
  }
}

/* Document gestures are local to these scroll regions. Browser zoom remains available elsewhere. */
.preview-body,
.pdf-proof-pages {
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
}
.comparison-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.comparison-tabs [role="tab"] {
  padding: 9px 12px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ui-surface);
  color: var(--ui-muted);
  cursor: pointer;
}
.comparison-tabs [aria-selected="true"] {
  background: var(--ui-selected);
  color: var(--ui-primary);
  border-color: var(--ui-primary);
}
.comparison-tabs [role="tab"]:focus-visible {
  outline: 2px solid var(--ui-primary);
  outline-offset: 2px;
}
.walkthrough-file a {
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
.walkthrough-file a:hover {
  text-decoration: underline;
}
@media (max-width: 1100px) {
  .top-actions #headerImportButton .action-label,
  .top-actions #exportButton .action-label {
    display: none;
  }
  .top-actions #headerImportButton,
  .top-actions #exportButton {
    width: 44px;
    min-width: 44px;
    padding: 8px;
  }
}
@media (max-width: 900px) {
  .compile-actions {
    gap: 2px;
  }
  .compile-actions #compileButton,
  .compile-actions #reportBugButton,
  .compile-actions .compile-guide-summary {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 8px;
  }
  .document-primary-controls #inspectPdfButton {
    width: 44px;
    min-width: 44px;
    padding: 8px;
  }
  .document-primary-controls #inspectPdfButton .action-label {
    display: none;
  }
  .preview-body {
    overflow: auto;
    scrollbar-gutter: auto;
  }
  .comparison-tabs [role="tab"] {
    min-height: 44px;
  }
}
@media (max-width: 700px) {
  .player-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .walkthrough-forms {
    grid-template-columns: minmax(0, 1fr);
  }
  .walkthrough-form-fields {
    height: 220px;
  }
}
@media (max-width: 600px) {
  .topbar {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    grid-template-rows: 44px 44px;
    height: auto;
    min-height: 100px;
    padding: 6px 8px;
    gap: 4px;
  }
  .brand-wrap {
    grid-column: 1;
    grid-row: 1;
  }
  .top-actions {
    grid-column: 1/-1;
    grid-row: 2;
    box-sizing: border-box;
    width: 100%;
    justify-content: center;
    gap: 12px;
  }
  .compile-actions {
    gap: 12px;
  }
  .topbar .brand {
    font-size: 18px;
  }
  .brand-wrap {
    gap: 8px;
  }
  .mobile-workspace-bar {
    gap: 4px;
    padding: 0 0 4px;
  }
  .mobile-workspace-bar .segmented {
    flex: 0 1 auto;
    margin: 0 auto;
  }
  .mobile-workspace-bar .layout-choice {
    padding: 7px 8px;
  }
  .mobile-workspace-bar > .button {
    flex: 0 0 44px;
  }

  .top-actions #moreActionsButton {
    position: absolute;
    top: 6px;
    right: 8px;
  }
  .secondary-actions {
    top: 54px;
  }
  .compile-actions .compile-guide-popover {
    top: 104px;
  }
}

.comparison-mistakes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.comparison-mistakes h4 {
  margin: 8px 0;
}
.comparison-mistakes ul {
  padding-left: 18px;
}
@media (max-width: 600px) {
  .comparison-mistakes {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }
}

@media (max-width: 900px) {
  .file-entry {
    grid-template-columns: minmax(0, 1fr) 44px;
  }
  .file-menu-button {
    width: 44px;
    height: 44px;
  }
  .secondary-actions #appearanceCycle {
    width: 44px;
    min-width: 44px;
  }
  .secondary-actions {
    max-height: calc(var(--app-height, 100dvh) - 70px);
  }
  #pageNumber {
    min-width: 44px;
    min-height: 44px;
  }
  .document-edit-popover input,
  .document-edit-popover select {
    min-height: 44px;
    min-width: 44px;
  }
}

/* The scroll surface follows display scale without changing document layout. */
.document-zoom-surface {
  overflow: clip;
  position: relative;
  margin: 0 auto;
  flex: 0 0 auto;
}
.document-zoom-surface > .preview-pages,
.document-zoom-surface > .pdf-proof-stack {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  transform-origin: 0 0;
}

.editor-pane {
  container-type: inline-size;
}
.insert-options[popover] {
  position: fixed;
  inset: auto;
  margin: 0;
  width: 170px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  color: var(--ink);
}
.insert-options[popover]:not(:popover-open) {
  display: none;
}
.insert-options[popover]:popover-open {
  display: flex;
}
