:root{font:15px/1.5 system-ui,sans-serif;color:#243b38;background:#f3f1eb}*{box-sizing:border-box}body{margin:0}header{padding:14px 22px;background:#173e37;color:white;display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap}header b{font:26px Georgia;letter-spacing:3px}header span{margin-left:20px}header small{color:#d4e2dc}main{padding:16px;max-width:1600px;margin:auto}.toolbar{display:flex;gap:9px;align-items:center;flex-wrap:wrap;margin-bottom:10px}button,input,select,textarea{font:inherit;border:1px solid #c9d2cd;border-radius:7px;background:white;padding:8px;color:inherit}button{cursor:pointer;min-height:40px}button[aria-pressed=true],button[type=submit]{background:#245e51;color:white}label{display:inline-flex;gap:8px;align-items:center}input[type=color]{width:44px;height:40px;padding:3px}input[type=range]{width:100px}#help,footer{font-size:13px;color:#566862}#status{color:#8c4525;min-height:22px;margin:6px 0}.day{margin:18px 0 26px;background:white;border:1px solid #b9c8c2;border-radius:8px;overflow:hidden}.day h2{font-size:17px;margin:0;padding:10px 14px;background:#e7ede6}.scroll{overflow:auto}.sheet{position:relative;padding-left:50px}.timeline{height:32px;display:flex;background:#f6f7f1}.timeline span{flex:none;font-size:11px;border-left:1px solid #bfcfc4;padding:7px 2px}.row{height:50px;display:flex;position:relative;border-top:1px solid #b5c5bd}.name{position:sticky;left:0;width:50px;flex:none;margin-left:-50px;background:#edf1e9;z-index:4;display:flex;align-items:center;justify-content:center;font-weight:600;border-right:1px solid #a1b4a8}.slot{height:50px;flex:none;border-right:1px solid #d9dfd4;background:#fffef8;color:#c2cdc1;text-align:center;padding-top:13px}.slot:nth-child(2n){border-right-color:#aebeb2}.slot.off{background:repeating-linear-gradient(135deg,#eceee9 0 5px,#f4f5ef 5px 10px);color:#a4aaa2}.grid{position:relative;touch-action:pan-x pan-y pinch-zoom}.grid.drawing{touch-action:none}.booking,.marker{position:absolute;z-index:2;touch-action:none;overflow:hidden}.booking{height:34px;min-height:0;top:7px;border:1px solid #82a69b;border-radius:4px;padding:3px 5px;background:#eef7f2;text-align:left;white-space:nowrap;font-size:12px}.booking strong,.booking small{display:block;overflow:hidden;text-overflow:ellipsis}.marker{height:16px;min-height:0;border:0;border-radius:3px;opacity:.75;padding:0}.drag{opacity:.55;outline:2px dashed #194d40;z-index:8}.ink{position:absolute;left:50px;top:0;height:100%;pointer-events:none;z-index:3;overflow:visible}.ink path{fill:none;stroke:#c52f38;stroke-width:.055;stroke-linecap:round;stroke-linejoin:round}.erase .ink{pointer-events:auto}.erase .ink path{pointer-events:stroke;stroke-width:.1}.public .booking,.public .marker,.public .ink{display:none}.public .slot{color:#377568}.public .slot.busy{color:#ab6153;background:#fbede5}dialog{width:min(94vw,480px);border:0;border-radius:12px;padding:22px;box-shadow:0 12px 80px #0003}dialog::backdrop{background:#122b2966}dialog h2{font-size:20px;margin-top:0}#fields label{display:flex;align-items:stretch;flex-direction:column;gap:4px;margin:10px 0}#fields input,#fields select,#fields textarea{width:100%}.actions{display:flex;gap:8px;justify-content:flex-end;margin-top:18px}#delete{margin-right:auto;color:#a43136}#error{color:#ae3030}.rule{padding:8px;border-bottom:1px solid #ddd;display:flex;justify-content:space-between;align-items:center;font-size:13px}footer{padding:10px 0 22px}@media(max-width:600px){main{padding:10px}header{padding:10px 14px}header small{font-size:11px}.toolbar{gap:6px}.toolbar button{font-size:13px}header span{font-size:13px}.tools label{font-size:12px}}

/* Compact notebook layout; time strip sticks to the page, outside horizontal scroller. */
header{padding:7px 14px;gap:4px}header b{font-size:22px}header small{font-size:11px}main{padding:8px 12px}.toolbar{gap:6px;margin-bottom:5px}.toolbar button,.toolbar input,.toolbar select{padding:5px 7px;min-height:34px;font-size:13px}.toolbar label{font-size:12px;gap:5px}input[type=color]{height:34px;width:36px}.toolbar input[type=range]{width:82px}#help{font-size:12px;margin:4px 0}#status{font-size:12px;margin:3px 0;min-height:0}#status:empty{display:none}.day{overflow:visible;margin:10px 0 16px}.day h2{padding:5px 10px;font-size:15px}.time-fixed{position:sticky;top:0;z-index:9;display:flex;height:30px;background:#f6f7f1;border-bottom:1px solid #b5c5bd}.time-label{width:50px;flex:none;background:#edf1e9;text-align:center;font-size:11px;padding-top:6px;border-right:1px solid #a1b4a8}.time-clip{overflow:hidden;flex:1}.timeline{height:30px}.timeline span{font-size:9px;padding:7px 0;letter-spacing:-.4px}.marker{height:13px}.booking{padding:2px 3px;line-height:15px}.actions #delete{font-weight:bold}.actions #delete:not([hidden]){border-color:#cc7777;background:#fff3f3}@media(max-width:600px){header{padding:6px 10px}main{padding:6px}.toolbar{gap:4px}.toolbar button{font-size:12px}.day h2{font-size:14px}.tools label{font-size:11px}}

/* Hour boundaries solid; half-hour boundaries dotted. The name is row child 1. */
.slot{border-right:1px dotted #a6b6ac}.slot:nth-child(odd){border-right:1px solid #91a89a}.slot:nth-child(even){border-right:1px dotted #a6b6ac}.timeline span{border-left:1px solid #91a89a}.timeline span:nth-child(even){border-left:1px dotted #a6b6ac}.name{font-size:14px}.marker{height:11px}.booking{font-size:11px;padding:1px 2px;line-height:14px}

/* Keep controls available and reserve their responsive height above the time strip. */
#controls{position:sticky;top:0;z-index:20;background:#f3f1eb;padding:3px 0 4px;border-bottom:1px solid #d6ded7}
#controls .toolbar{margin-bottom:3px;gap:4px 6px}
#controls .toolbar button,#controls .toolbar input,#controls .toolbar select{padding:4px 6px;min-height:32px}
#controls #help{margin:2px 0;font-size:11px;line-height:1.3}
#controls #status{margin:1px 0 0;font-size:10px;line-height:1.3}
.time-fixed{top:var(--controls-height,120px)}


/* Intrinsic-height booking form: fields shrink and scroll; footer stays in normal flow. */
#dialog-x{display:none}
dialog:is(.booking-editor,.rules-editor){position:fixed;inset:auto;top:var(--dialog-top,8px);left:50%;transform:translateX(-50%);margin:0;padding:0;border:0;width:min(calc(100vw - 16px),460px);height:auto;max-height:var(--dialog-height,calc(100dvh - 16px));overflow:hidden;box-sizing:border-box}
:is(.booking-editor,.rules-editor) #form{display:flex;flex-direction:column;margin:0;max-height:var(--dialog-height,calc(100dvh - 16px));min-height:0;overflow:hidden}
:is(.booking-editor,.rules-editor) #title{flex:0 0 auto;margin:0;padding:10px 48px 6px 14px;font-size:17px;line-height:24px}
:is(.booking-editor,.rules-editor) #dialog-x{display:block;position:absolute;right:6px;top:4px;width:36px;height:36px;min-height:36px;padding:0;font-size:25px;border:0;background:transparent;z-index:2}
:is(.booking-editor,.rules-editor) #fields{flex:0 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-content:start;gap:5px 8px;padding:2px 14px 7px}
:is(.booking-editor,.rules-editor) #fields label{margin:0;gap:2px;font-size:12px;line-height:15px;min-width:0}
:is(.booking-editor,.rules-editor) #fields [data-field=name],:is(.booking-editor,.rules-editor) #fields [data-field=menu],:is(.booking-editor,.rules-editor) #fields [data-field=memo]{grid-column:1/-1}
:is(.booking-editor,.rules-editor) #fields input,:is(.booking-editor,.rules-editor) #fields select,:is(.booking-editor,.rules-editor) #fields textarea{width:100%;min-width:0;min-height:32px;font-size:16px;line-height:20px;padding:4px 7px}
:is(.booking-editor,.rules-editor) #fields textarea{height:38px;min-height:38px;resize:none}
:is(.booking-editor,.rules-editor) #error{flex:none;margin:0;padding:0 14px;font-size:12px;max-height:36px;overflow:auto}
:is(.booking-editor,.rules-editor) #error:empty{display:none}
:is(.booking-editor,.rules-editor) .actions{flex:0 0 auto;position:static;display:flex;align-items:center;justify-content:flex-end;flex-wrap:nowrap;gap:8px;margin:0;padding:8px 12px;background:#f7f8f4;border-top:1px solid #d8dfd9}
:is(.booking-editor,.rules-editor) .actions button{flex-shrink:0;min-height:40px;padding:7px 12px;font-size:14px}

.booking{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}.booking.drag{cursor:grabbing}

/* Keep the viewport stable during month updates and Safari scrolling. */
#boards{overflow-anchor:none}.scroll{-webkit-overflow-scrolling:touch}.grid:not(.drawing){touch-action:pan-x pan-y pinch-zoom}
dialog:is(.booking-editor,.rules-editor){left:var(--dialog-left,50%);width:var(--dialog-width,min(calc(100vw - 16px),460px));max-width:calc(100vw - 16px);right:auto}
.multi-calendar{margin:8px 0}.calendar-nav{display:flex;align-items:center;justify-content:space-between;gap:8px}.calendar-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px;margin-top:8px;text-align:center}.calendar-grid button{padding:5px;min-height:36px}.calendar-grid button[aria-pressed=true]{background:#245e51;color:white}.calendar-summary{font-size:12px;overflow-wrap:anywhere;max-height:65px;overflow:auto}

/* Shared viewport frame for schedule settings; only its content scrolls. */
.rules-editor #fields{display:block;overflow-x:hidden}.rules-editor #fields label{margin:7px 0}.rules-editor .calendar-nav input{min-width:0;flex:1}.rules-editor .calendar-grid{width:100%;min-width:0}.rules-editor .rule{gap:8px;overflow-wrap:anywhere}.rules-editor .rule button{flex-shrink:0}
/* Keep horizontal overflow local to the sheets; preserve native two-axis gestures. */
html{overflow-x:clip;overscroll-behavior-x:none;overscroll-behavior-y:auto}
body{overflow-x:clip;max-width:100%;overscroll-behavior-x:none}
main{min-width:0}#boards,.day{min-width:0;max-width:100%}.scroll{max-width:100%;overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:none;overscroll-behavior-y:auto;touch-action:pan-x pan-y pinch-zoom}
.time-clip{min-width:0}.timeline{will-change:transform}

/* Actions follow working hours; the separate history cannot push them offscreen. */
.rules-editor #fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:4px 8px;flex:0 1 auto}
.rules-editor #fields>p,.rules-editor .multi-calendar{grid-column:1/-1;margin:3px 0}
.rules-editor #fields>p{font-size:11px;line-height:1.3}
.rules-editor #fields label{margin:0;min-width:0}
.rules-editor .calendar-grid{margin-top:4px;gap:3px}
.rules-editor .calendar-grid button{min-height:32px;padding:3px}
.rules-editor .calendar-summary{margin:4px 0;max-height:30px}
.rules-editor .rule-history{flex:0 1 150px;min-height:36px;overflow:auto;overscroll-behavior:contain;padding:6px 14px;border-top:1px solid #d8dfd9}
.rule-history h3{font-size:13px;margin:0 0 4px}.rule-history summary{cursor:pointer;font-size:13px;padding:7px 0}.rule-history .empty-rules{font-size:12px;margin:4px 0}.rule-history .rule{padding:4px 0}.rule-history .rule button{min-height:32px;padding:3px 7px}

/* Default finger gestures remain native; explicit drawing still permits pinch zoom. */
.grid.drawing{touch-action:pinch-zoom}#finger-draw{min-height:0!important;width:18px;height:18px}.tools button:disabled{opacity:.45;cursor:default}

/* Allow native scrolling across appointments without changing their size. */
.grid:not(.drawing) .booking,.grid:not(.drawing) .marker,.memo-icon{touch-action:pan-x pan-y pinch-zoom}
.memo-icon{position:absolute;z-index:5;width:22px;height:16px;min-height:0;padding:0;border:0;border-radius:3px;background:#fff9dc;font-size:14px;line-height:16px}
header>div{min-width:0;max-width:100%}header b{font:600 clamp(16px,4.3vw,22px)/1.4 system-ui,sans-serif;letter-spacing:0;overflow-wrap:anywhere}header span{display:inline-block;margin-left:10px}

/* The shop name and all controls share one sticky frame; its measured height
   also offsets the time strip and reservation/date navigation. */
#controls{padding-top:0;padding-bottom:4px}
#controls header{padding:4px 8px;margin-bottom:4px;border-radius:5px;gap:2px 8px}
#controls header b{font-size:16px;line-height:1.35}
#controls header span{font-size:11px;margin-left:8px}
#controls header small{font-size:10px;line-height:1.2}
#controls .toolbar button,#controls .toolbar input,#controls .toolbar select{min-height:34px}
#controls .tools[hidden]{display:none}
@media(max-width:600px){
 #controls header{padding:4px 6px}
 #controls header b{font-size:14px}
 #controls header span{margin-left:5px}
 #controls header small{font-size:9px}
 #controls .toolbar{gap:3px 5px}
 #controls #help{font-size:10px}
}

/* Keep short appointments the same size; use both name lines without ellipsis. */
.booking.short-booking{padding:0 1px;white-space:normal}
.short-booking strong{font-size:10px;line-height:10px;height:20px;white-space:normal;overflow-wrap:anywhere;word-break:break-all;text-overflow:clip}
.short-booking small{font-size:9px;line-height:10px;height:10px;white-space:nowrap;text-overflow:clip}
/* Explicit equal cells avoid flex rounding accumulating at fractional zoom widths. */
.timeline span,.slot{flex-shrink:0}
.chosen-swatch{display:inline-block;width:20px;height:20px;vertical-align:middle;background:var(--chosen-color,#e8b832);border:1px solid #64756c;border-radius:3px}
#palette{width:min(94vw,440px);max-height:calc(100dvh - 16px);padding:14px;overflow:auto;overscroll-behavior:contain}
#palette h2{margin:0;font-size:18px}#palette p{font-size:12px;margin:7px 0}
#palette-list{display:grid;gap:7px}.palette-row{display:flex;gap:12px}.palette-pick{flex:1;text-align:left;min-height:44px}.palette-pick::before{content:'';display:inline-block;vertical-align:middle;width:28px;height:24px;margin-right:12px;background:var(--swatch);border:1px solid #64756c;border-radius:4px}.palette-remove{min-height:44px;color:#a43136}
.palette-add-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:14px}.palette-add-row input{width:48px;height:44px}.palette-add-row button{min-height:44px}
#palette-confirm{border:1px solid #bf7575;background:#fff4f1;padding:10px;margin-top:10px}#palette-delete{color:#a43136;margin-left:8px}
.palette-footer{position:sticky;bottom:-14px;background:white;padding:10px 0 0;text-align:right}.palette-footer button{min-width:100px;min-height:44px;background:#245e51;color:white}

.memo-icon.short-memo{transform:translateY(6px);height:12px;min-height:0;font-size:11px;line-height:12px}

/* Customer preview: display availability only, without staff editing UI. */
.customer-view #help,.customer-view #status,.customer-view header small,.customer-view footer,.customer-view #hours,.customer-view .tools{display:none!important}
.customer-view #controls header span{font-size:0}.customer-view header span::after{content:'空き状況';font-size:11px}
#customer-help{font-size:11px;line-height:1.4;margin:3px 0}
.customer-view #controls{padding-bottom:3px}
.public .slot{font-size:10px;white-space:nowrap;padding-top:15px;user-select:none}
.public .grid,.public .slot{touch-action:pan-x pan-y pinch-zoom}
@media(max-width:600px){#customer-help{font-size:10px}}

/* Customer symbols only; preserve staff cells and appointment geometry. */
.public .slot{display:flex;align-items:center;justify-content:center;padding:0;font-size:15px;font-weight:400;line-height:1;color:#929a94}
.public .slot.off{font-size:13px;color:#929a94}
.public .slot.busy{color:#929a94;background:#fffef8}
.public .slot.off.busy{background:repeating-linear-gradient(135deg,#eceee9 0 5px,#f4f5ef 5px 10px)}
.absence-label{position:absolute;z-index:1;height:46px;display:flex;align-items:flex-end;justify-content:center;padding:0 3px 2px;background:#f1e7d0;color:#6b501b;font-size:12px;overflow:hidden;pointer-events:none;text-align:center;line-height:15px;overflow-wrap:anywhere}.login{max-width:620px;margin:30px auto}.login label{display:flex;flex-direction:column;align-items:stretch;margin:16px 0}.availability-scroll{overflow:auto;border:1px solid #b9c8c2;border-radius:8px}.availability-table{border-collapse:collapse;min-width:850px;width:100%;background:#fffef8}.availability-table th,.availability-table td{padding:12px 6px;text-align:center;border:1px solid #d9dfd4}.availability-table th{background:#edf1e9;font-size:12px}.availability-table tr th:first-child{position:sticky;left:0;min-width:62px}.available{color:#21634f}.unavailable{color:#8b8d87}button:disabled{opacity:.45;cursor:default}#session-name{font-weight:700;color:#245e51}

[hidden]{display:none!important}

/* Compact fixed controls: one date row and one tool row, without wrapping.
   Overflow stays horizontal so small phones retain usable tap targets. */
#controls{padding-bottom:2px}
#controls header{position:relative;flex-wrap:nowrap;padding:2px 6px;margin-bottom:2px;gap:6px;min-height:26px}
#controls header>div{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#controls header b{font-size:13px;line-height:20px}
#controls header span{font-size:10px;margin-left:6px}
#controls>.toolbar{flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;gap:4px;margin:0 0 2px;touch-action:pan-x pan-y pinch-zoom;scrollbar-width:thin}
#controls>.toolbar>*{flex-shrink:0;white-space:nowrap}
#controls .toolbar button,#controls .toolbar input,#controls .toolbar select{font-size:11px;line-height:18px;min-height:28px;padding:3px 5px;border-radius:5px}
#controls .toolbar label{font-size:10px;gap:3px;white-space:nowrap}
#controls .toolbar input[type=date]{width:112px}
#controls .toolbar input[type=range]{width:62px;min-height:24px;padding:0}
#controls .chosen-swatch{width:15px;height:15px}
#controls #month-nav{white-space:nowrap}
#more-controls{flex:none;font-size:11px;color:white}
#more-controls>summary{cursor:pointer;list-style:none;padding:3px 6px;min-height:26px;border:1px solid #6e8f83;border-radius:4px;white-space:nowrap}
#more-controls>summary::-webkit-details-marker{display:none}
.more-panel{position:absolute;right:0;top:100%;width:min(360px,calc(100vw - 20px));padding:9px;background:#f3f1eb;color:#243b38;border:1px solid #9eb3a9;border-radius:6px;box-shadow:0 4px 14px #0002;white-space:normal;z-index:25}
#controls .more-panel small{color:#566862;font-size:10px}
#controls .more-panel .toolbar{flex-wrap:wrap;margin-top:5px}
#controls .more-panel #help{font-size:11px;margin-top:5px}
@media(max-width:600px){#controls header span{display:none}#controls header b{font-size:12px}}

/* Fit the schedule's scroll container to the visual viewport while pinched.
   Margin, rather than transform, preserves the fixed booking-dialog frame. */
body.viewport-fitted main{width:min(var(--visible-width),1600px);margin-left:var(--visible-left);margin-right:0}

/* Same staff, same time: overlapping appointments share the row in stacked lanes. */
.booking.stacked-booking{display:flex;align-items:center;padding:0 3px;white-space:nowrap;font-size:10px;line-height:1}
.booking.stacked-booking strong{height:auto;font-size:10px;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;word-break:normal}
.booking.stacked-booking small{display:none}
#add-overlap{color:#174b43;background:#edf4f0}
.booking-editor .actions{flex-wrap:wrap}
dialog:not(.booking-editor) #add-overlap,dialog:not(.booking-editor) #copy-booking{display:none}

/* Copy a booking: banner while choosing the destination slot. */
#copy-banner{position:fixed;left:50%;bottom:max(12px,env(safe-area-inset-bottom));transform:translateX(-50%);z-index:30;display:flex;align-items:center;gap:10px;max-width:calc(100vw - 20px);padding:8px 8px 8px 14px;background:#173e37;color:white;border-radius:10px;box-shadow:0 6px 24px #0004;font-size:14px;line-height:1.4}
#copy-banner button{flex:none;min-height:38px;background:white;color:#173e37;border-color:white;font-weight:700}
.copying .grid{cursor:copy}.copying .slot{background-color:#f4fbf6}
.booking-editor .copy-help{grid-column:1/-1;margin:0 0 3px;font-size:12px;color:#405955}
