  :root {
      --chassis-bg: #d0ceca;
      --chassis-border: #a9a7a3;
      --screen-bg: #9eb59e;
      --screen-text: #1a241a;
      --key-num-bg: #e8e6e1;
      --key-num-text: #2b2b2b;
      --key-op-bg: #8d9499;
      --key-op-text: #ffffff;
      --key-danger: #c0392b;
      --key-action: #d35400;
      --key-tab: #b5b3af;
      --hard-shadow: #888681;
      --hard-shadow-dark: #5c5a57;
      --highlight: #ffffff;
  }

  * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      font-family: 'Courier New', Courier, monospace, sans-serif;
      -webkit-tap-highlight-color: transparent;
  }

  body {
      background: #2c3e50;
      color: var(--key-num-text);
      height: 100dvh;
      display: flex;
      justify-content: center;
      align-items: center;
      overflow: hidden;
      padding: 10px;
  }

  .app {
      /* height: 90%; */
      width: 100%;
      max-width: 480px;
      background: var(--chassis-bg);
      border: 4px solid var(--chassis-border);
      border-radius: 12px;
      box-shadow:
          inset 2px 2px 5px var(--highlight),
          inset -4px -4px 10px rgba(0, 0, 0, 0.1),
          8px 12px 25px rgba(0, 0, 0, 0.5);
      display: flex;
      flex-direction: column;
      padding: 14px;
      gap: 12px;
      position: relative;
  }

  .calculator {
      display: none;
  }

  /* ===== DISPLAY ===== */
  .display-module {
      background: #111;
      padding: 10px;
      border-radius: 8px;
      border: 2px solid #555;
      box-shadow: 0 4px 0 #888;
      flex-shrink: 0;
  }

  .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
      padding: 0 4px;
  }

  .header h1 {
      font-size: 1rem;
      color: #d0ceca;
      font-family: Arial, sans-serif;
      text-transform: uppercase;
      letter-spacing: 2px;
  }

  .mode-badge {
      font-size: 0.75rem;
      font-weight: bold;
      padding: 2px 8px;
      background: var(--chassis-border);
      color: #000;
      border-radius: 4px;
  }

  .screen-container {
      background: var(--screen-bg);
      border: 4px inset #6a7c6a;
      border-radius: 4px;
      padding: 10px 12px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      min-height: 64px;
      box-shadow: inset 2px 4px 10px rgba(0, 0, 0, 0.2);
  }

  .screen-text {
      font-size: 1.05rem;
      font-weight: bold;
      color: var(--screen-text);
      text-align: center;
      line-height: 1.6;
      word-break: break-word;
      white-space: pre-line;
  }

  .screen-text.small {
      font-size: 0.85rem;
      font-weight: normal;
  }

  .screen-text.flash {
      animation: resFlash 0.35s ease;
  }

  @keyframes resFlash {
      0% {
          opacity: 1;
      }

      30% {
          opacity: 0.3;
      }

      100% {
          opacity: 1;
      }
  }

  /* ===== TOOLS GRID ===== */
  .tools-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      flex: 1;
      align-content: stretch;
  }

  .tool-card {
      background: var(--key-num-bg);
      border: 2px solid var(--chassis-border);
      border-radius: 8px;
      cursor: pointer;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 14px 6px;
      box-shadow:
          -1px -1px 0 rgba(255, 255, 255, 0.8) inset,
          3px 4px 0 var(--hard-shadow);
      transition: transform 0.05s, box-shadow 0.05s;
      min-height: 105px;
  }

  .tool-card:active {
      transform: translate(3px, 4px);
      box-shadow: 0 0 0 transparent;
  }

  .tool-card .icon-box {
      width: 42px;
      height: 42px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--key-op-bg);
      color: var(--key-op-text);
      border-radius: 6px;
      font-size: 1.4rem;
      box-shadow: 1px 2px 0 var(--hard-shadow-dark);
  }

  .tool-card .name {
      font-size: 0.68rem;
      font-weight: bold;
      text-align: center;
      font-family: Arial, sans-serif;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      line-height: 1.25;
  }

  .tool-card .desc {
      font-size: 0.58rem;
      color: #777;
      text-align: center;
      font-family: Arial, sans-serif;
  }

  /* Featured card (calculator) */
  .tool-card.featured {
      grid-column: 1 / -1;
      flex-direction: row;
      gap: 14px;
      padding: 12px 18px;
      min-height: 65px;
  }

  .tool-card.featured .icon-box {
      width: 46px;
      height: 46px;
      font-size: 1.5rem;
      flex-shrink: 0;
  }

  .tool-card.featured .text-group {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 2px;
  }

  .tool-card.featured .name {
      font-size: 0.82rem;
  }

  .tool-card.featured .desc {
      font-size: 0.62rem;
      text-align: left;
  }

  .text-icon {
      font-weight: bold;
      font-size: 0.8em;
      /* Adjust to fit inside your box */
      text-transform: uppercase;
  }

  /* ===== TOOL PANEL ===== */
  .tool-panel {
      /* display: none; */
      display: none;
      flex-direction: column;
      flex: 1;
      gap: 10px;
      min-height: 0;
  }

  .tool-panel.active {
      display: flex;
  }

  .tool-toolbar {
      display: flex;
      gap: 8px;
      flex-shrink: 0;
      align-items: center;
  }

  .tool-title {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      font-family: Arial, sans-serif;
      font-weight: bold;
      font-size: 0.82rem;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: var(--key-num-text);
  }

  .tool-body {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 10px;
      padding-right: 4px;
  }

  .input-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
  }

  .input-link .input-group {
      display: flex;
      flex-direction: column;
  }

  .input-group.full {
      grid-column: span 2;
  }

  .input-group label {
      font-size: 0.72rem;
      font-weight: bold;
      font-family: Arial, sans-serif;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 4px;
  }

  .input-group input,
  .input-group select {
      padding: 9px 8px;
      background: var(--key-num-bg);
      border: 2px solid var(--hard-shadow);
      border-top-color: var(--hard-shadow-dark);
      border-left-color: var(--hard-shadow-dark);
      border-radius: 4px;
      font-family: 'Courier New', monospace;
      font-weight: bold;
      font-size: 1.1rem;
      text-align: center;
      color: var(--key-num-text);
      outline: none;
      width: 100%;
      -webkit-appearance: none;
      appearance: none;
  }

  .input-group select {
      font-size: 0.85rem;
      cursor: pointer;
      padding-right: 6px;
  }

  .input-group input:focus,
  .input-group select:focus {
      border-color: var(--key-op-bg);
  }

  .input-hint {
      font-size: 0.6rem;
      color: #888;
      text-align: center;
      font-family: Arial, sans-serif;
  }

  .calc-btn {
      height: 48px;
      border: 2px solid #a04000;
      border-radius: 6px;
      background: var(--key-action);
      color: white;
      font-size: 1.05rem;
      font-weight: bold;
      font-family: Arial, sans-serif;
      cursor: pointer;
      box-shadow: 2px 3px 0 #a04000;
      transition: transform 0.05s, box-shadow 0.05s;
      text-transform: uppercase;
      letter-spacing: 1px;
  }

  .calc-btn:active {
      transform: translate(2px, 3px);
      box-shadow: 0 0 0 transparent;
  }

  .back-btn {
      height: 40px;
      min-width: 40px;
      border: 2px solid var(--hard-shadow-dark);
      border-radius: 6px;
      background: var(--key-op-bg);
      color: white;
      font-size: 1rem;
      font-weight: bold;
      cursor: pointer;
      box-shadow: 2px 3px 0 var(--hard-shadow-dark);
      transition: transform 0.05s, box-shadow 0.05s;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 12px;
      flex-shrink: 0;
  }

  .back-btn:active {
      transform: translate(2px, 3px);
      box-shadow: 0 0 0 transparent;
  }

  /* ===== RESISTOR VISUAL ===== */
  .resistor-visual {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 14px 10px;
      background: var(--key-num-bg);
      border: 2px solid var(--chassis-border);
      border-radius: 6px;
      box-shadow: inset 1px 1px 3px var(--highlight);
  }

  .resistor-body {
      width: 170px;
      height: 38px;
      background: linear-gradient(180deg, #e8c97a 0%, #d4a76a 40%, #c49555 100%);
      border-radius: 5px;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: space-evenly;
      padding: 0 22px;
      box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.25);
  }

  .resistor-body::before,
  .resistor-body::after {
      content: '';
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      width: 18px;
      height: 10px;
      background: linear-gradient(180deg, #aaa, #888);
      border-radius: 2px;
  }

  .resistor-body::before {
      left: -18px;
  }

  .resistor-body::after {
      right: -18px;
  }

  .color-band {
      width: 12px;
      height: 32px;
      border-radius: 2px;
      cursor: pointer;
      border: 1px solid rgba(0, 0, 0, 0.25);
      transition: transform 0.1s;
      flex-shrink: 0;
  }

  .color-band:active {
      transform: scaleY(0.88);
  }

  .band-tap-row {
      display: flex;
      justify-content: center;
      gap: 16px;
      margin-top: 10px;
  }

  .band-tap {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 3px;
  }

  .band-tap .swatch {
      width: 24px;
      height: 24px;
      border-radius: 4px;
      cursor: pointer;
      border: 1px solid rgba(0, 0, 0, 0.3);
      transition: transform 0.1s;
  }

  .band-tap .swatch:active {
      transform: scale(0.9);
  }

  .band-tap .swatch-label {
      font-size: 0.58rem;
      font-family: Arial, sans-serif;
      color: #666;
      text-transform: uppercase;
  }

  /* ===== SCROLLBAR ===== */
  ::-webkit-scrollbar {
      width: 5px;
  }

  ::-webkit-scrollbar-track {
      background: var(--chassis-bg);
      border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb {
      background: var(--hard-shadow);
      border-radius: 4px;
  }

  /* ===== TOAST ===== */
  .toast {
      position: fixed;
      top: 20px;
      left: 50%;
      transform: translateX(-50%) translateY(-100px);
      background: #111;
      color: #0f0;
      font-family: 'Courier New', monospace;
      padding: 10px 24px;
      border: 2px solid #555;
      border-radius: 4px;
      font-weight: bold;
      z-index: 999;
      transition: transform 0.3s ease;
      font-size: 0.82rem;
      text-align: center;
      white-space: pre-line;
  }

  .toast.show {
      transform: translateX(-50%) translateY(0);
  }

  /* ===== RESPONSIVE ===== */
  @media (max-height: 900px) {
      .app {
          height: 95%;
          background: var(--chassis-bg);
          border: 4px solid var(--chassis-border);
          border-radius: 12px;
          box-shadow:
              inset 2px 2px 5px var(--highlight),
              inset -4px -4px 10px rgba(0, 0, 0, 0.1),
              8px 12px 25px rgba(0, 0, 0, 0.5);
          display: flex;
          flex-direction: column;
          padding: 14px;
          gap: 12px;
          position: relative;
      }

      .tool-card {
          min-height: 80px;
          padding: 10px 4px;
          gap: 4px;
      }

      .tool-card .icon-box {
          width: 50px;
          height: 50px;
          font-size: 1.1rem;
      }

      .custom-logo {
          width: 40px;
          height: 40px;
          /* object-fit: contain; */
          /* Keeps the SVG proportions perfect */
          /* max-width: 50px; */
          /* Adjust this to match your FontAwesome size */
      }

      .tool-card .name {
          font-size: 0.6rem;
      }

      .tool-card .desc {
          display: none;
      }

      .tools-grid {
          gap: 7px;
      }
  }

  @media (max-height: 650px) {
      .app {
          height: 95%;
          background: var(--chassis-bg);
          border: 4px solid var(--chassis-border);
          border-radius: 12px;
          box-shadow:
              inset 2px 2px 5px var(--highlight),
              inset -4px -4px 10px rgba(0, 0, 0, 0.1),
              8px 12px 25px rgba(0, 0, 0, 0.5);
          display: flex;
          flex-direction: column;
          padding: 14px;
          gap: 12px;
          position: relative;
      }

      .tool-card {
          min-height: 65px;
          padding: 6px 4px;
          gap: 3px;
      }

      .tool-card .icon-box {
          width: 38px;
          height: 38px;
          font-size: 0.9rem;
          border-radius: 4px;
      }



      .tools-grid {
          gap: 5px;
      }

      .display-module {
          padding: 8px;
      }

      .screen-container {
          min-height: 50px;
          padding: 8px;
      }

      .screen-text {
          font-size: 0.9rem;
      }
  }