:root {
  --ink: #18201e;
  --muted: #66706d;
  --line: #dfe4e1;
  --paper: #f6f7f4;
  --panel: #ffffff;
  --sidebar: #14201d;
  --sidebar-muted: #91a09b;
  --accent: #dff36a;
  --accent-dark: #a7be2f;
  --orange: #ff8657;
  --blue: #5f86ef;
  --purple: #a778df;
  --teal: #32a88e;
  --shadow: 0 14px 44px rgba(24, 32, 30, .12);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.arrow-touch-grip { display: none; }
.finish-drawing { position: absolute; right: 14px; bottom: 70px; z-index: 5; min-height: 44px; padding: 0 20px; box-shadow: var(--shadow); }
.account-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; overflow: auto; background: #14201d; }
.account-card { width: min(100%,430px); margin: auto; padding: 32px; background: var(--paper); border-radius: 20px; box-shadow: var(--shadow); }
.account-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 22px; border-radius: 13px; background: var(--accent); font-size: 30px; }
.account-card h1 { font-family: Georgia,serif; font-size: 30px; margin: 12px 0; }
.account-card p { font-size: 13px; line-height: 1.6; color: var(--muted); }
.account-card .field-label { margin-top: 18px; }
.account-card .text-input { font-size: 16px; }
.account-card .account-message { min-height: 24px; color: #a13030; }
.account-card .account-help { font-size: 11px; margin-bottom: 0; }
.account-card code { overflow-wrap: anywhere; }
.account-feedback { color: #ffc3b3; font-size: 11px; line-height: 1.4; }
.sidebar-collapsed .account-feedback { display: none; }
.local-note #accountIdentity { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.autosave::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #4eb58e; margin-right: 5px; }
.autosave[data-status="saving"]::before { background: #dfad39; }
.autosave[data-status="error"] { color: #b42f2f; }
.autosave[data-status="error"]::before { background: #b42f2f; }
.workspace { position: relative; }
.server-save-warning { position: absolute; z-index: 10; top: 0; left: 0; right: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; background: #fff0e6; border: 1px solid #ecb59c; font-size: 12px; }
.server-save-warning span { flex: 1 1 240px; }
.server-save-warning button { background: white; border: 1px solid #ecb59c; border-radius: 6px; padding: 8px; cursor: pointer; }

.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); height: 100%; }
.sidebar { background: var(--sidebar); color: white; padding: 24px 16px 18px; display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 25px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--sidebar); background: var(--accent); }
.brand-mark svg { width: 26px; height: 26px; stroke-width: 2.4; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand span { color: var(--sidebar-muted); font-size: 9px; font-weight: 700; letter-spacing: .18em; margin-top: 1px; }
.primary-button, .secondary-button { border: 0; border-radius: 10px; min-height: 42px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 700; transition: transform .15s, background .15s, opacity .15s; }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
.primary-button { background: var(--accent); color: #19221f; }
.secondary-button { background: white; border: 1px solid var(--line); }
.primary-button svg, .secondary-button svg { width: 18px; height: 18px; }
.new-project-button { width: 100%; margin-bottom: 27px; }
.sidebar-section-label, .eyebrow { color: var(--sidebar-muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.sidebar-section-label { padding: 0 10px 9px; }
.project-list { display: flex; flex-direction: column; gap: 5px; overflow-y: auto; margin: 0 -4px; padding: 0 4px 10px; }
.project-item { display: grid; grid-template-columns: 33px 1fr auto; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; color: #c9d3d0; border-radius: 10px; padding: 9px 8px; text-align: left; cursor: pointer; }
.project-item:hover { background: rgba(255,255,255,.055); }
.project-item.active { background: rgba(223,243,106,.11); color: white; }
.project-icon { width: 33px; height: 33px; border-radius: 9px; background: rgba(255,255,255,.07); display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.project-item.active .project-icon { background: var(--accent); color: var(--sidebar); }
.project-copy { min-width: 0; }
.project-copy strong, .project-copy span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-copy strong { font-size: 12px; font-weight: 650; }
.project-copy span { color: var(--sidebar-muted); font-size: 10px; margin-top: 3px; }
.project-menu { opacity: 0; color: var(--sidebar-muted); font-weight: 900; }
.project-item:hover .project-menu { opacity: 1; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding-top: 16px; }
.local-note { display: flex; gap: 9px; align-items: flex-start; padding: 0 7px 13px; }
.local-note svg { width: 17px; height: 17px; color: var(--accent); flex: none; }
.local-note strong, .local-note span { display: block; }
.local-note strong { font-size: 11px; }
.local-note span { font-size: 9px; color: var(--sidebar-muted); margin-top: 3px; line-height: 1.35; }
.sidebar-link { width: 100%; padding: 7px; border: 0; background: transparent; color: var(--sidebar-muted); text-align: left; font-size: 11px; cursor: pointer; }
.sidebar-link span { display: inline-grid; width: 18px; height: 18px; border: 1px solid currentColor; place-items: center; border-radius: 50%; margin-right: 6px; }
.app-shell.sidebar-collapsed { grid-template-columns: 74px minmax(0,1fr); }
.sidebar-collapsed .brand { justify-content: center; padding-inline: 0; }
.sidebar-collapsed .brand > div:last-child, .sidebar-collapsed .sidebar-section-label, .sidebar-collapsed .project-copy, .sidebar-collapsed .project-menu, .sidebar-collapsed .local-note div { display: none; }
.sidebar-collapsed .new-project-button { padding: 0; font-size: 0; }
.sidebar-collapsed .project-item { grid-template-columns: 1fr; padding: 7px; }
.sidebar-collapsed .project-icon { margin: auto; }
.sidebar-collapsed .sidebar-link { font-size: 0; text-align: center; }
.sidebar-collapsed .sidebar-link span { font-size: 11px; margin-right: 0; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-toggle { flex: none; }
.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
.sidebar-backdrop { display: none; }

.main-area { min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: 64px minmax(0, 1fr); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 22px; background: white; border-bottom: 1px solid var(--line); }
.breadcrumb { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 650; }
.breadcrumb > svg { width: 15px; height: 15px; color: #9ba4a0; }
.plan-selector { border: 0; background: transparent; padding: 7px; display: flex; align-items: center; gap: 5px; color: var(--muted); cursor: pointer; border-radius: 7px; }
.plan-selector:hover { background: var(--paper); }
.plan-selector svg { width: 14px; height: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.autosave { color: var(--muted); font-size: 10px; margin-right: 5px; }
.autosave span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #4eb58e; margin-right: 5px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); background: white; border-radius: 9px; display: grid; place-items: center; cursor: pointer; }
.icon-button:hover { background: var(--paper); }
.icon-button:disabled { opacity: .35; cursor: default; }
.icon-button svg { width: 16px; height: 16px; }
.secondary-button { min-height: 36px; font-size: 11px; }

.workspace { --rail-width: 86px; display: grid; grid-template-columns: var(--rail-width) minmax(300px, 1fr) 288px; min-height: 0; }
.workspace.inspector-collapsed { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
.workspace.inspector-collapsed .inspector { display: none; }
.inspector-open-buttons { position: absolute; top: 14px; right: 14px; z-index: 4; display: flex; gap: 6px; }
.inspector-open-button { box-shadow: var(--shadow); padding: 8px 11px; }
.inspector-open-button.active { background: #eef4ce; border-color: var(--accent-dark); }
.annotation-title { font-family: Georgia,serif; font-size: 18px; margin: 16px 0 8px; }
@media(max-width:1050px) { .inspector-open-buttons { top: 60px; } }
.tool-rail { background: white; border-right: 1px solid var(--line); padding: 13px 8px; display: flex; flex-direction: column; gap: 5px; overflow-y: auto; }
.tool-button { border: 0; background: transparent; border-radius: 10px; min-height: 57px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #6d7673; font-size: 8px; font-weight: 650; cursor: pointer; }
.tool-button:hover { background: #f2f4f1; color: var(--ink); }
.tool-button.active { background: #eef4ce; color: #51600f; }
.tool-button svg { width: 22px; height: 22px; }
.tool-divider { height: 1px; background: var(--line); margin: 5px 7px; }

.canvas-shell { position: relative; min-width: 0; min-height: 0; overflow: hidden; background-color: #e9ebe7; background-image: radial-gradient(#ced3ce 1px, transparent 1px); background-size: 18px 18px; }
#planCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.canvas-shell[data-tool="select"] #planCanvas { cursor: default; }
.canvas-shell[data-tool="arc"] #planCanvas, .canvas-shell[data-tool="manual"] #planCanvas, .canvas-shell[data-tool="calibrate"] #planCanvas { cursor: crosshair; }
.canvas-shell.panning #planCanvas { cursor: grabbing; }
.canvas-shell[data-tool="rectangle"] #planCanvas { cursor: crosshair; }
.canvas-shell[data-tool="annotation"] #planCanvas { cursor: crosshair; }
.annotation-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; z-index: 1; }
.plan-arrow { pointer-events: none; }
.arrow-hit { stroke: transparent; stroke-width: 24; fill: none; pointer-events: stroke; cursor: grab; touch-action: none; }
.arrow-line, .arrow-outline { stroke: #c25077; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.arrow-outline { stroke: white; stroke-width: 8; }
.plan-arrow .arrow-line, .plan-arrow.selected .arrow-line { stroke: var(--arrow-color,#c25077); }
.plan-arrow .arrow-move, .plan-arrow .arrow-rotate { stroke: var(--arrow-color,#c25077); }
.plan-arrow .arrow-rotate { fill: var(--arrow-color,#c25077); fill-opacity: .2; }
.plan-arrow .arrow-number { fill: var(--arrow-color,#c25077); }
.arrow-style-control { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.arrow-style-control .field-label:first-child { margin-top: 0; }
.arrow-style-control .secondary-button { margin-top: 10px; min-height: 30px; padding: 6px 9px; font-size: 10px; }
.plan-arrow.selected .arrow-line { stroke: var(--arrow-color,#c25077); }
.arrow-move, .arrow-rotate { fill: white; stroke: #8f2859; stroke-width: 2; pointer-events: all; cursor: move; touch-action: none; }
.arrow-rotate { fill: #f8d7e7; cursor: crosshair; }
.arrow-number { font: bold 12px sans-serif; fill: #8f2859; paint-order: stroke; stroke: white; stroke-width: 3; }
.canvas-shell:not([data-tool="select"]):not([data-tool="annotation"]) .arrow-hit, .canvas-shell:not([data-tool="select"]):not([data-tool="annotation"]) .arrow-move, .canvas-shell:not([data-tool="select"]):not([data-tool="annotation"]) .arrow-rotate { pointer-events: none; }
.arrow-details { margin-top: 16px; }
.arrow-details .field-label { display: block; margin-top: 15px; margin-bottom: 7px; }
.arrow-details input[type="range"] { width: 100%; accent-color: #8f2859; }
.arrow-photo-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.arrow-photo-actions .secondary-button { font-size: 10px; padding: 8px; min-height: 36px; }
.arrow-photos { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.arrow-photo { min-width: 0; }
.arrow-photo button { width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: white; cursor: pointer; font-size: 10px; }
.arrow-photo img { display: block; width: 100%; height: 100px; object-fit: cover; border-radius: 6px; }
.arrow-photo button[data-remove-photo] { margin-top: 4px; padding: 5px; color: #9f3d34; }
.arrow-list-section { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 20px; }
.arrow-list-item { display: block; width: 100%; margin-top: 9px; padding: 10px; border: 1px solid var(--line); background: white; border-radius: 9px; text-align: left; cursor: pointer; }
.arrow-list-item strong, .arrow-list-item span { display: block; font-size: 11px; overflow-wrap: anywhere; }
.arrow-list-item span { color: var(--muted); margin-top: 4px; white-space: pre-line; }
.arrow-list-item:hover { border-color: #c25077; }
.arrow-photo-dialog { max-width: 94vw; max-height: 94vh; border: 0; border-radius: 12px; padding: 15px; }
.arrow-photo-dialog::backdrop { background: rgba(0,0,0,.65); }
.arrow-photo-dialog img { display: block; max-width: 85vw; max-height: 75vh; object-fit: contain; margin-top: 12px; }
.canvas-shell[data-tool="rectangle"].panning #planCanvas { cursor: grabbing; }
.rectangle-options { position:absolute;top:58px;left:14px;display:flex;align-items:center;gap:7px;background:white;border:1px solid var(--line);border-radius:9px;padding:7px;font-size:10px;box-shadow:0 4px 18px rgba(24,32,30,.09); }
.rectangle-options button { border:0;border-radius:5px;background:#eef4ce;color:#51600f;padding:5px 7px;cursor:pointer;font-size:10px; }
.canvas-hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 8px 12px; border-radius: 9px; background: rgba(20,32,29,.86); color: #e7ece9; font-size: 9px; pointer-events: none; backdrop-filter: blur(7px); white-space: nowrap; }
kbd { font-family: inherit; border: 1px solid #cfd5d1; border-bottom-width: 2px; background: white; color: #34403c; padding: 1px 4px; border-radius: 4px; font-size: 9px; }
.canvas-hint kbd { background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.28); color: white; }
.zoom-controls { position: absolute; left: 14px; bottom: 14px; display: flex; height: 33px; background: white; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; box-shadow: 0 5px 20px rgba(24,32,30,.08); }
.zoom-controls button { width: 34px; border: 0; border-right: 1px solid var(--line); background: white; cursor: pointer; font-size: 17px; }
.zoom-controls button:hover { background: var(--paper); }
.zoom-controls button svg { width: 15px; }
.zoom-controls span { display: grid; place-items: center; min-width: 49px; font-size: 9px; color: var(--muted); }
.scale-chip { position: absolute; top: 14px; left: 14px; background: white; border: 1px solid var(--line); box-shadow: 0 4px 18px rgba(24,32,30,.09); border-radius: 9px; min-height: 34px; padding: 0 8px; display: flex; align-items: center; gap: 7px; font-size: 9px; font-weight: 650; }
.scale-dot { width: 7px; height: 7px; border-radius: 50%; background: #42ae84; }
.scale-chip.uncalibrated .scale-dot { background: #e3aa3b; }
.scale-chip button { border: 0; color: #64781a; background: #eef4ce; border-radius: 5px; padding: 3px 6px; cursor: pointer; font-size: 8px; font-weight: 700; }
.hover-tooltip { position: absolute; z-index: 3; pointer-events: none; transform: translate(12px, -110%); background: #17201d; color: white; border-radius: 8px; padding: 7px 9px; box-shadow: var(--shadow); font-size: 10px; line-height: 1.35; }
.hover-tooltip strong { display: block; font-size: 12px; color: var(--accent); }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; padding: 30px; background: rgba(233,235,231,.9); }
.empty-icon { width: 72px; height: 72px; display: grid; place-items: center; border-radius: 20px; background: white; box-shadow: var(--shadow); color: #637019; }
.empty-icon svg { width: 42px; stroke-width: 2; }
.empty-state h2 { margin: 18px 0 5px; font-family: Georgia, serif; font-size: 25px; }
.empty-state p { color: var(--muted); max-width: 350px; font-size: 12px; line-height: 1.6; margin: 0 0 17px; }

.inspector { background: white; border-left: 1px solid var(--line); min-width: 0; padding: 20px 18px; overflow-y: auto; display: flex; flex-direction: column; }
.inspector-header { display: flex; justify-content: space-between; align-items: flex-start; }
.inspector .eyebrow { color: #89938f; }
.inspector-header h2 { font-family: Georgia, serif; margin: 5px 0 0; font-size: 21px; font-weight: 600; }
.inspector-header .icon-button { width: 29px; height: 29px; }
.inspector-header { gap: 10px; }
.inspector-heading { flex: 1; min-width: 0; }
.inspector-header .icon-button { flex: none; }
.inspector-back { margin-top: 1px; }
#annotationOverview { border-top: 0; margin-top: 12px; padding-top: 0; }
.selection-empty { padding: 30px 7px 26px; text-align: center; border-bottom: 1px solid var(--line); }
.selection-illustration svg { width: 120px; color: #b8c0bc; stroke-width: 2; }
.selection-illustration .accent { color: var(--orange); stroke-width: 4; }
.selection-illustration .accent-fill { fill: var(--orange); stroke: white; }
.selection-empty p { color: var(--muted); font-size: 11px; line-height: 1.55; margin: 13px auto 8px; max-width: 210px; }
.selection-empty small { color: #959e9a; font-size: 9px; }
.selection-details { padding: 18px 0 21px; border-bottom: 1px solid var(--line); }
.total-card { background: #f3f6e4; border-radius: 11px; padding: 13px 14px; display: grid; grid-template-columns: 1fr auto; align-items: baseline; margin-bottom: 15px; }
.total-card span { color: var(--muted); font-size: 9px; font-weight: 650; }
.total-card strong { font-family: Georgia, serif; font-size: 24px; }
.total-card small { color: #85906b; font-size: 9px; grid-column: 1/-1; margin-top: 3px; }
.field-label { display: block; font-size: 9px; color: #818b87; font-weight: 800; letter-spacing: .1em; margin: 0 0 6px; }
.select-input, .text-input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: white; padding: 0 10px; color: var(--ink); font-size: 11px; outline: none; }
.select-input:focus, .text-input:focus { border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgba(199,220,82,.2); }
.note-input { height: auto; min-height: 90px; padding: 10px; resize: vertical; line-height: 1.5; }
.note-hint { color: var(--muted); font-size: 10px; line-height: 1.5; margin: 6px 0; }
.hover-tooltip { max-width: 280px; white-space: pre-wrap; overflow-wrap: anywhere; }
.summary-card { width: 100%; background: white; text-align: left; cursor: pointer; }
.summary-card:hover { border-color: var(--accent-dark); }
.segment-row button { border: 0; background: none; color: inherit; cursor: pointer; text-align: left; }
.wide { width: 100%; margin-top: 8px; min-height: 39px; font-size: 11px; }
.segment-list { margin-top: 10px; max-height: 112px; overflow-y: auto; }
.segment-row { display: flex; align-items: center; justify-content: space-between; font-size: 9px; color: var(--muted); padding: 5px 2px; }
.segment-row strong { color: var(--ink); }
.measurement-color-control { margin-bottom: 16px; }
.color-palette { display: flex; flex-wrap: wrap; gap: 8px; padding: 3px; }
.color-swatch { width: 27px; height: 27px; border: 2px solid white; border-radius: 50%; background: var(--swatch-color); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.color-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.color-swatch:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 4px; }
.color-swatch:disabled { cursor: wait; opacity: .6; }
#arrowColorOptions .color-swatch { width: 34px; height: 34px; min-height: 34px; padding: 0; margin: 0; }
.custom-measure-color { display: flex; align-items: center; gap: 8px; margin-top: 9px; color: var(--muted); font-size: 10px; }
.custom-measure-color input { width: 32px; height: 26px; padding: 2px; border: 1px solid var(--line); border-radius: 5px; background: white; cursor: pointer; }
.custom-measure-color span { font-size: 9px; }
.selection-name { border: 0; background: transparent; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.selection-name:hover:not(:disabled) { text-decoration: underline dotted; text-underline-offset: 4px; }
.selection-name:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 4px; border-radius: 3px; }
.selection-name:disabled { cursor: default; opacity: 1; }
.inspector-header h2 { overflow-wrap: anywhere; }
.segment-row button { min-width: 0; overflow-wrap: anywhere; }
.summary-section { padding-top: 19px; }
.delete-selection-button { min-height: 38px; margin-top: 14px; padding: 9px 12px; border: 1px solid #e5b0aa; border-radius: 9px; background: #fff5f3; color: #9f3d34; font-size: 11px; font-weight: 650; cursor: pointer; }
.delete-selection-button:hover { background: #ffe9e5; border-color: #9f3d34; }
.delete-selection-button:focus-visible { outline: 2px solid #9f3d34; outline-offset: 3px; }
.summary-search { display: grid; grid-template-columns: minmax(0,1fr) 34px; gap: 6px; margin-top: 12px; }
.summary-search .icon-button { width: 34px; height: 40px; font-size: 22px; }
.summary-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.summary-search-status { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.summary-search-status:empty { display: none; }
.annotation-filters { margin-top: 14px; }
.annotation-date-range { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; }
.annotation-date-range > div { min-width: 0; }
.annotation-filters .text-input { min-width: 0; width: 100%; max-width: 100%; font-size: 12px; }
.annotation-filters .secondary-button { margin-top: 12px; }
.annotation-filter-error { color: #a13030; font-size: 11px; line-height: 1.5; margin: 8px 0 0; }
.annotation-filter-error:empty { display: none; }
.annotation-filters input[aria-invalid="true"] { border-color: #a13030; }
.section-title-row { display: flex; justify-content: space-between; align-items: center; }
.section-title-row button { border: 0; background: transparent; color: #667818; font-size: 9px; font-weight: 750; cursor: pointer; }
.summary-list { margin-top: 11px; display: flex; flex-direction: column; gap: 7px; }
.summary-empty { color: var(--muted); font-size: 10px; line-height: 1.5; padding: 12px 0; }
.summary-card { display: grid; grid-template-columns: 7px 1fr auto; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; }
.summary-color { width: 7px; height: 30px; border-radius: 5px; }
.summary-copy { min-width: 0; }
.summary-copy strong, .summary-copy span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-copy strong { font-size: 9px; }
.summary-copy span { color: var(--muted); font-size: 8px; margin-top: 3px; }
.summary-value { text-align: right; }
.summary-value strong, .summary-value span { display: block; }
.summary-value strong { font-family: Georgia, serif; font-size: 14px; }
.summary-value span { color: var(--muted); font-size: 8px; margin-top: 2px; }
.grand-total { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; display: flex; justify-content: space-between; align-items: center; font-size: 9px; color: var(--muted); }
.grand-total strong { color: var(--ink); font-family: Georgia, serif; font-size: 17px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,24,21,.56); display: grid; place-items: center; z-index: 20; backdrop-filter: blur(3px); padding: 20px; }
.modal { width: min(430px, 100%); max-height: min(720px, 90vh); overflow-y: auto; background: white; border-radius: 17px; box-shadow: 0 25px 80px rgba(0,0,0,.27); padding: 25px; }
.modal h2 { font-family: Georgia, serif; font-size: 25px; margin: 0 0 7px; }
.modal > p { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 0 0 20px; }
.modal-form { display: grid; gap: 13px; }
.modal-row { display: grid; grid-template-columns: 1fr 110px; gap: 9px; }
.modal label span { display: block; font-size: 9px; font-weight: 800; letter-spacing: .08em; color: #7e8884; margin-bottom: 5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 21px; }
.modal-actions button { min-width: 90px; }
.modal .ghost-button { border: 0; background: #f0f2ef; border-radius: 9px; cursor: pointer; font-weight: 650; font-size: 11px; }
.modal .danger-button { border: 0; background: #ef675d; color: white; border-radius: 9px; padding: 0 14px; font-weight: 700; cursor: pointer; }
.plan-option { width: 100%; display: flex; gap: 12px; align-items: center; padding: 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; }
.plan-option:hover, .plan-option.active { background: #f0f3e2; }
.plan-thumb { width: 48px; height: 36px; background: #e8ebe7; border: 1px solid var(--line); border-radius: 6px; display: grid; place-items: center; }
.plan-thumb svg { width: 21px; color: #727e79; }
.plan-option strong, .plan-option span { display: block; }
.plan-option strong { font-size: 11px; }
.plan-option span { font-size: 9px; color: var(--muted); margin-top: 3px; }
.upload-plan-option { color: #5c7010; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; }
.calibration-preview { height: 82px; border-radius: 10px; background: #eff1ed; display: grid; place-items: center; margin-bottom: 16px; position: relative; overflow: hidden; }
.calibration-preview::before { content:""; width: 70%; height: 3px; background: var(--orange); position: absolute; }
.calibration-preview::after { content:""; width: 70%; height: 18px; border-left: 3px solid var(--orange); border-right: 3px solid var(--orange); position: absolute; }
.step-list { display: grid; gap: 13px; margin: 20px 0 0; }
.step { display: grid; grid-template-columns: 28px 1fr; gap: 10px; }
.step b { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--accent); font-size: 11px; }
.step strong, .step span { display: block; }
.step strong { font-size: 11px; }
.step span { color: var(--muted); font-size: 10px; line-height: 1.5; margin-top: 2px; }
.toast-region { position: fixed; right: 310px; top: 76px; z-index: 30; display: grid; gap: 7px; }
.toast { background: #17201d; color: white; border-radius: 9px; padding: 10px 13px; box-shadow: var(--shadow); font-size: 10px; animation: toast-in .2s ease-out; }
.toast.success { border-left: 4px solid var(--accent); }
.toast.error { border-left: 4px solid #ef675d; }
@keyframes toast-in { from { transform: translateY(-7px); opacity: 0; } }

@media (max-width: 1050px) {
  .workspace { --rail-width: 72px; grid-template-columns: var(--rail-width) minmax(0, 1fr) 270px; }
  .topbar { padding-inline: 12px; gap: 8px; }
  .breadcrumb { min-width: 0; }
  .breadcrumb > span { max-width: 125px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .plan-selector { min-width: 0; }
  .plan-selector span { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .autosave { display: none; }
}
@media (max-width: 760px) {
  html, body { overflow: auto; }
  .app-shell { display: block; min-height: 100%; }
  .sidebar { display: none; }
  .app-shell:not(.sidebar-collapsed) .sidebar { display: flex; position: fixed; top: 56px; bottom: 0; left: 0; width: 244px; z-index: 10; box-shadow: var(--shadow); }
  .app-shell:not(.sidebar-collapsed) .sidebar-backdrop { display: block; position: fixed; top: 56px; bottom: 0; left: 0; right: 0; width: 100%; border: 0; background: rgba(0,0,0,.3); z-index: 9; }
  .main-area { min-height: 100vh; grid-template-rows: 56px minmax(0, 1fr); }
  .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(520px, calc(100vh - 56px)) auto; }
  .workspace.inspector-collapsed { grid-template-columns: 1fr; grid-template-rows: minmax(520px, calc(100vh - 56px)); }
  .tool-rail { position: fixed; z-index: 8; left: 10px; right: 10px; bottom: 10px; height: 64px; display: flex; flex-direction: row; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 5px; overflow-x: auto; }
  .tool-button { min-width: 64px; min-height: 50px; }
  .tool-divider { width: 1px; height: 35px; margin: 8px 3px; flex: none; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); padding-bottom: 90px; }
  .canvas-hint { display: none; }
  .zoom-controls { bottom: 84px; }
  .toast-region { right: 12px; top: 66px; }
  .autosave { display: none; }
  .topbar { padding: 0 10px; }
  .breadcrumb > span, .breadcrumb > svg { display: none; }
}

/* Tablet/touch layout, independent of iPad orientation or desktop-style user agent. */
@media (any-pointer: coarse), (max-width: 760px) {
  html, body { overflow: hidden; height: 100%; }
  .app-shell, .app-shell.sidebar-collapsed { display: block; height: 100vh; height: 100dvh; min-height: 0; }
  .main-area { height: 100%; min-height: 0; grid-template-rows: 64px minmax(0,1fr); }
  .sidebar { display: none; }
  .app-shell:not(.sidebar-collapsed) .sidebar { display: flex; position: fixed; top: 64px; bottom: 0; left: 0; width: min(300px,85vw); z-index: 32; padding-bottom: max(20px,env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
  .app-shell:not(.sidebar-collapsed) .sidebar-backdrop { display: block; position: fixed; top: 64px; bottom: 0; left: 0; right: 0; width: 100%; border: 0; background: rgba(0,0,0,.3); z-index: 31; }
  .workspace, .workspace.inspector-collapsed { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr); height: 100%; min-height: 0; padding: 0; }
  .canvas-shell { grid-column: 1; grid-row: 1; min-height: 0; }
  .tool-rail { position: absolute; left: max(12px,env(safe-area-inset-left)); right: max(12px,env(safe-area-inset-right)); bottom: max(12px,env(safe-area-inset-bottom)); top: auto; height: 76px; z-index: 12; display: flex; flex-direction: row; align-items: stretch; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.98); box-shadow: var(--shadow); overflow-x: auto; overflow-y: hidden; touch-action: pan-x; -webkit-overflow-scrolling: touch; }
  .tool-button { flex: 1 0 72px; min-width: 72px; min-height: 60px; font-size: 11px; padding: 6px; touch-action: manipulation; }
  .tool-button svg { width: 25px; height: 25px; }
  .tool-divider { width: 1px; height: 38px; margin: 10px 3px; flex: none; }
  .inspector { position: absolute; z-index: 8; right: 12px; top: 72px; bottom: calc(102px + env(safe-area-inset-bottom)); width: min(360px,44vw); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .inspector-header { position: sticky; z-index: 2; top: -16px; margin: -16px -16px 0; padding: 16px 12px 12px; background: white; border-bottom: 1px solid var(--line); }
  .inspector-header h2 { font-size: 23px; }
  .icon-button, .inspector-header .icon-button, .summary-search .icon-button { min-width: 44px; min-height: 44px; width: 44px; height: 44px; }
  .summary-search { grid-template-columns: minmax(0,1fr) 44px; }
  .inspector .text-input, .modal .text-input, .account-card .text-input { min-height: 44px; font-size: 16px; }
  .annotation-filters .text-input { font-size: 14px; }
  .inspector .primary-button, .inspector .secondary-button, .inspector .delete-selection-button, .modal button, .plan-option { min-height: 44px; font-size: 14px; }
  .inspector .field-label, .inspector .eyebrow { font-size: 11px; }
  .note-hint, .summary-search-status, .summary-empty, .arrow-list-item span { font-size: 12px; }
  .summary-card, .arrow-list-item { min-height: 64px; padding: 14px 10px; }
  .summary-copy strong, .summary-value strong { font-size: 15px; }
  .summary-copy span, .summary-value span { font-size: 12px; }
  .segment-row button { min-height: 44px; font-size: 13px; }
  .segment-row strong { font-size: 13px; }
  .project-item { min-height: 56px; }
  .project-copy strong { font-size: 14px; }
  .sidebar-link { min-height: 44px; font-size: 13px; }
  .color-swatch, #arrowColorOptions .color-swatch { width: 40px; height: 40px; min-height: 40px; }
  .custom-measure-color { flex-wrap: wrap; font-size: 13px; }
  .custom-measure-color input { width: 44px; height: 44px; }
  .arrow-photo button { min-height: 44px; font-size: 13px; }
  input[type="range"] { min-height: 44px; width: 100%; touch-action: pan-y; }
  .inspector-open-buttons { top: 12px; right: 12px; }
  .inspector-open-button { min-height: 44px; font-size: 13px; }
  .scale-chip { top: 12px; left: 12px; min-height: 44px; font-size: 12px; }
  .scale-chip button { min-height: 36px; padding: 4px 8px; font-size: 11px; }
  .zoom-controls { bottom: calc(104px + env(safe-area-inset-bottom)); left: 12px; min-height: 44px; }
  .zoom-controls button { width: 44px; min-height: 44px; font-size: 23px; }
  .zoom-controls span { min-width: 50px; font-size: 12px; }
  .canvas-hint { display: none; }
  .finish-drawing { bottom: calc(106px + env(safe-area-inset-bottom)); right: 14px; font-size: 15px; z-index: 10; }
  .rectangle-options { top: 68px; left: 12px; right: auto; max-width: calc(100% - 24px); flex-wrap: wrap; }
  .rectangle-options button { min-height: 44px; font-size: 12px; }
  .topbar { padding: 0 max(10px,env(safe-area-inset-right)) 0 max(10px,env(safe-area-inset-left)); gap: 8px; }
  .breadcrumb { min-width: 0; }
  .breadcrumb > span, .breadcrumb > svg { display: none; }
  .plan-selector { min-height: 44px; min-width: 0; font-size: 14px; }
  .plan-selector span { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-left { flex: 1; overflow: hidden; }
  .topbar .secondary-button { min-height: 44px; font-size: 13px; padding: 0 10px; }
  .autosave { display: none; }
  .arrow-hit { stroke-width: 44; }
  .arrow-touch-grip { display: block; pointer-events: all; fill: transparent; stroke: none; touch-action: none; }
  .toast-region { left: 12px; right: 12px; top: 74px; z-index: 40; pointer-events: none; }
  .toast { font-size: 13px; }
  .modal { max-height: 85dvh; overflow-y: auto; padding: 22px; }
}
@media (max-width: 700px) {
  .inspector { left: 12px; right: 12px; top: auto; bottom: calc(100px + env(safe-area-inset-bottom)); width: auto; max-height: 48vh; max-height: 48dvh; padding-bottom: 18px; }
  .inspector-open-buttons { top: 68px; right: 12px; }
  .plan-selector span { max-width: 150px; }
  .zoom-controls { bottom: calc(100px + env(safe-area-inset-bottom)); }
}
