.utility-app{box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0;overflow:auto;padding:clamp(12px,3%,24px);container-type:inline-size;color:var(--text-main)}
.utility-app button{min-height:44px;cursor:pointer}.utility-app button:focus-visible,.utility-app input:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
/* Layouts follow the Calculator window's own size (a size container), not the whole work area, so
   Safari's bars and narrow windows are accounted for. The keypad fills the height (44px minimum keys). */
.calculator-app{container-type:size;padding:0}
.calc-layout{box-sizing:border-box;display:flex;flex-direction:column;gap:16px;min-height:100%;padding:clamp(12px,3cqw,24px)}
.calc-main{display:flex;flex-direction:column;justify-content:center;flex:1 0 auto;min-width:0;gap:10px;max-width:540px;width:100%;margin-inline:auto}
.calc-display,.calc-history,.clock-local,.clock-zone{border:1px solid var(--line);border-radius:18px;padding:14px;background:var(--surface-solid)}
.calc-display{display:flex;flex-direction:column;gap:2px;padding:10px 14px}
/* A steady ring on the card while typing, instead of an outline on the field that blinks with each key. */
.calculator-app .calc-input:focus-visible{outline:none}.calc-display:focus-within{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.calc-input-label,.clock-eyebrow{font-size:13px;color:var(--text-muted)}
.calc-input{width:100%;min-width:0;background:transparent;border:0;padding:2px 0;text-align:right;font:500 clamp(18px,4.5cqw,26px) var(--font-code)}
.calc-result{text-align:right;font-size:clamp(24px,6cqw,36px);line-height:1.15;font-weight:700;overflow-wrap:anywhere}
.calc-message{margin:0;min-height:20px;font-size:13px;color:var(--text-muted)}.calc-message[data-error=true]{color:var(--danger)}
.calc-memory-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.calc-memory-bar button{background:var(--surface-solid);border:1px solid var(--line);border-radius:12px;padding:6px 9px}.calc-memory{font-size:13px;margin-left:auto;color:var(--text-muted)}
.calc-keypad{flex:1 0 auto;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));grid-auto-rows:minmax(44px,1fr);gap:8px;max-height:460px}.calc-key{min-width:0;min-height:44px!important;border-radius:14px;border:1px solid var(--line);background:var(--surface-solid);font-size:21px;font-weight:600}
.calc-key[data-kind=operator]{color:var(--accent-strong);background:var(--control-hover)}
.calc-key[data-kind=equals],.clock-primary{background:var(--accent-strong);color:var(--surface-content);border:1px solid transparent;font-weight:700}
.calc-history{min-width:0}.calc-history h2{font-size:19px;margin-bottom:8px}.calc-history-list{display:grid;gap:5px}.calc-history-item{min-width:0;display:flex;flex-wrap:wrap;justify-content:space-between;gap:5px;text-align:left;background:transparent;border:0;border-radius:10px;padding:8px}.calc-history-item:hover{background:var(--control-hover)}.calc-history-item span{overflow-wrap:anywhere}.calc-history-item strong{color:var(--accent-strong)}
.clock-app{display:flex;flex-direction:column;gap:16px}.clock-tabs,.clock-actions,.clock-sound-row{display:flex;align-items:center;flex-wrap:wrap;gap:10px}.clock-tab,.clock-actions button{border:1px solid var(--line);border-radius:12px;padding:8px 16px;background:var(--surface-solid)}.clock-tab[aria-pressed=true]{border-color:var(--accent);background:var(--control-hover)}
.clock-view{min-width:0}.clock-local{margin-bottom:12px}.clock-local p{margin:0 0 5px}.clock-local-time{font-size:clamp(30px,7cqw,48px);font-weight:700}.clock-zone{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:4px 12px;margin-bottom:8px}.clock-zone h3{width:100%;margin:0}.clock-zone-time{font-size:25px;font-weight:700}.clock-zone-date{font-size:13px;color:var(--text-muted)}
.clock-digits{display:block;font:650 clamp(28px,8cqw,52px) var(--font-code);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}.clock-actions{margin:18px 0}.clock-actions button{padding:9px 22px}
.clock-duration-inputs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.clock-duration-inputs label{min-width:0;display:grid;gap:5px}.clock-duration-inputs input{width:100%;min-width:0;min-height:44px;border:1px solid var(--line);border-radius:12px;padding:8px;background:var(--surface-solid);font-size:20px}
.clock-zone-heading{width:100%;display:flex;align-items:center;justify-content:space-between;gap:8px}.clock-zone-heading h3{flex:1;width:auto;margin:0;min-width:0;overflow-wrap:anywhere}.clock-zone-remove{flex:0 0 44px;width:44px;height:44px;display:grid;place-items:center;border:0;border-radius:12px;background:transparent;color:var(--text-muted)}.clock-zone-remove:hover{background:var(--control-hover)}
.clock-zone-add{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:12px}.clock-zone-add label{font-size:13px;font-weight:650}.clock-zone-select{flex:1 1 160px;min-width:0;min-height:44px;padding:6px 8px;border:1px solid var(--line);border-radius:12px;background:var(--surface-solid)}.clock-zone-add button{min-height:44px;padding:8px 18px;border:1px solid var(--line);border-radius:12px;background:var(--surface-solid)}.clock-zone-add :disabled{opacity:.45}.clock-zone-message{min-height:1.4em;margin:6px 0 0;font-size:13px}
.clock-alert{min-height:1.5em;line-height:1.5;margin:6px 0;color:var(--accent-strong)}.clock-sound-row label{display:flex;align-items:center;gap:8px}.clock-explainer{color:var(--text-muted);font-size:13px;line-height:1.5;max-width:680px}
/* Wide and tall enough: History sits beside the keypad and the toggle is not needed. */
.calc-history-toggle{display:none}
@container (min-width:710px) and (min-height:421px){.calc-layout{flex-direction:row;align-items:stretch;height:100%}.calc-main{flex:1.3 1 0}.calc-history{flex:.9 1 0;min-width:240px;align-self:flex-start;max-height:100%;overflow:auto}}
/* Compact (phones, small windows): History is behind a toggle and replaces the keypad while open. */
@container (max-width:709px) or (max-height:420px){
  .calc-memory-bar .calc-history-toggle{display:inline-flex;align-items:center;margin-left:0}
  .calc-layout:not([data-history-open=true]) .calc-history{display:none}
  .calc-layout[data-history-open=true] .calc-keypad{display:none}
  .calc-layout[data-history-open=true] .calc-main{flex:0 0 auto}
  .calc-layout[data-history-open=true] .calc-history{flex:1 0 auto;max-width:540px;width:100%;margin-inline:auto;overflow:auto}
}
@container(min-width:500px){.clock-zone-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.clock-zone{margin:0}}
@media(forced-colors:active){.calc-key[data-kind=equals],.clock-primary{color:ButtonText;background:ButtonFace;border:2px solid ButtonText}}

/* Short and wide (phones sideways, especially with Safari's bars showing): display and memory on the
   left, and a 6×4 keypad on the right with functions left of the usual 789÷ / 456× / 123− / 0.=+ block.
   Keys shrink to fit the height; open History takes the keypad's place. */
@container (max-height:420px) and (min-width:480px){
  .calc-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.5fr);grid-template-rows:auto auto minmax(0,1fr);gap:4px 10px;align-items:start;height:100%;min-height:0;padding:5px 8px}
  .calc-main{display:contents}
  .calc-display{grid-column:1;grid-row:1;padding:4px 10px;gap:0}
  .calc-input-label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
  .calc-message:not([data-error=true]){display:none}.calc-message{min-height:0;font-size:12px}
  .calc-input{font-size:18px}.calc-result{font-size:24px}
  .calc-memory-bar{grid-column:1;grid-row:2;gap:4px}.calc-memory-bar button{min-height:30px;padding:3px 8px}
  .calc-keypad,.calc-layout[data-history-open=true] .calc-history{grid-column:2;grid-row:1/4;align-self:stretch;height:100%;max-height:none;min-height:0}
  .calc-keypad{grid-template-columns:repeat(6,minmax(0,1fr));grid-template-rows:repeat(4,minmax(22px,1fr));grid-auto-rows:auto;gap:4px}
  .calc-key{min-height:22px!important;font-size:16px;border-radius:10px}
  .calc-layout[data-history-open=true] .calc-history{padding:8px;max-width:none}
  [data-key="("]{grid-area:1/1}[data-key=")"]{grid-area:1/2}[data-key="7"]{grid-area:1/3}[data-key="8"]{grid-area:1/4}[data-key="9"]{grid-area:1/5}[data-key="÷"]{grid-area:1/6}
  [data-key=clear]{grid-area:2/1}[data-key=erase]{grid-area:2/2}[data-key="4"]{grid-area:2/3}[data-key="5"]{grid-area:2/4}[data-key="6"]{grid-area:2/5}[data-key="×"]{grid-area:2/6}
  [data-key=Ans]{grid-area:3/1}[data-key="^"]{grid-area:3/2}[data-key="1"]{grid-area:3/3}[data-key="2"]{grid-area:3/4}[data-key="3"]{grid-area:3/5}[data-key="−"]{grid-area:3/6}
  [data-key=sign]{grid-area:4/1}[data-key="%"]{grid-area:4/2}[data-key="0"]{grid-area:4/3}[data-key="."]{grid-area:4/4}[data-key=equals]{grid-area:4/5}[data-key="+"]{grid-area:4/6}
}
