:root {
  font-family: -apple-system, BlinkMacSystemFont, "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: #262a33; background: #f4f5f7; font-size: 16px; line-height: 1.6;
  --navy: #20232b; --teal: #f4bf4f; --line: #d7d9de; --muted: #626771; --keyboard-bottom: 0px;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; min-height: 44px; border: 1px solid transparent; border-radius: 4px; padding: 9px 15px; color: var(--navy); background: transparent; font-size: .9rem; font-weight: 650; }
button:hover { background-color: #e7e8ec; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, canvas:focus-visible { outline: 3px solid #995c0f; outline-offset: 3px; }
[hidden] { display: none !important; }
.primary { background: var(--teal); color: #20232b; border-color: #dca62f; }
.primary:hover { background: #ffd177; }
.outline { background: white; border-color: #979ca5; }
.text-button { color: #444a55; padding: 8px 10px; }
.danger-button { color: #a13130; background: #fff0ef; }
.full { width: 100%; }
.muted { color: var(--muted); font-size: .875rem; font-weight: 400; }
.app-header { min-height: 78px; padding: 14px 5%; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: #20232b; color: white; border-bottom: 3px solid var(--teal); }
.brand { display: flex; gap: 13px; align-items: center; text-decoration: none; color: white; }
.brand-mark { display: grid; place-items: center; width: 43px; height: 43px; background: var(--teal); color: #20232b; font: 32px Arial, sans-serif; border-radius: 2px; }
.brand small { display: block; color: #c8cbd3; font-size: .75rem; letter-spacing: .07em; }
.brand strong { font-size: 1.05rem; letter-spacing: .045em; }
.local-badge { display: flex; align-items: center; gap: 8px; font-size: .8125rem; white-space: nowrap; color: #f3d599; }
.local-badge span { width: 7px; height: 7px; background: var(--teal); }
main { max-width: 1480px; margin: 0 auto; padding: 0 4.2% 32px; }
.start-screen { max-width: 1100px; margin: 32px auto 0; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px 32px; align-items: stretch; }
.intro { grid-column: 1 / -1; display: grid; grid-template-columns: 1.4fr 1fr; column-gap: 30px; align-items: end; padding-bottom: 20px; border-bottom: 1px solid #b9bdc5; }
.eyebrow { font-size: .875rem; color: #6b511e; font-weight: 650; letter-spacing: .07em; margin: 0 0 9px; }
.intro .eyebrow { grid-column: 1 / -1; }
.intro h1 { font-size: clamp(1.8rem, 3.5vw, 2.75rem); letter-spacing: -.035em; line-height: 1.4; margin: 0; font-weight: 800; color: var(--navy); }
.intro h1 span { display: block; }
.intro h1 em { font-style: normal; box-shadow: inset 0 -.23em #f4bf4f; }
.intro > p:last-child { color: #565c68; line-height: 1.9; font-size: 1rem; margin: 0 0 4px; }
.start-card { background: white; border: 1px solid var(--line); border-top: 4px solid #20232b; border-radius: 4px; padding: 25px 28px; }
.step-kicker { font-size: 1rem; font-weight: 750; margin-bottom: 20px; }
.step-kicker span { display: inline-grid; place-items: center; background: #20232b; color: white; width: 30px; height: 30px; font-size: .8125rem; margin-right: 9px; }
label { font-size: .9rem; font-weight: 650; display: block; margin-bottom: 8px; }
input, textarea, select { border: 1px solid #a9aeb8; background: white; border-radius: 3px; padding: 11px 13px; color: #252b34; }
input, textarea { width: 100%; font-size: 16px; }
input::placeholder, textarea::placeholder { color: #737985; }
.upload-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 17px; min-height: 56px; font-size: 1rem; }
.upload-button span { font-size: 24px; font-weight: 400; }
.file-help { font-size: .8125rem; line-height: 1.65; color: var(--muted); text-align: center; margin: 11px 0 15px; }
.start-secondary { border-top: 1px solid var(--line); padding-top: 8px; display: flex; justify-content: space-between; gap: 8px; }
.start-secondary button { font-size: .875rem; padding: 7px 0; }
.flow { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; justify-content: stretch; }
.flow li { display: flex; align-items: center; flex: 1; gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.flow li:last-child { border-bottom: 0; }
.flow b { align-self: flex-start; margin-top: 3px; font-size: 1rem; font-variant-numeric: tabular-nums; color: #777d88; }
.flow small { color: #626771; font-size: .8125rem; font-weight: 650; }
.flow strong { display: block; font-size: 1rem; margin: 2px 0; }
.flow p { margin: 2px 0 0; color: var(--muted); font-size: .875rem; }
.flow .automatic-step { border: 1px solid #e1bd73; background: #fff6e3; }
.automatic-step b, .automatic-step small { color: #82500c; }
.privacy-note { color: var(--muted); font-size: .8125rem; line-height: 1.85; margin: 16px 0; text-align: center; }
.start-screen > .privacy-note { grid-column: 1 / -1; margin: -2px 0 0; }
.workspace-heading { margin-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.workspace-heading h1 { font-size: 1.4rem; margin: 0; overflow-wrap: anywhere; }
.workspace-heading .eyebrow { margin-bottom: 3px; }
.workspace-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; font-size: .8125rem; color: var(--muted); min-height: 38px; margin-bottom: 10px; }
#saveStatus[data-state="saved"] { color: #396244; }
#saveStatus[data-state="failed"] { color: #a13130; }
#imageInfo { margin-left: auto; }
.work-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
.drawing-panel { border: 1px solid #b9bdc5; border-radius: 4px; overflow: hidden; background: white; }
.drawing-toolbar { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid #b9bdc5; background: white; }
.segmented { display: flex; background: #edeef1; border-radius: 3px; padding: 2px; }
.segmented button { min-height: 38px; padding: 5px 12px; font-size: .875rem; }
.zoom-controls { display: flex; align-items: center; gap: 3px; }
.zoom-controls button { font-size: 20px; padding: 2px 10px; }
.zoom-controls span { font-size: .8125rem; min-width: 46px; text-align: center; }
#canvasViewport { position: relative; height: 560px; max-height: calc(100dvh - 255px); min-height: 320px; background-color: #e6e7eb; background-image: linear-gradient(#d4d6dc 1px, transparent 1px), linear-gradient(90deg, #d4d6dc 1px, transparent 1px); background-size: 24px 24px; overflow: hidden; }
#drawing { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#canvasHint { position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); padding: 7px 14px; border-left: 3px solid var(--teal); border-radius: 3px; background: #20232bf2; color: white; font-size: .8125rem; pointer-events: none; white-space: nowrap; max-width: 95%; overflow: hidden; text-overflow: ellipsis; }
.canvas-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 3px 12px; font-size: .8125rem; color: var(--muted); }
.canvas-footer button { font-size: .875rem; }
.notes-panel { background: white; border: 1px solid var(--line); border-top: 3px solid #20232b; border-radius: 4px; padding: 16px; }
.notes-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.notes-heading h2 { font-size: 1rem; margin: 0; }
.notes-heading h2 span { font-size: .8125rem; color: #515763; background: #edeef1; padding: 3px 7px; margin-left: 5px; }
.notes-heading button { font-size: .875rem; }
.empty-notes { padding: 58px 5px; text-align: center; color: var(--muted); font-size: .9rem; line-height: 1.9; }
#noteList { list-style: none; margin: 10px 0; padding: 0; max-height: 410px; overflow: auto; }
#noteList li { margin: 8px 0; }
#noteList button { display: flex; align-items: flex-start; gap: 11px; width: 100%; text-align: left; background: #f4f5f7; border: 1px solid transparent; padding: 12px 10px; font-weight: 400; }
#noteList button[aria-current="true"] { border-color: #b27619; background: #fff6e3; }
#noteList .note-number { display: grid; place-items: center; min-width: 26px; height: 26px; border-radius: 3px; background: #20232b; color: white; font-size: .8125rem; font-weight: 700; }
#noteList .note-copy { font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
#noteList .lock-label { display: block; color: #72521d; font-size: .8125rem; margin-top: 5px; }
.side-help { font-size: .8125rem; line-height: 1.8; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; margin: 16px 0 0; }
.project-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 18px 0 0; }
.project-actions button { font-size: .875rem; }
.notice { padding: 13px 16px; border-radius: 4px; font-size: .9rem; white-space: pre-line; margin-top: 15px; }
.warning { background: #fff3df; border: 1px solid #d9ae61; color: #77500f; }
.message { position: fixed; z-index: 12; left: 50%; bottom: 24px; transform: translateX(-50%); background: #20232b; color: white; border-left: 4px solid var(--teal); box-shadow: 0 6px 24px #16182130; padding: 14px 20px; border-radius: 4px; max-width: calc(100% - 32px); width: max-content; font-size: .9rem; white-space: pre-line; }
.message.error { background: #873e2e; }
.editor-panel { position: fixed; z-index: 10; bottom: var(--keyboard-bottom); left: 0; right: 0; background: white; border-top: 4px solid var(--teal); box-shadow: 0 -8px 35px #20232b20; padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); max-height: 85dvh; overflow: auto; }
.editor-inner { max-width: 940px; margin: auto; }
.editor-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.editor-heading h2 { font-size: 1rem; margin: 0; }
.editor-panel label { font-size: .875rem; margin-bottom: 4px; }
.editor-panel textarea { resize: vertical; min-height: 70px; max-height: 28dvh; line-height: 1.65; }
.editor-bottom { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-top: 8px; }
.editor-bottom > span { font-size: .8125rem; color: var(--muted); }
.editor-bottom > div { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.editor-bottom button { font-size: .875rem; }
body.editing main { padding-bottom: 300px; }
body.editing .message { bottom: auto; top: 90px; }
dialog { border: 1px solid #b9bdc5; border-top: 4px solid var(--teal); border-radius: 5px; padding: 24px; width: min(1100px, 96vw); max-height: 94dvh; color: #262a33; background: #f4f5f7; overscroll-behavior: contain; }
dialog::backdrop { background: #141720bb; }
.preview-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.preview-header h2 { font-size: 1.25rem; margin: 0; }
.preview-header .eyebrow { margin: 0 0 2px; }
.preview-help { font-size: .875rem; color: var(--muted); margin: 14px 0; }
.preview-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.preview-controls label { display: flex; align-items: center; gap: 9px; margin: 0; font-size: .875rem; }
.preview-controls select { font-size: .875rem; padding: 9px; }
.export-status { font-size: .9rem; color: #515763; white-space: pre-line; }
.generated-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0 18px; }
.generated-actions p { flex-basis: 100%; font-size: .8125rem; margin: 0; color: var(--muted); }
.button-link { font-size: .9rem; color: #72521d; min-height: 44px; padding: 10px; }
.preview-paper { background: white; border: 1px solid var(--line); box-shadow: 0 4px 20px #20232b0a; }
.preview-paper canvas, .preview-paper img { display: block; width: 100%; height: auto; }
.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; }
@media (min-width: 1400px) { #canvasViewport { height: 640px; } }
@media (max-width: 1000px) {
  .intro { grid-template-columns: 1.2fr 1fr; column-gap: 20px; }
  .work-grid { grid-template-columns: minmax(0, 1fr) 270px; }
  .drawing-toolbar { padding: 6px; gap: 5px; flex-wrap: wrap; }
  .drawing-toolbar > button { font-size: .875rem; padding: 7px; }
  .segmented button { padding: 4px 9px; }
  .zoom-controls { gap: 0; }
}
@media (max-width: 720px) {
  .app-header { min-height: 70px; padding: 11px 16px; gap: 8px; }
  .brand { gap: 9px; }
  .brand-mark { width: 32px; height: 36px; font-size: 27px; }
  .brand strong { font-size: .9rem; }
  .brand small { font-size: .75rem; letter-spacing: 0; }
  .local-badge { font-size: .75rem; gap: 5px; }
  main { padding: 0 16px 20px; }
  .start-screen { margin: 24px auto 0; display: flex; flex-direction: column; gap: 20px; align-items: stretch; max-width: 500px; }
  .intro { display: block; padding-bottom: 18px; }
  .intro h1 { font-size: clamp(1.6rem, 6.7vw, 2.2rem); line-height: 1.45; }
  .intro > p:last-child { font-size: 1rem; line-height: 1.7; margin: 10px 0 0; }
  .intro .eyebrow { margin-bottom: 7px; font-size: .875rem; letter-spacing: .025em; }
  .start-card { padding: 20px; }
  .step-kicker { margin-bottom: 16px; }
  .flow li { padding: 12px 13px; gap: 14px; }
  .flow strong { font-size: .9375rem; }
  .flow p { font-size: .875rem; }
  .start-screen > .privacy-note { margin: 0; text-align: left; }
  .workspace-heading { margin-top: 18px; align-items: flex-start; }
  .workspace-heading h1 { font-size: 1.125rem; }
  .workspace-heading .primary { font-size: .875rem; white-space: nowrap; padding: 9px 10px; }
  .workspace-heading .eyebrow { font-size: .8125rem; }
  .workspace-meta { gap: 5px 12px; margin-bottom: 6px; }
  #imageInfo { margin-left: 0; max-width: 100%; overflow-wrap: anywhere; }
  .work-grid { display: flex; flex-direction: column; gap: 14px; }
  .drawing-panel, .notes-panel { width: 100%; }
  .drawing-toolbar { padding: 6px 8px; gap: 4px; flex-wrap: wrap; }
  .drawing-toolbar > button { margin-left: auto; font-size: .875rem; padding: 5px 4px; }
  .segmented button { min-height: 44px; font-size: .875rem; padding: 5px 8px; }
  .zoom-controls button { font-size: 18px; min-width: 34px; padding: 2px 5px; }
  .zoom-controls span { font-size: .8125rem; min-width: 36px; }
  #canvasViewport { height: 480px; max-height: 58dvh; min-height: 300px; }
  .canvas-footer { font-size: .8125rem; padding: 3px 9px; flex-wrap: wrap; }
  .canvas-footer button { font-size: .875rem; padding: 5px; }
  #canvasHint { font-size: .8125rem; }
  .notes-panel { padding: 12px; }
  .empty-notes { padding: 16px; }
  #noteList { max-height: 330px; }
  #noteList button { padding: 10px; }
  .project-actions { gap: 5px; }
  .project-actions .outline { width: 100%; }
  .privacy-note { font-size: .8125rem; }
  .editor-panel { padding: 9px 14px calc(10px + env(safe-area-inset-bottom)); }
  .editor-heading { margin-bottom: 2px; }
  .editor-panel textarea { max-height: 22dvh; min-height: 70px; }
  .editor-bottom { align-items: flex-start; gap: 5px; flex-wrap: wrap; }
  .editor-bottom > span { font-size: .8125rem; white-space: nowrap; }
  .editor-bottom button { font-size: .875rem; padding: 8px; }
  .editor-bottom > div { gap: 3px; flex: 1; }
  .editor-bottom .primary { min-width: 110px; }
  dialog { padding: 15px; width: calc(100% - 14px); max-height: 96dvh; }
  .preview-header h2 { font-size: 1.125rem; }
  .preview-header button { font-size: .875rem; padding: 8px 10px; }
  .preview-controls { gap: 8px; }
  .preview-controls > button.primary { width: 100%; }
  .preview-controls label { gap: 5px; }
  .preview-controls select { padding: 8px 6px; }
  .generated-actions { gap: 7px; }
}
@media (max-width: 360px) {
  .local-badge { white-space: normal; max-width: 4.5em; }
  .brand strong { font-size: .875rem; }
  .start-secondary { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media (max-height: 500px) {
  .editor-panel textarea { min-height: 50px; }
  .editor-heading { margin: 0; }
  .editor-panel { max-height: 95dvh; padding-top: 4px; }
  .editor-heading button { min-height: 32px; }
  .editor-bottom { margin-top: 1px; }
}
