  /* ══ MODALS ═════════════════════════════════════════════ */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5,12,28,0.75);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    touch-action: pan-y;
  }
  .modal-overlay.open { display: flex; }

  .modal {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    max-height: 82dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    touch-action: pan-y;
  }

  .modal-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
  }

  /* ══ COMPASS HUD ════════════════════════════════════════ */
  #compass-hud {
    position: fixed;
    bottom: calc(var(--safe-bottom) + 78px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    pointer-events: none;
    animation: compassIn 0.22s ease-out;
  }
  #compass-hud.visible { display: flex; }
  @keyframes compassIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
  }

  #compass-dial {
    width: 76px; height: 76px;
    position: relative;
    display: flex; align-items: center; justify-content: center;
  }
  /* needle-wrap: rotates the needle group, centred on SVG centre */
  #compass-needle-wrap {
    transform-origin: 38px 38px;
    transition: transform 0.25s linear;
    will-change: transform;
  }

  

  #compass-readout {
    background: rgba(12,14,20,0.94);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 14px;
    display: flex; align-items: center; gap: 7px;
    box-shadow: 0 2px 14px rgba(0,0,0,0.45);
  }
  #compass-deg {
    font-size: 16px; font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    min-width: 40px; text-align: right;
  }
  #compass-card {
    font-size: 14px; font-weight: 700;
    color: var(--accent);
    min-width: 26px;
  }
  #compass-hint {
    background: rgba(245,158,11,0.14);
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 12px; font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
  }


  /* ══ PIN DIRECTION ROW ══════════════════════════════════ */
  #pin-heading-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    min-height: 52px;
    padding: 8px 12px;
    margin-bottom: 18px;
  }
  #pin-heading-header-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(46,61,85,0.92);
    background:
      radial-gradient(circle at 35% 28%, rgba(59,130,246,0.18), transparent 58%),
      rgba(23,33,51,0.9);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
  }
  #pin-heading-header-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(96,165,250,0.72);
  }
  #pin-heading-header-btn:active {
    transform: scale(0.97);
  }
  #pin-heading-header-btn svg {
    width: 30px;
    height: 30px;
    display: block;
  }
  #pin-heading-header-btn.is-empty {
    color: var(--text3);
  }
  #pin-add-photo-btn,
  #pin-record-video-btn {
    display: none;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(46,61,85,0.92);
    background: rgba(23,33,51,0.9);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
  }
  #pin-add-photo-btn:hover,
  #pin-record-video-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(96,165,250,0.72);
  }
  #pin-add-photo-btn:active,
  #pin-record-video-btn:active {
    transform: scale(0.97);
  }
  #pin-add-photo-btn svg,
  #pin-record-video-btn svg {
    width: 18px;
    height: 18px;
    display: block;
  }
  #pin-heading-header-needle,
  #pin-direction-modal-needle {
    transform-origin: 16px 16px;
    transition: transform 0.16s ease;
  }
  #pin-heading-mini-dial {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--bg);
    border: 1.5px solid var(--border);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
  }
  #pin-heading-text { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
  #pin-heading-label { font-size: 9px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; }
  #pin-heading-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #pin-heading-edit-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 13px; font-weight: 700;
    height: 34px; padding: 0 12px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
  }
  #pin-direction-modal {
    max-width: 460px;
  }
  #pin-direction-modal-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    margin-bottom: 16px;
    border-radius: 16px;
    border: 1px solid rgba(46,61,85,0.92);
    background:
      linear-gradient(180deg, rgba(59,130,246,0.08), rgba(59,130,246,0.02) 120px),
      rgba(22,31,49,0.9);
  }
  #pin-direction-modal-dial {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(10,15,24,0.92);
    border: 1px solid rgba(46,61,85,0.9);
  }
  #pin-direction-modal-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  #pin-direction-modal-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text3);
  }
  #pin-direction-modal-value {
    font-size: 16px;
    line-height: 1.4;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
  }

  /* ══ DIRECTION PICKER ═══════════════════════════════════ */
  .dir-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    margin-top: 10px;
  }
  .dir-btn {
    background: var(--surface2);
    border: 1.5px solid var(--border);
    color: var(--text);
    font-size: 14px; font-weight: 700;
    height: 50px;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    display: flex; align-items: center; justify-content: center;
    touch-action: manipulation;
    transition: all 0.1s;
  }
  .dir-btn:active, .dir-btn.selected {
    background: var(--accent2);
    border-color: var(--accent2);
    color: #fff;
    transform: scale(0.95);
  }
  #pin-direction-modal.is-readonly .dir-btn {
    opacity: 0.5;
    pointer-events: none;
  }

  /* ══ MOVE PIN MODE ════════════════════════════════════════ */
  #move-pin-bar {
    position:fixed; bottom:0; left:0; right:0;
    padding:12px 16px calc(var(--safe-bottom) + 12px);
    background:var(--surface); border-top:2px solid var(--accent2);
    display:none; gap:10px; z-index:150; align-items:center;
  }
  #move-pin-bar.visible { display:flex; }
  .move-pin-action-btn {
    flex: 0 0 136px;
    min-width: 136px;
    padding: 0 18px;
    justify-content: center;
    gap: 6px;
  }
  .move-pin-action-btn svg {
    flex-shrink: 0;
  }
  .move-pin-instruction {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    line-height: 1.35;
    letter-spacing: 0.01em;
  }
  #move-pin-hint {
    position:fixed; top:calc(var(--safe-top) + 64px); left:50%;
    transform:translateX(-50%);
    background:rgba(59,130,246,0.92); color:#fff;
    font-size:13px; font-weight:700; padding:8px 18px; border-radius:20px;
    pointer-events:none; z-index:151; display:none; white-space:nowrap;
    box-shadow:0 2px 12px rgba(0,0,0,0.3);
  }
  #move-pin-hint.visible { display:block; }
  .pin-marker.moving { z-index:30; animation:pinMovePulse 1s ease-in-out infinite; }
  .pin-marker.moving svg { transform:scale(1.5); transform-origin:50% 100%; filter:drop-shadow(0 0 8px rgba(245,158,11,0.9)); }
  .pin-marker.dimmed { opacity:0.3; pointer-events:none; }
  @keyframes pinMovePulse {
    0%,100% { filter:drop-shadow(0 0 6px rgba(245,158,11,0.6)); }
    50%      { filter:drop-shadow(0 0 14px rgba(245,158,11,1.0)); }
  }

  /* ══ MISC ═══════════════════════════════════════════════ */
  .divider { height: 1px; background: var(--border); margin: 14px 0; }
  .text-sm { font-size: 13px; color: var(--text2); }
  .text-danger { color: var(--danger); }
  select option { background: var(--surface2); }


  /* ══ UTILITY ══════════════════════════════════════════════ */
  #app-logo-wrap { display:flex; flex-direction:column; gap:0; flex-shrink:0; line-height:1; align-items:flex-start; }
  #app-logo { position:relative; display:inline-flex; align-self:flex-start; font-size:14px; font-weight:900; color:var(--accent); letter-spacing:0.08em; }
  #app-logo-wrap.has-need-update #app-logo::after {
    content:'';
    position:absolute;
    top:0;
    right:0;
    transform:translate(36%,-28%);
    width:7px;
    height:7px;
    border-radius:999px;
    background:#ef4444;
    box-shadow:0 0 0 2px rgba(20,29,46,0.85);
  }
  #app-logo-sub {
    display:flex;
    align-items:center;
    gap:4px;
    flex-wrap:wrap;
    min-height:10px;
    font-size:8px;
    font-weight:600;
    color:var(--text3);
    letter-spacing:0.06em;
    text-transform:uppercase;
  }
  #app-logo-sub .app-user-label { white-space:nowrap; }
  #app-logo-sub .app-sync-status {
    display:inline-flex;
    align-items:center;
    gap:3px;
    font-size:7px;
    font-weight:800;
    letter-spacing:0.08em;
    color:var(--text3);
    opacity:0.92;
    white-space:nowrap;
  }
  #app-logo-sub .app-sync-status::before {
    content:'';
    width:5px;
    height:5px;
    border-radius:999px;
    background:currentColor;
    flex:0 0 auto;
  }
  #app-logo-sub .app-sync-status.is-synced { color:#22c55e; }
  #app-logo-sub .app-sync-status.is-syncing { color:#60a5fa; }
  #app-logo-sub .app-sync-status.is-local { color:#f59e0b; }
  body.web-mode #app-logo-sub .app-sync-status { font-size:8px; }
  .export-row { display:flex; gap:8px; margin-bottom:10px; }
  .export-row .btn { flex:1; font-size:13px; display:flex; align-items:center; justify-content:center; gap:5px; }
  .project-transfer-btn {
    position: relative;
    overflow: hidden;
    min-height: 48px;
    gap: 6px !important;
    font-size: 13px !important;
    font-weight: 800;
    letter-spacing: 0.01em;
  }
  .project-transfer-btn svg,
  .project-transfer-btn .project-transfer-label {
    position: relative;
    z-index: 1;
  }
  .project-transfer-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    opacity: 0.22;
    border-radius: inherit;
    transition: width 0.25s ease;
    pointer-events: none;
  }
  .project-transfer-btn--archive {
    border-color: #3b82f6 !important;
    color: #60a5fa !important;
    background: linear-gradient(180deg, rgba(59,130,246,0.08), rgba(59,130,246,0.03));
  }
  .project-transfer-btn--archive .project-transfer-progress {
    background: linear-gradient(90deg, #1d4ed8, #3b82f6);
  }
  .project-transfer-btn--package {
    border-color: #f59e0b !important;
    color: #fbbf24 !important;
    background: linear-gradient(180deg, rgba(245,158,11,0.08), rgba(245,158,11,0.03));
  }
  .project-transfer-btn--package .project-transfer-progress {
    background: linear-gradient(90deg, #b45309, #f59e0b);
  }
  .project-transfer-btn:disabled {
    opacity: 0.82;
    cursor: default;
  }
  .project-transfer-btn.state-normal {
    border-color: #3b82f6 !important;
    color: #60a5fa !important;
    background: linear-gradient(180deg, rgba(59,130,246,0.08), rgba(59,130,246,0.03));
  }
  .project-transfer-btn.state-recommended {
    border-color: #22c55e !important;
    color: #4ade80 !important;
    background: linear-gradient(180deg, rgba(34,197,94,0.12), rgba(34,197,94,0.04));
  }
  .project-transfer-btn.state-disabled {
    border-color: rgba(100,116,139,0.28) !important;
    color: #94a3b8 !important;
    background: rgba(51,65,85,0.18);
  }
  #project-modal-layout { display:block; }
  #project-modal-main { min-width:0; min-height:0; }
  #project-modal-side {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    min-width: 0;
  }
  .project-side-header {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    margin-bottom:12px;
  }
  .project-side-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--text3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .project-count-badge {
    min-width: 28px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }
  #add-pin-btn.active { background:var(--pin); border-color:var(--pin); color:#fff; box-shadow:0 0 0 3px rgba(229,62,62,0.25); }
  .drawing-tab.active { background:var(--accent2); border-color:var(--accent2); color:#fff; box-shadow:0 2px 8px rgba(59,130,246,0.3); }
  .photo-thumb:active { opacity:0.82; transform:scale(0.97); transition:transform 0.1s; }
  @media(max-width:380px) { #pin-heading-row { padding:8px 10px; gap:8px; } #pin-heading-edit-btn { padding:0 10px; font-size:12px; } }

  #empty-state {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text3); gap: 12px;
    pointer-events: none;
  }
  #empty-state .icon { font-size: 52px; }
  #empty-state .msg  { font-size: 15px; text-align: center; max-width: 220px; line-height: 1.6; color: var(--text3); }
  #empty-state-detail {
    display: none;
    width: min(92vw, 420px);
    max-height: min(38vh, 360px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    pointer-events: auto;
    margin-top: 8px;
    padding: 14px;
    border-radius: 18px;
    background: rgba(20, 29, 46, 0.92);
    border: 1px solid rgba(53, 69, 98, 0.92);
    box-shadow: 0 18px 40px rgba(0,0,0,0.22);
    text-align: left;
  }
  #empty-state-detail.show { display: block; }
  #empty-state-detail::-webkit-scrollbar { width: 8px; }
  #empty-state-detail::-webkit-scrollbar-thumb {
    background: rgba(96, 117, 155, 0.45);
    border-radius: 999px;
  }
  .synced-fallback-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
  }
  .synced-fallback-title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #93c5fd;
  }
  .synced-fallback-count {
    font-size: 12px;
    color: var(--text3);
    white-space: nowrap;
  }
  .synced-fallback-note {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text3);
    margin-bottom: 12px;
  }
  .synced-pin-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    touch-action: pan-y;
  }
  .synced-pin-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.72);
    border: 1px solid rgba(59, 130, 246, 0.12);
  }
  .synced-pin-badge {
    flex-shrink: 0;
    min-width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.18);
    color: #bfdbfe;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
  }
  .synced-pin-copy {
    flex: 1;
    min-width: 0;
  }
  .synced-pin-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
  }
  .synced-pin-meta {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text2);
    word-break: break-word;
  }
  .synced-pin-open {
    flex-shrink: 0;
    min-height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid rgba(96, 165, 250, 0.28);
    background: rgba(37, 99, 235, 0.14);
    color: #dbeafe;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
  }
  .synced-pin-open:active {
    transform: scale(0.98);
  }

  #loading-overlay {
    position: absolute; inset: 0;
    background: rgba(7,9,16,0.82);
    display: none; align-items: center; justify-content: center;
    z-index: 50; flex-direction: column; gap: 12px;
    padding: 24px;
  }
  #loading-overlay.show { display: flex; }
  #loading-card {
    width: min(88vw, 360px);
    background: rgba(17,24,39,0.96);
    border: 1px solid rgba(46,61,85,0.95);
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    padding: 20px 18px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  #loading-card[data-tone="finalizing"] {
    border-color: rgba(217, 119, 6, 0.42);
    box-shadow: 0 10px 30px rgba(0,0,0,0.35), 0 0 0 1px rgba(217,119,6,0.12);
  }
  #loading-card[data-tone="success"] {
    border-color: rgba(34, 197, 94, 0.35);
    box-shadow: 0 10px 30px rgba(0,0,0,0.35), 0 0 0 1px rgba(34,197,94,0.12);
  }
  #loading-card[data-tone="failure"] {
    border-color: rgba(248, 113, 113, 0.34);
    box-shadow: 0 10px 30px rgba(0,0,0,0.35), 0 0 0 1px rgba(248,113,113,0.12);
  }
  .spinner {
    width: 34px; height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  #loading-status-icon {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    flex-shrink: 0;
  }
  #loading-status-icon.show { display: flex; }
  #loading-card[data-tone="success"] #loading-status-icon {
    background: rgba(34, 197, 94, 0.16);
    color: #4ade80;
  }
  #loading-card[data-tone="failure"] #loading-status-icon {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
  }
  #loading-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--text2);
    text-align: center;
    line-height: 1.45;
    min-height: 20px;
  }
  #loading-subtext {
    display: none;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text3);
    text-align: center;
    white-space: pre-line;
  }
  #loading-subtext.show { display: block; }
  #loading-progress-wrap {
    width: 100%;
    display: none;
    flex-direction: column;
    gap: 7px;
  }
  #loading-progress-wrap.show { display: flex; }
  #loading-progress-track {
    width: 100%;
    height: 10px;
    background: rgba(36,48,68,0.95);
    border: 1px solid rgba(46,61,85,0.95);
    border-radius: 999px;
    overflow: hidden;
  }
  #loading-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #1d4ed8, #3b82f6);
    border-radius: inherit;
    transition: width 0.25s ease;
  }
  #loading-progress-bar[data-tone="finalizing"] {
    background: linear-gradient(90deg, #d97706, #f59e0b);
  }
  #loading-progress-bar[data-tone="success"] {
    background: linear-gradient(90deg, #16a34a, #22c55e);
  }
  #loading-progress-bar[data-tone="failure"] {
    background: linear-gradient(90deg, #b91c1c, #ef4444);
  }
  #loading-progress-text {
    font-size: 12px;
    font-weight: 700;
    color: var(--text3);
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  #loading-actions {
    width: 100%;
    display: none;
    gap: 10px;
    margin-top: 2px;
  }
  #loading-actions.show { display: flex; }
  #loading-actions button {
    flex: 1;
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(71,85,105,0.72);
    background: rgba(31,41,55,0.92);
    color: #f8fafc;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.12s ease, transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
  }
  #loading-actions button:hover {
    filter: brightness(1.06);
  }
  #loading-actions button:active {
    transform: scale(0.97);
  }
  #loading-action-primary {
    background: rgba(29, 78, 216, 0.92);
    border-color: rgba(59, 130, 246, 0.7);
  }
  #loading-card[data-tone="failure"] #loading-action-primary {
    background: rgba(185, 28, 28, 0.92);
    border-color: rgba(248, 113, 113, 0.52);
  }
#loading-card[data-tone="success"] .spinner,
#loading-card[data-tone="failure"] .spinner {
  display: none;
}

#local-storage-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5,12,28,0.76);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}
#local-storage-popup-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
#local-storage-popup {
  width: min(92vw, 360px);
  background: rgba(17,24,39,0.97);
  border: 1px solid rgba(46,61,85,0.95);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  padding: 22px 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: scale(0.96) translateY(8px);
  opacity: 0;
  transition: transform 0.16s ease, opacity 0.16s ease;
}
#local-storage-popup-overlay.show #local-storage-popup {
  transform: scale(1) translateY(0);
  opacity: 1;
}
#local-storage-popup-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
}
#local-storage-popup-subtitle {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text3);
  text-align: center;
}
#local-storage-popup-actions {
  width: 100%;
  display: flex;
  gap: 10px;
  margin-top: 2px;
}
.local-storage-popup-btn {
  flex: 1;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(71,85,105,0.72);
  background: rgba(31,41,55,0.92);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
  transition: filter 0.12s ease, transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.local-storage-popup-btn:hover {
  filter: brightness(1.06);
}
.local-storage-popup-btn:active {
  transform: scale(0.97);
}
.local-storage-popup-btn svg {
  flex-shrink: 0;
}

  /* project list rows */
  .project-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid rgba(71,85,105,0.32);
    transition: border-color 0.14s ease, background 0.14s ease, opacity 0.14s ease;
  }
  .project-row:last-child { border-bottom: none; }
  .project-row.active {
    margin: 0 -10px;
    padding: 14px 10px;
    border: 1px solid rgba(201,138,46,0.55);
    border-bottom-color: rgba(201,138,46,0.55);
    border-radius: 14px;
    background: rgba(201,138,46,0.08);
  }
  body.ipad-mode .project-row.active {
    margin: 0;
    padding-left: 14px;
    padding-right: 14px;
  }
  .project-row.is-unavailable {
    opacity: 0.5;
  }
  .project-row.is-unavailable .project-row-code,
  .project-row.is-unavailable .project-row-meta {
    color: var(--text3) !important;
  }
  .project-row-code {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.01em;
  }
  .project-row-meta {
    font-size: 12px;
    color: var(--text3);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .project-row-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
  }
  .project-row-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    flex: 0 0 auto;
    box-shadow: 0 0 0 1px rgba(226,232,240,0.08);
  }
  .project-row-icon-btn {
    border: 1px solid rgba(95,118,144,0.38);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    padding: 0;
    border-radius: 10px;
    cursor: pointer;
    touch-action: manipulation;
    min-height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.12s ease, transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  }
  .project-row-icon-btn--download,
  .project-row-icon-btn--upload,
  .project-row-icon-btn--edit {
    background: #223045;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  }
  .project-row-icon-btn--delete {
    background: var(--danger);
  }
  .project-row-icon-btn.is-recommended {
    background: #3A7D5D;
    border-color: rgba(103,160,128,0.42);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  }
  .project-row-icon-btn.is-disabled {
    background: #4B5563;
    border-color: rgba(148,163,184,0.16);
    color: rgba(241,245,249,0.6);
    box-shadow: none;
  }
  .project-row-icon-btn.is-danger {
    background: var(--danger);
    box-shadow: none;
  }
  .project-row-icon-btn:hover {
    filter: brightness(1.08);
  }
  .project-row-icon-btn:active {
    transform: scale(0.96);
  }
  .project-row-icon-btn:disabled {
    opacity: 1;
    filter: none;
  }
  body:not(.ipad-mode):not(.web-mode) .project-row {
    gap: 10px;
    padding: 11px 0;
  }
  body:not(.ipad-mode):not(.web-mode) .project-row.active {
    margin: 0 -6px;
    padding: 12px 8px;
    border-radius: 12px;
  }
  body:not(.ipad-mode):not(.web-mode) .project-row-code {
    font-size: 15px;
    font-weight: 800;
  }
  body:not(.ipad-mode):not(.web-mode) .project-row-actions {
    gap: 6px;
  }
  body:not(.ipad-mode):not(.web-mode) .project-row-status-dot {
    width: 8px;
    height: 8px;
  }
  body:not(.ipad-mode):not(.web-mode) .project-row-icon-btn {
    min-width: 36px;
    min-height: 36px;
    border-radius: 9px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 3px 8px rgba(7, 12, 20, 0.1);
  }
  body:not(.ipad-mode):not(.web-mode) .project-row-icon-btn:hover {
    filter: brightness(1.05);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 4px 10px rgba(7, 12, 20, 0.12);
  }
  body:not(.ipad-mode):not(.web-mode) .project-row-icon-btn:focus-visible {
    filter: brightness(1.05);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 4px 10px rgba(7, 12, 20, 0.12);
  }
  body:not(.ipad-mode):not(.web-mode) .project-row-icon-btn:active {
    filter: brightness(0.97);
    transform: scale(0.96);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 2px 5px rgba(7, 12, 20, 0.08);
  }
    .project-form-mode {
      margin-bottom: 14px;
      padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(59,130,246,0.14);
    background: rgba(59,130,246,0.05);
  }
  .project-form-mode[data-mode="edit"] {
    border-color: rgba(59,130,246,0.34);
    background: rgba(59,130,246,0.1);
  }
  .project-form-mode-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(148,163,184,0.16);
    color: var(--text2);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
  }
  .project-form-mode[data-mode="edit"] .project-form-mode-chip {
    background: rgba(59,130,246,0.16);
    color: #93c5fd;
  }
  .project-form-mode-text {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text2);
    line-height: 1.5;
  }
  #project-form-panel {
    display: none;
  }
  #project-form-panel.open {
    display: block;
  }

  /* ══ ANNOTATION OVERLAY ════════════════════════════════ */
  #annot-overlay {
    position: fixed; inset: 0; z-index: 8000;
    background: #080d18;
    display: none; flex-direction: column;
    -webkit-user-select: none; user-select: none;
  }
  #annot-overlay.open { display: flex; }

  #annot-toolbar {
    background: #0d1520;
    flex-shrink: 0;
    border-bottom: 1px solid #1e2d42;
    padding-top: env(safe-area-inset-top, 0px);
  }

  #annot-row1, #annot-row2 {
    display: flex; align-items: center;
    padding: 7px 12px; gap: 6px;
    min-height: 56px; /* comfortable touch row */
  }
  #annot-row1 { border-bottom: 1px solid #1a2535; }
  #annot-row2 {
    gap: 7px;
    justify-content: flex-start;
  }

  #annot-canvas-wrap {
    flex: 1; position: relative; overflow: hidden;
    touch-action: none;
    display: flex; align-items: center; justify-content: center;
    background: #060b14;
  }
  #annot-bg {
    position: absolute;
    max-width: 100%; max-height: 100%;
    object-fit: contain; pointer-events: none;
  }
  #annot-draw {
    position: absolute; cursor: crosshair; touch-action: none;
  }

  #annot-footer {
    display: flex; gap: 12px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: #0d1520; flex-shrink: 0;
    border-top: 1px solid #1e2d42;
  }

  /* Tool buttons — 48×48px minimum (Apple HIG) */
  .annot-tool {
    width: 48px; height: 48px; border-radius: 12px;
    border: 2px solid transparent;
    background: #1b2438;
    color: #94a3b8; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; touch-action: manipulation;
    transition: background .12s, border-color .12s, transform .08s;
    -webkit-tap-highlight-color: transparent;
  }
  .annot-tool:active { transform: scale(0.90); }
  .annot-tool.active {
    background: #1e3354; border-color: #3b82f6; color: #fff;
  }

  /* Colour swatches — 40×40px (comfortable touch) */
  .annot-swatch {
    width: 36px; height: 36px; border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer; flex-shrink: 0;
    touch-action: manipulation;
    transition: transform .1s, border-color .1s;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.1);
  }
  .annot-swatch:active { transform: scale(0.88); }
  .annot-swatch.active {
    border-color: #fff;
    transform: scale(1.18);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.35);
  }

  .annot-sep {
    width: 1px; height: 32px; background: #1e2d42;
    flex-shrink: 0; margin: 0 2px 0 1px;
  }
  .annot-label {
    font-size: 10px; font-weight: 700; color: #4b5d74;
    letter-spacing: .04em; white-space: nowrap; flex-shrink: 0;
    text-transform: uppercase;
  }
  #annot-size {
    flex: 0 0 96px;
    width: 96px;
    min-width: 96px;
    max-width: 96px;
    display: block;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    accent-color: #3b82f6;
  }
