/*
 * Number base converter (calc.html). Runs inside an iframe, so the Bilingual Workbench tokens are repeated here.
 * Keep the values in step with app/globals.css. Teal is the single action (equals), blue marks the current mode and focus.
 */
@font-face { font-family: "Mona Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(/tools-static/lib/fonts/mona-sans-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400 600; font-display: swap; src: url(/tools-static/lib/fonts/jetbrains-mono-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: "Hind Siliguri"; font-style: normal; font-weight: 400; font-display: swap; size-adjust: 106%; src: url(/tools-static/lib/fonts/hind-siliguri-bengali-400.woff2) format("woff2"); unicode-range: U+0964-0965, U+0980-09FE, U+200C-200D, U+25CC; }

:root{
  --sunken: #0e161e;
  --canvas: #121b24;
  --panel: #16212b;
  --surface: #1b2733;
  --raised: #22303e;
  --select: #1a3353;
  --line: #26364a;
  --line-mid: #34465b;
  --line-strong: #6a7f98;
  --ink-1: #e8eef5;
  --ink-2: #ccd6e1;
  --ink-3: #aebbcb;
  --ink-4: #91a1b4;
  --ink-off: #6f8094;
  --teal: #3cc4b0;
  --teal-hover: #5ad6c4;
  --on-teal: #021714;
  --blue: #3a86d6;
  --blue-text: #8dbef2;
  --green: #6ccb7e;
  --red: #ff9e99;
  --radius-shell: 12px;
  --radius-key: 6px;
  --font-display: "JetBrains Mono", "Hind Siliguri", ui-monospace, Menlo, Consolas, monospace;
  --font-body: "Mona Sans", "Hind Siliguri", system-ui, -apple-system, sans-serif;
}

*{ box-sizing: border-box; }

html{
  background: var(--canvas);
}

body{
  margin:0;
  padding:0;
  color: var(--ink-1);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background: var(--canvas);
}
::selection{ background: rgb(31 79 143 / .75); color: #fff; }

.app-shell{
  max-width: 460px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.site-header{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.brand-mark{
  display:flex;
  justify-content:center;
}
.brand-tile{
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1f4f8f, #3a86d6 40%, #3cc4b0 75%, #6ccb7e);
}
.site-title{
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--ink-1);
}
.site-title span{
  color: var(--ink-1);
}
.site-subtitle{
  margin:0;
  font-size: 0.8125rem;
  color: var(--ink-3);
}

/* Calculator shell */
.calculator{
  background: var(--panel);
  border-radius: var(--radius-shell);
  padding: 16px;
  box-shadow: inset 0 0 0 1px var(--line);
}

/* Mode tabs */
.mode-tabs{
  display:flex;
  gap:2px;
  margin-bottom: 12px;
  background: var(--sunken);
  padding: 2px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--line-mid);
}
.mode-tab{
  flex:1;
  border:none;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  min-height: 36px;
  padding: 6px 0;
  border-radius: 4px;
  cursor:pointer;
  transition: background-color 120ms cubic-bezier(.2, 0, 0, 1), color 120ms cubic-bezier(.2, 0, 0, 1);
}
.mode-tab:hover{ color: var(--ink-1); }
.mode-tab.active{
  background: var(--raised);
  color: var(--ink-1);
}

/* Screen */
.screen-unit{
  background: var(--sunken);
  border-radius: 8px;
  padding: 10px 12px 12px;
  margin-bottom: 12px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.screen-brand{
  display: none;
}
.screen{
  position: relative;
  overflow: hidden;
}
.screen-meta{
  font-family: var(--font-display);
  font-size: 0.8125rem;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.screen-display{
  width:100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--ink-1);
  text-align: right;
  padding: 4px 0;
  caret-color: var(--blue-text);
}
.screen-display:focus-visible{
  box-shadow: 0 1px 0 var(--blue-text);
}
.screen-pending{
  font-family: var(--font-display);
  font-size: 0.8125rem;
  color: var(--ink-3);
  text-align: right;
  min-height: 1.1em;
}
.screen-result{
  font-family: var(--font-display);
  font-size: 1.0625rem;
  color: var(--ink-2);
  text-align: right;
  min-height: 1.4em;
  border-top: 1px solid var(--line);
  padding-top: 4px;
  margin-top: 2px;
  word-break: break-all;
}

/* Panels */
.panel{ margin-bottom: 10px; }
.base-row{
  display:flex;
  align-items:flex-end;
  gap:8px;
}
.base-field{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width:0;
}
.base-field label{
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-2);
}
.base-select, .digits-input{
  background: var(--sunken);
  color: var(--ink-1);
  border: 0;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  border-radius: 6px;
  min-height: 44px;
  padding: 9px 10px;
  font-family: var(--font-body);
  font-size: 1rem;
  width: 100%;
  transition: box-shadow 120ms cubic-bezier(.2, 0, 0, 1);
}
.base-select:hover, .digits-input:hover{ box-shadow: inset 0 0 0 1px var(--ink-4); }
.base-select:focus, .digits-input:focus{
  outline: none;
  box-shadow: inset 0 0 0 1px var(--blue-text), 0 0 0 1px var(--blue-text);
}
.swap-btn{
  flex:0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  border: 0;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-mid);
  color: var(--ink-1);
  font-size: 1.1rem;
  cursor: pointer;
}
.swap-btn:hover{ background: var(--raised); }
.swap-btn:active{ transform: translateY(1px); }

.options-row{
  margin-top: 10px;
}
.checkbox-field{
  display:flex;
  align-items:center;
  gap:8px;
  font-size: 0.875rem;
  color: var(--ink-3);
}
.checkbox-field input{ accent-color: var(--blue); }

.all-bases{
  margin-top: 10px;
  display:grid;
  grid-template-columns: 1fr;
  gap:2px;
  max-height: 220px;
  overflow-y:auto;
  padding-right: 2px;
}
.all-bases-row{
  display:flex;
  justify-content:space-between;
  gap:10px;
  border-bottom: 1px solid var(--line);
  padding: 6px 4px;
  font-family: var(--font-display);
  font-size: 0.8125rem;
}
.all-bases-row .b-label{ color: var(--ink-3); }
.all-bases-row .b-value{ color: var(--ink-1); word-break: break-all; text-align:right; }

.complement-results{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top: 12px;
}
.complement-card{
  background: var(--sunken);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 10px 12px;
}
.complement-label{
  display:block;
  font-size: 0.8125rem;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.complement-value{
  display:block;
  font-family: var(--font-display);
  font-size: 1.125rem;
  color: var(--ink-1);
  word-break: break-all;
}

.error-line{
  min-height: 1.1em;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--red);
  text-align:center;
  margin: 4px 0 6px;
}

/* Keypad: keycaps with a 2px bottom edge */
.keypad{
  display:grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 6px;
}
.key{
  aspect-ratio: 1 / 0.72;
  border: none;
  border-radius: var(--radius-key);
  background: var(--surface);
  color: var(--ink-1);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line-mid), 0 2px 0 var(--sunken);
  transition: background-color 120ms cubic-bezier(.2, 0, 0, 1);
}
.key:hover{ background: var(--raised); }
.key:active{ transform: translateY(1px); box-shadow: inset 0 0 0 1px var(--line-mid); }
.key:disabled{
  color: var(--ink-off);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: not-allowed;
}
.key:disabled:active{ transform:none; }

.operator-row{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.op-btn{
  min-height: 44px;
  padding: 10px 0;
  border:none;
  border-radius: var(--radius-key);
  background: var(--raised);
  color: var(--ink-1);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.125rem;
  cursor:pointer;
  box-shadow: inset 0 0 0 1px var(--line-mid), 0 2px 0 var(--sunken);
}
.op-btn:hover{ background: var(--select); }
.op-btn:active{ transform: translateY(1px); box-shadow: inset 0 0 0 1px var(--line-mid); }
.op-btn.is-active{
  background: var(--select);
  box-shadow: inset 0 0 0 2px var(--blue-text);
}

.function-row{
  display:grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.fn-btn{
  min-height: 44px;
  padding: 10px 0;
  border:none;
  border-radius: var(--radius-key);
  background: var(--surface);
  color: var(--ink-1);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  cursor:pointer;
  box-shadow: inset 0 0 0 1px var(--line-mid), 0 2px 0 var(--sunken);
}
.fn-btn:hover{ background: var(--raised); }
.fn-btn:active{ transform: translateY(1px); box-shadow: inset 0 0 0 1px var(--line-mid); }
.fn-clear{ color: var(--red); }
.fn-equals{ background: var(--teal); color: var(--on-teal); box-shadow: 0 2px 0 var(--sunken); }
.fn-equals:hover{ background: var(--teal-hover); }

/* Promo buttons */
.promo-buttons{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-top: 20px;
}
.promo-btn{
  display:block;
  text-align:center;
  text-decoration:none;
  font-weight:600;
  font-size: 0.875rem;
  padding: 12px 16px;
  border-radius: var(--radius-key);
}
.promo-btn:active{ transform: translateY(1px); }
.promo-btn--main{
  background: var(--surface);
  color: var(--ink-1);
  box-shadow: inset 0 0 0 1px var(--line-mid);
}
.promo-btn--main:hover{ background: var(--raised); }
.chevron-divider span{
  width: 9px;
  height: 9px;
  border-left: 2px solid var(--line-mid);
  border-bottom: 2px solid var(--line-mid);
  transform: rotate(45deg);
}

/* SEO content */
.seo-content{
  margin-top: 18px;
  padding: 18px 4px 0;
  border-top: 1px solid var(--line);
}
.seo-content h2{
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-1);
  margin: 18px 0 8px;
}
.seo-content h2:first-child{ margin-top:0; }
.seo-content p{
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 65ch;
  margin: 0 0 8px;
}

.site-footer{
  text-align:center;
  margin-top: 26px;
  font-size: 0.8125rem;
  color: var(--ink-3);
}

/* Lock the layout to one vertical screen on phones: no page scrolling */
@media (max-width: 640px){
  html, body{
    height: 100%;
    overscroll-behavior: none;
    touch-action: manipulation;
  }
  body{
    overflow: hidden;
  }
  .app-shell{
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    overflow: hidden;
  }
  .site-header{ margin-bottom: 8px; flex: 0 0 auto; }
  .brand-tile{ width: 20px; height: 20px; }
  .site-title{ font-size: 1rem; margin: 0; }
  .calculator{
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 10px 10px 12px;
    overflow: hidden;
  }
  .mode-tabs{ flex: 0 0 auto; margin-bottom: 8px; }
  .screen-unit{ flex: 0 0 auto; margin-bottom: 8px; padding: 8px 10px 9px; }
  .screen-display{ font-size: 1.4rem; padding: 2px 0; }
  .screen-pending{ font-size: 0.8125rem; }
  .screen-result{ font-size: 0.9375rem; min-height: 1.2em; }
  .panel{ flex: 0 0 auto; margin-bottom: 6px; }
  .base-select, .digits-input{ min-height: 40px; padding: 7px 8px; font-size: 1rem; }
  .swap-btn{ width: 40px; height: 40px; }
  .all-bases{ max-height: 16vh; }
  .complement-results{ margin-top: 8px; gap: 6px; }
  .complement-card{ padding: 7px 10px; }
  .error-line{ flex: 0 0 auto; min-height: 0.9em; margin: 2px 0 4px; font-size: 0.8125rem; }
  .keypad{
    flex: 1 1 auto;
    min-height: 0;
    gap: 5px;
    margin-top: 4px;
    grid-template-columns: repeat(6, 1fr);
  }
  .key{ font-size: 1rem; aspect-ratio: auto; }
  .operator-row{ flex: 0 0 auto; gap: 6px; margin-top: 6px; }
  .op-btn{ min-height: 40px; padding: 6px 0; font-size: 1rem; }
  .function-row{ flex: 0 0 auto; gap: 6px; margin-top: 6px; }
  .fn-btn{ min-height: 40px; padding: 6px 0; font-size: 0.9375rem; }
  .promo-buttons{ flex: 0 0 auto; margin-top: 8px; gap: 6px; }
  .promo-btn{ padding: 8px 12px; font-size: 0.8125rem; }
}

/* Responsive tightening for very small screens */
@media (max-width: 360px){
  .keypad{ grid-template-columns: repeat(5, 1fr); }
  .site-title{ font-size: 1rem; }
  .screen-display{ font-size: 1.5rem; }
}

@media (min-width: 480px){
  .app-shell{ padding-top: 32px; }
}

@media (prefers-reduced-motion: reduce){
  *{ transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

:focus-visible{
  outline: 2px solid var(--blue-text);
  outline-offset: 2px;
}
