/* Shared rhythm for the timer and guided tea flow. Keep the original artwork. */
.header-actions{display:flex;align-items:center;gap:8px;flex-shrink:0}
#time-share-dialog{width:min(440px,calc(100% - 24px));max-height:calc(100svh - 24px);padding:20px;overscroll-behavior:contain}
#time-share-dialog .dialog-header{gap:12px}
#time-share-title{font:500 20px/1.5 Pretendard,system-ui,sans-serif;letter-spacing:-.5px}
#time-share-close{flex-shrink:0}
#time-share-description{font-size:14px;line-height:1.7;color:var(--muted);margin:14px 0 18px;word-break:keep-all}
.time-share-qr-area{text-align:center;min-height:44px}
#time-share-qr{display:block;width:min(100%,240px);height:auto;aspect-ratio:1;margin:0 auto;background:#fff}
#time-share-qr-note{font-size:14px;line-height:1.6;color:var(--muted)}
#time-share-url{display:block;width:100%;min-height:44px;margin-top:16px;padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--paper);color:var(--ink);font:16px/1.5 Pretendard,system-ui,sans-serif;text-align:center}
#time-share-save{display:block;margin:4px auto;font-size:14px}
.time-share-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.time-share-actions button{font-size:14px;min-height:48px;border-radius:8px;padding:10px 8px}
#time-share-status{font-size:13px;line-height:1.6;color:var(--muted);margin:12px 0 0;min-height:21px}
@media(max-height:680px){#time-share-qr{width:min(100%,180px)}#time-share-dialog{padding:16px}#time-share-description{margin:10px 0 12px}#time-share-url{margin-top:12px}}
.app-shell,.app-shell:has(#tea-panel:not([hidden])){width:100%;max-width:520px;min-height:100svh;height:auto;padding:calc(24px + env(safe-area-inset-top)) 32px calc(20px + env(safe-area-inset-bottom));font-size:16px}
.header{height:52px;min-height:52px;margin-bottom:24px}
.header .icon-button{border-radius:12px}
.tool-modes{max-width:none;margin:0 auto;background:var(--tone-e9e7dc);border-radius:12px;padding:4px;gap:4px}
.tool-modes button{font-size:16px;border-radius:9px;min-height:44px}
.tool-modes button[aria-pressed=true]{background:var(--paper);color:var(--ink);font-weight:500}
#ritual{display:flex;flex-direction:column;align-items:center;flex:1;padding-top:28px}
#ritual .intro{margin:0;width:100%}
#ritual h1{font:500 25px/1.5 Pretendard,system-ui,sans-serif;letter-spacing:-.7px}
#ritual .subtitle{font-size:14px;line-height:1.6;margin-top:6px}
#ritual .duration-options{width:100%;max-width:360px;margin:20px auto 0;padding:0;border:0;gap:8px;border-radius:0}
#ritual .duration-options button{min-height:46px;font-size:15px;padding:10px 8px;border:1px solid var(--line);border-radius:10px;flex:1}
#ritual .duration-options button[aria-pressed=true]{background:var(--tone-e9e7dc);color:var(--ink);border-color:var(--tone-9aa59a)}
#ritual .duration-options #custom-open{flex:1.5;font-size:14px;background:transparent}
#ritual .hourglass-wrap,.app-shell.has-update #ritual .hourglass-wrap{width:162px;height:203px;margin:20px auto 0;flex-shrink:0}
#ritual .hourglass{width:100%;height:100%}
#ritual .time,#tea-panel#tea-panel #tea-clock{font:400 64px/1.15 Pretendard,system-ui,sans-serif;letter-spacing:-2px;font-variant-numeric:tabular-nums;margin:8px 0 16px;text-align:center}
#ritual .actions{max-width:none;width:100%;margin:20px auto 0}
.primary-button,#ritual .primary-button,#tea-panel#tea-panel .primary-button{min-height:54px;border-radius:10px;font-size:16px;font-weight:500;line-height:1.5;padding:14px 20px;gap:10px}
#ritual .sound-hint{font-size:13px;line-height:1.65;margin:12px auto 0;max-width:32ch}
#ritual .secondary-actions{gap:10px;margin-top:10px}
#ritual #reset{border:0;background:transparent;color:var(--muted);font-size:14px}
#ritual .timer-sound-tools{border-top:1px solid var(--line);padding-top:18px;margin-top:8px;gap:10px}
#ritual .timer-sound-tools .secondary-button{min-height:48px;border-radius:10px;font-size:14px}
#ritual .install-link{margin:4px auto 0;font-size:13px}
#tea-panel#tea-panel{max-width:none;flex:1;height:auto;min-height:0}
#tea-panel#tea-panel .tea-home{padding:28px 0 0;justify-content:flex-start;flex:1}
#tea-panel#tea-panel .tea-home h1{font:500 25px/1.6 Pretendard,system-ui,sans-serif;letter-spacing:-.7px}
#tea-panel#tea-panel .tea-home .tea-visual{height:160px;flex:0 0 160px;margin:26px 0 16px}
#tea-panel#tea-panel .tea-config-minimal{font-size:16px;min-height:52px;margin:0 0 12px}
#tea-panel#tea-panel .tea-config-minimal>span:first-child{font-size:16px;line-height:1.7}
#tea-panel#tea-panel .tea-config-edit{font-size:14px}
#tea-panel#tea-panel #tea-start{margin:12px 0 0}
#tea-panel#tea-panel .tea-flow{padding:18px 0 0;flex:1}
.tea-flow-header>p{font-size:14px;color:var(--muted)}
#tea-panel#tea-panel #tea-exit{background:transparent;border:0;font-size:14px;color:var(--muted);text-decoration:none;padding:8px;min-height:44px}
#tea-panel#tea-panel #tea-exit:before{content:none}
#tea-panel#tea-panel .tea-steps{margin:12px 0 24px;gap:8px}
#tea-panel#tea-panel .tea-steps li{font-size:12px;padding-top:12px}
#tea-panel#tea-panel .tea-steps li:before{height:3px}
#tea-panel#tea-panel .tea-phase-center{display:flex;flex-direction:column;flex:1;min-height:0;justify-content:flex-start;align-items:stretch;margin:0;padding:0;text-align:center}
#tea-panel#tea-panel #tea-phase-title{font:500 25px/1.5 Pretendard,system-ui,sans-serif;letter-spacing:-.7px;text-wrap:balance}
#tea-panel#tea-panel #tea-phase-copy{display:block;font-size:15px;line-height:1.75;margin:10px auto 0;max-width:34ch;color:var(--muted)}
#tea-panel#tea-panel[data-phase="1"] .tea-phase-center{text-align:left}
#tea-panel#tea-panel[data-phase="1"] #tea-phase-copy{margin:6px 0 0;max-width:none}
#tea-panel#tea-panel .tea-preparation{gap:10px;margin:24px 0}
#tea-panel#tea-panel .tea-preparation label{min-height:54px;padding:12px;font-size:15px;border-radius:10px}
#tea-panel#tea-panel .tea-guide-toggle{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:16px 0;border-top:1px solid var(--line);border-bottom:1px solid var(--line);font-size:16px;min-height:76px}
.tea-guide-toggle small{display:block;margin-top:4px;font-size:14px;font-weight:400;line-height:1.6;color:var(--muted)}
#tea-panel #tea-guide-enabled{appearance:none;position:relative;width:48px;height:28px;border-radius:20px;background:var(--tone-c7cbbd);flex-shrink:0}
#tea-guide-enabled:before{content:"";position:absolute;left:4px;top:4px;width:20px;height:20px;background:var(--paper);border-radius:50%;transition:transform .2s}
#tea-panel #tea-guide-enabled:checked{background:var(--ink)}
#tea-guide-enabled:checked:before{transform:translateX(20px)}
#tea-panel#tea-panel #tea-brew-info{order:0;grid-area:auto;text-align:center;font-size:14px;line-height:1.7;margin:18px 0;color:var(--muted)}
#tea-panel#tea-panel[data-phase="1"] #tea-brew-info{text-align:left}
#tea-panel#tea-panel[data-phase="2"] #tea-brew-info{order:-1;margin:0 0 12px}
#tea-panel#tea-panel[data-phase="2"] #tea-phase-copy{order:4;margin-top:4px}
#tea-panel#tea-panel #tea-brew-visual{order:1;width:156px;height:156px;align-self:center;margin:24px auto 8px;flex-shrink:0}
#tea-panel#tea-panel #tea-clock{order:2;margin:8px 0 14px}
#tea-panel#tea-panel .tea-step-illustration{order:-1;width:84px;height:84px;align-self:center;margin:12px auto 24px}
.tea-guide-controls{display:flex;align-items:center;justify-content:center;gap:8px;margin:16px 0 4px;color:var(--muted);font-size:14px;min-height:44px}
.tea-guide-controls .text-button{font-size:14px;text-underline-offset:4px;padding:8px;min-height:44px}
#tea-panel#tea-panel #tea-flow-note{position:static;width:auto;height:auto;clip-path:none;white-space:normal;overflow:visible;border:0;background:transparent;padding:0;margin:18px 0 0;font-size:13px;line-height:1.7;text-align:left;color:var(--muted)}
#tea-panel#tea-panel[data-phase="2"] #tea-flow-note{text-align:center;max-width:34ch;align-self:center;margin-top:18px}
#tea-panel#tea-panel .tea-step-actions{flex-direction:column;gap:4px;margin-top:20px}
#tea-panel#tea-panel .tea-step-actions:has(#tea-next[hidden]){display:none}
#tea-panel#tea-panel #tea-next{flex:auto;width:100%;background:var(--ink);color:var(--paper);border:0;margin:0}
#tea-panel#tea-panel #tea-next:hover{background:var(--tone-505d52)}
#tea-panel#tea-panel #tea-previous{order:1;flex:auto;border:0;background:transparent;color:var(--muted);font-size:14px;min-height:44px}
#tea-panel#tea-panel #tea-pause{width:100%;margin-top:14px;background:var(--ink);color:var(--paper);border:0}
#tea-panel#tea-panel .tea-result{text-align:center}
#tea-panel#tea-panel .tea-guide-status{font-size:13px;line-height:1.7;margin:10px 0;color:var(--muted)}
#tea-brew-visual[data-running="true"] .tea-brew-steam{animation:tea-steam-rise 3s ease-in-out infinite}
#tea-brew-visual[data-running="true"] .tea-bag{animation:tea-bag-sway 4s ease-in-out infinite;transform-origin:64px 61px}
#tea-home .tea-steam{animation:tea-steam-rise 3s ease-in-out infinite}
@keyframes tea-steam-rise{0%,100%{transform:translateY(1px);opacity:.45}50%{transform:translateY(-4px);opacity:.9}}
@keyframes tea-bag-sway{0%,100%{transform:rotate(-3deg)}50%{transform:rotate(3deg)}}
@media(max-width:420px){
 .app-shell,.app-shell:has(#tea-panel:not([hidden])){padding:calc(20px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom))}
 #ritual h1,#tea-panel#tea-panel #tea-phase-title,#tea-panel#tea-panel .tea-home h1{font-size:23px}
 #ritual .hourglass-wrap,.app-shell.has-update #ritual .hourglass-wrap{width:148px;height:185px}
 #ritual .time,#tea-panel#tea-panel #tea-clock{font-size:60px}
 #tea-panel#tea-panel .tea-preparation label{font-size:14px;padding:10px}
}
@media(max-height:700px){
 .header{margin-bottom:16px}
 #ritual{padding-top:22px}
 #ritual .hourglass-wrap,.app-shell.has-update #ritual .hourglass-wrap{width:128px;height:160px;margin-top:12px}
 #tea-panel#tea-panel #tea-brew-visual{width:128px;height:128px;margin-top:18px}
 #tea-panel#tea-panel .tea-steps{margin-bottom:20px}
 #tea-panel#tea-panel .tea-preparation{margin:18px 0}
}
@media(prefers-reduced-motion:reduce){#tea-brew-visual .tea-brew-steam,#tea-brew-visual .tea-bag,#tea-home .tea-steam{animation:none!important}}

/* Fit timer controls inside the small viewport with browser bars visible.
   Keep natural page scrolling for landscape, large text and unusually short screens. */
html:has(#ritual:not([hidden])),html:has(#ritual:not([hidden])) body{height:auto;min-height:100%;overflow-y:auto}
.app-shell:has(#ritual:not([hidden])){min-height:100svh;max-height:none;overflow:visible}
@media(max-height:900px){
 .app-shell,.app-shell:has(#tea-panel:not([hidden])){padding-top:calc(12px + env(safe-area-inset-top));padding-bottom:calc(12px + env(safe-area-inset-bottom))}
 .header{height:44px;min-height:44px;margin-bottom:12px}
 #ritual{padding-top:16px}
 #ritual h1{font-size:23px;line-height:1.5}
 #ritual .duration-options{margin-top:12px}
 #ritual .duration-options button{min-height:44px;padding-block:8px}
 #ritual .hourglass-wrap,.app-shell.has-update #ritual .hourglass-wrap{height:clamp(64px,calc(100svh - 590px - env(safe-area-inset-top) - env(safe-area-inset-bottom) - var(--update-space,0px)),185px);width:auto;max-width:148px;margin-top:12px}
 #ritual .hourglass{width:auto;height:100%}
 #ritual .time{font-size:56px;line-height:1.15;margin:8px 0 12px}
 #ritual .actions{margin-top:12px}
 #ritual .primary-button{min-height:48px;padding-block:12px}
 #ritual .sound-hint{font-size:12px;line-height:1.6;margin-top:8px;max-width:none}
 #ritual .secondary-actions{margin-top:8px}
 #ritual .timer-sound-tools{padding-top:12px;margin-top:0}
 #ritual .install-link{margin:0 auto;padding-block:8px;min-height:44px}
}

/* Keep the shared chrome anchored when document scrollbars appear in either mode. */
html{scrollbar-gutter:stable}
.header{flex-shrink:0}
#tea-panel#tea-panel #tea-choose{display:flex;justify-content:space-between;align-items:center;gap:16px;width:100%;margin:0 0 16px;padding:16px;border:1px solid var(--line);border-radius:12px;background:transparent;text-align:left}
#tea-panel#tea-panel .tea-config-content{display:flex;flex:1;flex-direction:column;gap:6px;min-width:0;max-width:none;overflow-wrap:anywhere}
.tea-config-label{font-size:13px;line-height:1.5;color:var(--muted)}
#tea-product-name{font-size:18px;font-weight:500;line-height:1.5}
#tea-panel #tea-product-info{font-size:14px;line-height:1.7;color:var(--muted)}
#tea-panel#tea-panel .tea-config-edit{display:flex;align-items:center;justify-content:center;flex-shrink:0;font-size:14px;min-height:44px;padding:8px 14px;border:1px solid var(--tone-9aa59a);border-radius:8px;color:var(--ink);background:var(--tone-e9e7dc)}

/* Reserve room for the primary action before sizing the tea illustration. */
@media(max-height:800px){
 #tea-panel#tea-panel:is([data-phase="1"],[data-phase="2"]) .tea-flow{padding-top:4px}
 #tea-panel#tea-panel:is([data-phase="1"],[data-phase="2"]) .tea-steps{margin:8px 0 12px}
 #tea-panel#tea-panel:is([data-phase="1"],[data-phase="2"]) #tea-phase-title{font-size:22px;line-height:1.4}
 #tea-panel#tea-panel:is([data-phase="1"],[data-phase="2"]) #tea-phase-copy{font-size:14px;line-height:1.6;margin-top:6px}
 #tea-panel#tea-panel .tea-preparation{gap:8px;margin:12px 0}
 #tea-panel#tea-panel .tea-preparation label{min-height:48px;padding:10px}
 #tea-panel#tea-panel .tea-guide-toggle{min-height:64px;padding:10px 0}
 #tea-panel#tea-panel .tea-guide-toggle small{margin-top:2px;font-size:13px}
 #tea-panel#tea-panel:is([data-phase="1"],[data-phase="2"]) #tea-brew-info{font-size:13px;line-height:1.5;margin:10px 0}
 #tea-panel#tea-panel[data-phase="2"] #tea-brew-info{margin:0 0 8px}
 #tea-panel#tea-panel #tea-brew-visual{width:clamp(72px,calc(100svh - 530px),128px);height:clamp(72px,calc(100svh - 530px),128px);margin:12px auto 4px}
 #tea-panel#tea-panel #tea-clock{font-size:52px;line-height:1.15;margin:4px 0 8px}
 #tea-panel#tea-panel:is([data-phase="1"],[data-phase="2"]) #tea-flow-note{font-size:12px;line-height:1.5;margin-top:8px}
 #tea-panel#tea-panel .tea-guide-controls{min-height:44px;margin:8px 0 0}
 #tea-panel#tea-panel .tea-step-actions{margin-top:12px}
 #tea-panel#tea-panel #tea-pause{min-height:48px;margin-top:8px;padding-block:12px}
 #tea-panel#tea-panel[data-phase="1"] #tea-next{min-height:48px;padding-block:12px}
}
@media(max-height:650px){
 #tea-panel#tea-panel[data-phase="1"] #tea-phase-copy{display:none}
 #tea-panel#tea-panel:is([data-phase="1"],[data-phase="2"]) #tea-flow-note{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
 #tea-panel#tea-panel .tea-preparation label{min-height:44px;padding:8px}
 #tea-panel#tea-panel .tea-guide-toggle{min-height:60px;padding:8px 0}
 #tea-panel#tea-panel #tea-clock{font-size:48px}
}

/* Keep the update notice in the home content, below its greeting. */
#main-update{width:100%;max-width:400px;text-align:center;padding:20px 18px;margin:20px auto 0;background:var(--tone-e9e7dc);border:1px solid var(--line);border-radius:16px;flex-shrink:0}#main-update[hidden]{display:none}#main-update .update-kicker{font-size:10px;letter-spacing:2px;color:var(--muted)}#main-update .main-update-row{position:relative;justify-content:center;margin:8px 0 0}#main-update-message{font-size:19px;line-height:1.5;font-weight:500}#main-update-dismiss{position:absolute;right:-10px;top:-28px}#main-update-apply{margin-top:16px;min-height:50px;font-size:15px}#main-update-notes{margin-top:10px;font-size:12px;line-height:1.7}#tea-home>#main-update{margin-bottom:18px}.app-shell.has-update{height:auto;overflow:visible}
