/* App Layout */
    body {
      display: flex;
      flex-direction: column;
      height: 100vh;
      overflow: hidden;
      background-color: var(--bg);
    }
    
    /* Top Header */
    header.app-header {
      height: var(--nav-h);
      background: var(--nav-bg);
      backdrop-filter: blur(20px);
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      padding: 0 2rem;
      flex-shrink: 0;
      gap: 2rem;
      position: relative;
      z-index: 200;
    }

    .brand-logo {
      font-family: 'Fraunces', serif;
      font-weight: 900;
      font-size: 1.5rem;
      color: var(--navy);
      text-decoration: none;
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
    
    .brand-logo svg {
      width: 24px;
      height: 24px;
      fill: var(--amber);
    }

    .sem-nav {
      display: flex;
      gap: 1rem;
    }
    
    .sem-btn {
      padding: 0.5rem 1rem;
      border: none;
      background: transparent;
      font-family: 'Figtree', sans-serif;
      font-weight: 600;
      font-size: 0.95rem;
      color: var(--muted);
      cursor: pointer;
      border-radius: 8px;
      transition: all 0.2s ease;
    }
    
    .sem-btn:hover {
      color: var(--text);
      background: var(--bg2);
    }
    
    .sem-btn.active {
      background: var(--navy);
      color: var(--white);
    }

    .header-search {
      display: flex;
      align-items: center;
      background: var(--bg2);
      border: 1px solid var(--border);
      border-radius: 99px;
      padding: 0.4rem 1rem;
      gap: 0.5rem;
      margin-left: auto;
      transition: all 0.2s;
      position: relative;
    }
    .header-search:focus-within {
      border-color: var(--amber);
      background: var(--white);
      box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
    }
    .header-search .search-icon {
      width: 16px;
      height: 16px;
      stroke: var(--muted);
    }
    .header-search input {
      border: none;
      background: transparent;
      font-family: 'Figtree', sans-serif;
      font-size: 0.95rem;
      color: var(--text);
      outline: none;
      width: 220px;
    }
    .header-search input::placeholder {
      color: var(--muted);
    }

    /* Main Workspace */
    .workspace {
      display: flex;
      flex: 1;
      overflow: hidden;
    }

    /* Sidebar */
    .sidebar {
      width: 280px;
      background: var(--white);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      overflow-y: auto;
      flex-shrink: 0;
      padding: 1.5rem;
    }

    .sidebar-section {
      margin-bottom: 1.5rem;
    }

    .sidebar-title {
      font-size: 0.75rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--muted);
      font-weight: 700;
      margin-bottom: 0.75rem;
      padding-left: 0.5rem;
    }

    .calc-list {
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
    }

    .calc-item {
      padding: 0.75rem 1rem;
      border-radius: 8px;
      font-size: 0.95rem;
      font-weight: 500;
      color: var(--text);
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      gap: 0.75rem;
      border: 1px solid transparent;
    }

    .calc-item:hover {
      background: var(--bg);
    }

    .calc-item.active {
      background: rgba(245, 158, 11, 0.1);
      color: var(--amber);
      border-color: rgba(245, 158, 11, 0.2);
    }
    
    .calc-item svg {
      width: 18px;
      height: 18px;
      stroke: currentColor;
    }

    /* Main Area */
    .main-area {
      flex: 1;
      background: var(--bg2);
      padding: 2rem;
      overflow-y: auto;
      display: flex;
      justify-content: center;
    }
    
    .calc-container {
      width: 100%;
      max-width: 800px;
      display: none;
      animation: fadeIn 0.4s ease forwards;
    }
    
    .calc-container.active {
      display: block;
    }

    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(10px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .card {
      background: var(--white);
      border-radius: 16px;
      padding: 2.5rem;
      box-shadow: 0 10px 30px rgba(0,0,0,0.05);
      border: 1px solid var(--border);
      margin-bottom: 2rem;
    }

    .card-header {
      margin-bottom: 2rem;
      border-bottom: 1px solid var(--border);
      padding-bottom: 1.5rem;
    }

    .card-title {
      font-family: 'Fraunces', serif;
      font-size: 2rem;
      color: var(--navy);
      margin-bottom: 0.5rem;
    }

    .card-desc {
      color: var(--muted);
      font-size: 1rem;
      line-height: 1.5;
    }

    /* Matrix Input Grid */
    .matrix-input-wrapper {
      display: inline-block;
      position: relative;
      padding: 0 1rem;
    }
    
    .matrix-input-wrapper::before,
    .matrix-input-wrapper::after {
      content: '';
      position: absolute;
      top: 0;
      bottom: 0;
      width: 10px;
      border: 2px solid var(--navy);
      border-radius: 4px;
    }
    
    .matrix-input-wrapper::before {
      left: 0;
      border-right: none;
    }
    
    .matrix-input-wrapper::after {
      right: 0;
      border-left: none;
    }

    .matrix-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 0.5rem;
      padding: 0.5rem;
    }

    .matrix-cell {
      width: 60px;
      height: 60px;
      text-align: center;
      font-family: 'IBM Plex Mono', monospace;
      font-size: 1.25rem;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--bg);
      color: var(--text);
      transition: border-color 0.2s;
    }
    
    .matrix-cell:focus {
      outline: none;
      border-color: var(--amber);
      background: var(--white);
    }

    .calc-action {
      margin-top: 2rem;
      display: flex;
      justify-content: flex-end;
    }

    .btn-primary {
      background: var(--amber);
      color: var(--navy);
      border: none;
      padding: 0.75rem 2rem;
      font-size: 1rem;
      font-weight: 700;
      border-radius: 8px;
      cursor: pointer;
      transition: transform 0.2s, box-shadow 0.2s;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
    }

    .btn-primary:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    }

    /* Steps Section */
    .steps-container {
      display: none;
      margin-top: 2rem;
    }
    
    .steps-container.active {
      display: block;
      animation: fadeIn 0.5s ease;
    }

    .step-card {
      background: var(--white);
      border: 1px solid var(--border);
      border-left: 4px solid var(--teal);
      border-radius: 8px;
      padding: 1.5rem;
      margin-bottom: 1rem;
      box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    }

    .step-header {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      margin-bottom: 1rem;
    }

    .step-number {
      background: rgba(13, 148, 136, 0.1);
      color: var(--teal);
      width: 28px;
      height: 28px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 700;
      font-size: 0.85rem;
    }

    .step-title {
      font-weight: 600;
      color: var(--navy);
      font-size: 1.1rem;
    }
    
    .step-desc {
      color: var(--muted);
      font-size: 0.95rem;
      margin-bottom: 1rem;
    }

    .step-body-flex {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 2rem;
      padding: 1rem 0;
      flex-wrap: wrap;
    }

    .step-action-col {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.5rem;
      color: var(--muted);
      font-size: 0.95rem;
      text-align: center;
      max-width: 200px;
    }

    .step-arrow svg {
      width: 24px;
      height: 24px;
      stroke: var(--amber);
    }

    .display-matrix-wrapper {
      display: inline-block;
      position: relative;
      padding: 0 0.75rem;
    }
    .display-matrix-wrapper::before,
    .display-matrix-wrapper::after {
      content: '';
      position: absolute;
      top: 0;
      bottom: 0;
      width: 8px;
      border: 2px solid var(--navy);
      border-radius: 4px;
    }
    .display-matrix-wrapper::before {
      left: 0;
      border-right: none;
    }
    .display-matrix-wrapper::after {
      right: 0;
      border-left: none;
    }
    .display-matrix {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 0.5rem 1rem;
      text-align: center;
      font-family: 'IBM Plex Mono', monospace;
      font-size: 1.1rem;
      color: var(--text);
    }
    .final-result {
      background: #111827;
      color: #ffffff;
      padding: 1.5rem;
      border-radius: 12px;
      margin-top: 2rem;
      text-align: center;
      font-family: 'Fraunces', serif;
      font-size: 1.5rem;
    }
    
    .final-result span {
      color: var(--amber);
    }

    .placeholder-state {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100%;
      color: var(--muted);
      text-align: center;
    }
    
    .placeholder-state svg {
      width: 64px;
      height: 64px;
      stroke: var(--border2);
      margin-bottom: 1rem;
    }

    /* ==========================================================
       RESPONSIVE MEDIA QUERIES FOR GET STARTED WORKSPACE
       ========================================================= */

    /* Global Responsive Class for dynamic columns */
    .overview-grid {
      display: grid !important;
      grid-template-columns: repeat(4, 1fr) !important;
    }

    /* Tablet and laptop landscape adjustments (< 1024px) */
    @media (max-width: 1023px) {
      body {
        height: 100vh !important;
        overflow: hidden !important;
      }
      .workspace {
        flex-direction: row !important;
        overflow: hidden !important;
        position: relative !important;
        height: calc(100vh - var(--nav-h)) !important;
      }
      .sidebar {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        height: 100% !important;
        width: 280px !important;
        max-width: 85vw !important;
        z-index: 100 !important;
        background: var(--white) !important;
        border-right: 1px solid var(--border) !important;
        border-bottom: none !important;
        flex-shrink: 0 !important;
        padding: 1.25rem !important;
        transform: translateX(0) !important;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
      }
      
      .sidebar.mobile-collapsed {
        transform: translateX(-100%) !important;
      }
      
      /* Mobile Menu button */
      #mobile-menu-btn {
        display: flex !important;
      }
      .calc-list {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
        gap: 0.5rem !important;
      }
      .sidebar-section {
        margin-bottom: 1rem !important;
      }
      .main-area {
        width: 100% !important;
        height: 100% !important;
        padding: 1.5rem 1rem !important;
        overflow-y: auto !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
      }
      .overview-grid {
        grid-template-columns: repeat(2, 1fr) !important;
      }
    }

    /* Mobile devices (< 768px) */
    @media (max-width: 767px) {
      /* Header wrapping for logo, semester switcher, and search box */
      header.app-header {
        height: auto !important;
        padding: 1rem !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        gap: 0.75rem !important;
      }
      .sem-nav {
        width: 100% !important;
        justify-content: center !important;
        order: 2 !important;
        margin-top: 0.25rem;
      }
      .header-search {
        width: 100% !important;
        margin-left: 0 !important;
        order: 3 !important;
      }
      .header-search input {
        width: 100% !important;
      }
      #theme-toggle {
        margin-left: auto !important;
        order: 1 !important;
      }

      /* Stack Calculator Param Inputs */
      #newton-input-container > div,
      #false-position-input-container > div,
      #jacobi-grid-container > div,
      #hyperbolic-input-container > div,
      #poly-roots-input-container > div {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
        width: 100% !important;
      }
      
      #newton-input-container div,
      #false-position-input-container div,
      #jacobi-grid-container div,
      #hyperbolic-input-container div,
      #poly-roots-input-container div {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
      }

      #newton-input-container input,
      #false-position-input-container input,
      #jacobi-grid-container input,
      #hyperbolic-input-container input,
      #hyperbolic-input-container select,
      #poly-roots-input-container input {
        width: 100% !important;
      }

      /* Overview Grid columns */
      .overview-grid {
        grid-template-columns: 1fr !important;
      }

      /* Cards responsive spacing and buttons stacking */
      .card {
        padding: 1.5rem !important;
        border-radius: 12px !important;
        margin-bottom: 1.5rem !important;
      }
      .card-header {
        margin-bottom: 1.5rem !important;
        padding-bottom: 1rem !important;
      }
      .calc-action {
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.75rem !important;
      }
      .calc-action button,
      .card-header button {
        width: 100% !important;
        justify-content: center !important;
      }

      /* Heading typography adjustments */
      .card-title {
        font-size: 1.5rem !important;
      }
      .card-desc {
        font-size: 0.9rem !important;
      }
      .step-title {
        font-size: 1rem !important;
      }

      /* Table layout & local scrolls */
      .step-card table {
        min-width: 600px !important;
      }
      .step-card {
        padding: 1rem !important;
      }
      
      /* Matrix brackets local scroll safety */
      .matrix-input-wrapper {
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 0 1rem 0.5rem 1rem !important;
        display: inline-block !important;
      }
      .display-matrix-wrapper {
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 0 0.75rem 0.5rem 0.75rem !important;
        display: inline-block !important;
      }
    }