@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');
:root{
  color-scheme:light;
  --bg:#f5f7fb;
  --surface:#fff;
  --soft:#f8faff;
  --text:#182337;
  --muted:#66748a;
  --border:#e0e7f1;
  --primary:#1769e0;
  --primary2:#0e55bd;
  --grid:#e6ecf5;
  --axis:#728097;
  --shadow:0 12px 34px rgba(27,48,80,.07)
}
:root[data-theme=dark]{
  color-scheme:dark;
  --bg:#0d1421;
  --surface:#151f30;
  --soft:#101a29;
  --text:#eef4ff;
  --muted:#a6b3c8;
  --border:#29374c;
  --primary:#76adff;
  --primary2:#9ac2ff;
  --grid:#29374b;
  --axis:#96a5bb;
  --shadow:0 12px 34px rgba(0,0,0,.2)
}
*{
  box-sizing:border-box
}
html{
  scroll-behavior:smooth;
  scroll-padding-top:90px
}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font:16px/1.65 "DM Sans",Arial,sans-serif
}
a{
  color:var(--primary);
  text-decoration:none
}
a:hover{
  text-decoration:underline
}
button,input,select,textarea{
  font:inherit
}
button{
  cursor:pointer
}
h1,h2,h3{
  font-family:Manrope,"DM Sans",sans-serif;
  line-height:1.2;
  letter-spacing:-.025em
}
h1{
  font-size:clamp(20px,2.5vw,27px);
  margin:8px 0 12px
}
h2{
  font-size:clamp(19px,2.3vw,25px);
  margin:7px 0 14px
}
h3{
  font-size:17px
}
.site-header{
  height:74px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:0 max(18px,calc((100% - 1160px)/2));
  background:var(--surface);
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  z-index:20
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  color:var(--text);
  font:800 17px Manrope,sans-serif;
  white-space:nowrap
}
.brand-mark{
  display:grid;
  place-items:center;
  background:var(--primary);
  color:#fff;
  width:39px;
  height:39px;
  border-radius:12px;
  font-size:18px
}
.header-actions{
  display:flex;
  align-items:center;
  gap:9px
}
.theme-toggle,.hamburger{
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--surface);
  color:var(--text);
  padding:9px 12px;
  font-weight:700
}
.hamburger{
  font-size:20px;
  width:44px;
  height:44px;
  padding:0
}
.eyebrow{
  font-size:11px;
  font-weight:800;
  letter-spacing:1.7px;
  color:var(--primary)
}
.page-wrap{
  max-width:1160px;
  margin:0 auto;
  padding:35px 22px 55px
}
.hero{
  display:grid;
  grid-template-columns:1.15fr .85fr;
  align-items:center;
  gap:38px;
  padding:40px 0 48px
}
.hero p,.lead{
  font-size:17px;
  color:var(--muted);
  max-width:680px
}
.hero-art{
  border:1px solid var(--border);
  background:var(--surface);
  border-radius:22px;
  padding:20px;
  box-shadow:var(--shadow)
}
.hero-art svg{
  width:100%;
  display:block
}
.button{
  display:inline-flex;
  justify-content:center;
  align-items:center;
  gap:8px;
  padding:11px 15px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--surface);
  color:var(--text);
  font-weight:700;
  font-size:13px
}
.button-primary{
  background:var(--primary);
  color:white;
  border-color:var(--primary)
}
.button-primary:hover{
  background:var(--primary2);
  text-decoration:none
}
.button-row{
  display:flex;
  gap:9px;
  flex-wrap:wrap;
  margin-top:22px
}
.section{
  padding:32px 0
}
.section-heading{
  display:flex;
  align-items:end;
  justify-content:space-between;
  gap:18px;
  margin-bottom:20px
}
.tool-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:16px
}
.tool-card,.content-card,.tool-panel,.article-card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow)
}
.tool-card{
  padding:21px;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:10px;
  color:var(--text)
}
.tool-card:hover{
  border-color:var(--primary);
  transform:translateY(-2px);
  text-decoration:none
}
.tool-icon{
  display:grid;
  place-items:center;
  width:45px;
  height:45px;
  background:color-mix(in srgb,var(--primary) 12%,transparent);
  color:var(--primary);
  border-radius:12px;
  font-weight:800;
  font-size:17px
}
.tool-card strong{
  font:800 17px Manrope,sans-serif
}
.tool-card p{
  font-size:13px;
  color:var(--muted);
  margin:0
}
.card-link{
  font-size:12px;
  font-weight:800;
  color:var(--primary);
  margin-top:auto
}
.sidebar-backdrop{
  position:fixed;
  inset:0;
  background:rgba(4,12,25,.42);
  z-index:40;
  display:none
}
.sidebar{
  position:fixed;
  z-index:41;
  right:0;
  top:0;
  height:100dvh;
  width:min(360px,88vw);
  background:var(--surface);
  border-left:1px solid var(--border);
  box-shadow:-16px 0 45px rgba(0,0,0,.16);
  padding:20px;
  transform:translateX(105%);
  transition:transform .24s ease;
  overflow:auto
}
.sidebar.open{
  transform:translateX(0)
}
.sidebar-backdrop.open{
  display:block
}
.sidebar-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding-bottom:18px;
  border-bottom:1px solid var(--border);
  margin-bottom:12px
}
.sidebar-head strong{
  font:800 18px Manrope,sans-serif
}
.sidebar-close{
  border:1px solid var(--border);
  background:var(--soft);
  color:var(--text);
  border-radius:9px;
  width:38px;
  height:38px;
  font-size:23px
}
.sidebar-label{
  font-size:10px;
  letter-spacing:1.5px;
  font-weight:800;
  color:var(--muted);
  padding:14px 9px 5px
}
.sidebar a{
  display:flex;
  gap:12px;
  align-items:center;
  padding:11px 10px;
  border-radius:10px;
  color:var(--text);
  font-weight:600;
  font-size:14px
}
.sidebar a:hover,.sidebar a[aria-current=page]{
  background:var(--soft);
  color:var(--primary);
  text-decoration:none
}
.sidebar .side-icon{
  width:28px;
  text-align:center;
  font-size:18px
}
.tool-panel{
  overflow:hidden
}
.tool-panel-head{
  padding:18px 20px;
  border-bottom:1px solid var(--border);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px
}
.tool-panel-head h2{
  font-size:21px;
  margin:0
}
.tool-layout{
  display:grid;
  grid-template-columns:280px minmax(0,1fr);
  min-height:500px
}
.expression-panel{
  padding:18px;
  border-right:1px solid var(--border)
}
.panel-title{
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-weight:800;
  margin-bottom:8px
}
.icon-btn{
  border:0;
  background:var(--primary);
  color:white;
  border-radius:8px;
  width:33px;
  height:33px;
  font-size:22px
}
.hint{
  font-size:12px;
  color:var(--muted);
  margin:6px 0 14px
}
.expr-list{
  display:flex;
  flex-direction:column;
  gap:9px
}
.expr-row{
  display:grid;
  grid-template-columns:7px 1fr 26px;
  gap:8px;
  align-items:center;
  border:1px solid var(--border);
  background:var(--soft);
  padding:8px;
  border-radius:9px
}
.expr-color{
  width:6px;
  height:28px;
  border-radius:4px
}
.expr-input{
  width:100%;
  min-width:0;
  border:0;
  outline:0;
  background:transparent;
  color:var(--text);
  font:13px ui-monospace,Consolas,monospace
}
.delete-btn{
  border:0;
  background:transparent;
  color:var(--muted);
  font-size:18px
}
.graph-area{
  min-width:0;
  display:flex;
  flex-direction:column
}
.graph-toolbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:10px 13px;
  border-bottom:1px solid var(--border);
  font-size:12px;
  color:var(--muted)
}
.graph-toolbar .toolbar-buttons{
  display:flex;
  gap:5px
}
.graph-toolbar button{
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  border-radius:7px;
  padding:5px 9px
}
.canvas-wrap{
  height:480px;
  min-height:350px;
  position:relative;
  touch-action:none
}
.canvas-wrap canvas{
  width:100%;
  height:100%;
  display:block;
  cursor:crosshair
}
.graph-readout{
  display:flex;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  padding:10px 14px;
  border-top:1px solid var(--border);
  font-size:11px;
  color:var(--muted)
}
.math-keyboard{
  padding:16px 18px;
  border-top:1px solid var(--border);
  background:var(--soft)
}
.keyboard-title{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px
}
.keyboard-title strong{
  font-size:14px
}
.keyboard-title span{
  font-size:11px;
  color:var(--muted)
}
.key-grid{
  display:grid;
  grid-template-columns:repeat(8,minmax(0,1fr));
  gap:7px
}
.math-key{
  min-height:39px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--surface);
  color:var(--text);
  font-weight:700;
  font-size:13px
}
.math-key:hover{
  border-color:var(--primary);
  color:var(--primary)
}
.math-key.special{
  background:color-mix(in srgb,var(--primary) 10%,var(--surface));
  color:var(--primary)
}
.status{
  font-size:12px;
  color:var(--muted);
  margin:12px 0 0;
  overflow-wrap:anywhere
}
.status.error{
  color:#d04444
}
.article-grid{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:16px
}
.article-card{
  padding:22px
}
.article-card p,.article-card li{
  color:var(--muted);
  font-size:14px
}
.article-card h3{
  margin:0 0 12px
}
.example-equation{
  font:700 21px Georgia,serif;
  padding:12px 14px;
  background:var(--soft);
  border:1px solid var(--border);
  border-radius:9px;
  margin:12px 0
}
.step-list{
  padding-left:23px
}
.step-list li{
  padding:4px 0
}
.formula-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:12px
}
.formula-item{
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--surface);
  padding:14px
}
.formula-item strong,.formula-item code,.formula-item span{
  display:block
}
.formula-item code{
  color:var(--primary);
  margin:5px 0;
  font:13px ui-monospace,monospace
}
.formula-item span{
  font-size:12px;
  color:var(--muted)
}
.faq details{
  border-bottom:1px solid var(--border);
  padding:15px 2px
}
.faq summary{
  cursor:pointer;
  font-weight:700;
  display:flex;
  justify-content:space-between;
  gap:15px
}
.faq summary:after{
  content:"+";
  color:var(--primary);
  font-size:19px
}
.faq details[open] summary:after{
  content:"−"
}
.faq details p{
  color:var(--muted);
  font-size:14px;
  max-width:850px
}
.content-card{
  padding:26px
}
.content-card p,.content-card li{
  color:var(--muted)
}
.content-card h2{
  margin-top:28px
}
.content-card h2:first-child{
  margin-top:0
}
.field-label{
  display:block;
  font-size:13px;
  font-weight:800;
  margin:0 0 7px
}
/* Scientific Calculator expression box: touch-resizable and responsive */
.scientific-expression-input{
  display:block;
  min-height:64px;
  height:76px;
  max-height:45vh;
  resize:vertical;
  overflow:auto;
  line-height:1.55;
  font:inherit;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  touch-action:pan-y;
  cursor:text;
}
.scientific-expression-input:focus{
  outline:2px solid var(--primary);
  outline-offset:1px;
  border-color:var(--primary);
}
@media (max-width:650px){
  .scientific-expression-input{
    min-height:72px;
    height:88px;
    max-height:42vh;
    padding:14px;
    font-size:16px;
  }
}
.field-input,.field-select{
  width:100%;
  padding:12px;
  border:1px solid var(--border);
  border-radius:9px;
  background:var(--soft);
  color:var(--text);
  margin-bottom:14px
}
.result-box{
  padding:14px;
  border-radius:10px;
  background:var(--soft);
  border:1px solid var(--border);
  margin-top:14px;
  overflow-wrap:anywhere
}
.site-footer{
  background:var(--surface);
  border-top:1px solid var(--border);
  padding:35px 20px;
  text-align:center
}
.footer-brand{
  justify-content:center
}
.footer-links{
  display:flex;
  justify-content:center;
  flex-wrap:wrap;
  gap:16px;
  margin:17px 0;
  color:var(--muted);
  font-size:12px
}
.site-footer p,.site-footer small{
  color:var(--muted);
  font-size:12px
}
.notice{
  font-size:12px;
  color:var(--muted);
  margin:12px 0 0
}
@media(max-width:900px){
  .tool-layout{
    grid-template-columns:235px minmax(0,1fr)
  }
  .key-grid{
    grid-template-columns:repeat(6,minmax(0,1fr))
  }
  .top-spacer{
    display:none
  }
  .hero{
    gap:20px
  }
  .tool-grid{
    grid-template-columns:repeat(2,1fr)
  }
}
@media(max-width:650px){
  .site-header{
    height:66px;
    padding:0 14px
  }
  .brand{
    font-size:15px
  }
  .brand-mark{
    width:35px;
    height:35px
  }
  .theme-toggle{
    font-size:12px;
    padding:8px
  }
  .theme-toggle .theme-text{
    display:none
  }
  .page-wrap{
    padding:24px 14px 40px
  }
  .hero{
    grid-template-columns:1fr;
    padding:22px 0 30px;
    gap:20px
  }
  .hero p,.lead{
    font-size:15px
  }
  .hero-art{
    max-width:380px
  }
  .tool-grid,.article-grid{
    grid-template-columns:1fr
  }
  .section{
    padding:23px 0
  }
  .section-heading{
    align-items:flex-start;
    flex-direction:column
  }
  .tool-layout{
    grid-template-columns:1fr
  }
  .expression-panel{
    border-right:0;
    border-bottom:1px solid var(--border)
  }
  .canvas-wrap{
    height:360px;
    min-height:330px
  }
  .key-grid{
    grid-template-columns:repeat(5,minmax(0,1fr));
    gap:6px
  }
  .math-key{
    min-height:38px;
    font-size:12px
  }
  .math-keyboard{
    padding:13px
  }
  .formula-grid{
    grid-template-columns:repeat(2,1fr)
  }
  .content-card{
    padding:19px
  }
  .tool-panel-head{
    padding:15px
  }
  .tool-panel-head h2{
    font-size:18px
  }
  .graph-readout span:last-child{
    display:none
  }
}
@media(prefers-reduced-motion:reduce){
  html{
    scroll-behavior:auto
  }
  .sidebar{
    transition:none
  }
}
/* Requested compact drawer and on-demand Scientific keyboard */
.sidebar{
  width:min(310px,82vw);
  padding:17px
}
.sidebar-close{
  width:48px;
  height:48px;
  min-width:48px;
  font-size:32px;
  line-height:1;
  font-weight:500;
  display:inline-flex;
  align-items:center;
  justify-content:center
}
.math-keyboard:not(.active){
  display:none
}
.keyboard-title{
  align-items:center
}
.keyboard-title>div{
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width:0
}
.keyboard-toggle{
  white-space:nowrap;
  padding:9px 11px;
  font-size:12px
}
.key-grid{
  grid-template-columns:repeat(8,minmax(0,1fr))
}
@media(max-width:650px){
  .sidebar{
    width:min(300px,84vw);
    padding:15px
  }
  .sidebar-close{
    width:48px;
    height:48px;
    font-size:34px
  }
  .keyboard-title{
    align-items:flex-start;
    flex-wrap:wrap
  }
  .keyboard-toggle{
    margin-left:auto
  }
  .key-grid{
    grid-template-columns:repeat(5,minmax(0,1fr))
  }
}
/* Focused layout refinements requested for Graphly Math */
.sidebar{
  width:min(310px,82vw);
  padding:16px
}
.sidebar-head{
  gap:12px;
  min-height:44px;
  margin-bottom:12px
}
.sidebar-head strong{
  font-size:16px;
  letter-spacing:.01em
}
.sidebar-close,.hamburger{
  width:44px;
  height:44px;
  min-width:44px;
  min-height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border:1px solid var(--border);
  border-radius:10px;
  box-sizing:border-box;
  line-height:1
}
.sidebar-close{
  font-size:30px;
  font-weight:500;
  background:var(--surface);
  color:var(--text)
}
.sidebar a{
  padding:10px 11px;
  font-size:14px
}
.sidebar-label{
  font-size:10px
}
h1{
  max-width:850px
}
h2{
  max-width:900px
}
.lead{
  font-size:16px;
  line-height:1.65;
  max-width:850px
}
.math-keyboard{
  display:none
}
.math-keyboard.active{
  display:block
}
.math-keyboard .keyboard-title{
  align-items:center;
  gap:12px
}
.math-keyboard .keyboard-title span{
  display:block;
  font-size:12px;
  color:var(--muted);
  line-height:1.4;
  margin-top:3px
}
.math-keyboard .key-grid{
  margin-top:10px
}
@media(max-width:600px){
  .site-header{
    height:64px
  }
  h1{
    font-size:clamp(25px,7vw,32px)
  }
  h2{
    font-size:clamp(19px,5vw,23px)
  }
  .sidebar{
    width:min(292px,80vw);
    padding:13px
  }
  .sidebar a{
    padding:9px 10px
  }
  .theme-toggle{
    padding:8px 9px
  }
}
/* Requested menu and math-keyboard refinements */
.hamburger,.sidebar-close{
  width:44px;
  height:44px;
  min-width:44px;
  min-height:44px;
  box-sizing:border-box;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border:1px solid var(--border);
  border-radius:10px;
  line-height:1
}
.sidebar-close{
  font-size:30px;
  font-weight:500;
  text-align:center;
  vertical-align:middle
}
.sidebar-head{
  display:flex;
  align-items:center;
  justify-content:space-between
}
.sidebar{
  width:min(292px,80vw)
}
.math-keyboard{
  display:none
}
.math-keyboard.active{
  display:block
}
/* Final menu alignment: same square dimensions for hamburger and close */
.hamburger,
.sidebar-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  line-height: 1;
}
.sidebar-close {
  font-size: 30px;
  font-weight: 500;
  text-align: center;
  vertical-align: middle;
}
.sidebar {
  width: min(292px, 80vw);
}
.math-keyboard {
  display: none;
}
.math-keyboard.active {
  display: block;
}
/* Popup scientific keyboard: anchored near the active expression field */
.math-keyboard-popup {
  display: none;
  position: absolute;
  z-index: 1000;
  width: min(390px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  max-height: min(52vh, 360px);
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(0,0,0,.18);
}
.math-keyboard-popup.active {
  display: block;
}
.math-keyboard-popup .keyboard-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.math-keyboard-popup .keyboard-toggle {
  min-width: 42px;
  min-height: 38px;
  padding: 6px 10px;
  flex: 0 0 auto;
}
.math-keyboard-popup .key-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.math-keyboard-popup .math-key {
  min-height: 38px;
  padding: 5px;
  font-size: 14px;
}
@media (max-width: 600px) {
  .math-keyboard-popup {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 14px;
    top: auto;
    width: auto;
    max-height: 44vh;
  }
}
/* Graph canvas and footer adjustments */
.graph-area {
  min-height:620px;
  height:clamp(560px,72vh,820px);
  width:100%;
}
.graph-area canvas, #graphCanvas {
  display:block;
  width:100% !important;
  height:100% !important;
  min-height:560px;
}
.tool-layout {
  align-items:stretch;
}
.site-footer, footer {
  font-size:16px;
  line-height:1.75;
}
.site-footer p, footer p, .site-footer a, footer a, .site-footer li, footer li {
  font-size:16px;
}
.math-keyboard-popup {
  overflow:visible;
}
.math-keyboard-popup .keyboard-title {
  position:relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.math-keyboard-popup .keyboard-toggle {
  position:absolute;
  right:-16px;
  top:-16px;
  z-index:1002;
  width:36px;
  height:36px;
  min-width:36px;
  min-height:36px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
  font-size:21px;
  box-shadow:0 3px 12px rgba(0,0,0,.18);
}
.keyboard-actions {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-top:8px;
}
.keyboard-actions .action-key {
  min-height:40px;
  font-weight:600;
}
@media(max-width:700px) {
  .graph-area {
    min-height:460px;
    height:62vh;
  }
  .graph-area canvas, #graphCanvas {
    min-height:440px;
  }
}
/* Scientific keyboard popup: attached to the active field;
close control outside its border */
.math-keyboard-popup {
  display:none;
  position:fixed;
  z-index:1000;
  width:min(390px,calc(100vw - 28px));
  max-width:calc(100vw - 28px);
  max-height:min(52vh,360px);
  overflow:visible;
  padding:12px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--surface);
  box-shadow:0 12px 36px rgba(0,0,0,.18);
}
.math-keyboard-popup.active {
  display:block;
}
.math-keyboard-popup .keyboard-title {
  position:relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.math-keyboard-popup .keyboard-toggle {
  position:absolute;
  right:-22px;
  top:-22px;
  z-index:1005;
  width:36px;
  height:36px;
  min-width:36px;
  min-height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:50%;
  padding:0;
  font-size:20px;
  box-shadow:0 3px 12px rgba(0,0,0,.2);
}
.keyboard-actions {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-top:8px;
}
.keyboard-actions .action-key {
  min-height:40px;
  font-weight:600;
}
.graph-area {
  min-height:620px;
  height:clamp(560px,72vh,820px);
  width:100%;
}
.graph-area canvas, #graphCanvas {
  display:block;
  width:100% !important;
  height:100% !important;
  min-height:560px;
}
@media(max-width:700px) {
  .math-keyboard-popup {
    position:fixed !important;
    left:14px !important;
    right:14px !important;
    top:auto !important;
    bottom:14px !important;
    width:auto !important;
    max-height:44vh;
  }
  .graph-area {
    min-height:460px;
    height:62vh;
  }
  .graph-area canvas, #graphCanvas {
    min-height:440px;
  }
}
/* Final requested polish: larger header logo and reliable scientific-keyboard popup */
.site-header .brand-mark {
  width: 50px;
  height: 50px;
  min-width: 50px;
  min-height: 50px;
  font-size: 23px;
  border-radius: 14px;
}
.site-header .brand {
  gap: 12px;
  font-size: 18px;
}
.math-keyboard-popup {
  position: fixed;
  z-index: 10000;
  overflow: visible;
}
.math-keyboard-popup .keyboard-title {
  padding-right: 18px;
  min-height: 30px;
}
.math-keyboard-popup .keyboard-toggle {
  position: absolute;
  right: -19px;
  top: -19px;
  z-index: 10005;
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.keyboard-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}
.keyboard-actions .math-key {
  min-height: 42px;
  font-weight: 800;
}
.math-keyboard-popup .keyboard-title span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
@media (max-width: 650px) {
  .site-header .brand-mark {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 21px;
  }
  .site-header .brand {
    font-size: 15px;
    gap: 9px;
  }
  .math-keyboard-popup {
    left: 14px !important;
    right: 14px !important;
    bottom: 14px !important;
    top: auto !important;
    width: auto !important;
    max-width: none;
    max-height: 44vh;
    overflow-y: auto;
    padding-top: 20px;
  }
  .math-keyboard-popup .keyboard-toggle {
    right: -5px;
    top: -18px;
  }
}
/* Final requested header sizing and Function Grapher control layout */
.site-header .brand {
  font-size: 20px;
  gap: 13px;
  letter-spacing: -.02em;
}
.site-header .brand-mark {
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  font-size: 25px;
  border-radius: 15px;
}
.graph-toolbar {
  flex-wrap: wrap;
}
.graph-toolbar .toolbar-buttons button {
  min-width: 36px;
  min-height: 34px;
  font-size: 15px;
  font-weight: 800;
}
.graph-toolbar .toolbar-buttons button:focus-visible,
.math-key:focus-visible,
.math-input:focus-visible,
.expr-input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: 2px;
}
.expr-input:focus {
  background: color-mix(in srgb, var(--primary) 7%, transparent);
  border-radius: 5px;
}
@media (max-width: 650px) {
  .site-header .brand {
    font-size: 16px;
    gap: 9px;
  }
  .site-header .brand-mark {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 21px;
    border-radius: 12px;
  }
  .graph-toolbar {
    align-items: flex-start;
  }
  .graph-toolbar > span {
    width: 100%;
  }
}
.function-grapher-page .graph-area .canvas-wrap {
  height: clamp(560px, 72vh, 820px);
  min-height: 560px;
}
.function-grapher-page .graph-area .canvas-wrap #graphCanvas {
  height: 100% !important;
  min-height: 0 !important;
}
@media (max-width: 700px) {
  .function-grapher-page .graph-area .canvas-wrap {
    height: 62vh;
    min-height: 460px;
  }
  .function-grapher-page .graph-area .canvas-wrap #graphCanvas {
    min-height: 0 !important;
  }
}

/* Final scientific-keyboard and touch-graph interaction adjustments */
.keyboard-actions { display: none !important; }
.math-keyboard-popup .keyboard-toggle {
  right: -20px;
  top: -20px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 23px;
  z-index: 10010;
}
.math-keyboard-popup .key-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.math-keyboard-popup .math-key {
  min-height: 40px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
#graphCanvas { touch-action: none; }
@media (max-width: 650px) {
  .math-keyboard-popup { padding-top: 20px; max-height: 44vh; overflow-y: auto; }
  .math-keyboard-popup .keyboard-toggle { right: -5px; top: -18px; }
}

.math-keyboard-popup .keyboard-title {
  padding-right: 20px;
  align-items: flex-start;
}
.math-keyboard-popup .keyboard-toggle {
  position: absolute;
  right: -12px;
  top: -12px;
  z-index: 10005;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}
@media (max-width: 600px) {
.math-keyboard-popup .keyboard-toggle { right: -5px; top: -12px; }
}

/* Refreshed math input fields: the field itself is the editing control. */
.math-input, .expr-input, .expression-input, #scientificInput, #functionInput, #functionX {
  cursor: text;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.field-input.math-input {
  min-height: 48px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  background: var(--surface);
  font: 15px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.field-input.math-input:focus,
.field-input.math-input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
  background: var(--surface);
}
.expr-row {
  grid-template-columns: 7px minmax(0, 1fr) 26px !important;
  gap: 8px;
}
.expr-row .expr-input {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: 14px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.expr-row .expr-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
.math-keyboard-popup .keyboard-title {
  padding: 5px 34px 10px 2px;
  border-bottom: 1px solid var(--border);
  margin: 0 0 10px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
}
.math-keyboard-popup .keyboard-title:active { cursor: grabbing; }
.math-keyboard-popup .keyboard-title strong { display: block; font-size: 14px; }
.math-keyboard-popup .keyboard-title span { line-height: 1.4; margin-top: 3px; }
.math-keyboard-popup.dragged { max-width: calc(100vw - 16px) !important; }
.math-keyboard-popup .keyboard-toggle { touch-action: manipulation; }
@media (max-width: 650px) {
  .field-input.math-input { font-size: 16px; min-height: 48px; }
  .expr-row .expr-input { font-size: 16px; min-height: 44px; }
  .math-keyboard-popup.dragged {
    left: 8px !important;
    right: auto !important;
    bottom: auto !important;
    max-height: calc(100vh - 16px);
    overflow-y: auto;
  }
}

/* Editable math fields: native caret follows the exact tap/click position. */
.math-input, .expr-input, .expression-input, #scientificInput, #functionInput, #functionX, [data-math-expression="true"] {
  box-sizing: border-box;
  max-width: 100%;
  caret-color: #111;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}
.math-input:focus, .expr-input:focus, .expression-input:focus,
#scientificInput:focus, #functionInput:focus, #functionX:focus,
[data-math-expression="true"]:focus {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 1px;
}
.math-keyboard-popup {
  box-sizing: border-box;
  width: min(390px, calc(100vw - 24px)) !important;
  max-width: calc(100vw - 16px) !important;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.math-keyboard-popup .key-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  gap: clamp(3px, 1.2vw, 7px);
}
.math-keyboard-popup .math-key {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding: 5px 2px;
  overflow-wrap: anywhere;
  font-size: clamp(12px, 1.8vw, 14px);
}
@media (max-width: 650px) {
  .math-keyboard-popup, .math-keyboard-popup.active {
    left: 8px !important;
    right: 8px !important;
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: min(48vh, 390px) !important;
    padding: 12px 10px;
  }
  .math-keyboard-popup .key-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .math-keyboard-popup .math-key { min-height: 40px; font-size: 13px; }
  .expr-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
  .expr-row .expr-input { min-width: 0; width: 100%; font-size: 16px; }
}

/* Consolidated responsive fixes for the requested graph tools and scientific keyboard. */
.tool-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.tool-panel-head h2 {
  flex: 1 1 auto;
  min-width: 0;
}
.tool-panel-head > .button-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 !important;
}
.field-input.math-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 56px;
  font-size: 16px;
  caret-color: #111;
  user-select: text;
  -webkit-user-select: text;
}
.math-keyboard-popup {
  box-sizing: border-box;
  min-width: 0;
  width: min(390px, calc(100vw - 16px)) !important;
  max-width: calc(100vw - 16px) !important;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.math-keyboard-popup .key-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  gap: clamp(3px, 1vw, 7px);
}
.math-keyboard-popup .math-key {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding-inline: 2px;
}
@media (max-width: 700px) {
  .tool-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .tool-panel-head > .button-row {
    width: 100%;
    justify-content: flex-start;
  }
  .math-keyboard-popup,
  .math-keyboard-popup.active {
    left: 8px !important;
    right: 8px !important;
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: min(48vh, 390px) !important;
  }
  .math-keyboard-popup .key-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .math-keyboard-popup .math-key {
    min-height: 40px;
    font-size: 13px;
  }
}

/* Scientific Calculator keyboard: compact, responsive, image-inspired layout. */
h1 { font-size: clamp(24px, 3vw, 34px); }
.scientific-keyboard { padding: 12px; background: #f0f0f0; color: #222; border: 1px solid #c8c8c8; border-radius: 10px; }
.scientific-keyboard .keyboard-title { margin-bottom: 10px; }
.scientific-keyboard .keyboard-title span { display: none; }
.scientific-keyboard-toolbar { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin-bottom:12px; }
.keyboard-tabs { display:flex; align-items:center; gap:4px; }
.keyboard-tab { background:transparent; border:0; padding:7px 12px; border-bottom:3px solid transparent; color:#555; }
.keyboard-tab.active { border-bottom-color:#0876df; color:#111; }
.angle-switch { display:flex; border:1px solid #aaa; border-radius:7px; overflow:hidden; }
.angle-switch button { border:0; background:#f7f7f7; padding:6px 10px; }
.angle-switch button.active { background:#dceaff; color:#145ca7; box-shadow:inset 0 0 0 1px #2878c7; }
.keyboard-utility { display:flex; align-items:center; gap:5px; margin-left:auto; }
.keyboard-utility button { border:0; background:transparent; color:#555; padding:6px; }
.scientific-key-layout { display:grid; grid-template-columns:minmax(0,1fr); gap:10px; }
.scientific-key-panel[hidden] { display:none !important; }
.scientific-key-grid { grid-template-columns:repeat(3,minmax(0,1fr)) !important; gap:6px !important; }
.scientific-keyboard .math-key { min-height:48px; background:#fff; border:1px solid #d1d1d1; border-radius:5px; color:#161616; font-size:clamp(14px,1.5vw,18px); font-weight:500; }
.scientific-keyboard .scientific-number-pad { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:6px; }
.scientific-keyboard .number-key { background:#d4d4d4; font-size:clamp(17px,2vw,22px); }
.scientific-keyboard .operator-key { background:#fff; }
.scientific-keyboard .backspace-key { background:#c9c9c9; font-size:23px; }
.scientific-keyboard .enter-key { background:#0876df; color:#fff; border-color:#0876df; font-size:25px; }
.scientific-keyboard .math-key:active { background:#dceaff; }
@media (max-width:600px) { .scientific-keyboard { padding:10px; } .scientific-keyboard-toolbar { gap:6px; } .keyboard-tab { padding:6px 8px; } .keyboard-utility { margin-left:0; } .scientific-keyboard .scientific-number-pad { grid-template-columns:repeat(4,minmax(0,1fr)); } .scientific-keyboard .math-key { min-height:44px; } }

/* Keyboard title bar: minimal drag handle */
.math-keyboard-popup .keyboard-title {
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 6px;
  cursor: grab;
  touch-action: none;
}
.math-keyboard-popup .keyboard-title:active { cursor: grabbing; }
.math-keyboard-popup .keyboard-title strong,
.math-keyboard-popup .keyboard-title span { display: none !important; }
.math-keyboard-popup .keyboard-toggle { flex: 0 0 auto; }
.math-keyboard-popup .scientific-keyboard-toolbar { min-width: 0; max-width: 100%; }
.math-keyboard-popup .math-key { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .math-keyboard-popup { max-width: calc(100vw - 16px); }
  .math-keyboard-popup .scientific-keyboard-toolbar { flex-wrap: wrap; }
}


/* Final keyboard key sizing: clear mathematical symbols on every tool. */
.math-keyboard-popup .key-grid {
  gap: 7px;
}
.math-keyboard-popup .math-key {
  min-width: 0;
  min-height: 48px;
  padding: 9px 6px;
  font-size: clamp(17px, 2.1vw, 24px);
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
}
.scientific-keyboard .math-key {
  min-height: 54px;
  padding: 10px 7px;
  font-size: clamp(18px, 2.3vw, 27px);
  line-height: 1.15;
}
.scientific-keyboard .keyboard-tab,
.scientific-keyboard .angle-switch button,
.scientific-keyboard .keyboard-utility button {
  font-size: clamp(15px, 1.8vw, 20px);
}
.scientific-keyboard .scientific-number-pad {
  gap: 7px;
}
@media (max-width: 600px) {
  .math-keyboard-popup .math-key {
    min-height: 42px;
    padding: 7px 4px;
    font-size: clamp(16px, 4.2vw, 21px);
  }
  .scientific-keyboard .math-key {
    min-height: 44px;
    font-size: clamp(17px, 4.5vw, 23px);
  }
}
@media (min-width: 601px) {
  .math-keyboard-popup .math-key {
    min-height: 50px;
  }
}


/* Scientific Calculator: readable keypad layout and larger copyright text */
.scientific-keyboard .scientific-number-pad {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
}

.site-footer .footer-copyright {
  display: block;
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.6;
  text-align: center;
}

@media (max-width: 600px) {
  .site-footer .footer-copyright {
    font-size: 15px;
  }
}


/* Tool-page educational content and consistent footer copyright */
.tool-introduction {
  max-width: 850px;
  margin: 0.75rem 0 1.25rem;
  line-height: 1.7;
}

.why-use {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.why-use p {
  line-height: 1.75;
}

.site-footer small,
.site-footer .footer-copyright {
  font-size: 14px;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .tool-introduction {
    line-height: 1.65;
  }
}


/* Readable tool-page content typography */
.page-wrap p,
.page-wrap li,
.page-wrap .article-card,
.page-wrap .formula-item span,
.page-wrap .content-card > label,
.page-wrap .field-help {
  font-size: 15px;
}

.page-wrap .example-equation {
  font-size: 17px;
  line-height: 1.45;
}

.footer-copyright {
  font-size: 14px;
}


/* Graphing Calculator: introduction and note typography */
.graphing-calculator-page .lead {
  font-size: 15px;
  line-height: 1.6;
}

.graphing-calculator-page .graph-area + .graph-readout,
.graphing-calculator-page .notice {
  font-size: 13px;
  line-height: 1.6;
}

/* Footer navigation links */
.site-footer .footer-links a {
  font-size: 14px;
}

/* Keep heading introductions visually consistent with the body paragraphs. */
.page-wrap > .lead,
.hero > div > p {
  color: var(--muted);
  font-weight: 400;
}



/* Single-page About, Privacy Policy, Terms, and Contact navigation */
.section-anchor-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 20px 0;
}

.section-anchor-nav a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-information-content section + section {
  margin-top: 32px;
}

.site-information-content h3 {
  margin-top: 20px;
}

.site-information-content p {
  color: var(--muted);
  line-height: 1.75;
}
