  :root {
    --bg: #111827;
    --surface: #1b2438;
    --surface2: #243044;
    --border: #2e3d55;
    --accent: #f59e0b;
    --accent2: #3b82f6;
    --danger: #ef4444;
    --text: #f1f5f9;
    --text2: #94a3b8;
    --text3: #64748b;
    --pin: #e53e3e;
    --radius: 14px;
    --sheet-radius: 22px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
  }

  * { box-sizing: border-box; margin: 0; padding: 0;
      -webkit-tap-highlight-color: transparent; }

  body {
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    display: flex;
    flex-direction: column;
  }

  /* Light copy-friction only for non-editable display areas.
     Editable controls remain fully selectable and usable. */
  body.copy-guard-enabled {
    -webkit-user-select: none;
    user-select: none;
  }
  body.copy-guard-enabled input,
  body.copy-guard-enabled textarea,
  body.copy-guard-enabled select,
  body.copy-guard-enabled option,
  body.copy-guard-enabled [contenteditable]:not([contenteditable="false"]),
  body.copy-guard-enabled [role="textbox"],
  body.copy-guard-enabled [data-allow-editing="true"] {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
  }

  body.ipad-mode {
    --radius: 16px;
    --sheet-radius: 26px;
  }
  body.ipad-mode #topbar {
    gap: 10px;
    padding: calc(var(--safe-top) + 12px) 18px 12px;
  }
  body.ipad-mode #drawing-bar {
    gap: 10px;
    padding: 10px 18px;
  }
  body.ipad-mode #bottom-toolbar {
    gap: 10px;
    padding: 12px 18px calc(var(--safe-bottom) + 12px);
  }
  body.ipad-mode #project-selector {
    height: 50px;
    font-size: 16px;
    border-radius: 12px;
  }
  body.ipad-mode .icon-btn {
    width: 50px;
    height: 50px;
    border-radius: 12px;
  }
  body.ipad-mode .drawing-tab {
    height: 42px;
    padding: 0 18px;
    font-size: 14px;
    border-radius: 10px;
  }
  body.ipad-mode #upload-pdf-btn {
    height: 42px;
    padding: 0 18px;
    font-size: 14px;
    border-radius: 10px;
  }
  body.ipad-mode #page-nav {
    border-radius: 12px;
  }
  body.ipad-mode #page-nav .icon-btn {
    width: 46px;
    height: 54px;
    font-size: 22px;
  }
  body.ipad-mode #page-info {
    min-width: 44px;
    height: 54px;
    font-size: 14px;
  }
  body.ipad-mode .tool-btn {
    height: 54px;
    font-size: 16px;
    border-radius: 14px;
  }
  body.ipad-mode #canvas-container {
    contain: layout paint;
  }
  body.ipad-mode .sheet-overlay {
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  body.ipad-mode .sheet {
    width: min(820px, calc(100vw - 48px));
    max-height: min(88dvh, 980px);
    border-radius: var(--sheet-radius);
    border: 1px solid var(--border);
    box-shadow: 0 24px 70px rgba(0,0,0,0.35);
    animation: ipadSheetIn 0.2s ease-out;
  }
  body.ipad-mode .sheet-footer {
    padding: 14px 18px 18px;
  }
  body.ipad-mode .modal {
    max-width: 680px;
    max-height: 86dvh;
  }
  body.ipad-mode .modal-body {
    padding: 18px;
  }
  body.ipad-mode #project-modal {
    max-width: min(1080px, calc(100vw - 56px));
    max-height: min(88dvh, 860px);
  }
  body.ipad-mode #project-modal-body {
    padding: 0;
    overflow: hidden;
  }
  body.ipad-mode #project-modal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
    min-height: min(72dvh, 760px);
  }
  body.ipad-mode #project-modal-main {
    padding: 22px 22px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.ipad-mode #project-modal-side {
    margin-top: 0;
    padding: 22px 22px 18px;
    border-top: none;
    border-left: 1px solid var(--border);
    background:
      linear-gradient(180deg, rgba(59,130,246,0.08), rgba(59,130,246,0.02) 120px),
      var(--surface);
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  body.ipad-mode #project-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 2px;
    -webkit-overflow-scrolling: touch;
  }
  body.ipad-mode.ipad-landscape #drawing-bar {
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px 12px;
    padding: 10px 14px;
    overflow: visible;
    flex-wrap: wrap;
  }
  body.ipad-mode.ipad-landscape #drawing-tabs {
    flex: 1 1 720px;
    min-width: 0;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
    overflow: visible;
  }
  body.ipad-mode.ipad-landscape .drawing-tab {
    min-width: clamp(136px, 16vw, 220px);
    justify-content: center;
    text-align: center;
  }
  body.ipad-mode.ipad-landscape #upload-pdf-btn {
    flex: 0 0 auto;
    align-self: stretch;
    min-width: 150px;
    justify-content: center;
  }
  body.ipad-mode #annot-toolbar {
    padding-top: calc(env(safe-area-inset-top, 0px) + 4px);
  }
  body.ipad-mode #annot-row1,
  body.ipad-mode #annot-row2 {
    min-height: 62px;
    padding: 10px 16px;
    gap: 8px;
  }
  body.ipad-mode .annot-tool {
    width: 54px;
    height: 54px;
    border-radius: 14px;
  }
  body.ipad-mode .annot-swatch {
    width: 44px;
    height: 44px;
  }
  body.ipad-mode #annot-size {
    max-width: 180px;
  }
  body.ipad-mode #annot-canvas-wrap {
    background:
      radial-gradient(circle at top, rgba(59,130,246,0.08), transparent 38%),
      #060b14;
  }
  body.ipad-mode #annot-footer {
    padding-left: 20px;
    padding-right: 20px;
  }
  body.ipad-mode #move-pin-bar {
    padding-left: 18px;
    padding-right: 18px;
  }
  body.web-mode {
    --radius: 16px;
    --sheet-radius: 24px;
    background:
      radial-gradient(circle at top, rgba(59,130,246,0.16), transparent 34%),
      linear-gradient(180deg, #0b1220 0%, #09101a 100%);
  }
  body.web-mode #topbar,
  body.web-mode #drawing-bar,
  body.web-mode #workspace-shell {
    width: auto;
    max-width: none;
    align-self: stretch;
    margin-left: 12px;
    margin-right: 12px;
  }
  body.web-mode #topbar {
    margin-top: 8px;
    padding: 12px 16px;
    border: 1px solid rgba(46,61,85,0.92);
    border-bottom: 1px solid rgba(46,61,85,0.92);
    border-radius: 20px;
    background: rgba(20,29,46,0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 24px 70px rgba(0,0,0,0.32);
    margin-bottom: 8px;
  }
  body.web-mode #drawing-bar {
    display: none;
  }
  body.web-mode #workspace-shell {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(264px, 296px) minmax(0, 1fr);
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
  }
  body.web-mode.desktop-wide #workspace-shell,
  body.web-mode.desktop-pin-sheet-open #workspace-shell {
    grid-template-columns: minmax(264px, 296px) minmax(0, 1fr) minmax(292px, 336px);
  }
  body.web-mode #canvas-container {
    min-width: 0;
    min-height: calc(100dvh - 102px);
    height: calc(100dvh - 102px);
    margin-top: 0;
    margin-bottom: 0;
    border: 1px solid rgba(46,61,85,0.92);
    border-radius: 24px;
    background:
      radial-gradient(circle at top, rgba(59,130,246,0.10), transparent 42%),
      linear-gradient(180deg, #0b111c 0%, #080d16 100%);
    box-shadow: 0 30px 90px rgba(0,0,0,0.34);
  }
  body.web-mode #project-selector {
    height: 48px;
    font-size: 16px;
    border-radius: 12px;
  }
  body.web-mode .icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
  }
  body.web-mode #topbar-upload-btn {
    display: inline-flex;
  }
  body.web-mode .icon-btn:hover,
  body.web-mode .drawing-tab:hover,
  body.web-mode .tool-btn:hover,
  body.web-mode #upload-pdf-btn:hover {
    border-color: rgba(96,165,250,0.65);
    box-shadow: 0 10px 26px rgba(15,23,42,0.24);
  }
  body.web-mode .drawing-tab {
    height: 40px;
    padding: 0 16px;
    font-size: 14px;
    border-radius: 10px;
  }
  body.web-mode #upload-pdf-btn {
    display: none;
  }
  body.web-mode #pdf-canvas {
    filter: drop-shadow(0 20px 46px rgba(0,0,0,0.28));
  }
  body.web-mode .pin-marker:hover svg {
    transform: scale(1.12);
  }
  body.web-mode #bottom-toolbar {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    width: auto;
    min-width: min(620px, calc(100vw - 64px));
    max-width: calc(100vw - 56px);
    padding: 10px 12px;
    border: 1px solid rgba(46,61,85,0.92);
    border-radius: 20px;
    background: rgba(20,29,46,0.88);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 22px 50px rgba(0,0,0,0.3);
    gap: 10px;
  }
  body.web-mode #active-drawing-chip {
    display: inline-flex;
  }
  body.web-mode #page-nav {
    border-radius: 14px;
  }
  body.web-mode #page-nav .icon-btn {
    width: 44px;
    height: 50px;
  }
  body.web-mode #page-info {
    min-width: 54px;
    height: 50px;
    font-variant-numeric: tabular-nums;
  }
  body.web-mode .tool-btn {
    min-width: 148px;
    height: 50px;
    border-radius: 14px;
  }
  body.web-mode #project-modal {
    max-width: min(1240px, calc(100vw - 96px));
    max-height: min(88dvh, 900px);
  }
  body.web-mode #project-modal-body {
    padding: 0;
    overflow: hidden;
  }
  body.web-mode #project-modal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.16fr) minmax(340px, 0.84fr);
    min-height: min(76dvh, 780px);
  }
  body.web-mode #project-modal-main {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 24px 20px;
  }
  body.web-mode #project-modal-side {
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 24px 24px 18px;
    border-left: 1px solid var(--border);
    background:
      linear-gradient(180deg, rgba(59,130,246,0.08), rgba(59,130,246,0.015) 150px),
      var(--surface);
  }
  body.web-mode #project-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
  }
  body.web-mode .project-row {
    padding: 14px 0;
  }
  body.web-mode .project-row.active {
    margin: 0;
    padding-left: 14px;
    padding-right: 14px;
  }
  #workspace-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #desktop-sidepanel {
    display: none;
  }
  #desktop-inspector-host {
    display: none;
  }
  body.web-mode #desktop-sidepanel {
    display: flex;
    min-height: 0;
    position: relative;
    top: auto;
    align-self: stretch;
    height: calc(100dvh - 102px);
    max-height: calc(100dvh - 102px);
    border: 1px solid rgba(46,61,85,0.92);
    border-radius: 24px;
    background:
      linear-gradient(180deg, rgba(59,130,246,0.08), rgba(59,130,246,0.02) 140px),
      rgba(20,29,46,0.9);
    box-shadow: 0 30px 90px rgba(0,0,0,0.28);
    overflow: hidden;
  }
  body.web-mode.desktop-wide #desktop-inspector-host,
  body.web-mode.desktop-pin-sheet-open #desktop-inspector-host {
    display: flex;
    min-height: 0;
    position: relative;
    top: auto;
    align-self: stretch;
    height: calc(100dvh - 102px);
    max-height: calc(100dvh - 102px);
    overflow: hidden;
    border: 1px solid rgba(46,61,85,0.92);
    border-radius: 24px;
    background:
      linear-gradient(180deg, rgba(59,130,246,0.08), rgba(59,130,246,0.02) 140px),
      rgba(20,29,46,0.92);
    box-shadow: 0 30px 90px rgba(0,0,0,0.28);
  }
  body.web-mode.desktop-wide #desktop-inspector-host::before {
    content: 'Select a pin to view and edit its details here.';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 24px;
    text-align: center;
    color: var(--text3);
    font-size: 13px;
    line-height: 1.6;
  }
  body.web-mode.desktop-pin-sheet-open #desktop-inspector-host::before {
    display: none;
  }
  body.web-mode #desktop-inspector-host .sheet {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    animation: none;
    box-shadow: none;
    background: transparent;
  }
  body.web-mode #desktop-inspector-host .sheet-handle {
    display: none;
  }
  body.web-mode #desktop-inspector-host .sheet-header {
    padding: 14px 18px;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 2;
  }
  body.web-mode #desktop-inspector-host .sheet-body {
    padding: 14px 16px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(96,165,250,0.5) rgba(15,23,42,0.86);
  }
  body.web-mode #desktop-inspector-host .sheet-body::-webkit-scrollbar {
    display: block !important;
    width: 12px;
    height: 12px;
  }
  body.web-mode #desktop-inspector-host .sheet-body::-webkit-scrollbar-track {
    background: rgba(15,23,42,0.82);
    border-radius: 999px;
    border: 1px solid rgba(46,61,85,0.64);
  }
  body.web-mode #desktop-inspector-host .sheet-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(59,130,246,0.82), rgba(37,99,235,0.74));
    border-radius: 999px;
    border: 2px solid rgba(15,23,42,0.88);
  }
  body.web-mode #desktop-inspector-host .sheet-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(96,165,250,0.9), rgba(59,130,246,0.82));
  }
  body.web-mode #desktop-inspector-host .sheet-footer {
    padding: 10px 16px 14px;
    background: var(--surface);
  }
  body.web-mode #pin-heading-row {
    display: none;
  }
  body.web-mode #pin-heading-header-btn {
    display: inline-flex;
  }
  body.web-mode #pin-add-photo-btn,
  body.web-mode #pin-record-video-btn {
    display: inline-flex;
  }
  body.web-mode #desktop-inspector-host .photo-grid {
    display: block;
    margin-bottom: 8px;
  }
  body.web-mode #desktop-inspector-host .desktop-photo-viewer {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  body.web-mode #desktop-inspector-host .desktop-photo-stage {
    position: relative;
    min-height: 300px;
    max-height: min(46vh, 420px);
    border-radius: 16px;
    overflow: hidden;
    background:
      radial-gradient(circle at top, rgba(59,130,246,0.12), transparent 42%),
      rgba(14,20,31,0.94);
    border: 1px solid rgba(46,61,85,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  body.web-mode #desktop-inspector-host .desktop-photo-stage img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: rgba(10,15,24,0.94);
  }
  body.web-mode #desktop-inspector-host .desktop-photo-chip {
    display: none;
  }
  body.web-mode #desktop-inspector-host .desktop-photo-controls,
  body.web-mode #desktop-inspector-host .desktop-photo-nav,
  body.web-mode #desktop-inspector-host .desktop-photo-slider,
  body.web-mode #desktop-inspector-host .desktop-photo-status {
    display: none !important;
  }
  body.web-mode #desktop-inspector-host .desktop-photo-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1.5px solid rgba(255,255,255,0.24);
    background: rgba(0,0,0,0.72);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  body.web-mode #desktop-inspector-host .desktop-photo-status {
    display: none;
  }
  body.web-mode #desktop-inspector-host .desktop-photo-caption {
    min-height: 0;
    font-size: 11px;
    color: var(--text3);
    line-height: 1.45;
  }
  body.web-mode #desktop-inspector-host .desktop-photo-empty {
    min-height: 180px;
    border-radius: 16px;
    border: 1px dashed rgba(46,61,85,0.92);
    background: rgba(18,25,40,0.56);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 18px;
    color: var(--text3);
    font-size: 13px;
  }
  body.web-mode #desktop-inspector-host .form-group {
    margin-bottom: 12px;
  }
  body.web-mode #desktop-inspector-host label {
    margin-bottom: 6px;
  }
  body.web-mode #desktop-inspector-host #pin-title-input {
    height: 46px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body.web-mode #desktop-inspector-host #pin-note-input {
    min-height: 46px;
    max-height: 180px;
    resize: none;
    overflow-y: hidden;
  }
  #desktop-sidepanel-inner {
    flex: 1;
    min-height: 0;
    display: block;
    overflow-y: auto;
    padding: 18px 16px 18px 18px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(96,165,250,0.46) rgba(15,23,42,0.84);
  }
  #desktop-sidepanel-inner::-webkit-scrollbar {
    width: 12px;
  }
  #desktop-sidepanel-inner::-webkit-scrollbar-track {
    background: rgba(15,23,42,0.82);
    border-radius: 999px;
    border: 1px solid rgba(46,61,85,0.64);
  }
  #desktop-sidepanel-inner::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(59,130,246,0.78), rgba(37,99,235,0.68));
    border-radius: 999px;
    border: 2px solid rgba(15,23,42,0.88);
  }
  #desktop-sidepanel-inner::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(96,165,250,0.88), rgba(59,130,246,0.8));
  }
  .desktop-side-header {
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom: 14px;
  }
  .desktop-side-eyebrow {
    font-size: 11px;
    font-weight: 800;
    color: var(--text3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .desktop-side-project {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
    margin-top: 4px;
  }
  .desktop-side-badge {
    min-width: 34px;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(59,130,246,0.28);
    background: rgba(59,130,246,0.12);
    color: #dbeafe;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
  }
  .desktop-side-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(148,163,184,0.12);
  }
  .desktop-side-section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }
  .desktop-side-section-title {
    font-size: 11px;
    font-weight: 800;
    color: var(--text3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 10px;
  }
  .desktop-drawing-list,
  .desktop-pin-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .desktop-drawing-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  .desktop-pin-list {
    max-height: none;
    min-height: 0;
    overflow: visible;
    padding-right: 0;
  }
  .desktop-drawing-item,
  .desktop-pin-item,
  .desktop-pin-page-btn {
    width: 100%;
    border: 1px solid rgba(46,61,85,0.92);
    background: rgba(27,36,56,0.82);
    color: var(--text);
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
  }
  .desktop-drawing-item,
  .desktop-pin-page-btn {
    padding: 12px 13px;
  }
  .desktop-pin-item {
    padding: 10px 12px;
  }
  .desktop-drawing-item.active,
  .desktop-pin-page-btn.active,
  .desktop-pin-item.active {
    border-color: rgba(96,165,250,0.58);
    background: rgba(59,130,246,0.14);
    box-shadow: inset 0 0 0 1px rgba(96,165,250,0.16);
  }
  .desktop-drawing-item:hover,
  .desktop-pin-page-btn:hover,
  .desktop-pin-item:hover {
    border-color: rgba(96,165,250,0.4);
  }
  .desktop-drawing-name,
  .desktop-pin-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
  }
  .desktop-drawing-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .desktop-drawing-head .desktop-drawing-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .desktop-drawing-delete {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(239, 68, 68, 0.34);
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
  }
  .desktop-drawing-item.active .desktop-drawing-delete {
    border-color: rgba(255,255,255,0.24);
    background: rgba(255,255,255,0.14);
    color: #fff;
  }
  .desktop-drawing-delete:active {
    opacity: 0.78;
  }
  .desktop-drawing-meta,
  .desktop-pin-meta {
    font-size: 12px;
    color: var(--text3);
    margin-top: 3px;
    line-height: 1.4;
  }
  .desktop-pin-page {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .desktop-pin-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 8px;
  }
  .desktop-pin-item-row {
    display:flex;
    align-items:flex-start;
    gap:10px;
  }
  .desktop-pin-num {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: #c0392b;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    flex-shrink: 0;
    margin-top: 1px;
  }
  .desktop-pin-num.has-video {
    background: var(--accent);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.16), 0 6px 14px rgba(245,158,11,0.22);
  }
  .desktop-pin-copy {
    min-width: 0;
    flex: 1;
  }
  .desktop-pin-empty {
    font-size: 13px;
    color: var(--text3);
    padding: 12px 2px;
    line-height: 1.5;
  }
  body.web-mode .modal-overlay {
    padding: 36px;
  }
  body.web-mode .sheet-overlay {
    padding: 28px;
  }
  body.web-mode .sheet {
    width: min(980px, calc(100vw - 56px));
    max-height: min(88dvh, 920px);
    box-shadow: 0 30px 80px rgba(0,0,0,0.34);
  }
  @keyframes ipadSheetIn {
    from { transform: translateY(18px) scale(0.985); opacity: 0.55; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
  }

  /* ══ TOP BAR ══════════════════════════════════════════ */
  #topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(var(--safe-top) + 10px) 12px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
  }


  #project-selector {
    flex: 1;
    min-width: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    padding: 0 36px 0 12px;
    height: 44px;
    border-radius: 10px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
  }

  #topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  /* ── Icon buttons (44×44 — Apple HIG minimum) ── */
  .icon-btn {
    width: 44px; height: 44px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 18px;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: background 0.1s, transform 0.1s;
  }
.icon-btn:active { background: var(--border); transform: scale(0.92); }
.icon-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }
.icon-btn--storage {
  color: inherit;
}
.icon-btn--storage:active {
  background: var(--border);
}
.topbar-action-wrap {
  position: relative;
  flex-shrink: 0;
}
  #topbar-upload-btn { display: none; }

  body:not(.ipad-mode):not(.web-mode) #topbar {
    gap: 6px;
    padding: calc(var(--safe-top) + 10px) 10px 8px;
    border-bottom-color: rgba(86, 104, 130, 0.72);
    box-shadow: inset 0 -1px 0 rgba(255,255,255,0.04);
  }
body:not(.ipad-mode):not(.web-mode) #app-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 54px;
  max-width: 58px;
  gap: 0;
}
  body:not(.ipad-mode):not(.web-mode) #app-logo {
    font-size: 14px;
    letter-spacing: 0.08em;
  }
  body:not(.ipad-mode):not(.web-mode) #app-logo-wrap.has-need-update #app-logo::after {
    transform: translate(30%, -22%);
  }
body:not(.ipad-mode):not(.web-mode) #app-logo-sub {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  flex-wrap: nowrap;
  min-height: 12px;
  margin-top: 0;
  font-size: 7px;
  letter-spacing: 0.04em;
  line-height: 0.78;
  white-space: nowrap;
}
body:not(.ipad-mode):not(.web-mode) #app-logo-sub .app-user-label {
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 7.8px;
  line-height: 0.82;
}
body:not(.ipad-mode):not(.web-mode) #app-logo-sub .app-sync-status {
  align-self: flex-start;
  gap: 3px;
  font-size: 6.9px;
  letter-spacing: 0.05em;
  line-height: 0.82;
}
body:not(.ipad-mode):not(.web-mode) #app-logo-sub .app-sync-status::before {
  width: 4px;
  height: 4px;
}
body:not(.ipad-mode):not(.web-mode) #local-storage-btn .storage-icon-mobile {
  width: 28px;
  height: 28px;
}
  body:not(.ipad-mode):not(.web-mode) #project-selector {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(78, 96, 122, 0.58);
    background: #223045;
    color: rgba(248, 250, 252, 0.96);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.01em;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: none;
  }
  body:not(.ipad-mode):not(.web-mode) #project-selector:focus {
    outline: none;
    border-color: rgba(120, 145, 180, 0.68);
    box-shadow: 0 0 0 1px rgba(120, 145, 180, 0.24), inset 0 1px 0 rgba(255,255,255,0.04);
  }
  body:not(.ipad-mode):not(.web-mode) #project-selector::-ms-expand {
    display: none;
  }
  body:not(.ipad-mode):not(.web-mode) #topbar-actions {
    gap: 6px;
  }
  body:not(.ipad-mode):not(.web-mode) #topbar .icon-btn,
  body:not(.ipad-mode):not(.web-mode) #topbar #local-storage-btn {
    background: #223045;
    border: 1px solid rgba(78, 96, 122, 0.58);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 4px 10px rgba(7, 12, 20, 0.14);
    transition: filter 0.1s ease, background 0.1s ease, transform 0.1s ease, box-shadow 0.1s ease;
  }
  body:not(.ipad-mode):not(.web-mode) #topbar .icon-btn:hover,
  body:not(.ipad-mode):not(.web-mode) #topbar #local-storage-btn:hover,
  body:not(.ipad-mode):not(.web-mode) #topbar .icon-btn:focus-visible,
  body:not(.ipad-mode):not(.web-mode) #topbar #local-storage-btn:focus-visible {
    filter: brightness(1.05);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 5px 12px rgba(7, 12, 20, 0.16);
  }
  body:not(.ipad-mode):not(.web-mode) #topbar .icon-btn:active,
  body:not(.ipad-mode):not(.web-mode) #topbar #local-storage-btn:active {
    background: #1d2a3c;
    transform: scale(0.96);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 2px 6px rgba(7, 12, 20, 0.1);
  }
  body:not(.ipad-mode):not(.web-mode) .icon-btn--storage {
    background: #223045;
    border-color: rgba(78, 96, 122, 0.58);
    color: #fff;
  }
  body:not(.ipad-mode):not(.web-mode) .icon-btn--storage:active {
    background: #28384e;
  }

  /* ══ DRAWING BAR ══════════════════════════════════════ */
  #drawing-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #drawing-bar::-webkit-scrollbar { display: none; }

  #drawing-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    padding-bottom: 2px;
  }
  #drawing-tabs::-webkit-scrollbar { display: none; }

  .drawing-tab-swipe {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    flex-shrink: 0;
    scroll-snap-align: start;
    touch-action: pan-x pan-y;
  }

  .drawing-tab-track {
    position: relative;
    z-index: 2;
    min-width: 0;
  }

  .drawing-tab {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 13px;
    font-weight: 600;
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    display: flex; align-items: center;
    touch-action: manipulation;
    transition: all 0.1s;
    flex-shrink: 0;
    min-width: 0;
    max-width: min(46vw, 240px);
    gap: 8px;
  }

  .drawing-tab-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
  }
  .drawing-tab.active {
    background: var(--accent2);
    border-color: var(--accent2);
    color: #fff;
  }
  .drawing-tab:active { opacity: 0.75; }

  .drawing-tab-swipe.is-pressing .drawing-tab {
    transform: scale(0.98);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.14);
  }

  .drawing-tab-delete {
    width: 0;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0);
    background:
      linear-gradient(180deg, rgba(239, 68, 68, 0.22), rgba(185, 28, 28, 0.2)),
      rgba(127, 29, 29, 0.18);
    color: rgba(254, 202, 202, 0);
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-6px) scale(0.92);
    transition: width 0.18s ease, opacity 0.16s ease, transform 0.18s ease, color 0.18s ease, border-color 0.18s ease;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  }

  .drawing-tab-swipe.is-open.is-active .drawing-tab-delete {
    width: 38px;
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0) scale(1);
    color: #fecaca;
    border-color: rgba(239, 68, 68, 0.42);
  }

  .drawing-tab-delete:active {
    opacity: 0.78;
  }

  body.web-mode .drawing-tab-delete {
    display: none !important;
  }

  #upload-pdf-btn {
    height: 36px;
    padding: 0 14px;
    background: transparent;
    border: 1.5px dashed var(--accent2);
    color: var(--accent2);
    font-size: 13px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    display: flex; align-items: center; gap: 4px;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: filter 0.1s ease, background 0.1s ease, border-color 0.1s ease, transform 0.1s ease, box-shadow 0.1s ease;
  }
  body:not(.ipad-mode):not(.web-mode) #upload-pdf-btn {
    box-shadow: 0 3px 8px rgba(7, 12, 20, 0.08);
  }
  body:not(.ipad-mode):not(.web-mode) #upload-pdf-btn:hover,
  body:not(.ipad-mode):not(.web-mode) #upload-pdf-btn:focus-visible {
    filter: brightness(1.04);
    background: rgba(59,130,246,0.06);
    box-shadow: 0 4px 10px rgba(7, 12, 20, 0.1);
  }
  body:not(.ipad-mode):not(.web-mode) #upload-pdf-btn:active {
    opacity: 1;
    filter: brightness(0.97);
    background: rgba(59,130,246,0.05);
    transform: scale(0.96);
    box-shadow: 0 2px 5px rgba(7, 12, 20, 0.08);
  }

  /* ══ CANVAS ════════════════════════════════════════════ */
  #canvas-container {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: #080a10;
    touch-action: none;
    overscroll-behavior: none;
  }
  #canvas-container.sync-fallback-active {
    touch-action: pan-y;
  }

  #pdf-canvas {
    position: absolute;
    top: 0; left: 0;
    transform-origin: 0 0;
    display: block;
    pointer-events: none;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    will-change: transform, width, height;
    backface-visibility: hidden;
  }

  body.ios-mode #pdf-canvas,
  body.ios-mode #pins-overlay {
    will-change: auto;
    backface-visibility: visible;
  }

  #pins-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 0; height: 0;
    pointer-events: none;
    z-index: 10;
    transform-origin: 0 0;
    will-change: transform, width, height;
  }

  .pin-marker {
    position: absolute;
    pointer-events: all;
    transform: translate(-50%, -100%);
    cursor: pointer;
    z-index: 10;
  }
  .pin-marker svg {
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
    transition: transform 0.1s;
  }
  .pin-marker:active svg { transform: scale(1.15); }
  .pin-marker.flash svg {
    animation: pinFlash 0.72s ease-in-out 3;
    transform-origin: 50% 100%;
  }
  @keyframes pinFlash {
    0%, 100% {
      transform: scale(1);
      filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
    }
    35% {
      transform: scale(1.38);
      filter: drop-shadow(0 0 16px rgba(96,165,250,0.95));
    }
    70% {
      transform: scale(1.12);
      filter: drop-shadow(0 0 10px rgba(248,113,113,0.85));
    }
  }

  /* ══ BOTTOM TOOLBAR ════════════════════════════════════ */
  #bottom-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px calc(var(--safe-bottom) + 10px);
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
  }
  #active-drawing-chip {
    display: none;
    align-items: center;
    min-width: 0;
    max-width: 280px;
    height: 48px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 1 280px;
  }
  #active-drawing-chip.is-empty {
    color: var(--text3);
  }

  /* Page nav cluster */
  #page-nav {
    display: flex;
    align-items: center;
    gap: 0;
    height: 48px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
  }
  #page-nav .icon-btn {
    border: none;
    border-radius: 0;
    background: transparent;
    width: 40px; height: 100%;
    font-size: 20px;
    font-weight: 300;
    color: var(--text2);
  }
  body:not(.ipad-mode):not(.web-mode) #page-nav .icon-btn {
    transition: filter 0.1s ease, background 0.1s ease, transform 0.1s ease;
  }
  body:not(.ipad-mode):not(.web-mode) #page-nav .icon-btn:hover,
  body:not(.ipad-mode):not(.web-mode) #page-nav .icon-btn:focus-visible {
    filter: brightness(1.05);
    background: rgba(148,163,184,0.07);
  }
  #page-nav .icon-btn:active {
    background: var(--border);
    transform: scale(0.96);
  }
  #page-info {
    min-width: 38px;
    text-align: center;
    padding: 0 2px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    height: 100%;
    display: flex; align-items: center; justify-content: center;
  }

  /* Main tool buttons */
  .tool-btn {
    flex: 1;
    height: 48px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    padding: 0 8px;
    border-radius: 12px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    gap: 6px;
    touch-action: manipulation;
    transition: filter 0.1s ease, background 0.1s ease, border-color 0.1s ease, transform 0.1s ease, box-shadow 0.1s ease;
    -webkit-tap-highlight-color: transparent;
  }
  body:not(.ipad-mode):not(.web-mode) .tool-btn {
    box-shadow: 0 4px 10px rgba(7, 12, 20, 0.1);
  }
  body:not(.ipad-mode):not(.web-mode) .tool-btn:hover,
  body:not(.ipad-mode):not(.web-mode) .tool-btn:focus-visible {
    filter: brightness(1.05);
    box-shadow: 0 5px 12px rgba(7, 12, 20, 0.12);
  }
  .tool-btn:active {
    opacity: 1;
    filter: brightness(0.97);
    transform: scale(0.96);
    box-shadow: 0 2px 6px rgba(7, 12, 20, 0.08);
  }
  .tool-btn.active { background: var(--pin); border-color: var(--pin); color: #fff; }
  .tool-btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }

  /* ══ BOTTOM SHEET ══════════════════════════════════════ */
  .sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5,12,28,0.7);
    z-index: 200;
    display: none;
    align-items: flex-end;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    touch-action: pan-y;
    overscroll-behavior: contain;
  }
  .sheet-overlay.open { display: flex; }

  body.mobile-pin-sheet-open #pin-sheet-overlay,
  body.mobile-pin-sheet-open #pin-sheet,
  body.mobile-pin-sheet-open #pin-sheet .sheet-body {
    overscroll-behavior: contain;
  }

  .sheet {
    background: var(--surface);
    border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
    width: 100%;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    touch-action: pan-y;
    overscroll-behavior: contain;
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .sheet-handle {
    width: 40px; height: 5px;
    background: var(--border);
    border-radius: 3px;
    margin: 12px auto 6px;
    flex-shrink: 0;
  }

  .sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .sheet-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .sheet-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
  }
  .sheet-title { font-size: 18px; font-weight: 700; }

  .sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-y;
    overscroll-behavior: contain;
  }
  .sheet-body::-webkit-scrollbar { display: none; }

  .sheet-footer {
    display: flex;
    gap: 10px;
    padding: 12px 16px calc(var(--safe-bottom) + 12px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
    position: sticky;
    bottom: 0;
  }

  /* ══ FORMS ═════════════════════════════════════════════ */
  label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 8px;
  }

  input[type="text"], input[type="number"], textarea {
    width: 100%;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    color: var(--text);
    font-size: 16px; /* prevents iOS auto-zoom */
    padding: 12px 14px;
    border-radius: 12px;
    outline: none;
    font-family: inherit;
    resize: none;
    -webkit-appearance: none;
    transition: border-color 0.15s;
  }
  input[type="text"]:focus, input[type="number"]:focus, textarea:focus {
    border-color: var(--accent2);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  }
  textarea { line-height: 1.5; }
  #pin-note-input {
    min-height: 46px;
    max-height: 160px;
    overflow-y: hidden;
  }
  #pin-note-input::placeholder {
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  select {
    width: 100%;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    color: var(--text);
    font-size: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    outline: none;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
  }

  .form-group { margin-bottom: 18px; }
  .pin-readonly-note {
    display: none;
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(245,158,11,0.26);
    background: rgba(245,158,11,0.12);
    color: #fcd34d;
    font-size: 12px;
    line-height: 1.45;
  }
  .pin-readonly-note.show { display: block; }

  /* ══ BUTTONS ═══════════════════════════════════════════ */
  .btn {
    font-size: 16px;
    font-weight: 700;
    height: 52px;
    padding: 0 20px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    display: flex; align-items: center; justify-content: center;
    gap: 6px;
    touch-action: manipulation;
    transition: opacity 0.1s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
  }
  .btn:active { opacity: 0.75; transform: scale(0.97); }
  .btn:disabled,
  .tool-btn:disabled,
  #pin-add-photo-btn:disabled,
  #pin-record-video-btn:disabled,
  #pin-heading-edit-btn:disabled,
  #pin-heading-header-btn:disabled,
  .remove-photo:disabled,
  .desktop-photo-nav:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
    box-shadow: none;
  }
  .btn-primary { background: var(--accent2); color: #fff; flex: 1; }
  .btn-accent  { background: var(--accent);  color: #000; flex: 1; }
  .btn-danger  { background: var(--danger);  color: #fff; }
  .btn-ghost   { background: var(--surface2); color: var(--text); border: 1.5px solid var(--border); }
  .btn-sm      { font-size: 13px; height: 38px; padding: 0 14px; border-radius: 10px; }

  .close-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text2);
    width: 36px; height: 36px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    touch-action: manipulation;
  }
  #pin-sheet .sheet-header-actions .close-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 8px 18px rgba(245,158,11,0.28);
  }
  #photo-sheet-overlay .sheet-header .close-btn,
  #video-sheet-overlay .sheet-header .close-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 8px 18px rgba(245,158,11,0.28);
  }
  .close-btn:active { background: var(--border); }
  #pin-sheet .sheet-header-actions .close-btn:active,
  #photo-sheet-overlay .sheet-header .close-btn:active,
  #video-sheet-overlay .sheet-header .close-btn:active { background: #d97706; }

  /* ══ PHOTO GRID ═════════════════════════════════════════ */
  .photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
  }

  .photo-thumb {
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    background: var(--surface2);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
  }
  .photo-thumb.photo-thumb--video {
    aspect-ratio: 16 / 9;
    padding: 10px 10px 18px;
    border: 1px solid rgba(46,61,85,0.92);
    background:
      repeating-linear-gradient(to right, rgba(255,255,255,0.18) 0 9px, transparent 9px 18px) left 12px top 8px / calc(100% - 24px) 6px no-repeat,
      repeating-linear-gradient(to right, rgba(255,255,255,0.18) 0 9px, transparent 9px 18px) left 12px bottom 8px / calc(100% - 24px) 6px no-repeat,
      linear-gradient(180deg, rgba(14,165,233,0.18), rgba(15,23,42,0.94));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
  }
  .photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
  .photo-thumb img {
    touch-action: manipulation;
    -webkit-user-drag: none;
    user-select: none;
  }
  .photo-thumb--video .video-film-media {
    position: absolute;
    inset: 20px 10px 28px;
    border-radius: 9px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.12);
    background: #020617;
    box-shadow: 0 8px 22px rgba(0,0,0,0.22);
    pointer-events: none;
  }
  .photo-thumb--video .video-film-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .photo-thumb--video .video-film-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(2,6,23,0.06), rgba(2,6,23,0.38));
    pointer-events: none;
  }
  .photo-thumb--video .video-film-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f8fafc;
    font-size: 24px;
    font-weight: 900;
    text-shadow: 0 4px 16px rgba(0,0,0,0.38);
    pointer-events: none;
  }
  .photo-thumb--video .video-film-badge,
  .photo-thumb--video .video-film-duration {
    position: absolute;
    bottom: 10px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(5,12,28,0.86);
    color: #e2e8f0;
    font-size: 10px;
    line-height: 1;
    pointer-events: none;
  }
  .photo-thumb--video .video-film-badge {
    left: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
  }
  .photo-thumb--video .video-film-duration {
    right: 10px;
    font-weight: 700;
  }

  .photo-thumb .remove-photo {
    position: absolute;
    top: 5px; right: 5px;
    background: rgba(0,0,0,0.72);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    width: 28px; height: 28px;
    font-size: 12px; font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    touch-action: manipulation;
  }

  .add-photo-btn {
    min-height: 88px;
    border-radius: 12px;
    background: var(--surface2);
    border: 1.5px dashed var(--border);
    position: relative;
    overflow: visible;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text2);
    gap: 7px;
    padding: 12px 8px;
    touch-action: manipulation;
    transition: border-color 0.12s, background 0.12s;
  }
  .add-photo-btn:active { border-color: var(--accent2); background: rgba(59,130,246,0.08); transform: scale(0.97); }
  .add-photo-btn svg { color: var(--text2); }
  .add-photo-btn span { font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
