/* Calculator Hub only: compact navigation and comfortable phone controls. */
.calc-mobile-picker { display: none; }
#btnCalculatorFullscreen { display: none; }
.calc-studio-container > *, .calc-view-grid > * { min-width: 0; }

@media screen and (max-width: 1080px) {
  .calc-sidebar { display: none; }
  .calc-mobile-picker { display: grid; gap: 6px; }
  .calc-mobile-picker label { font-weight: 700; }
  .calc-mobile-picker select { width: 100%; min-width: 0; min-height: 44px; }
  .calc-workspace { scroll-margin-top: 12px; }
}

/* Phone layout follows a native calculator: display above a four-column keypad. */
@media screen and (max-width: 600px) {
  body { background: #eef0f5; }
  .gov-header, .gov-tricolor-strip, .site-footer { display: none; }
  .calc-studio-container { min-height: 100svh; padding: max(8px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom)); grid-template-rows: auto 1fr; }
  .calc-mobile-picker { grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
  .calc-mobile-picker label { display: none; }
  .calc-mobile-picker select { background: transparent; border: 0; color: #285b96; }
  #btnCalculatorFullscreen { display: block; min-height: 44px; border: 0; background: transparent; color: #285b96; font-size: 26px !important; cursor: pointer; }
  .calc-workspace { border: 0; border-radius: 0; box-shadow: none; background: transparent; overflow: visible; }
  .active-tool-header { background: transparent; padding: 8px 0 14px; }
  .active-tool-actions { display: none; }
  .calc-tool-view { padding: 8px 0; }
  body:has(#tool-sci.active-tool) .active-tool-header { display: none; }
  #tool-sci.active-tool { flex: 1; padding: 0; }
  #tool-sci .calc-view-grid { flex: 1; display: flex; }
  #tool-sci .calc-result-panel { display: none; }
  #tool-sci .calc-input-panel { width: 100%; padding: 0; background: transparent; border: 0; border-radius: 0; gap: 10px; }
  #tool-sci .calc-input-panel > div:first-child { display: none !important; }
  #tool-sci .calc-input-panel > div:nth-child(2) { flex: 1; min-height: 100px; background: transparent !important; border: 0 !important; padding: 24px 10px !important; }
  #sciInputDisplay { color: #65738a !important; font-size: 22px !important; }
  #sciResultDisplay { color: #285b96 !important; font-family: 'Inter', sans-serif !important; font-size: clamp(40px, 10vw, 64px) !important; font-weight: 400; overflow-wrap: normal; }
  #tool-sci .sci-keypad-view { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(8px, 3vw, 20px); padding: 8px 6px; }
  #tool-sci .sci-btn-v { display: none; aspect-ratio: 1; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: #e1e7ef; color: #285b96; box-shadow: none; font-size: clamp(24px, 7vw, 42px) !important; font-weight: 400; touch-action: manipulation; }
  #tool-sci .sci-btn-v:active { background: #ccd7e6; transform: scale(.95); }
  #tool-sci .sci-btn-v:is([data-action="clear"], [data-action="backspace"], [data-val="%"], [data-val="÷"], [data-val="7"], [data-val="8"], [data-val="9"], [data-val="×"], [data-val="4"], [data-val="5"], [data-val="6"], [data-val="-"], [data-val="1"], [data-val="2"], [data-val="3"], [data-val="+"], [data-val="("], [data-val="0"], [data-val="."], [data-action="eval"]) { display: flex; }
  #tool-sci [data-action="clear"] { order: 1; color: #c63732; }
  #tool-sci [data-action="backspace"] { order: 2; color: #c63732; }
  #tool-sci [data-val="%"] { order: 3; }
  #tool-sci [data-val="÷"] { order: 4; color: #a33560; }
  #tool-sci [data-val="7"] { order: 5; }
  #tool-sci [data-val="8"] { order: 6; }
  #tool-sci [data-val="9"] { order: 7; }
  #tool-sci [data-val="×"] { order: 8; color: #a33560; }
  #tool-sci [data-val="4"] { order: 9; }
  #tool-sci [data-val="5"] { order: 10; }
  #tool-sci [data-val="6"] { order: 11; }
  #tool-sci [data-val="-"] { order: 12; color: #a33560; }
  #tool-sci [data-val="1"] { order: 13; }
  #tool-sci [data-val="2"] { order: 14; }
  #tool-sci [data-val="3"] { order: 15; }
  #tool-sci [data-val="+"] { order: 16; color: #a33560; }
  #tool-sci [data-val="("] { order: 17; font-size: 0 !important; }
  #tool-sci [data-val="("]::after { content: '( )'; font-size: clamp(24px, 7vw, 42px); }
  #tool-sci [data-val="0"] { order: 18; }
  #tool-sci [data-val="."] { order: 19; }
  #tool-sci .sci-btn-v[data-action="eval"] { order: 20; grid-column: auto; background: #cc7297; color: white; }
  [data-theme="dark"] body { background: #111827; }
  [data-theme="dark"] #tool-sci .sci-btn-v { background: #253248; color: #b6d3f7; }
  [data-theme="dark"] #sciResultDisplay { color: #b6d3f7 !important; }
}

@media screen and (max-width: 600px) {
  body { --site-control-size: 16px; }
  .calc-studio-container { padding: 12px 10px 20px; gap: 12px; }
  .gov-header { position: relative; }
  .gov-header-inner { padding: 10px 12px; flex-wrap: wrap; gap: 10px; }
  .gov-brand, .gov-brand > div, .gov-brand-title { min-width: 0; }
  .gov-brand { max-width: 100%; }
  .gov-brand-title { flex-wrap: wrap; font-size: 17px; }
  .gov-brand-subtitle { white-space: normal; font-size: 11px; }
  .gov-header-nav { display: flex; width: 100%; flex-wrap: wrap; gap: 6px; }
  .gov-header-nav .gov-header-link { padding: 8px; min-height: 44px; font-size: 12px; }
  .gov-header-nav .gov-offline-badge { display: none; }
  .gov-header-nav .theme-toggle-btn { margin-left: auto; min-width: 44px; min-height: 44px; }
  .active-tool-header { padding: 14px; gap: 12px; }
  .active-tool-title-group, .active-tool-title-info { min-width: 0; }
  .active-tool-title-group { align-items: flex-start; gap: 10px; }
  .active-tool-title-info { overflow-wrap: anywhere; }
  .active-tool-actions { width: 100%; }
  .active-tool-actions .btn { flex: 1; min-height: 44px; }
  .calc-tool-view { padding: 12px; gap: 14px; }
  .calc-view-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .calc-input-panel { padding: 14px; gap: 14px; }
  .calc-tool-view :is(input, select, textarea) { max-width: 100%; min-width: 0; min-height: 44px; }
  .calc-result-panel, .hero-stat-card > div { min-width: 0; }
  .hero-stat-card { padding: 14px; gap: 8px; }
  .hero-stat-value, .stat-mini-val { overflow-wrap: anywhere; }
  .btn-copy-calc { flex-shrink: 0; min-width: 44px; min-height: 44px; }
  .calc-guide-section { padding: 14px; overflow-wrap: anywhere; }
}
