:root {
  --bg: #303030; /* matches the skin background so full-bleed skins blend in */
  --panel: #2b2b2e;
  --text: #f2f2f2;
  --muted: #a0a0a6;
  --accent: #f4b400;
  --danger: #d9534f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  align-items: center;
  justify-content: center;
}

#calc {
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  outline: none;
  border-radius: 10px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .5);
}

#loading {
  position: absolute;
  color: var(--muted);
  padding: 0 24px;
  text-align: center;
}

#menu-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 6px);
  right: calc(env(safe-area-inset-right) + 6px);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 18px;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 22px;
  line-height: 36px;
  cursor: pointer;
  z-index: 2;
  opacity: .55;
}
#menu-btn:hover, #menu-btn:focus-visible { opacity: 1; }

dialog {
  border: 0;
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  width: min(92vw, 420px);
  padding: 18px 20px;
}
dialog[open] { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 4; margin: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { margin: 0; font-size: 20px; outline: none; }
dialog .version { margin: 2px 0 14px; color: var(--muted); font-size: 13px; }
dialog label { display: block; margin: 10px 0; }
dialog label.check { display: flex; gap: 8px; align-items: center; }
dialog select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #555;
  background: #1f1f22;
  color: var(--text);
  font: inherit;
}
dialog .row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
dialog button {
  flex: 1 1 auto;
  padding: 9px 12px;
  border: 1px solid #555;
  border-radius: 8px;
  background: #3a3a3e;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
dialog button.primary { background: var(--accent); border-color: var(--accent); color: #111; }
dialog button.danger { border-color: var(--danger); color: #ffb3b0; }
dialog .small { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; -webkit-user-select: text; user-select: text; }
dialog a { color: var(--accent); }

#toast {
  position: fixed;
  left: 50%;
  /* anchored to the visible bottom (--vis-bottom, set by layout()), not to CSS bottom */
  top: calc(var(--vis-bottom, 100vh) - 20px);
  transform: translate(-50%, -100%);
  background: rgba(20, 20, 20, .92);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
  z-index: 3;
}
#toast.show { opacity: 1; }

/* Full-bleed skins (iPhone): no frame, the picture fills the safe area. */
#calc.full-bleed {
  border-radius: 0;
  box-shadow: none;
}

dialog .device { word-break: break-all; font-size: 11px; }

/* iOS haptics: transparent real switch over the calculator (see app.js, tap layer) */
#tap-layer {
  position: fixed;
  z-index: 1;
  margin: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#tap-layer[hidden] { display: none; }
#tap-layer input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0.01;
  touch-action: none;
}

#action-toast {
  position: fixed;
  left: 50%;
  top: calc(var(--vis-bottom, 100vh) - 64px);
  transform: translate(-50%, -100%);
  z-index: 3;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #111;
  font: inherit;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
  cursor: pointer;
}
#action-toast[hidden] { display: none; }
dialog button:disabled { opacity: .45; cursor: default; }

#copy-choice {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: min(92vw, 380px);
  padding: 12px;
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .55);
}
#copy-choice[hidden] { display: none; }
#copy-choice .cc-title { font-weight: 600; margin: 2px 4px 8px; }
#copy-choice button {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid #555;
  border-radius: 10px;
  background: #3a3a3e;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
#copy-choice .cc-label { display: block; font-size: 12px; color: var(--muted); }
#copy-choice .cc-value { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }

/* Desktop: print dialog shows only the receipt image */
#print-area { display: none; }
@media print {
  @page { margin: 4mm; }
  html, body { background: #fff !important; overflow: visible !important; height: auto !important; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  #print-area img { display: block; image-rendering: pixelated; }
}

dialog h3 { margin: 16px 0 0; font-size: 16px; }
dialog .prog-info { margin-top: 2px; }
dialog code { font-size: 12px; }
#copy-choice button[hidden] { display: none; }

/* E-readers (tolino): flat, high-contrast clipboard menu – no shadows or transforms */
.eink #copy-choice {
  box-shadow: none;
  background: #fff;
  color: #000;
  border: 2px solid #000;
}
.eink #copy-choice button { background: #fff; color: #000; border: 1px solid #000; }
.eink #copy-choice .cc-label { color: #333; }

