.step-video {
  display:block;
  width:100%;
  max-height:480px;
  margin:18px 0;
  background:#101e2c;
  border-radius:12px;
}
.step-media-controls {
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:18px;
}
.step-media-controls button { min-height:44px; }
.step-media-controls small { width:100%; color:#748397; line-height:1.6; }
.photo-editor {
  width:min(1000px,96vw);
  max-height:94dvh;
  padding:0;
  border:0;
  border-radius:16px;
  background:#fff;
  color:#203247;
}
.photo-editor::backdrop { background:rgba(12,26,42,.78); }
.photo-editor header,.photo-editor footer {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 18px;
  background:#fff;
}
.editor-tools {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  padding:12px 18px;
  border-top:1px solid #e2e8f0;
  border-bottom:1px solid #e2e8f0;
}
.editor-tools button {
  background:#edf2f8;
  color:#365779;
  min-height:44px;
}
.editor-tools button.selected { background:#173b5b; color:white; }
.editor-tools label { margin:0; font-size:12px; }
.editor-tools input { margin:4px 0 0; }
.editor-tools input[type=color] { width:60px; height:36px; padding:3px; }
.editor-tools input[data-caption] { width:190px; }
.editor-hint { padding:0 18px; color:#748397; font-size:12px; }
.editor-stage { padding:12px; background:#e9eef4; text-align:center; }
.editor-stage canvas {
  display:block;
  width:auto;
  max-width:100%;
  height:auto;
  max-height:50dvh;
  margin:auto;
  touch-action:none;
}
.photo-editor footer span { font-size:12px; }

@media(max-width:800px) {
  html { scroll-padding-top:18px; }
  body { width:100%; }
  input,textarea,select { font-size:16px !important; }
  button,.pdf-link,.library-footer a { min-height:44px; }
  #workspace aside { position:static; width:100%; height:auto; }
  #workspace aside .brand { height:70px; min-height:70px; }
  #workspace aside .brand-logo { width:80px; height:50px; }
  #workspace aside .app-name { display:none; }
  #workspace nav {
    display:flex;
    overflow-x:auto;
    gap:8px;
    padding:10px 12px;
  }
  #workspace nav button {
    flex:0 0 auto;
    min-height:44px;
    padding:10px 14px;
    font-size:12px;
  }
  #workspace nav button[hidden] { display:none; }
  #workspace main { margin-left:0; width:100%; }
  #workspace main > header {
    height:auto;
    min-height:72px;
    padding:18px 16px;
  }
  #pageTitle { font-size:22px; overflow-wrap:anywhere; }
  #content { padding:16px 12px 40px; }
  .form-card,.step { padding:18px 14px; border-radius:12px; }
  .fields { display:grid; grid-template-columns:1fr; }
  .toolbar { flex-wrap:wrap; }
  .toolbar input { width:100%; min-width:0; }
  .actions { flex-wrap:wrap; gap:8px; }
  .actions button { flex:1 1 140px; }
  .actions .badge { width:100%; }
  .step-top { display:flex; flex-direction:column; align-items:stretch; }
  .step-tools { display:flex; gap:8px; flex-wrap:wrap; }
  .step-tools button { min-width:44px; }
  .step-media-controls { display:grid; grid-template-columns:1fr 1fr; }
  .step-media-controls small { grid-column:1/-1; }
  .step .photo { width:100%; max-height:440px; object-fit:contain; }
  .instruction { font-size:16px; line-height:1.65; }
  .dashboard-stats { grid-template-columns:1fr; }
  .dashboard-row { text-align:left; flex-wrap:wrap; }
  .login { padding:20px 14px; }
  .login-card { padding:28px 20px; }
  main.public-main { padding:18px 12px; width:100%; }
  .public-header { padding:12px 16px; }
  .public-header img { width:80px; height:50px; }
  .public-header span { font-size:11px; }
  .grid { grid-template-columns:1fr; }
  #message { right:12px; bottom:12px; max-width:calc(100vw - 24px); }
  .photo-editor {
    width:100%;
    max-width:100%;
    max-height:100dvh;
    border-radius:0;
    margin:auto;
  }
  .photo-editor header,.photo-editor footer { padding:12px; }
  .editor-tools { padding:10px 12px; }
  .editor-tools button { font-size:12px; padding:10px 12px; }
  .editor-stage canvas { max-height:44dvh; }
  .library-hero h1 { font-size:clamp(30px,9vw,40px); }
  .library-brand-name { font-size:11px; }
}

/* Menu mobile vertical */
@media (max-width: 800px) {
  #workspace nav {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
    gap: 6px;
    padding: 12px;
    width: 100%;
    box-sizing: border-box;
  }

  #workspace nav button {
    width: 100% !important;
    flex: none !important;
    justify-content: flex-start !important;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 14px;
    text-align: left;
  }

  #workspace nav button[hidden] {
    display: none !important;
  }
}

@media (max-width: 800px) {
  #workspace aside .brand {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  #workspace nav {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    overflow: visible !important;
    gap: 6px;
    padding: 12px;
    width: 100%;
    box-sizing: border-box;
  }

  #workspace nav button {
    width: 100% !important;
    flex: none !important;
    justify-content: center !important;
    text-align: center !important;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 14px;
  }

  #workspace nav button[hidden] {
    display: none !important;
  }
}

/* LIBRARY DELETE CONTROLS */
.library-delete-bar {
  display:flex; align-items:center; flex-wrap:wrap; gap:14px;
  padding:16px; margin-bottom:20px; background:white;
  border:1px solid #dce4ee; border-radius:12px;
}
.library-delete-bar label {
  display:flex; align-items:center; gap:8px; margin:0;
}
.library-delete-bar input,.library-card-select input {
  width:22px; height:22px; margin:0; padding:0; accent-color:#173b5b;
}
.library-delete-bar > span { font-size:13px; color:#748397; }
.library-delete-bar button {
  display:flex; align-items:center; gap:8px; margin-left:auto;
  min-height:44px; background:#fff0f0; color:#b42332;
}
.library-delete-bar button:disabled { opacity:.45; cursor:default; }
.library-delete-bar svg,.library-trash svg { width:20px; height:20px; }
.library-card-controls {
  position:absolute; top:12px; left:12px; right:12px; z-index:10;
  display:flex; justify-content:space-between; pointer-events:none;
}
.library-card-select,.card.sop-card .library-trash {
  display:grid; place-items:center; width:44px; height:44px;
  padding:0; margin:0; border:1px solid #dce4ee; border-radius:12px;
  background:white; box-shadow:0 3px 12px #172b4420;
  pointer-events:auto; cursor:pointer;
}
.card.sop-card .library-trash { color:#b42332; align-self:auto; }
.card.sop-card .library-trash:hover { background:#fff0f0; }
.card.sop-card.is-selected { outline:3px solid #245477; outline-offset:2px; }
#workspace .sop-card .sop-cover .badge { top:auto; bottom:12px; }
@media(max-width:800px) {
  .library-delete-bar button { width:100%; margin-left:0; justify-content:center; }
}

/* BEGIN PORTAL MENU APPEARANCE */
#workspace aside {
  background:#1d3044;
  color:#b8c3cf;
}
#workspace aside .brand {
  display:flex;
  justify-content:center;
  align-items:center;
  border-bottom:1px solid rgba(255,255,255,.07);
}
#workspace aside .brand-logo {
  width:80px;
  height:50px;
  object-fit:contain;
}
#workspace nav {
  display:flex !important;
  flex-direction:column !important;
  align-items:stretch !important;
  flex-wrap:nowrap !important;
  overflow:visible !important;
  width:100%;
  padding:12px 14px;
  gap:4px;
  box-sizing:border-box;
}
#workspace nav button,
#workspace nav #libraryButton {
  display:flex !important;
  align-items:center;
  justify-content:flex-start !important;
  flex:none !important;
  width:100% !important;
  min-height:48px;
  padding:13px 14px;
  gap:14px;
  margin:0;
  border:0;
  border-radius:8px;
  background:transparent;
  color:#b8c3cf;
  text-align:left !important;
  font-family:Helvetica,"Helvetica Neue",Arial,sans-serif;
  font-size:14px;
  font-weight:600;
  line-height:1.4;
  box-shadow:none;
}
#workspace nav button .nav-icon {
  width:20px;
  height:20px;
  flex:0 0 20px;
}
#workspace nav button:hover {
  background:rgba(255,255,255,.06);
  color:#fff;
}
#workspace nav button.active {
  background:#2b4259;
  color:#fff;
}
#workspace nav button:focus-visible {
  outline:2px solid #8eb9df;
  outline-offset:2px;
}
#workspace nav button[hidden],
#workspace nav #libraryButton[hidden] {
  display:none !important;
}
@media(max-width:800px) {
  #workspace aside {
    position:static;
    width:100%;
    height:auto;
  }
  #workspace nav {
    max-width:440px;
    margin:0 auto;
    padding:10px 14px 16px;
  }
}
/* END PORTAL MENU APPEARANCE */

/* SOP ROLE CONTROLS */
#workspace button[hidden] { display:none !important; }
.sop-order-controls {
  display:flex; gap:8px; padding:0 16px 16px;
}
.card.sop-card .sop-order-controls button {
  flex:1; min-height:44px; margin:0; padding:10px 8px;
  background:#edf2f8; color:#365779; font-size:12px;
}
