:root{
  --bg: #0a0b0e;
  --shell-top: #2f333c;
  --shell-bottom: #17191f;
  --shell-edge: #08090b;
  --screen-bg: #f6f6f0;
  --screen-bg-dim: #e9e9e1;
  --screen-ink: #262624;
  --screen-ink-soft: #6f6f68;
  --key-digit: #3b414c;
  --key-digit-hover: #474e5b;
  --key-fn: #545b68;
  --key-op: #8fd13a;
  --key-op-hover: #a3e04d;
  --key-equals: #c8ff3c;
  --key-equals-hover: #d8ff6d;
  --text-main: #eef0f0;
  --text-muted: #939ba3;
  --accent: #c8ff3c;
  --accent-dim: #96c22a;
  --accent-ink: #10230a;
  --danger: #ff6b5b;
  --grid-line: rgba(200, 255, 60, 0.055);
  --grid-line-bold: rgba(200, 255, 60, 0.1);
  --radius-shell: 28px;
  --radius-key: 14px;
  --font-display: 'Share Tech Mono', monospace;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

*{ box-sizing: border-box; }

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

body{
  margin:0;
  padding:0;
  color: var(--text-main);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(var(--grid-line-bold) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line-bold) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(200,255,60,0.10), transparent 55%);
  background-size: 28px 28px, 28px 28px, 140px 140px, 140px 140px, 100% 100%;
  background-position: -1px -1px, -1px -1px, -1px -1px, -1px -1px, 0 0;
  background-repeat: repeat, repeat, repeat, repeat, no-repeat;
}

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

.site-header{
  text-align:center;
  margin-bottom: 26px;
}
.brand-mark{
  display:flex;
  justify-content:center;
  margin-bottom: 10px;
}
.brand-logo{
  width: 46px;
  height: auto;
  filter: drop-shadow(0 0 14px rgba(200,255,60,0.35));
}
.site-title{
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin: 0 0 6px;
  color: var(--text-main);
}
.site-title span{
  color: var(--accent);
}
.site-subtitle{
  margin:0;
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Calculator shell */
.calculator{
  background: linear-gradient(160deg, var(--shell-top), var(--shell-bottom));
  border-radius: var(--radius-shell);
  padding: 18px 16px 22px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.08) inset,
    0 -6px 18px rgba(0,0,0,0.35) inset,
    0 20px 40px rgba(0,0,0,0.5);
  border: 1px solid var(--shell-edge);
}

/* Mode tabs */
.mode-tabs{
  display:flex;
  gap:8px;
  margin-bottom: 14px;
  background: rgba(0,0,0,0.25);
  padding: 4px;
  border-radius: 12px;
}
.mode-tab{
  flex:1;
  border:none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 0;
  border-radius: 9px;
  cursor:pointer;
  transition: background .15s ease, color .15s ease;
}
.mode-tab.active{
  background: var(--key-op);
  color: var(--accent-ink);
  box-shadow: 0 0 14px rgba(200,255,60,0.25);
}

/* Screen */
.screen-unit{
  background: linear-gradient(180deg, #0e0f13, #17191f);
  border-radius: 16px;
  padding: 10px 12px 12px;
  margin-bottom: 14px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4) inset;
}
.screen-brand{
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.25em;
  color: #5c6270;
  text-align: right;
  margin-bottom: 4px;
}
.screen{
  background: linear-gradient(180deg, var(--screen-bg), var(--screen-bg-dim));
  border-radius: 10px;
  padding: 10px 14px 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25) inset;
  position: relative;
  overflow: hidden;
}
.screen::after{
  content:"";
  position:absolute; inset:0;
  background: repeating-linear-gradient(180deg, rgba(0,0,0,0.035) 0px, rgba(0,0,0,0.035) 1px, transparent 1px, transparent 3px);
  pointer-events:none;
}
.screen-meta{
  font-family: var(--font-display);
  font-size: 0.72rem;
  color: var(--screen-ink-soft);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.screen-display{
  width:100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-display);
  font-size: 1.85rem;
  color: var(--screen-ink);
  letter-spacing: 0.03em;
  text-align: right;
  padding: 4px 0;
  caret-color: var(--screen-ink);
}
.screen-pending{
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--screen-ink-soft);
  text-align: right;
  min-height: 1.1em;
  letter-spacing: 0.04em;
}
.screen-result{
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--screen-ink-soft);
  text-align: right;
  min-height: 1.4em;
  border-top: 1px dashed rgba(28,51,24,0.3);
  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.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.base-select, .digits-input{
  background: #1c1e24;
  color: var(--text-main);
  border: 1px solid #34383f;
  border-radius: 10px;
  padding: 9px 8px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  width: 100%;
  transition: border-color .15s ease;
}
.base-select:focus, .digits-input:focus{
  border-color: var(--accent-dim);
}
.swap-btn{
  flex:0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #383c46;
  background: #23262e;
  color: var(--accent);
  font-size: 1.1rem;
  cursor: pointer;
}
.swap-btn:active{ transform: scale(0.93); }

.options-row{
  margin-top: 10px;
}
.checkbox-field{
  display:flex;
  align-items:center;
  gap:8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.checkbox-field input{ accent-color: var(--key-op); }

.all-bases{
  margin-top: 10px;
  display:grid;
  grid-template-columns: 1fr;
  gap:6px;
  max-height: 220px;
  overflow-y:auto;
  padding-right: 2px;
}
.all-bases-row{
  display:flex;
  justify-content:space-between;
  gap:10px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--font-display);
  font-size: 0.8rem;
}
.all-bases-row .b-label{ color: var(--text-muted); }
.all-bases-row .b-value{ color: var(--text-main); word-break: break-all; text-align:right; }

.complement-results{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top: 12px;
}
.complement-card{
  background: rgba(0,0,0,0.25);
  border: 1px solid #2c2f38;
  border-radius: 10px;
  padding: 10px 12px;
}
.complement-label{
  display:block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.complement-value{
  display:block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--accent);
  word-break: break-all;
}

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

/* Keypad */
.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(--key-digit);
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: 1 rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.35), 0 1px 0 rgba(255,255,255,0.06) inset;
  transition: transform .06s ease, background .12s ease;
}
.key:hover{ background: var(--key-digit-hover); }
.key:active{ transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.35); }
.key:disabled{
  opacity: 0.25;
  cursor: not-allowed;
  box-shadow:none;
}
.key:disabled:active{ transform:none; }

.operator-row{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.op-btn{
  padding: 12px 0;
  border:none;
  border-radius: var(--radius-key);
  background: var(--key-op);
  color: var(--accent-ink);
  font-family: var(--font-body);
  font-weight:800;
  font-size: 1.1rem;
  cursor:pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.35);
}
.op-btn:hover{ background: var(--key-op-hover); }
.op-btn:active{ transform: translateY(2px); box-shadow:none; }
.op-btn.is-active{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.function-row{
  display:grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.fn-btn{
  padding: 12px 0;
  border:none;
  border-radius: var(--radius-key);
  background: var(--key-fn);
  color:#fff;
  font-family: var(--font-body);
  font-weight:700;
  font-size: 0.95rem;
  cursor:pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.35);
}
.fn-btn:active{ transform: translateY(2px); box-shadow:none; }
.fn-clear{ background: var(--danger); }
.fn-equals{ background: var(--key-equals); color: var(--accent-ink); }
.fn-equals:hover{ background: var(--key-equals-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:700;
  font-size: 0.88rem;
  padding: 13px 16px;
  border-radius: 14px;
  transition: transform .1s ease, filter .15s ease;
}
.promo-btn:active{ transform: scale(0.98); }
.promo-btn--main{
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 6px 20px rgba(200,255,60,0.2);
}
.promo-btn--main:hover{ filter: brightness(1.06); }
.chevron-divider span{
  width: 9px;
  height: 9px;
  border-left: 2px solid var(--accent-dim);
  border-bottom: 2px solid var(--accent-dim);
  transform: rotate(45deg);
  opacity: 0.55;
}
.chevron-divider span:nth-child(2){ opacity: 0.8; border-color: var(--accent); }
.chevron-divider span:nth-child(3){ opacity: 0.55; }

/* SEO content */
.seo-content{
  margin-top: 18px;
  padding: 18px 4px 0;
  border-top: 1px solid #1c1f26;
}
.seo-content h2{
  font-size: 0.95rem;
  color: var(--text-main);
  margin: 18px 0 8px;
}
.seo-content h2:first-child{ margin-top:0; }
.seo-content p{
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.site-footer{
  text-align:center;
  margin-top: 26px;
  font-size: 0.72rem;
  color: #5c6270;
}

/* 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-mark{ margin-bottom: 4px; }
  .brand-logo{ width: 30px; }
  .site-title{ font-size: 1.05rem; 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-brand{ font-size: 0.55rem; margin-bottom: 2px; }
  .screen-display{ font-size: 1.4rem; padding: 2px 0; }
  .screen-pending{ font-size: 0.72rem; }
  .screen-result{ font-size: 0.88rem; min-height: 1.2em; }
  .panel{ flex: 0 0 auto; margin-bottom: 6px; }
  .base-select, .digits-input{ padding: 7px 7px; font-size: 0.85rem; }
  .swap-btn{ width: 34px; height: 34px; }
  .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.72rem; }
  .keypad{
    flex: 1 1 auto;
    min-height: 0;
    gap: 5px;
    margin-top: 4px;
    grid-template-columns: repeat(6, 1fr);
  }
  .key{ font-size: 0.95 rem; aspect-ratio: auto; }
  .operator-row{ flex: 0 0 auto; gap: 6px; margin-top: 6px; }
  .op-btn{ padding: 8px 0; font-size: 0.95rem; }
  .function-row{ flex: 0 0 auto; gap: 6px; margin-top: 6px; }
  .fn-btn{ padding: 8px 0; font-size: 0.85rem; }
  .promo-buttons{ flex: 0 0 auto; margin-top: 8px; gap: 6px; }
  .promo-btn{ padding: 8px 12px; font-size: 0.72rem; }
}

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

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

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

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