:root {
  --green: #4f5d3c;
  --green-deep: #3a4530;
  --brass: #b3944e;
  --brass-soft: #c9b27a;
  --ink: #1d211b;
  --ink-soft: #3f453b;
  --mute: #6b7166;
  --paper: #f3f0e8;
  --concrete: #e4e0d6;
  --line: #cfc9bb;
  --white: #faf8f3;
  --danger: #8b3a2f;
  --pen: #c2410c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  font-size: 16px;
}

a { color: var(--green-deep); }

.tb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 0 16px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
}

.brand img { width: 28px; height: 28px; }

.tb-bar-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.tb-bar-meta .btn {
  flex-shrink: 0;
}

.tb-bar-meta strong {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-bar-meta .meta {
  font-size: 13px;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-pill {
  flex-shrink: 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--green-deep);
  background: #d7ddcc;
  padding: 4px 8px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 2px;
}

.tag:hover {
  border-color: var(--green);
  color: var(--green-deep);
}

.tag.is-on {
  background: #d7ddcc;
  color: var(--green-deep);
  border-color: #c5cdb8;
}

.tag-add {
  margin-top: 12px;
}

.tag-add .row {
  margin-top: 0;
  align-items: center;
}

.tag-add input[type="text"] {
  flex: 1 1 12rem;
  width: auto;
  min-width: 0;
}

.desk-tabs {
  margin: 0 0 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  max-width: 100%;
  min-width: 0;
}

.desk-tabs .tag.is-on {
  background: #f3efe3;
  color: var(--green-deep);
  border-color: var(--brass);
  box-shadow: inset 0 -2px 0 var(--brass);
}

.desk-tabs .tag:hover {
  border-color: var(--brass);
  color: var(--green-deep);
}

#tree-panel,
#job-files-panel {
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.desk-tree-scroll {
  overflow: visible;
  max-width: 100%;
  min-width: 0;
}

.desk-tree {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  min-width: 0;
  max-width: 100%;
}

.desk-tree ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 1px solid var(--line);
  min-width: 0;
}

.desk-tree details[open] > ul {
  display: block;
}

.desk-tree > li + li {
  margin-top: 6px;
}

.desk-tree li {
  margin: 0;
  padding: 0;
  min-width: 0;
}

.desk-tree details {
  display: block;
  margin: 0;
  min-width: 0;
}

.desk-tree summary {
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 2px;
  color: var(--ink);
  min-width: 0;
}

.desk-tree summary::-webkit-details-marker {
  display: none;
}

.desk-tree summary::before {
  content: "";
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--brass);
  border-bottom: 2px solid var(--brass);
  transform: rotate(-45deg);
  margin: 8px 2px 0 4px;
  transition: transform 0.12s ease;
}

.desk-tree details[open] > summary::before {
  transform: rotate(45deg);
  margin-top: 10px;
}

.desk-tree summary:hover {
  background: var(--concrete);
}

.desk-tree .tree-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.desk-tree .tree-label {
  flex: 1 1 8rem;
  min-width: 0;
  font-weight: 600;
  font-size: 14px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.desk-tree .tree-meta {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--mute);
  font-weight: 500;
}

.desk-tree .tree-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  position: relative;
  z-index: 1;
}

.desk-tree .tree-actions .btn {
  padding: 5px 10px;
  font-size: 12px;
  flex: 0 0 auto;
}

.desk-tree .tree-actions .card-menu {
  flex: 0 0 auto;
}

.desk-tree li:has(.card-menu[open]),
.desk-tree details:has(> summary .card-menu[open]),
.desk-tree .tree-file:has(.card-menu[open]) {
  position: relative;
  z-index: 40;
}

.desk-tree .tree-file {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 4px 6px 18px;
  min-width: 0;
}

.desk-tree .tree-file a.tree-label {
  color: var(--green-deep);
  text-decoration: none;
  font-weight: 500;
}

.desk-tree .tree-file a.tree-label:hover {
  color: var(--brass);
  text-decoration: underline;
}

.desk-tree .tree-empty {
  padding: 6px 4px 6px 18px;
  font-size: 13px;
  color: var(--mute);
}

.desk-tree .tree-kind-folder summary .tree-label::after {
  content: " · folder";
  color: var(--mute);
  font-weight: 500;
  font-size: 12px;
}

@media (max-width: 420px) {
  .desk-tree ul {
    padding-left: 10px;
  }
  .desk-tree .tree-file,
  .desk-tree .tree-empty {
    padding-left: 12px;
  }
  .desk-tree .tree-actions {
    flex: 1 1 100%;
    /* Keep ··· on the trailing edge so right:0 menus stay in-viewport */
    justify-content: flex-end;
  }
  .desk-tree .tree-actions .btn {
    padding: 5px 8px;
  }
  .files-head .view-switch,
  .jobs-head-actions .view-switch {
    flex: 1 1 100%;
  }
  .client-filter {
    flex: 1 1 100%;
  }
  .client-filter select {
    flex: 1 1 auto;
    max-width: 100%;
  }
  .desk-tabs {
    gap: 6px;
  }
  .files-head h2,
  .files-head .files-heading-label {
    flex: 1 1 100%;
  }
}

#jobs-heading,
#clients-heading {
  margin-top: 0;
}

.jobs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.jobs-head h2 {
  margin: 0;
}

.jobs-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.jobs-head-actions .btn {
  padding: 7px 12px;
  font-size: 13px;
}

.client-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.client-filter-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
  white-space: nowrap;
}

.client-filter select {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 6px 10px;
  min-width: 0;
  max-width: min(220px, 100%);
}

.client-filter select:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 2px var(--brass-soft);
}

#clients-pane .client-row .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#clients-pane .client-row .actions .btn {
  padding: 7px 12px;
  font-size: 13px;
}

.tag-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tag-tools .btn {
  padding: 7px 12px;
  font-size: 13px;
}

.danger-panel {
  border-color: var(--danger);
  background: var(--white);
  box-shadow: inset 3px 0 0 var(--danger);
}

.wrap {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
  min-width: 0;
  max-width: 100%;
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 600;
  margin-bottom: 10px;
}

h1 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
}

.lede {
  margin-top: 10px;
  color: var(--ink-soft);
  max-width: 42em;
}

.panel {
  margin-top: 24px;
  background: var(--white);
  border: 1px solid var(--line);
  padding: 22px;
  min-width: 0;
  max-width: 100%;
}

#desk .panel {
  margin-top: 0;
}

.panel h2 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  font-size: 22px;
  margin-bottom: 8px;
}

.steps {
  margin: 12px 0 18px;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 14px;
}

.steps li { margin: 8px 0; }
.steps a { font-weight: 500; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 14px 0 6px;
}

/* Fields: paper wells, brass focus — distinct from function buttons */
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 2px;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 2px var(--brass-soft);
  background: var(--white);
}

input[readonly] {
  color: var(--mute);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* Create / primary commit — solid green */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
  color: var(--white);
  text-decoration: none;
  border: 1px solid var(--green);
  padding: 11px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 2px;
}

.btn:hover { background: var(--green-deep); border-color: var(--green-deep); }
.btn:disabled { opacity: 0.55; cursor: wait; }

/* Navigate / open / copy — brass chrome (not create, not danger) */
.btn-nav {
  background: var(--white);
  color: var(--green-deep);
  border: 1px solid var(--brass);
}

.btn-nav:hover {
  background: var(--concrete);
  border-color: var(--brass);
  color: var(--ink);
}

/* Secondary manage / cancel — quiet ink line */
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  border-color: var(--mute);
  color: var(--ink);
  background: var(--paper);
}

/* Danger — rust outline, soft fill on hover */
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: var(--concrete);
  border-color: var(--danger);
  color: var(--danger);
}

.drop {
  margin-top: 22px;
  border: 1px dashed var(--brass-soft);
  background: var(--white);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
}

.drop.over {
  background: #efe8d4;
  border-color: var(--brass);
}

.drop strong {
  display: block;
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
  font-weight: 500;
}

.drop span {
  display: block;
  margin-top: 6px;
  color: var(--mute);
  font-size: 14px;
}

.flash {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: #d7ddcc;
}

.flash.err {
  background: #f3e4df;
  border-color: #e0c4bc;
  color: var(--danger);
}

.flash code,
.cors {
  display: block;
  margin-top: 8px;
  font-family: "IBM Plex Sans", ui-monospace, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  background: var(--paper);
  padding: 10px 12px;
  border: 1px solid var(--line);
  color: var(--ink);
}

.files {
  list-style: none;
  margin-top: 22px;
  border: 1px solid var(--line);
  background: var(--white);
}

.files li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.files li:first-child { border-top: 0; }

.files .name {
  font-weight: 600;
  font-size: 14px;
}

.files .meta {
  font-size: 12px;
  color: var(--mute);
}

.file-thumb {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--concrete);
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-thumb.is-placeholder {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--mute);
  text-transform: uppercase;
  padding: 0 2px;
  text-align: center;
  line-height: 1.1;
}

.file-thumb.is-pdf {
  color: var(--green-deep);
  background: #e8eadf;
  border-color: var(--line);
}

.file-thumb.is-previewable {
  cursor: pointer;
}

.file-thumb.is-previewable:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.file-thumb-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
}

.file-thumb-overlay.hidden {
  display: none;
}

.file-thumb-overlay-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(29, 33, 27, 0.72);
  cursor: pointer;
}

.file-thumb-overlay-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: 0 16px 40px rgba(29, 33, 27, 0.28);
  box-sizing: border-box;
}

.file-thumb-overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.file-thumb-overlay-title {
  font-family: Fraunces, Georgia, serif;
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
  flex: 1 1 140px;
}

.file-thumb-overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.file-thumb-overlay-stage {
  flex: 1 1 auto;
  min-height: 180px;
  max-height: min(72vh, 760px);
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--concrete);
  border: 1px solid var(--line);
}

.file-thumb-overlay-stage img {
  display: block;
  max-width: 100%;
  max-height: min(70vh, 720px);
  width: auto;
  height: auto;
  object-fit: contain;
}

.file-thumb-overlay-pdf {
  width: 100%;
  height: min(68vh, 700px);
  min-height: 220px;
  border: 0;
  background: var(--white);
}


.files-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  min-width: 0;
  max-width: 100%;
}

.panel > .files-head:first-child {
  margin-top: 0;
}

.files-head + .lede {
  margin-top: 8px;
}

.files-head h2,
.files-head .files-heading-label {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
}

.files-head .files-heading-label {
  font-size: 18px;
}

.files-head .view-switch .btn {
  padding: 7px 12px;
  font-size: 13px;
}

.view-switch .btn-nav.is-on {
  background: #d7ddcc;
  color: var(--green-deep);
  border-color: var(--brass);
}

.files-head + .files,
.files-head ~ .files {
  margin-top: 12px;
}

.files.is-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 0;
}

.files.is-thumbs li {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

.files.is-thumbs li:first-child {
  border-top: 0;
}

.files.is-thumbs .file-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--white);
  text-decoration: none;
  color: inherit;
  border-radius: 2px;
  min-height: 100%;
  box-sizing: border-box;
}

.files.is-thumbs .file-tile:hover {
  border-color: var(--brass);
  background: var(--paper);
}

.files.is-thumbs .file-thumb {
  width: 100%;
  height: 96px;
}

.files.is-thumbs .file-thumb.is-placeholder {
  font-size: 14px;
  letter-spacing: 0.08em;
}

.files.is-thumbs .name {
  font-size: 13px;
  line-height: 1.25;
  word-break: break-word;
}

.files.is-thumbs li.empty {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  background: var(--white);
  padding: 16px 14px;
}

.files .file-info {
  min-width: 0;
  flex: 1 1 auto;
}

.files .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
  justify-content: flex-end;
}

/* Jobs list: row/name opens; ··· holds secondary actions */
#jobs.desk-files,
.files.desk-files {
  overflow: visible;
}

.files li.job-row {
  cursor: pointer;
  position: relative;
  overflow: visible;
  z-index: 0;
  transition: background 0.12s ease;
}

.files li.job-row:hover {
  background: var(--paper);
}

.files li.job-row:hover .name {
  color: var(--green-deep);
}

.files li.job-row:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: -2px;
}

.files li.job-row:has(.card-menu[open]) {
  z-index: 20;
  background: var(--paper);
}

.files li.job-row .actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-self: center;
}

.desk-files .actions .btn {
  padding: 8px 10px;
  font-size: 13px;
}

#job-files .btn-nav {
  background: var(--paper);
}

#job-files .btn-nav:hover {
  background: var(--concrete);
}

#archived-jobs {
  margin-top: 12px;
}

#trash-items {
  margin-top: 14px;
}

.files .empty {
  padding: 16px 14px;
  color: var(--mute);
  font-size: 14px;
}

#admin-desk .panel + .panel,
#shop-desk .panel + .panel {
  margin-top: 24px;
}

.status {
  margin-top: 28px;
  font-size: 13px;
  color: var(--mute);
}

.hidden { display: none !important; }

.preview-wrap {
  height: calc(100dvh - 52px);
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.preview-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--ink);
}

.preview-note {
  padding: 28px 24px;
  max-width: 32em;
  color: var(--white);
  text-align: center;
}

@media (max-width: 640px) {
  .files li {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .files .file-info {
    min-width: 0;
    flex: 1 1 auto;
  }
  .files li > :not(.actions):not(.file-thumb) {
    min-width: 0;
    flex: 1 1 auto;
  }
  .file-thumb {
    width: 40px;
    height: 40px;
  }
  .files.is-thumbs {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 10px;
  }
  .files.is-thumbs .file-thumb {
    width: 100%;
    height: 84px;
  }
  .file-thumb-overlay {
    padding: 8px;
  }
  .file-thumb-overlay-panel {
    width: min(100%, 390px);
    max-height: 94vh;
    padding: 10px;
  }
  .file-thumb-overlay-title {
    font-size: 16px;
  }
  .file-thumb-overlay-pdf {
    height: min(62vh, 520px);
    min-height: 200px;
  }
  /* File rows still wrap many buttons; job rows only have ··· */
  .files .actions {
    flex: 1 1 100%;
    max-width: 100%;
    justify-content: flex-start;
  }
  .files li.job-row .actions {
    flex: 0 0 auto;
    max-width: none;
    justify-content: flex-end;
  }
  .tb-bar-meta strong { max-width: 42vw; }
}

.view-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

#job-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  overflow: visible;
  position: relative;
}

#job-cards.hidden {
  display: none !important;
}

#job-cards .empty-copy {
  flex: 1 1 100%;
  color: var(--mute);
  font-size: 14px;
  padding: 16px 0;
}

.job-card {
  flex: 1 1 168px;
  width: 168px;
  max-width: 240px;
  min-width: 168px;
  border: 1px solid var(--line);
  background: var(--white);
  /* visible so ··· action menu can escape the card */
  overflow: visible;
  position: relative;
  z-index: 0;
}

.job-card:has(.card-menu[open]) {
  z-index: 20;
}

.job-card-cover {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  padding-top: 75%;
  border: 0;
  background: #e8e4d8;
  cursor: pointer;
  overflow: hidden;
}

.job-card-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.job-card-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  position: relative;
  z-index: 1;
}

.job-card-bar .name {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  cursor: pointer;
  flex: 1 1 auto;
}

.job-card-bar .name:hover {
  color: var(--green-deep);
}

.job-card-bar .name:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: 2px;
}

.card-menu {
  position: relative;
  flex-shrink: 0;
}

.card-menu summary {
  list-style: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--mute);
}

.card-menu summary::-webkit-details-marker { display: none; }

.card-menu summary:hover {
  color: var(--ink);
  background: var(--concrete);
}

.card-menu summary:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
  color: var(--ink);
}

.card-menu[open] summary {
  color: var(--ink);
  background: var(--concrete);
}

.card-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 148px;
  max-width: min(220px, 80vw);
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(29, 33, 27, 0.14);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-menu-list .btn {
  width: 100%;
  justify-content: flex-start;
  padding: 7px 10px;
  font-size: 13px;
}

@media (max-width: 420px) {
  .job-card {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* ~390px phones: keep ··· menu on-screen and above neighbors */
  .card-menu-list {
    right: 0;
    left: auto;
    min-width: 160px;
    max-width: min(220px, calc(100vw - 24px));
  }

  /* Tree: ··· sits on the trailing edge after wrap; pin menu to that edge */
  .desk-tree .tree-actions .card-menu-list {
    right: 0;
    left: auto;
    max-width: min(220px, calc(100vw - 24px));
  }

  #tree-panel,
  .desk-tree-scroll,
  .desk-tree,
  .desk-tree li,
  .desk-tree details,
  .desk-tree .tree-file,
  .desk-tree .tree-actions {
    overflow: visible;
  }

  .files li.job-row:has(.card-menu[open]),
  .job-card:has(.card-menu[open]),
  .desk-tree li:has(.card-menu[open]),
  .desk-tree details:has(> summary .card-menu[open]),
  .desk-tree .tree-file:has(.card-menu[open]) {
    z-index: 40;
  }
}


/* Phase 2 annotator */
.view-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.view-page .tb-bar {
  flex-shrink: 0;
}

.annot-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.annot-tools.hidden {
  display: none !important;
}

.annot-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 9px;
  min-height: 34px;
}

.annot-tool-icon {
  display: block;
  flex-shrink: 0;
}

.annot-tool-label {
  font-size: 13px;
  line-height: 1;
}

.annot-tools .btn.is-active {
  border-color: var(--brass);
  color: var(--green-deep);
  background: var(--concrete);
}

#annot-undo:disabled {
  cursor: default;
  opacity: 0.45;
}


.annot-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.annot-preview {
  flex: 1;
  height: auto;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  gap: 16px;
  flex-direction: column;
}

.annot-notes-panel {
  width: min(300px, 38vw);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-left: 1px solid var(--line);
  min-height: 0;
}

.annot-notes-panel.hidden {
  display: none !important;
}

.annot-notes-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.annot-notes-head strong {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}

.annot-notes-head .meta {
  font-size: 12px;
  color: var(--mute);
  margin-right: auto;
}

.annot-notes-close {
  display: none;
  padding: 4px 8px;
  font-size: 12px;
}

.annot-notes-list {
  flex: 1;
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.annot-notes-empty {
  margin: 16px 12px;
  font-size: 13px;
  color: var(--mute);
  line-height: 1.4;
}

.annot-notes-empty.hidden {
  display: none !important;
}

.annot-notes-list.hidden {
  display: none !important;
}

.annot-note-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
}

.annot-note-row:hover,
.annot-note-row:focus-within {
  border-color: var(--brass);
  outline: none;
  box-shadow: 0 0 0 2px var(--brass-soft);
}

.annot-note-row.is-active {
  border-color: var(--brass);
  background: var(--concrete);
}

.annot-note-row-main {
  flex: 1;
  min-width: 0;
  display: block;
  text-align: left;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  padding: 10px 8px 10px 10px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.annot-note-row-main:focus-visible {
  outline: none;
}

.annot-note-remove {
  flex-shrink: 0;
  align-self: center;
  margin: 6px 8px 6px 0;
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.annot-note-row .annot-note-page {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 4px;
}

.annot-note-row .annot-note-text {
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.annot-note-row.is-blank .annot-note-text {
  color: var(--mute);
  font-style: italic;
}

.annot-note.is-focus .annot-cross span {
  box-shadow: 0 0 0 3px var(--brass-soft);
}

.annot-note.is-focus .annot-bubble {
  border-color: var(--brass);
  box-shadow: 0 0 0 2px var(--brass-soft), 0 10px 24px rgba(29, 33, 27, 0.18);
}

.annot-preview[data-tool="pen"] .annot-draw {
  cursor: crosshair;
  touch-action: none;
}

.annot-preview[data-tool="navigate"] .annot-draw {
  cursor: grab;
  touch-action: pan-x pan-y;
  pointer-events: none;
}

.annot-preview[data-tool="navigate"] {
  cursor: grab;
}

.annot-preview[data-tool="note"] .annot-draw,
.annot-preview[data-tool="note"] .annot-page {
  cursor: cell;
}

.annot-page {
  position: relative;
  margin: 0 auto;
  background: var(--white);
  box-shadow: 0 8px 28px rgba(29, 33, 27, 0.35);
  max-width: 100%;
}

.annot-base,
.annot-draw {
  display: block;
  max-width: 100%;
  height: auto;
}

.annot-draw {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

.annot-notes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.annot-note {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  z-index: 2;
}

.annot-cross {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  position: relative;
}

.annot-cross span {
  position: absolute;
  background: var(--danger);
  left: 50%;
  top: 50%;
}

.annot-cross span:first-child {
  width: 18px;
  height: 2px;
  transform: translate(-50%, -50%);
}

.annot-cross span:last-child {
  width: 2px;
  height: 18px;
  transform: translate(-50%, -50%);
}

.annot-bubble {
  display: none;
  position: absolute;
  left: 18px;
  top: 18px;
  width: min(220px, 70vw);
  background: var(--white);
  border: 1px solid var(--line);
  padding: 8px;
  box-shadow: 0 10px 24px rgba(29, 33, 27, 0.18);
}

.annot-note.is-open .annot-bubble {
  display: block;
}

.annot-bubble textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 8px;
  resize: vertical;
  min-height: 72px;
}

@media (max-width: 640px) {
  .view-page .tb-bar {
    flex-wrap: wrap;
    min-height: 0;
    padding: 8px 12px;
    gap: 8px;
  }

  .view-page .tb-bar-meta {
    width: 100%;
    justify-content: flex-start;
  }

  .annot-tool {
    padding: 7px 8px;
  }

  .annot-tool-label {
    font-size: 12px;
  }

  .annot-layout {
    flex-direction: column;
    position: relative;
  }

  .annot-preview {
    min-height: 0;
    flex: 1;
    padding: 8px;
  }

  .annot-notes-panel {
    width: 100%;
    max-height: min(42vh, 320px);
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .annot-notes-panel.is-drawer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8;
    max-height: min(52vh, 380px);
    box-shadow: 0 -8px 24px rgba(29, 33, 27, 0.18);
  }

  .annot-notes-close {
    display: inline-flex;
  }
}
