/* Duo New Tab © 2026 DevRoshdi. All rights reserved. See LICENSE.txt. */
/*
 * Calculator, after Calculator in iPadOS 27: always dark, round Liquid Glass keys (grey digits, lighter
 * grey functions, orange operators), the sum and answer right-aligned above them, a floating glass
 * sidebar for History and Math Notes, and Liquid Glass menus. The window comes from notes.css.
 */

/* ---------- the icon: a dark calculator on silver; in the Dark style, four keys on black ---------- */

.tile.builtin-calculator { background: #e6e6ea; }
.tile.builtin-calculator::before {
  content: ""; position: absolute; inset: 0; display: none;
  background: url("icons/calculator.svg") center / 100% no-repeat;
}
body.icons-dark .tile.builtin-calculator::before, body.icons-clear .tile.builtin-calculator::before, body.icons-tinted .tile.builtin-calculator::before { display: block; }
body.icons-dark .tile.builtin-calculator { background: linear-gradient(180deg, #2c2c2e, #0c0c0e); }
body.icons-clear .tile.builtin-calculator::before, body.icons-tinted .tile.builtin-calculator::before {
  -webkit-mask: url("icons/calculator-mask.svg") center / 100% no-repeat; mask: url("icons/calculator-mask.svg") center / 100% no-repeat;
}
body.icons-clear .tile.builtin-calculator::before { background: rgba(255, 255, 255, 0.96); }
body.icons-tinted .tile.builtin-calculator::before { background: hsl(var(--hue), 95%, 72%); }

/* ---------- the window ---------- */

.capp {
  --n-bg: #000;
  --n-text: #fff;
  --n-sub: rgba(235, 235, 245, 0.6);
  --n-sep: rgba(84, 84, 88, 0.55);
  --n-fill: rgba(120, 120, 128, 0.32);
  --n-glass: rgba(44, 44, 46, 0.72);
  --c-orange: #ff9f0a;
  --c-side-w: 320px;
  color: #fff; color-scheme: dark;
}
/* Full screen, the status bar is white over Calculator's black. */
body[data-full-app="calculator"] .statusbar { color: #fff; }
.capp.windowed .n-win { box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.16), 0 24px 70px rgba(0, 0, 0, 0.6), 0 6px 18px rgba(0, 0, 0, 0.3); }

.capp .n-win.c-win {
  display: grid; grid-template-columns: 0 minmax(0, 1fr); background: #000; outline: none;
  transition: grid-template-columns 0.45s var(--smooth), transform 0.15s ease;
}
.capp .n-win.c-win.c-side-on { grid-template-columns: var(--c-side-w) minmax(0, 1fr); }
.capp .n-win.c-win.c-narrow.c-side-on { grid-template-columns: 0 minmax(0, 1fr); }

.c-sym { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- sidebar (History, or the Math Notes) ---------- */

.c-side {
  position: relative; z-index: 3; min-width: 0; overflow: hidden; display: flex; flex-direction: column;
  margin: 8px 0 8px 8px; border-radius: 24px;
  background: rgba(36, 36, 38, 0.86); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 0 0.5px rgba(255, 255, 255, 0.06);
}
.c-side > * { width: calc(var(--c-side-w) - 8px); flex: none; }
/* A narrow window: the sidebar slides over the keys instead of pushing them. */
.c-win.c-narrow .c-side {
  /* Over the toolbar, under the window controls (which stay usable, as in a wide window). */
  position: absolute; left: 0; top: 0; bottom: 0; width: min(var(--c-side-w), 86%); z-index: 5;
  transform: translateX(calc(-100% - 16px)); transition: transform 0.42s var(--smooth);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 20px 60px rgba(0, 0, 0, 0.6);
}
.c-win.c-narrow.c-side-on .c-side { transform: none; }
.c-win.c-narrow .c-side > * { width: 100%; }

.c-side-title { margin: 0; padding: calc(var(--n-top) + 48px) 20px 6px; font: 700 28px/1.2 var(--font); letter-spacing: 0.01em; }
.c-side-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 16px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }
.c-group { margin: 16px 10px 6px; font: 600 15px var(--font); color: var(--n-sub); }
.c-empty { margin: 60px 0; text-align: center; font: 500 17px var(--font); color: var(--n-sub); }
.c-hist, .c-note-row {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px; width: 100%; padding: 9px 12px; border: 0; border-radius: 12px;
  background: transparent; color: #fff; text-align: right; cursor: pointer; font-family: var(--font);
}
.c-hist + .c-hist, .c-note-row + .c-note-row { box-shadow: inset 0 0.5px 0 var(--n-sep); }
.c-hist:hover, .c-note-row:hover { background: rgba(255, 255, 255, 0.07); }
.c-hist:hover + .c-hist, .c-note-row:hover + .c-note-row, .c-note-row.sel + .c-note-row { box-shadow: none; }
.c-h-e { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; color: var(--n-sub); }
.c-h-r { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 24px; font-weight: 400; }
.c-note-row { align-items: flex-start; text-align: left; }
.c-note-row.sel { background: var(--c-orange); color: #000; }
.c-note-row.sel .c-nr-s { color: rgba(0, 0, 0, 0.6); }
.c-nr-t { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 16px var(--font); }
.c-nr-s { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--n-sub); }
.c-side-foot { padding: 8px 14px 14px; }
.c-clear {
  width: 100%; height: 40px; border: 0; border-radius: 20px; background: rgba(255, 255, 255, 0.08); color: #ff453a;
  font: 600 16px var(--font); cursor: pointer;
}
.c-clear:hover { background: rgba(255, 255, 255, 0.13); }

/* ---------- toolbar ---------- */

.c-side { grid-column: 1; grid-row: 1; }
.c-mainwrap { grid-column: 2; grid-row: 1; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.c-bar {
  position: relative; z-index: 4; display: flex; align-items: center; gap: 10px; flex: none;
  height: calc(var(--n-top) + 54px); padding: calc(var(--n-top) + 8px) 16px 0 98px; box-sizing: border-box;
  transition: padding 0.45s var(--smooth);
}
.c-win.c-side-on:not(.c-narrow) .c-bar { padding-left: 16px; }
.c-bar-gap { flex: 1; }
.c-gbtn {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; flex: none;
  background: rgba(255, 255, 255, 0.1); color: #fff; cursor: pointer;
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 0 0.5px rgba(255, 255, 255, 0.06);
  transition: background 0.2s ease, scale 0.3s var(--spring-pop);
}
.c-gbtn:hover { background: rgba(255, 255, 255, 0.16); }
.c-gbtn:active { scale: 0.92; }
.c-win.c-side-on .c-side-btn { color: var(--c-orange); }
.c-win:not(.c-notes-on) .c-mode-btn, .c-win:not(.c-notes-on) .c-note-btn { display: none; }
.c-mode-btn { color: var(--c-orange); }

/* ---------- the sum and the keys ---------- */

.c-body { position: relative; flex: 1; min-height: 0; }
.c-pane {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 0 var(--pad, 24px) var(--pad, 24px);
}
.c-display {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; flex: 1; min-height: 0;
  width: var(--keys-w, 100%); max-width: 100%; padding: 0 4px calc(var(--gap, 14px) + 8px); box-sizing: border-box;
}
.c-flags { position: absolute; left: 6px; bottom: calc(var(--gap, 14px) + 12px); display: flex; gap: 8px; }
.c-win.c-conv-on .c-flags { left: auto; right: 6px; bottom: auto; top: 0; }
.c-flag { font: 600 13px var(--font); letter-spacing: 0.02em; color: var(--n-sub); }
.c-flag[hidden] { display: none; }
.c-expr, .c-result, .c-cv {
  overflow: hidden; white-space: nowrap; text-align: right; font-family: var(--font); scrollbar-width: none;
}
.c-expr { min-height: 1.2em; font-size: calc(var(--font-base, 80px) * 0.34); line-height: 1.2; color: var(--n-sub); }
.c-result { font-size: var(--font-base, 80px); font-weight: 300; line-height: 1.12; letter-spacing: -0.02em; }

/* Convert: the value typed and the same in another unit, each with its unit menu. */
.c-conv { display: none; }
.c-win.c-conv-on .c-conv { display: flex; flex-direction: column; align-items: stretch; }
.c-win.c-conv-on .c-result { display: none; }
.c-cr { display: flex; align-items: center; gap: 12px; min-width: 0; }
.c-cv { flex: 1; min-width: 0; font-weight: 300; line-height: 1.15; letter-spacing: -0.02em; }
.c-cv.out { color: rgba(255, 255, 255, 0.92); }
.c-unit {
  display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 10px 0 14px; border: 0; border-radius: 17px; flex: none;
  background: rgba(255, 255, 255, 0.12); color: #fff; font: 600 16px var(--font); cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.c-unit:hover { background: rgba(255, 255, 255, 0.18); }
.c-unit .c-sym { width: 16px; height: 16px; stroke-width: 2.2; color: var(--n-sub); }
.c-swap { width: 34px; height: 34px; margin: 4px 0; }
.c-swap .c-sym { width: 18px; height: 18px; }

.c-keys {
  display: grid; grid-template-columns: repeat(4, var(--kw, 80px)); grid-auto-rows: var(--kh, 80px); gap: var(--gap, 14px); flex: none;
}
.c-keys.sci { grid-template-columns: repeat(10, var(--kw, 80px)); }
/* Liquid Glass keys: a soft sheen from the top over each key's colour. */
.c-key {
  --kc: #333336;
  display: grid; place-items: center; min-width: 0; padding: 0; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0) 55%) var(--kc);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.13), inset 0 -1px 0 rgba(0, 0, 0, 0.22);
  color: #fff; font: 500 calc(var(--kh, 80px) * 0.42) / 1 var(--font); cursor: pointer; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent; transition: filter 0.45s ease, background-color 0.3s ease;
}
.c-key:hover { filter: brightness(1.1); }
.c-key.down { filter: brightness(1.6); transition: none; }
.c-key.fn { --kc: #5c5c5f; font-size: calc(var(--kh, 80px) * 0.36); }
.c-key.op { --kc: var(--c-orange); font-size: calc(var(--kh, 80px) * 0.5); font-weight: 500; }
.c-key.op.down { filter: brightness(1.3) saturate(0.75); }
.c-key.sci { --kc: #1f1f21; font-size: calc(var(--kh, 80px) * 0.3); font-weight: 500; }
.c-key.sci.on { --kc: #77777c; }
.c-kl { white-space: nowrap; }
.c-key sup, .c-key sub { font-size: 0.62em; line-height: 0; }
.c-key sup { vertical-align: 0.62em; }
.c-key sub { vertical-align: -0.28em; }
.c-pm { font-size: 0.86em; letter-spacing: -0.06em; }
.c-key .c-back { width: calc(var(--kh, 80px) * 0.44); height: calc(var(--kh, 80px) * 0.44); stroke-width: 1.7; }
.c-key .c-calc { width: calc(var(--kh, 80px) * 0.4); height: calc(var(--kh, 80px) * 0.4); stroke-width: 1.7; }
.c-key[data-key="menu"] .c-calc path { stroke-width: 1.7; }

/* ---------- Math Notes ---------- */

.c-notes { position: absolute; inset: 0; display: none; }
.c-win.c-notes-on .c-notes { display: block; }
.c-win.c-notes-on .c-pane { display: none; }
.c-paper { position: absolute; inset: 0; }
/* The text, and under it a copy with the answers, laid out exactly alike. */
.c-mirror, .c-ta {
  /* A readable column (at most 760 px of text), centred, as in Notes. */
  position: absolute; inset: 0; box-sizing: border-box; margin: 0; padding: 6px max(28px, 6%, calc((100% - 760px) / 2)) 60px; border: 0;
  font: 400 21px/1.55 var(--font); letter-spacing: 0; tab-size: 4;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; overflow-y: auto; scrollbar-gutter: stable;
}
.c-mirror { color: transparent; overflow-y: hidden; pointer-events: none; }
.c-ta { background: transparent; color: #fff; caret-color: var(--c-orange); resize: none; outline: none; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }
.c-ta::placeholder { color: rgba(235, 235, 245, 0.3); }
.c-res { color: var(--c-orange); }
.c-err { text-decoration: underline wavy rgba(255, 69, 58, 0.85); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }

/* ---------- menus ---------- */

.c-pop {
  position: absolute; z-index: 20; min-width: 250px; padding: 6px; border-radius: 20px; color: #fff;
  background: rgba(40, 40, 42, 0.8); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 18px 50px rgba(0, 0, 0, 0.55);
  font: 16px/1.25 var(--font); animation: cPopIn 0.34s var(--spring-pop) both;
}
.c-pop.out { animation: cPopOut 0.16s ease both; pointer-events: none; }
@keyframes cPopIn { from { opacity: 0; scale: 0.86; } to { opacity: 1; scale: 1; } }
@keyframes cPopOut { to { opacity: 0; scale: 0.94; } }
.c-mi {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px 0 6px; border: 0; border-radius: 12px;
  background: transparent; color: #fff; font: inherit; text-align: left; cursor: pointer;
}
.c-mi:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.c-mi:disabled { opacity: 0.4; cursor: default; }
.c-mi-check { display: grid; place-items: center; width: 20px; flex: none; }
.c-mi-check .c-sym { width: 17px; height: 17px; stroke-width: 2.4; }
.c-mi-t { flex: 1; }
.c-mi-s { color: var(--n-sub); font-size: 15px; }
.c-sep { height: 0.5px; margin: 5px 10px; background: rgba(255, 255, 255, 0.16); }
.c-switch { position: relative; width: 44px; height: 26px; border-radius: 13px; background: rgba(120, 120, 128, 0.36); flex: none; transition: background 0.25s ease; }
.c-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); transition: translate 0.32s var(--spring-pop);
}
.c-switch.on { background: #30d158; }
.c-switch.on::after { translate: 18px 0; }

.c-units { width: min(330px, calc(100% - 20px)); padding: 8px 6px 6px; }
.c-cats { display: flex; gap: 6px; padding: 0 4px 8px; overflow-x: auto; scrollbar-width: none; }
.c-cats::-webkit-scrollbar { display: none; }
.c-cat {
  flex: none; height: 30px; padding: 0 12px; border: 0; border-radius: 15px; background: rgba(255, 255, 255, 0.09); color: #fff;
  font: 600 14px var(--font); cursor: pointer; white-space: nowrap;
}
.c-cat:hover { background: rgba(255, 255, 255, 0.15); }
.c-cat.on { background: var(--c-orange); color: #000; }
.c-ulist { max-height: min(340px, 50vh); overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }

@media (prefers-reduced-motion: reduce) {
  .c-pop, .c-pop.out { animation: none; }
  .capp .n-win.c-win, .c-win.c-narrow .c-side { transition: none; }
}
