:root {
  --ink: #121718;
  --muted: #667071;
  --paper: #f4f3ee;
  --card: #fff;
  --line: #d8d8d0;
  --accent: #ff5a36;
  --accent-dark: #d93d1f;
  --lime: #d8ff49;
  --radius: 18px;
  --shadow: 0 16px 40px rgba(24, 29, 29, .11);
}

* { box-sizing: border-box; }
html { background: var(--ink); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); font-family: "DM Sans", sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; background: radial-gradient(circle at 92% 8%, rgba(255,90,54,.09), transparent 28%), var(--paper); }
.topbar { height: 74px; padding: max(14px, env(safe-area-inset-top)) 20px 12px; display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: white; }
.brand { display: flex; align-items: center; gap: 10px; border: 0; color: white; background: transparent; padding: 0; text-align: left; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border: 2px solid var(--accent); border-radius: 50%; color: var(--accent); font-size: 25px; font-weight: 700; }
.brand b, .brand em { display: block; font-family: "Barlow Condensed", sans-serif; font-size: 20px; line-height: .82; letter-spacing: .06em; font-style: normal; }
.brand em { color: var(--accent); }
.status-pill { display: flex; align-items: center; gap: 7px; color: #c9cece; font-size: 10px; font-weight: 700; letter-spacing: .13em; }
.status-pill i { width: 7px; height: 7px; background: var(--lime); border-radius: 50%; box-shadow: 0 0 0 4px rgba(216,255,73,.12); }

main { width: min(760px, 100%); margin: 0 auto; padding: 32px 18px max(48px, env(safe-area-inset-bottom)); }
.hero { padding: 22px 2px 30px; }
.eyebrow { color: var(--accent-dark); font-size: 11px; font-weight: 800; letter-spacing: .18em; margin: 0 0 10px; }
h1, h2 { font-family: "Barlow Condensed", sans-serif; text-transform: uppercase; margin: 0; line-height: .95; }
.hero h1 { font-size: clamp(48px, 14vw, 76px); letter-spacing: -.02em; }
.hero > p:last-child { color: var(--muted); font-size: 15px; max-width: 410px; margin: 18px 0 0; }

.primary-button, .secondary-button { min-height: 58px; border: 0; border-radius: 12px; padding: 13px 20px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 12px; transition: transform .15s, background .15s; }
.primary-button { background: var(--accent); color: white; box-shadow: 0 8px 18px rgba(255,90,54,.2); }
.primary-button:active, .secondary-button:active { transform: scale(.98); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { border: 2px solid var(--ink); background: transparent; color: var(--ink); }
.new-project-button { width: 100%; justify-content: flex-start; min-height: 84px; padding: 15px 20px; }
.new-project-button .button-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.15); font-size: 29px; font-weight: 400; }
.new-project-button span:last-child { text-align: left; font-size: 17px; }
.new-project-button small { display: block; margin-bottom: 2px; font-size: 9px; letter-spacing: .15em; opacity: .75; }

.section-heading { display: flex; align-items: end; justify-content: space-between; margin: 38px 1px 14px; }
.section-heading h2 { font-size: 27px; }
.section-heading span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.project-list { display: grid; gap: 12px; }
.project-card { width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); display: flex; align-items: stretch; color: var(--ink); box-shadow: 0 4px 0 rgba(18,23,24,.03); }
.project-open { min-width: 0; flex: 1; border: 0; background: transparent; padding: 19px 12px 19px 19px; display: grid; grid-template-columns: 45px minmax(0, 1fr) auto; align-items: center; gap: 14px; color: var(--ink); text-align: left; }
.project-copy { min-width: 0; }
.project-number { width: 45px; height: 45px; display: grid; place-items: center; background: var(--ink); color: white; border-radius: 10px; font-family: "Barlow Condensed", sans-serif; font-size: 20px; }
.project-card h3 { margin: 0 0 5px; font-size: 16px; }
.project-card p { margin: 0; color: var(--muted); font-size: 12px; }
.project-arrow { font-size: 24px; color: var(--accent); }
.project-delete { width: 54px; flex: 0 0 54px; border: 0; border-left: 1px solid var(--line); background: #fff7f4; color: #a62c19; display: grid; place-items: center; }
.project-delete svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.empty-list { padding: 38px 20px; border: 1px dashed #b8b9b2; border-radius: var(--radius); text-align: center; color: var(--muted); }

.back-link { border: 0; background: transparent; padding: 5px 0 22px; color: var(--muted); font-weight: 700; }
.project-title-row { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.project-title-row h1 { font-size: clamp(38px, 11vw, 62px); overflow-wrap: anywhere; }
.count-badge { min-width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; font-family: "Barlow Condensed", sans-serif; font-size: 21px; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 5px; margin: 26px 0 20px; background: #deded7; border-radius: 14px; }
.mode-switch button { min-height: 49px; border: 0; border-radius: 10px; background: transparent; color: #717776; font-weight: 800; }
.mode-switch button.active { background: var(--ink); color: white; box-shadow: 0 4px 10px rgba(0,0,0,.16); }

.capture-card { padding: 18px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.step-label { margin-bottom: 14px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.step-label span { color: var(--accent); font-family: "Barlow Condensed", sans-serif; font-size: 20px; margin-right: 5px; }
.camera-button { min-height: 180px; border: 2px dashed #abaea9; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; background: #f7f7f3; cursor: pointer; }
.camera-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); border: 7px solid #ffd4ca; color: white; font-size: 19px; }
.camera-button strong { font-size: 16px; }
.camera-button small { color: var(--muted); }
.media-preview { margin-top: 12px; position: relative; overflow: hidden; border-radius: 12px; background: var(--ink); }
.media-preview img, .media-preview video { width: 100%; max-height: 280px; display: block; object-fit: contain; }
.media-preview button { position: absolute; top: 8px; right: 8px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: rgba(18,23,24,.82); color: white; font-size: 20px; }
.note-label, dialog label { display: block; margin: 18px 0 8px; font-size: 10px; font-weight: 800; letter-spacing: .12em; }
textarea, dialog input { width: 100%; border: 1px solid #c8cac5; border-radius: 11px; background: #fafaf7; color: var(--ink); padding: 14px; font-size: 16px; outline: none; }
textarea { resize: vertical; min-height: 95px; }
textarea:focus, dialog input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,90,54,.12); }
.capture-card > .primary-button { width: 100%; margin-top: 14px; }
.tool-picker-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 9px; }
.tool-picker-heading > span { font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.add-tool-link { min-height: 36px; border: 0; background: transparent; color: var(--accent-dark); padding: 4px; font-size: 11px; font-weight: 800; }
.tool-picker { display: flex; flex-wrap: wrap; gap: 8px; min-height: 45px; }
.tool-chip { min-height: 45px; display: flex; align-items: center; gap: 7px; border: 1px solid #c7c9c4; border-radius: 10px; padding: 8px 11px; background: #f8f8f4; color: var(--ink); font-size: 12px; font-weight: 700; }
.tool-chip .tool-icon { font-size: 20px; line-height: 1; }
.tool-chip.selected { border-color: var(--ink); background: var(--ink); color: white; box-shadow: 0 4px 10px rgba(18,23,24,.15); }
.tool-picker-empty { width: 100%; color: var(--muted); font-size: 12px; }
.tool-summary { width: 100%; min-height: 54px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; border: 1px solid #c7c9c4; border-radius: 11px; padding: 10px; background: #f8f8f4; color: var(--muted); text-align: left; font-size: 12px; font-weight: 700; }
.tool-summary .step-tool { background: var(--ink); color: white; }
.step-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.step-tool { display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 7px; background: #eeeee8; color: #4d5555; font-size: 10px; font-weight: 700; }

.timeline { position: relative; display: grid; gap: 13px; }
.timeline::before { content: ""; position: absolute; left: 22px; top: 20px; bottom: 20px; width: 2px; background: var(--line); }
.timeline-item { position: relative; display: grid; grid-template-columns: 46px 1fr; gap: 12px; }
.timeline-number { z-index: 1; width: 46px; height: 46px; display: grid; place-items: center; border: 3px solid var(--paper); border-radius: 50%; background: var(--ink); color: white; font-family: "Barlow Condensed", sans-serif; font-size: 18px; }
.timeline-body { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: white; }
.timeline-body img, .timeline-body video { width: 100%; max-height: 220px; display: block; object-fit: cover; background: var(--ink); }
.timeline-copy { padding: 14px; }
.timeline-copy p { margin: 0 0 8px; font-weight: 600; white-space: pre-wrap; }
.timeline-copy time { color: var(--muted); font-size: 11px; }
.timeline-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 11px; }
.step-actions { display: flex; gap: 7px; }
.step-action { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 0; background: #f5f5f1; color: var(--ink); }
.step-action svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.step-action.delete { color: #a62c19; border-color: #e5c3bb; background: #fff5f2; }

.progress-meta { display: flex; justify-content: space-between; font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.progress-meta strong { color: var(--accent-dark); }
.progress-track { height: 9px; margin: 9px 0 20px; overflow: hidden; border-radius: 10px; background: #d9dad4; }
.progress-track div { width: 0; height: 100%; background: var(--accent); transition: width .3s; }
.assembly-card { position: relative; overflow: hidden; border-radius: var(--radius); background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.reverse-flag { position: absolute; z-index: 2; top: 12px; left: 12px; padding: 7px 10px; border-radius: 7px; background: var(--lime); color: var(--ink); font-size: 9px; font-weight: 900; letter-spacing: .12em; }
.assembly-media { min-height: 230px; display: grid; place-items: center; background: var(--ink); color: #8d9695; }
.assembly-media img, .assembly-media video { width: 100%; max-height: 430px; display: block; object-fit: contain; }
.no-media { font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.assembly-content { padding: 22px; }
.assembly-content span { color: var(--accent-dark); font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.assembly-content h2 { margin: 9px 0 14px; font-family: "DM Sans", sans-serif; font-size: clamp(22px, 7vw, 32px); line-height: 1.2; text-transform: none; white-space: pre-wrap; }
.assembly-content time { color: var(--muted); font-size: 11px; }
.assembly-actions { display: grid; grid-template-columns: .75fr 1.25fr; gap: 10px; margin-top: 16px; }
.assembly-actions button { min-height: 66px; }
.empty-state, .done-state { padding: 52px 25px; border: 1px solid var(--line); border-radius: var(--radius); background: white; text-align: center; }
.empty-state > span { font-size: 54px; color: var(--accent); }
.empty-state h2, .done-state h2 { margin: 12px 0; font-size: 40px; }
.empty-state p, .done-state > p:last-of-type { color: var(--muted); }
.done-icon { width: 78px; height: 78px; margin: 0 auto 22px; display: grid; place-items: center; border-radius: 50%; background: var(--lime); font-size: 38px; font-weight: 800; }
.done-state .secondary-button { width: 100%; margin-top: 25px; }

dialog { width: min(480px, calc(100% - 28px)); border: 0; border-radius: 20px; padding: 0; background: var(--paper); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(7,10,10,.75); backdrop-filter: blur(3px); }
dialog form { position: relative; padding: 30px 22px 22px; }
dialog h2 { font-size: 40px; margin-bottom: 24px; }
dialog label span { float: right; color: var(--muted); font-weight: 500; }
dialog .primary-button { width: 100%; margin-top: 22px; }
.dialog-close { position: absolute; top: 13px; right: 14px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: #deded7; font-size: 25px; }
.edit-current-media { overflow: hidden; min-height: 90px; max-height: 230px; display: grid; place-items: center; border-radius: 11px; background: var(--ink); color: #9ba1a0; }
.edit-current-media:empty { display: none; }
.edit-current-media img, .edit-current-media video { width: 100%; max-height: 230px; display: block; object-fit: contain; }
.replace-media-button { min-height: 48px; margin: 12px 0 0; display: grid; place-items: center; border: 2px dashed #aeb1ac; border-radius: 10px; background: #f8f8f4; cursor: pointer; }
.annotate-photo-button { width: 100%; min-height: 48px; margin-top: 9px; border: 1px solid #ef9b89; border-radius: 10px; background: #fff0ec; color: #a62c19; font-weight: 800; }
.remove-media-option { display: flex; align-items: center; gap: 9px; margin: 12px 0 20px; color: var(--muted); font-size: 12px; letter-spacing: 0; cursor: pointer; }
.remove-media-option input { width: 20px; height: 20px; accent-color: var(--accent); }
.icon-choices { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.icon-choices button { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 23px; }
.icon-choices button.selected { border: 2px solid var(--accent); background: #fff1ed; }
.tool-select-dialog .dialog-panel { position: relative; padding: 30px 18px 20px; }
.dialog-hint { margin: 8px 0 18px; color: var(--muted); font-size: 13px; }
.tool-select-list { max-height: min(52vh, 520px); display: grid; gap: 9px; overflow-y: auto; padding-right: 2px; }
.tool-select-row { display: grid; grid-template-columns: 48px 1fr; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.tool-select-toggle { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: #f5f5f1; font-size: 23px; }
.tool-select-row.selected { border-color: var(--ink); box-shadow: inset 4px 0 var(--accent); }
.tool-select-row.selected .tool-select-toggle { background: var(--ink); color: white; }
.tool-select-copy { min-width: 0; }
.tool-select-copy strong { display: block; margin: 2px 0 8px; font-size: 13px; }
.tool-detail-input { width: 100%; min-height: 42px; border: 1px solid #c8cac5; border-radius: 8px; padding: 8px 10px; background: #fafaf7; font-size: 15px; }
.tool-detail-input:disabled { display: none; }
.add-tool-from-select { width: 100%; margin-top: 12px; }
.tool-select-dialog .primary-button { width: 100%; margin-top: 10px; }
.annotation-dialog { width: min(920px, calc(100% - 18px)); max-height: calc(100vh - 18px); background: #202627; }
.annotation-panel { padding: 18px; color: white; }
.annotation-header { position: relative; display: flex; justify-content: space-between; padding-right: 45px; }
.annotation-header h2 { font-size: clamp(30px, 7vw, 44px); }
.annotation-header .dialog-close { color: var(--ink); }
.annotation-toolbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 16px 0 10px; }
.annotation-toolbar button { min-height: 50px; border: 1px solid #515a5a; border-radius: 9px; background: #303737; color: white; font-size: 21px; }
.annotation-toolbar button span { margin-left: 3px; font-size: 11px; font-weight: 800; }
.annotation-toolbar button.active { border-color: var(--accent); background: var(--accent); }
.annotation-canvas-wrap { max-height: 62vh; overflow: auto; display: grid; place-items: center; border-radius: 10px; background: #0c0f10; touch-action: none; }
#annotationCanvas { display: block; max-width: 100%; height: auto; cursor: crosshair; touch-action: none; }
.annotation-help { margin: 9px 0; color: #b9c0bf; font-size: 11px; text-align: center; }
.annotation-panel > .primary-button { width: 100%; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 130px); width: min(420px, calc(100% - 30px)); padding: 14px 18px; border-radius: 11px; background: var(--ink); color: white; text-align: center; font-size: 13px; font-weight: 700; box-shadow: var(--shadow); transition: transform .25s; }
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: #a62c19; }

@media (min-width: 700px) {
  .topbar { padding-inline: max(28px, calc((100% - 980px) / 2)); }
  main { padding-top: 45px; }
  .project-list { grid-template-columns: 1fr 1fr; }
  .camera-button { min-height: 220px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
