/**
 * MathSolver v2 - Comprehensive Stylesheet
 * A complete, unified CSS for the entire application
 * 
 * Features:
 * - CSS Custom Properties (Variables)
 * - Mobile-first responsive design
 * - Orange professional theme
 * - Accessibility considerations
 * 
 * @version 2.0.0
 */

/* ==========================================================================
   1. CSS RESET & CUSTOM PROPERTIES
   ========================================================================== */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Primary Colors - Orange Theme */
    --primary: #f97316;
    --primary-dark: #ea580c;
    --primary-light: #fdba74;
    --primary-bg: #fff7ed;
    
    /* Secondary Colors */
    --secondary: #1e293b;
    --secondary-light: #334155;
    
    /* Neutral Colors */
    --text: #334155;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --white: #ffffff;
    
    /* Semantic Colors */
    --success: #22c55e;
    --success-dark: #16a34a;
    --success-bg: #dcfce7;
    --error: #ef4444;
    --error-dark: #dc2626;
    --error-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Consolas', 'Monaco', 'Courier New', monospace;
    --font-serif: 'Georgia', 'Times New Roman', serif;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Layout */
    --max-width: 1100px;
    --header-height: 50px;
}

/* ==========================================================================
   2. BASE STYLES
   ========================================================================== */

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Links */
a {
    color: var(--primary-dark);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Forms */
input,
button,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

button {
    cursor: pointer;
}

/* Lists */
ul,
ol {
    list-style: none;
}

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
}

/* ==========================================================================
   3. LAYOUT
   ========================================================================== */

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

.content-wrap {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 30px 20px;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
}

.main-col {
    min-width: 0;
}

.side-col {
    min-width: 0;
}

/* ==========================================================================
   4. HEADER
   ========================================================================== */

.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 0;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
}

.logo:hover {
    color: var(--white);
    text-decoration: none;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--white);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--primary);
}

.header-nav {
    display: flex;
    gap: 20px;
}

.header-nav a {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    font-size: 14px;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}

.header-nav a:hover,
.header-nav a.active {
    color: var(--white);
    text-decoration: none;
    border-bottom-color: var(--white);
}

/* ==========================================================================
   5. BREADCRUMB
   ========================================================================== */

.breadcrumb {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 16px;
    padding: 0px 0px 8px;
    border-bottom: 1px solid var(--border);
}

.breadcrumb a {
    color: var(--text-light);
}

.breadcrumb a:hover {
    color: var(--primary);
}

/* ==========================================================================
   6. TYPOGRAPHY
   ========================================================================== */

h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 20px;
    line-height: 1.3;
}

h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--secondary);
    margin: 32px 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-light);
}

h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary);
    margin: 24px 0 12px;
}

h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 16px 0 8px;
}

.page-desc {
    color: var(--text-light);
    font-size: 1.05em;
    line-height: 1.7;
    margin-bottom: 24px;
}

/* ==========================================================================
   7. BUTTONS
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
    text-decoration: none;
    color: var(--white);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--text-light);
    color: var(--white);
    box-shadow: var(--shadow);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

.calc-btn {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.calc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.calc-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   8. FORMS & INPUTS
   ========================================================================== */

.calc-input {
    flex: 1;
    padding: 14px 18px;
    font-size: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    outline: none;
    transition: all var(--transition);
    background: var(--bg);
    width: 100%;
}

.calc-input:focus {
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1);
}

.calc-input::placeholder {
    color: var(--text-light);
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-weight: 600;
    color: var(--secondary);
    font-size: 14px;
}

.input-group small {
    color: var(--text-light);
    font-size: 12px;
}

.input-row {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 30px 0;
}

.input-row .input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-row .input-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 8px;
}

.input-row .input-group input {
    width: 120px;
    padding: 14px 16px;
    font-size: 18px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    transition: all var(--transition);
}

.input-row .input-group input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

/* Select Dropdown */
select.calc-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    cursor: pointer;
}

/* ==========================================================================
   9. CALCULATOR BOX (Combined Input + Steps)
   ========================================================================== */

.calc-box {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
    overflow: visible;
}

.calc-box .calc-section {
    padding: 30px;
    text-align: center;
    position: relative;
}

.calc-box .calc-section form {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.calc-box .calc-section input[type="number"] {
    width: 100px;
    padding: 14px;
    font-size: 18px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.calc-box .calc-section input[type="text"],
.calc-box .calc-section .calc-input {
    flex: 1;
    min-width: 200px;
    padding: 14px 18px;
    font-size: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.calc-box .calc-section input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.calc-box .and-text {
    font-size: 16px;
    color: var(--text-light);
    font-weight: 500;
}

.calc-box .answer-display {
    font-size: 28px;
    color: var(--secondary);
}

.calc-box .answer-display .answer-label {
    font-weight: 500;
    color: var(--text-light);
}

.calc-box .answer-display .answer-value {
    font-weight: 700;
    color: var(--primary);
}

/* Steps Section */
.calc-box .steps-section {
    padding: 30px;
    border-top: 1px solid var(--border);
    background: var(--white);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.calc-box .steps-section .section-title {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 20px;
}

.calc-box .step-item {
    margin-bottom: 20px;
}

.calc-box .step-item:last-of-type {
    margin-bottom: 0;
}

.calc-box .step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.calc-box .step-number {
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    text-transform: uppercase;
}

.calc-box .step-title {
    font-size: 1.05em;
    font-weight: 600;
    color: var(--secondary);
}

.calc-box .step-body {
    color: var(--text);
    line-height: 1.8;
}

.calc-box .step-body ul {
    padding: 0;
    margin: 8px 0;
}

.calc-box .step-body ul li {
    padding: 4px 0 4px 20px;
    position: relative;
}

.calc-box .step-body ul li::before {
    content: '•';
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: 0;
}

.calc-box .step-body p {
    margin: 6px 0;
}

.calc-box .step-formula {
    background: var(--bg);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 15px;
    margin: 12px 0;
    color: var(--secondary);
    border: 1px solid var(--border);
}

/* ==========================================================================
   10. FRACTION CALCULATOR
   ========================================================================== */

.fraction-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fraction-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fraction-box input {
    width: 80px;
    padding: 12px;
    font-size: 20px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    transition: all var(--transition);
}

.fraction-box input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.fraction-box input::placeholder {
    color: var(--text-light);
}

.fraction-line {
    width: 80px;
    height: 3px;
    background: var(--secondary);
    margin: 4px 0;
    border-radius: 2px;
}

.fraction-label {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.operator {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary);
    padding: 0 15px;
}

.equals {
    font-size: 32px;
    color: var(--text-light);
    padding: 0 15px;
}

.result-preview {
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    min-width: 100px;
}

.result-preview .value {
    font-size: 28px;
    font-weight: bold;
    color: var(--primary);
}

/* ==========================================================================
   11. ANSWER BOX
   ========================================================================== */

.answer-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-xl);
    padding: 24px 32px;
    margin: 24px 0;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.answer-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.answer-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--white);
    font-family: var(--font-serif);
}

.answer-alt {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 8px;
}

/* Result Box (Green Success) */
.result-box {
    padding: 20px;
    border-radius: var(--radius-lg);
    margin: 20px 0;
}

.result-box.green {
    background: var(--success-bg);
    border: 1px solid var(--success);
}

.result-main {
    font-size: 24px;
    color: var(--success-dark);
}

.result-main .result-input {
    font-family: var(--font-mono);
    font-style: normal;
}

.result-main strong {
    font-weight: 700;
}

/* ==========================================================================
   12. STEPS (Alternative Style)
   ========================================================================== */

.step {
    display: flex;
    gap: 16px;
    margin: 20px 0;
    padding: 20px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.step-num {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
    min-width: 0;
}

.step-title {
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 8px;
    font-size: 16px;
}

.step-content p {
    color: var(--text);
    margin: 6px 0;
}

.step-math {
    background: var(--primary-bg);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    margin: 12px 0;
    color: var(--primary-dark);
    font-weight: 600;
    border: 1px solid var(--primary-light);
}

.step-note {
    background: var(--warning-bg);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-top: 12px;
    border-left: 3px solid var(--warning);
}

/* ==========================================================================
   13. EXAMPLE BUTTONS & CHIPS
   ========================================================================== */

.calc-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.calc-examples-label {
    font-size: 14px;
    color: var(--text-light);
    margin-right: 8px;
}

.calc-chip {
    display: inline-block;
    padding: 6px 14px;
    background: var(--primary-bg);
    color: var(--primary-dark);
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    border: 1px solid var(--primary-light);
}

.calc-chip:hover {
    background: var(--primary);
    color: var(--white);
    text-decoration: none;
    border-color: var(--primary);
}

.example-btn {
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius);
    padding: 10px 16px;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 14px;
    color: var(--primary-dark);
}

.example-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ==========================================================================
   14. DATA TABLES
   ========================================================================== */

.data-tbl {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-tbl td,
.data-tbl th {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.data-tbl tr:last-child td {
    border-bottom: none;
}

.data-tbl tr:nth-child(even) {
    background: var(--bg);
}

.data-tbl td:first-child {
    color: var(--text-light);
    font-weight: 500;
}

.data-tbl tr:hover {
    background: var(--primary-bg);
}

/* ==========================================================================
   15. INFO SECTIONS
   ========================================================================== */

.info-section {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.info-section h2 {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.info-section h3 {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--secondary);
    margin: 20px 0 12px;
}

.info-section p {
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 12px;
}

.info-section ul {
    padding: 0;
    margin: 0;
}

.info-section ul li {
    padding: 6px 0 6px 20px;
    position: relative;
    color: var(--text);
}

.info-section ul li::before {
    content: '•';
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* FAQ */
.faq-item {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin: 16px 0;
    box-shadow: var(--shadow);
}

.faq-item h4 {
    color: var(--secondary);
    margin: 0 0 10px;
}

.faq-item p {
    color: var(--text);
    margin: 0;
}

/* Conclusion */
.conclusion {
    background: var(--white);
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    margin: 24px 0;
    border: 2px solid var(--primary);
    font-size: 17px;
}

.conclusion .highlight {
    color: var(--primary);
    font-weight: 700;
    font-size: 20px;
}

/* ==========================================================================
   16. RELATED LINKS
   ========================================================================== */

.related-section {
    margin-top: 30px;
}

.related-section h3 {
    font-size: 1.2em;
    color: var(--secondary);
    margin-bottom: 16px;
}

.related-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.related-links a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    transition: all var(--transition);
}

.related-links a:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
    box-shadow: var(--shadow);
}

.related-links a::after {
    content: '→';
    color: var(--primary);
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.links-grid > div,
.link-card {
    color: var(--text);
    font-weight: 500;
    display: block;
}

.links-grid > div:hover,
.link-card:hover {
    text-decoration: none;
    color: var(--primary);
}

/* ==========================================================================
   17. HOME PAGE LISTS
   ========================================================================== */

.cat-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 12px 20px;
    font-weight: 600;
    font-size: 16px;
    margin: 24px 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.home-list {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 8px;
}

.home-list td {
    padding: 16px 20px;
    vertical-align: top;
    width: 50%;
    border-right: 1px solid var(--border);
}

.home-list td:last-child {
    border-right: none;
}

.home-list ul {
    margin: 0;
    padding: 0;
}

.home-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.home-list li:last-child {
    border-bottom: none;
}

.home-list a {
    color: var(--text);
    font-weight: 500;
}

.home-list a:hover {
    color: var(--primary);
    text-decoration: none;
}

/* ==========================================================================
   18. SIDEBAR
   ========================================================================== */

.sidebar-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
}

.sidebar-box ul {
    margin: 0;
    padding: 0;
}

.sidebar-box li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-box li:last-child {
    border-bottom: none;
}

.sidebar-box a {
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-box a:hover {
    color: var(--primary);
    text-decoration: none;
}

.sidebar-box .cat-icon {
    width: 28px;
    height: 28px;
    background: var(--primary-bg);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* ==========================================================================
   19. FOOTER
   ========================================================================== */

.footer {
    background: var(--secondary);
    color: rgba(255, 255, 255, 0.7);
    padding: 40px 20px;
    margin-top: 40px;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
}

.footer-col h4 {
    color: var(--white);
    margin-bottom: 16px;
    font-size: 16px;
}

.footer-col ul {
    margin: 0;
    padding: 0;
}

.footer-col li {
    padding: 6px 0;
}

.footer-col a {
    color: rgba(255, 255, 255, 0.7);
}

.footer-col a:hover {
    color: var(--primary-light);
    text-decoration: none;
}

.footer-bottom {
    max-width: var(--max-width);
    margin: 30px auto 0;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    font-size: 14px;
}

/* ==========================================================================
   20. ERROR & ALERT BOXES
   ========================================================================== */

.error-box {
    background: var(--error-bg);
    border: 1px solid #fecaca;
    border-left: 4px solid var(--error);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 20px 0;
}

.error-box strong {
    color: var(--error);
}

.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin: 16px 0;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid var(--success);
    color: var(--success-dark);
}

.alert-warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    color: #92400e;
}

.alert-info {
    background: var(--info-bg);
    border: 1px solid var(--info);
    color: #1d4ed8;
}

/* ==========================================================================
   21. LOADING & SPINNER
   ========================================================================== */

.detecting,
.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   22. UTILITY CLASSES
   ========================================================================== */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--error);
}

.font-mono {
    font-family: var(--font-mono);
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

/* ==========================================================================
   23. CALCULATOR PAGES STYLES
   ========================================================================== */

.calc-wrap {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 28px;
    margin: 24px 0;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.calc-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 20px;
    text-align: center;
}

.calc-input-wrap {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 60px 0;
    text-align: center;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--white);
}

.hero .subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 30px;
}

/* Solver Box */
.solver-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    max-width: 700px;
    margin: 0 auto;
    text-align: left;
}

.solver-form {
    display: flex;
    gap: 10px;
}

.solver-form input {
    flex: 1;
    padding: 15px 20px;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color var(--transition);
}

.solver-form input:focus {
    border-color: var(--primary);
}

/* Input wrapper for autocomplete */
.input-wrapper {
    position: relative;
    flex: 1;
}

.input-wrapper input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color var(--transition);
}

.input-wrapper input:focus {
    border-color: var(--primary);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
}

.autocomplete-dropdown.hidden {
    display: none;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--bg);
}

.autocomplete-item .ac-category {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--white);
    background: var(--primary);
    padding: 3px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    min-width: 70px;
    text-align: center;
}

.autocomplete-item .ac-text {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text);
    text-align: left;
}

.autocomplete-item .ac-text strong {
    color: var(--primary);
    font-weight: 600;
}

/* Quick Examples */
.quick-examples {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.quick-examples .examples-label {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

.quick-examples button,
.quick-examples a {
    display: inline-block;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition);
}

.quick-examples button:hover,
.quick-examples a:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* Error suggestions */
.error-suggestions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
    padding: 15px;
    background: var(--bg);
    border-radius: var(--radius);
}

.error-suggestions span {
    font-size: 0.9rem;
    color: var(--text-light);
}

.error-suggestions .suggestion-btn {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
}

.error-suggestions .suggestion-btn:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ==========================================================================
   24. 404 PAGE
   ========================================================================== */

.error-page {
    text-align: center;
    padding: 80px 20px;
}

.error-page h1 {
    font-size: 6rem;
    color: var(--border);
    margin-bottom: 0;
}

.error-page h2 {
    margin-bottom: 15px;
}

.error-page p {
    color: var(--text-light);
    margin-bottom: 30px;
}

.error-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* ==========================================================================
   25. PRINT STYLES
   ========================================================================== */

@media print {
    .header,
    .footer,
    .sidebar-box,
    .side-col,
    .calc-btn,
    .related-section {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .content-wrap {
        display: block;
    }
    
    .calc-box,
    .info-section {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ==========================================================================
   26. RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 900px) {
    .content-wrap {
        grid-template-columns: 1fr;
    }
    
    .main-col {
        order: 1;
    }
    
    .side-col {
        order: 2;
    }
    
    .header-nav {
        display: none;
    }
    
    .calc-input-wrap {
        flex-direction: column;
    }
    
    .home-list td {
        display: block;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .home-list td:last-child {
        border-bottom: none;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .answer-value {
        font-size: 28px;
    }
}

/* Small screens - stack input and button */
@media (max-width: 500px) {
    .input-row-inline {
        flex-direction: column;
        gap: 10px;
    }
    
    .input-row-inline .calc-input {
        width: 100%;
        flex: none;
        min-width: 0;
    }
    
    .input-row-inline .mk-toggle {
        display: none;
    }
    
    .input-row-inline .calc-btn {
        width: 100%;
        flex: none;
        white-space: normal;
    }
    
    .math-input-wrapper {
        width: 100%;
    }
    
    .calc-input-wrap .calc-btn,
    .calc-box .calc-section form > .calc-btn {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .input-grid {
        grid-template-columns: 1fr;
    }
    
    .input-row {
        gap: 8px;
        margin: 20px 0;
    }
    
    .operator,
    .equals {
        font-size: 24px;
        padding: 0 10px;
    }
    
    .fraction-box input {
        width: 60px;
        padding: 10px;
        font-size: 18px;
    }
    
    .fraction-line {
        width: 60px;
    }
    
    .result-preview {
        display: none;
    }
    
    .calc-box .calc-section form {
        flex-direction: column;
    }
    
    .calc-box .calc-section input[type="text"],
    .calc-box .calc-section .calc-input {
        width: 100%;
        min-width: auto;
    }
    
    .input-row .input-group input {
        width: 100px;
        padding: 12px;
        font-size: 16px;
    }
    
    .hero h1 {
        font-size: 1.8rem;
    }
    
    .solver-form {
        flex-direction: column;
    }
    
    .solver-form button {
        width: 100%;
    }
    
    .input-wrapper {
        width: 100%;
    }
    
    .quick-examples {
        justify-content: center;
    }
    
    .quick-examples button {
        font-size: 0.75rem;
        padding: 5px 10px;
    }
    
    .autocomplete-item {
        padding: 10px 12px;
    }
    
    .autocomplete-item .ac-category {
        font-size: 0.65rem;
        min-width: 60px;
        padding: 2px 6px;
    }
    
    .autocomplete-item .ac-text {
        font-size: 0.85rem;
    }
    
    .error-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .header-inner {
        padding: 0 10px;
        height: 45px;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .logo-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    /* Note: content-wrap padding now handled in MOBILE LAYOUT IMPROVEMENTS section */
}

/* ==========================================================================
   27. ADDITIONAL UTILITY CLASSES
   ========================================================================== */

/* Flexbox Utilities */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-1 {
    flex: 1;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.items-end {
    align-items: flex-end;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-1 {
    gap: 4px;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.gap-4 {
    gap: 16px;
}

.gap-5 {
    gap: 20px;
}

/* Display Utilities */
.inline {
    display: inline;
}

.inline-block {
    display: inline-block;
}

.block {
    display: block;
}

.inline-flex {
    display: inline-flex;
}

.grid {
    display: grid;
}

/* Width Utilities */
.w-full {
    width: 100%;
}

.w-auto {
    width: auto;
}

.w-60 {
    width: 60px;
}

.w-70 {
    width: 70px;
}

.w-80 {
    width: 80px;
}

.w-100 {
    width: 100px;
}

.w-120 {
    width: 120px;
}

.min-w-200 {
    min-width: 200px;
}

.min-w-250 {
    min-width: 250px;
}

.max-w-400 {
    max-width: 400px;
}

/* Margin Utilities */
.m-0 {
    margin: 0;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.ml-1 {
    margin-left: 4px;
}

.ml-2 {
    margin-left: 8px;
}

.ml-3 {
    margin-left: 12px;
}

.mr-1 {
    margin-right: 4px;
}

.mr-2 {
    margin-right: 8px;
}

.mr-3 {
    margin-right: 12px;
}

/* Padding Utilities */
.p-0 {
    padding: 0;
}

.p-1 {
    padding: 4px;
}

.p-2 {
    padding: 8px;
}

.p-3 {
    padding: 12px;
}

.p-4 {
    padding: 16px;
}

.px-2 {
    padding-left: 8px;
    padding-right: 8px;
}

.py-2 {
    padding-top: 8px;
    padding-bottom: 8px;
}

/* Font Size Utilities */
.text-xs {
    font-size: 12px;
}

.text-sm {
    font-size: 14px;
}

.text-base {
    font-size: 16px;
}

.text-lg {
    font-size: 18px;
}

.text-xl {
    font-size: 20px;
}

.text-2xl {
    font-size: 24px;
}

.text-3xl {
    font-size: 28px;
}

.text-4xl {
    font-size: 32px;
}

/* Font Weight Utilities */
.font-normal {
    font-weight: 400;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

/* Color Utilities */
.text-gray {
    color: var(--text-light);
}

.text-dark {
    color: var(--secondary);
}

.text-green {
    color: var(--success-dark);
}

.text-red {
    color: var(--error);
}

.bg-error-light {
    background: var(--error-bg);
}

.border-error-light {
    border-color: #fecaca;
}

/* Border Utilities */
.border {
    border: 1px solid var(--border);
}

.border-0 {
    border: none;
}

.rounded {
    border-radius: var(--radius);
}

.rounded-lg {
    border-radius: var(--radius-lg);
}

.rounded-full {
    border-radius: var(--radius-full);
}

/* Opacity */
.opacity-80 {
    opacity: 0.8;
}

.opacity-60 {
    opacity: 0.6;
}

/* ==========================================================================
   28. FORM COMPONENTS
   ========================================================================== */

/* Solver Form */
.solver-form-inline {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.solver-form-inline .calc-input {
    flex: 1;
    min-width: 200px;
}

.solver-form-centered {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.solver-form-centered .calc-input {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

/* Number Input Small */
.input-sm {
    width: 60px;
    padding: 10px;
    font-size: 16px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.input-md {
    width: 100px;
    padding: 12px;
    font-size: 16px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.input-lg {
    width: 120px;
    padding: 14px;
    font-size: 18px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.input-sm:focus,
.input-md:focus,
.input-lg:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.input-flex {
    flex: 1;
}

/* Example Buttons Row */
.examples-row {
    margin-top: 15px;
    text-align: center;
}

.examples-row .label {
    color: var(--text-light);
    margin-right: 10px;
}

.examples-row form {
    display: inline;
}

/* Answer Display Variants */
.answer-display-error {
    background: var(--error-bg);
    border-color: #fecaca;
}

.answer-display-error span {
    color: var(--error);
}

/* Success Message */
.success-msg {
    margin-top: 8px;
    color: var(--success-dark);
    font-size: 14px;
}

/* Decimal Hint */
.decimal-hint {
    margin-left: 10px;
    font-size: 14px;
    opacity: 0.8;
}

/* Large Operator Symbol */
.operator-symbol {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
}

/* ==========================================================================
   29. RESULT PAGE COMPONENTS
   ========================================================================== */

/* Formula Display */
.formula-box {
    background: var(--bg);
    padding: 16px 20px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 16px;
    margin: 16px 0;
    border: 1px solid var(--border);
    overflow-x: auto;
}

/* Variable Definition */
.var-def {
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin: 8px 0;
}

.var-def .var {
    font-family: var(--font-mono);
    color: var(--primary);
    font-weight: 600;
}

/* Step Calculation */
.step-calc {
    background: var(--primary-bg);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin: 12px 0;
    font-family: var(--font-mono);
}

/* Highlight Box */
.highlight-box {
    background: var(--warning-bg);
    border-left: 4px solid var(--warning);
    padding: 12px 16px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 16px 0;
}

/* Table Styles */
.simple-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.simple-table td,
.simple-table th {
    padding: 10px 14px;
    border: 1px solid var(--border);
    text-align: left;
}

.simple-table th {
    background: var(--bg);
    font-weight: 600;
}

.simple-table tr:hover {
    background: var(--primary-bg);
}

/* Debug/Test Page Styles */
.debug-table {
    border-collapse: collapse;
    width: 100%;
}

.debug-table td,
.debug-table th {
    border: 1px solid var(--border);
    padding: 8px 12px;
}

.debug-section {
    background: var(--success-bg);
    padding: 20px;
    border-radius: var(--radius);
    margin: 16px 0;
}

/* ==========================================================================
   30. CALCULATOR-SPECIFIC STYLES
   ========================================================================== */

/* Point Input (x, y) */
.point-input {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.point-input::before {
    content: '(';
    font-size: 20px;
    color: var(--text-light);
}

.point-input::after {
    content: ')';
    font-size: 20px;
    color: var(--text-light);
}

.point-input .comma {
    font-size: 18px;
    color: var(--text-light);
}

/* Fraction Display in Results */
.fraction-display {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 4px;
}

.fraction-display .num {
    border-bottom: 2px solid var(--secondary);
    padding: 0 8px 2px;
}

.fraction-display .den {
    padding: 2px 8px 0;
}

/* Mixed Number Display */
.mixed-number {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.mixed-number .whole {
    font-size: 1.2em;
}

/* Binary/Hex Display */
.base-number {
    font-family: var(--font-mono);
    background: var(--bg);
    padding: 4px 8px;
    border-radius: 4px;
}

.base-number sub {
    font-size: 0.7em;
    color: var(--text-light);
}

/* Coordinate Display */
.coord-display {
    font-family: var(--font-mono);
    background: var(--primary-bg);
    padding: 8px 12px;
    border-radius: var(--radius);
    display: inline-block;
}

/* Matrix Display */
.matrix-display {
    display: inline-block;
    border-left: 2px solid var(--secondary);
    border-right: 2px solid var(--secondary);
    padding: 8px 12px;
    margin: 8px 0;
}

.matrix-row {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.matrix-cell {
    min-width: 40px;
    text-align: center;
    font-family: var(--font-mono);
}

/* Equation Display */
.equation-display {
    font-size: 1.2em;
    font-family: var(--font-mono);
    background: var(--bg);
    padding: 16px 24px;
    border-radius: var(--radius);
    text-align: center;
    margin: 16px 0;
    overflow-x: auto;
}

/* Superscript/Subscript */
.sup {
    font-size: 0.7em;
    vertical-align: super;
}

.sub {
    font-size: 0.7em;
    vertical-align: sub;
}

/* Graph Placeholder */
.graph-placeholder {
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: var(--text-light);
    margin: 16px 0;
}

/* Number Line */
.number-line {
    position: relative;
    height: 40px;
    background: var(--bg);
    margin: 20px 0;
    border-radius: var(--radius);
}

.number-line-axis {
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 2px;
    background: var(--secondary);
}

.number-line-point {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
}

/* ==========================================================================
   31. ACCESSIBILITY
   ========================================================================== */

/* Focus Visible */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border: #000;
        --text-light: #333;
    }
    
    .calc-input,
    .btn {
        border-width: 2px;
    }
}

/* Calc Tabs */
.calc-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
}
.calc-tab {
    padding: 8px 16px;
    background: #f1f5f9;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
    transition: all 0.2s;
}
.calc-tab:hover {
    background: #e2e8f0;
}
.calc-tab.active {
    background: #f97316;
    color: white;
}

/* ==========================================================================
   MATH KEYBOARD & AUTO-SUGGESTIONS
   ========================================================================== */

/* Input Wrapper */
.math-input-wrapper {
    position: relative;
    width: 100%;
    z-index: 10;
}

.math-input-wrapper:focus-within {
    z-index: 100;
}

.math-input-wrapper .input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.math-input-wrapper .calc-input,
.math-input-wrapper .math-input {
    flex: 1;
    min-width: 0;
}

/* Inline Row: Input + Keyboard + Solve (Desktop) */
.input-row-inline {
    display: flex;
    align-items: stretch;
    gap: 10px;
    width: 100%;
}

.input-row-inline .calc-input {
    flex: 1;
    min-width: 0;
    padding: 14px 18px;
    font-size: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: all var(--transition);
}

.input-row-inline .calc-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.input-row-inline .mk-toggle {
    flex-shrink: 0;
    width: 50px;
    height: auto;
}

.input-row-inline .calc-btn {
    flex-shrink: 0;
    padding: 14px 28px;
    white-space: nowrap;
}

/* Mobile styles moved to MOBILE LAYOUT IMPROVEMENTS section at end of file */

/* Keyboard Toggle Button */
.mk-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 20px;
    transition: all var(--transition);
    flex-shrink: 0;
}

.mk-toggle:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.mk-toggle.active {
    background: var(--primary);
    border-color: var(--primary);
}

/* Math Keyboard */
.math-keyboard {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 10px;
    padding: 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 9999;
    user-select: none;
}

.mk-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    justify-content: center;
}

.mk-row:last-child {
    margin-bottom: 0;
}

.mk-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 40px;
    padding: 0 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    font-family: var(--font-sans);
    color: var(--text);
    transition: all 0.15s ease;
}

.mk-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.mk-btn:active {
    background: #e2e8f0;
    transform: translateY(0);
}

/* Number keys */
.mk-btn[data-insert="0"],
.mk-btn[data-insert="1"],
.mk-btn[data-insert="2"],
.mk-btn[data-insert="3"],
.mk-btn[data-insert="4"],
.mk-btn[data-insert="5"],
.mk-btn[data-insert="6"],
.mk-btn[data-insert="7"],
.mk-btn[data-insert="8"],
.mk-btn[data-insert="9"],
.mk-btn[data-insert="."] {
    background: #ffffff;
    font-weight: 600;
}

/* Operator keys */
.mk-btn[data-insert="+"],
.mk-btn[data-insert="-"],
.mk-btn[data-insert="*"],
.mk-btn[data-insert="/"],
.mk-btn[data-insert="="] {
    background: #fff7ed;
    border-color: #fed7aa;
    color: var(--primary-dark);
    font-weight: 600;
}

.mk-btn[data-insert="+"]:hover,
.mk-btn[data-insert="-"]:hover,
.mk-btn[data-insert="*"]:hover,
.mk-btn[data-insert="/"]:hover,
.mk-btn[data-insert="="]:hover {
    background: #ffedd5;
    border-color: #fdba74;
}

/* Function keys (sqrt, sin, cos, etc.) */
.mk-btn[data-insert^="sqrt"],
.mk-btn[data-insert^="sin"],
.mk-btn[data-insert^="cos"],
.mk-btn[data-insert^="tan"],
.mk-btn[data-insert^="log"],
.mk-btn[data-insert^="ln"],
.mk-btn[data-insert^="asin"],
.mk-btn[data-insert^="acos"],
.mk-btn[data-insert^="atan"],
.mk-btn[data-insert^="abs"],
.mk-btn[data-insert^="cbrt"],
.mk-btn[data-insert^="root"] {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
    font-size: 14px;
}

.mk-btn[data-insert^="sqrt"]:hover,
.mk-btn[data-insert^="sin"]:hover,
.mk-btn[data-insert^="cos"]:hover,
.mk-btn[data-insert^="tan"]:hover,
.mk-btn[data-insert^="log"]:hover,
.mk-btn[data-insert^="ln"]:hover,
.mk-btn[data-insert^="asin"]:hover,
.mk-btn[data-insert^="acos"]:hover,
.mk-btn[data-insert^="atan"]:hover,
.mk-btn[data-insert^="abs"]:hover,
.mk-btn[data-insert^="cbrt"]:hover,
.mk-btn[data-insert^="root"]:hover {
    background: #dcfce7;
    border-color: #86efac;
}

/* Special constants */
.mk-btn[data-insert="pi"],
.mk-btn[data-insert="e"] {
    background: #faf5ff;
    border-color: #e9d5ff;
    color: #7c3aed;
    font-style: italic;
}

.mk-btn[data-insert="pi"]:hover,
.mk-btn[data-insert="e"]:hover {
    background: #f3e8ff;
    border-color: #d8b4fe;
}

/* Action row */
.mk-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
}

.mk-clear {
    flex: 1;
    background: #fef2f2 !important;
    border-color: #fecaca !important;
    color: #dc2626 !important;
}

.mk-clear:hover {
    background: #fee2e2 !important;
    border-color: #fca5a5 !important;
}

.mk-backspace {
    flex: 1;
    background: #f8fafc !important;
}

/* Auto-Suggestions Dropdown */
.math-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 6px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 9998;
    max-height: 350px;
    overflow-y: auto;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.1s ease;
    border-bottom: 1px solid #f1f5f9;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active {
    background: #fff7ed;
}

.suggestion-item.active {
    background: #ffedd5;
}

.suggestion-icon {
    font-size: 14px;
    color: #94a3b8;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.suggestion-text {
    flex: 1;
    font-size: 15px;
    color: var(--text);
    font-family: var(--font-mono);
    text-align: left;
}

.suggestion-text strong {
    color: var(--primary);
    font-weight: 600;
}

/* Keyboard visible state - hide suggestions */
.math-keyboard:not([style*="display: none"]) ~ .math-suggestions {
    display: none !important;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .math-keyboard {
        padding: 8px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        margin: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .mk-row {
        gap: 4px;
        margin-bottom: 4px;
        flex-wrap: wrap;
    }
    
    .mk-btn {
        min-width: 38px;
        height: 38px;
        padding: 0 6px;
        font-size: 14px;
        flex: 1 0 auto;
        max-width: calc(12.5% - 4px);
    }
    
    .mk-toggle {
        width: 40px;
        height: 40px;
    }
    
    .suggestion-item {
        padding: 14px 16px;
    }
    
    .suggestion-text {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .mk-btn {
        min-width: 34px;
        height: 36px;
        font-size: 13px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .math-keyboard {
        background: #1e293b;
        border-color: #334155;
    }
    
    .mk-btn {
        background: #334155;
        border-color: #475569;
        color: #f1f5f9;
    }
    
    .mk-btn:hover {
        background: #475569;
        border-color: #64748b;
    }
    
    .math-suggestions {
        background: #1e293b;
        border-color: #334155;
    }
    
    .suggestion-item {
        border-color: #334155;
    }
    
    .suggestion-item:hover,
    .suggestion-item.active {
        background: #334155;
    }
    
    .suggestion-text {
        color: #f1f5f9;
    }
}

/* ==========================================================================
   KATEX MATH RENDERING
   ========================================================================== */

/* Math display containers */
.math, .math-formula, .katex-render {
    font-size: 1.1em;
}

.math-display {
    display: block;
    text-align: center;
    margin: 15px 0;
    font-size: 1.3em;
}

/* Step formula styling - clean display for both LaTeX and plain text */
.step-formula {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 15px 20px;
    border-radius: var(--radius);
    margin: 10px 0;
    border-left: 4px solid var(--primary);
    font-size: 1.1em;
    overflow-x: auto;
    text-align: center;
}

/* Plain text formulas (non-LaTeX) */
.step-formula-plain {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    font-weight: 500;
    color: #1e293b;
    letter-spacing: 0.02em;
    white-space: nowrap;
    text-align: left;
}

/* Step calculation lines */
.step-calc {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    font-size: 1em;
    color: #334155;
    padding: 4px 0;
    letter-spacing: 0.01em;
}

/* LaTeX rendered answers */
.answer-latex {
    display: inline-block;
}

.answer-latex .katex {
    font-size: 1.3em;
}

/* Answer values - plain text fallback */
.answer-value {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    font-size: 1.2em;
    font-weight: 600;
    color: #0f172a;
}

/* Result main display */
.result-main {
    font-size: 1.2em;
    font-weight: 500;
}

/* KaTeX specific styling */
.step-formula .katex {
    font-size: 1.3em;
}

.katex {
    font-size: 1.1em;
    font-weight: normal;
}

.katex-display {
    margin: 0;
    text-align: center;
}

.katex-display > .katex {
    display: inline-block;
    text-align: initial;
}

/* Fraction styling */
.katex .frac-line {
    border-bottom-width: 0.08em;
}

/* Make sure formulas don't overflow on mobile */
@media (max-width: 640px) {
    .step-formula {
        padding: 12px 15px;
        font-size: 0.95em;
    }
    
    .step-formula .katex {
        font-size: 1.1em;
    }
    
    .step-calc {
        font-size: 0.9em;
    }
    
    .answer-latex .katex {
        font-size: 1.1em;
    }
    
    .katex {
        font-size: 1em;
    }
}

/* Result box math styling */
.result-box .katex {
    vertical-align: middle;
}

/* Solution steps math */
.step-body .katex {
    margin: 5px 0;
}

/* ==========================================================================
   FUNCTION GRAPHING
   ========================================================================== */

.math-graph-container {
    position: relative;
    width: 100%;
    max-width: 700px;
    margin: 20px auto;
    background: #ffffff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.math-graph-canvas {
    display: block;
    width: 100%;
    cursor: crosshair;
    touch-action: none;
}

/* Graph Toolbar */
.graph-toolbar {
    display: flex;
    gap: 5px;
    padding: 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.graph-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    color: var(--text);
    transition: all 0.15s ease;
}

.graph-btn:hover {
    background: #f1f5f9;
    border-color: var(--primary);
    color: var(--primary);
}

.graph-btn:active {
    transform: scale(0.95);
}

/* Graph Info Display */
.graph-info {
    position: absolute;
    bottom: 10px;
    right: 10px;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-light);
    pointer-events: none;
}

/* Responsive Graph */
@media (max-width: 640px) {
    .math-graph-container {
        border-radius: var(--radius);
    }
    
    .graph-toolbar {
        padding: 8px;
    }
    
    .graph-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

/* Graph Legend */
.graph-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 10px 15px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.graph-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.graph-legend-color {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

/* ==========================================================================
   GEOMETRY VISUALIZATIONS
   ========================================================================== */

.geometry-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 15px auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.geometry-container {
    text-align: center;
    margin: 20px 0;
}

/* Responsive geometry */
@media (max-width: 640px) {
    .geometry-canvas {
        max-width: 100%;
    }
}

/* ==========================================================================
   COPY & SHARE TOOLBAR
   ========================================================================== */

.share-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
    margin-top: 15px;
    border-top: 1px solid #e2e8f0;
}

.share-toolbar-group {
    display: flex;
    gap: 5px;
    position: relative;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.share-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.share-btn:active {
    transform: scale(0.98);
}

.share-btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.share-btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.share-btn.copy-success {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.share-btn.copy-error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* Share Dropdown */
.share-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    min-width: 160px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    overflow: hidden;
}

.share-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    text-align: left;
    transition: background 0.1s ease;
}

.share-dropdown-item:hover {
    background: #f8fafc;
}

.share-icon {
    font-size: 16px;
}

/* Inline Copy Button */
.copy-inline-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    padding: 0;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

*:hover > .copy-inline-btn {
    opacity: 1;
}

.copy-inline-btn:hover {
    background: #f1f5f9;
    border-color: var(--primary);
}

/* Mobile responsive */
@media (max-width: 640px) {
    .share-toolbar {
        justify-content: center;
    }
    
    .share-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .share-dropdown {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ==========================================================================
   DARK MODE
   ========================================================================== */

.dark-mode {
    --bg: #0f172a;
    --bg-alt: #1e293b;
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
}

.dark-mode body {
    background-color: var(--bg);
    color: var(--text);
}

.dark-mode .header {
    background: var(--bg-alt);
    border-bottom-color: var(--border);
}

.dark-mode .calc-box,
.dark-mode .card {
    background: var(--bg-alt);
    border-color: var(--border);
}

.dark-mode .calc-input,
.dark-mode input[type="text"],
.dark-mode input[type="number"],
.dark-mode textarea,
.dark-mode select {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

.dark-mode .calc-input:focus,
.dark-mode input:focus {
    border-color: var(--primary);
}

.dark-mode .step-item {
    background: var(--bg);
    border-color: var(--border);
}

.dark-mode .step-formula {
    background: var(--bg);
}

.dark-mode .result-box {
    background: var(--bg);
}

.dark-mode .result-box.green {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
}

.dark-mode .footer {
    background: var(--bg-alt);
    border-top-color: var(--border);
}

.dark-mode .footer a {
    color: var(--text-light);
}

.dark-mode .footer a:hover {
    color: var(--primary);
}

.dark-mode .sidebar {
    background: var(--bg-alt);
}

.dark-mode .home-list td {
    border-color: var(--border);
}

.dark-mode .home-list a {
    color: var(--text);
}

.dark-mode .cat-header {
    background: var(--bg);
    border-color: var(--border);
}

.dark-mode .breadcrumb {
    color: var(--text-light);
}

.dark-mode .breadcrumb a {
    color: var(--primary);
}

.dark-mode .calc-chip {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

.dark-mode .calc-chip:hover {
    background: var(--primary);
    color: white;
}

/* Math Keyboard Dark Mode */
.dark-mode .math-keyboard {
    background: var(--bg-alt);
    border-color: var(--border);
}

.dark-mode .mk-btn {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

.dark-mode .mk-btn:hover {
    background: var(--bg-alt);
    border-color: var(--primary);
}

.dark-mode .mk-toggle {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

/* Suggestions Dark Mode */
.dark-mode .math-suggestions {
    background: var(--bg-alt);
    border-color: var(--border);
}

.dark-mode .suggestion-item {
    border-color: var(--border);
}

.dark-mode .suggestion-item:hover,
.dark-mode .suggestion-item.active {
    background: var(--bg);
}

.dark-mode .suggestion-text {
    color: var(--text);
}

/* Share Toolbar Dark Mode */
.dark-mode .share-toolbar {
    border-color: var(--border);
}

.dark-mode .share-btn {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

.dark-mode .share-btn:hover {
    background: var(--bg-alt);
}

.dark-mode .share-dropdown {
    background: var(--bg-alt);
    border-color: var(--border);
}

.dark-mode .share-dropdown-item:hover {
    background: var(--bg);
}

/* Graph Dark Mode */
.dark-mode .math-graph-container {
    background: var(--bg-alt);
}

.dark-mode .graph-toolbar {
    background: var(--bg);
    border-color: var(--border);
}

.dark-mode .graph-btn {
    background: var(--bg-alt);
    border-color: var(--border);
    color: var(--text);
}

/* Dark Mode Toggle Button */
.dark-mode-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.3);
    z-index: 1000;
    transition: transform 0.2s ease;
}

.dark-mode-toggle:hover {
    transform: scale(1.1);
}

.dark-mode .dark-mode-toggle {
    background: #fbbf24;
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3);
}

/* ==========================================================================
   STEP TOGGLE / COLLAPSIBLE STEPS
   ========================================================================== */

/* Step Controls Bar */
.step-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
}

.step-control-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    color: var(--text-light);
    transition: all 0.15s ease;
}

.step-control-btn:hover {
    background: #f1f5f9;
    border-color: var(--primary);
    color: var(--primary);
}

.step-control-icon {
    font-size: 10px;
}

.step-control-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    font-size: 13px;
    color: var(--text-light);
    cursor: pointer;
}

.step-control-toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Collapsible Step Header */
.step-header {
    position: relative;
    padding-right: 30px;
}

.step-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-light);
    transition: transform 0.2s ease;
}

.step-collapsed .step-toggle {
    transform: translateY(-50%) rotate(-90deg);
}

/* Step Body Animation */
.step-body,
.step-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.step-body.collapsed,
.step-content.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
}

/* Compact Mode */
.steps-compact .step-body,
.steps-compact .step-content {
    font-size: 0.9em;
}

.steps-compact .step-formula {
    padding: 10px 15px;
    font-size: 1em;
}

.steps-compact .step-item,
.steps-compact .step {
    padding: 10px 15px;
}

/* Hover effect on header */
.step-header:hover {
    background: rgba(249, 115, 22, 0.05);
    border-radius: var(--radius-sm);
}

/* Focus state for accessibility */
.step-header:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.step-header:focus:not(:focus-visible) {
    outline: none;
}

/* Step controls stay inline on all screen sizes */

/* ==========================================================================
   DARK MODE
   ========================================================================== */

.dark-mode {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --border: #334155;
    --primary: #fb923c;
    --primary-dark: #f97316;
}

.dark-mode body {
    background: var(--bg);
    color: var(--text);
}

.dark-mode .header {
    background: var(--bg-card);
    border-bottom-color: var(--border);
}

.dark-mode .calc-box,
.dark-mode .card {
    background: var(--bg-card);
    border-color: var(--border);
}

.dark-mode .calc-input,
.dark-mode input[type="text"],
.dark-mode input[type="number"],
.dark-mode textarea,
.dark-mode select {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

.dark-mode .calc-input:focus,
.dark-mode input:focus {
    border-color: var(--primary);
}

.dark-mode .result-box {
    background: rgba(251, 146, 60, 0.1);
    border-color: var(--primary);
}

.dark-mode .step-item,
.dark-mode .step {
    background: rgba(255, 255, 255, 0.02);
    border-color: var(--border);
}

.dark-mode .step-formula {
    background: rgba(255, 255, 255, 0.05);
}

.dark-mode .footer {
    background: var(--bg-card);
    border-top-color: var(--border);
}

.dark-mode .footer a {
    color: var(--text-light);
}

.dark-mode .footer a:hover {
    color: var(--primary);
}

.dark-mode .sidebar {
    background: var(--bg-card);
    border-color: var(--border);
}

.dark-mode .breadcrumb a {
    color: var(--text-light);
}

.dark-mode .home-list a {
    color: var(--text);
}

.dark-mode .cat-header {
    background: var(--bg-card);
    border-color: var(--border);
}

.dark-mode .share-btn,
.dark-mode .step-control-btn {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text-light);
}

.dark-mode .share-dropdown {
    background: var(--bg-card);
    border-color: var(--border);
}

.dark-mode .share-dropdown-item:hover {
    background: var(--bg);
}

.dark-mode .math-keyboard {
    background: var(--bg-card);
    border-color: var(--border);
}

.dark-mode .mk-btn {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

.dark-mode .mk-btn:hover {
    background: #334155;
}

.dark-mode .math-suggestions {
    background: var(--bg-card);
    border-color: var(--border);
}

.dark-mode .suggestion-item {
    border-color: var(--border);
}

.dark-mode .suggestion-item:hover,
.dark-mode .suggestion-item.active {
    background: var(--bg);
}

.dark-mode .math-graph-container {
    background: var(--bg-card);
}

.dark-mode .graph-toolbar {
    background: var(--bg);
    border-color: var(--border);
}

.dark-mode .graph-btn {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text);
}

/* Dark mode toggle button */
.dark-mode-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark-mode-toggle:hover {
    transform: scale(1.1);
}

.dark-mode .dark-mode-toggle {
    background: #334155;
}

/* Scrollbar in dark mode */
.dark-mode ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.dark-mode ::-webkit-scrollbar-track {
    background: var(--bg);
}

.dark-mode ::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Print - always light mode */
@media print {
    .dark-mode {
        --bg: #ffffff;
        --bg-card: #ffffff;
        --text: #000000;
        --text-light: #333333;
        --border: #cccccc;
    }
}

/* Dark Mode Button in Header */
.dark-mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
}

.dark-mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dark-mode .dark-mode-btn .dark-mode-icon::after {
    content: '☀️';
}

.dark-mode .dark-mode-btn .dark-mode-icon {
    font-size: 0;
}

.dark-mode .dark-mode-btn .dark-mode-icon::after {
    font-size: 18px;
}

/* ==========================================================================
   CALCULATOR PAGE SPECIFIC STYLES
   ========================================================================== */

/* Input labels in forms */
.input-label {
    font-size: 16px;
    color: var(--text-light);
    font-weight: 500;
    white-space: nowrap;
}

/* Result box variations */
.result-box.red {
    background: #fef2f2;
    border-color: #fecaca;
}

.result-box.red .result-main,
.result-box.red .result-value {
    color: #dc2626;
}

/* Links grid for popular calculations */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.link-card {
    display: block;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition);
}

.link-card:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

/* Data tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.data-table th,
.data-table td {
    padding: 10px 15px;
    border: 1px solid var(--border);
    text-align: center;
}

.data-table th {
    background: var(--bg);
    font-weight: 600;
}

.data-table tr:hover {
    background: var(--primary-bg);
}

/* Smaller inputs in inline row */
.input-row-inline input[style*="width:80px"] {
    width: 80px !important;
    min-width: 80px !important;
    flex: 0 0 80px !important;
}

@media (max-width: 600px) {
    .input-row-inline input[style*="width:80px"] {
        width: 70px !important;
        min-width: 70px !important;
        flex: 0 0 70px !important;
    }
    
    .input-label {
        font-size: 14px;
    }
}

/* ==========================================================================
   CALCULATOR INPUT FIXES
   ========================================================================== */

/* Number inputs in calc-input-group only - for number calculators */
.calc-input-group input[type="number"] {
    flex: 0 0 100px;
    min-width: 80px;
    max-width: 120px;
    padding: 14px 18px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: all var(--transition);
    text-align: center;
}

.calc-input-group input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

/* Mobile adjustments for calc-input-group */
@media (max-width: 600px) {
    .calc-input-group input[type="number"] {
        flex: 0 0 80px;
        max-width: 100px;
        padding: 12px 14px;
        font-size: 15px;
    }
    
    .calc-input-group .input-label {
        font-size: 14px;
    }
    
    .calc-input-group .calc-btn {
        margin-top: 10px;
        width: 100%;
        flex: 0 0 100%;
    }
}

/* ==========================================================================
   CALCULATOR INPUT GROUP - STABLE LAYOUT
   ========================================================================== */

.calc-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.calc-input-num {
    width: 100px;
    padding: 12px 16px;
    font-size: 18px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.calc-input-num:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.calc-input-group .input-label {
    font-size: 16px;
    color: var(--text);
    font-weight: 500;
}

.calc-input-group .calc-btn {
    padding: 12px 24px;
}

@media (max-width: 500px) {
    .calc-input-group {
        gap: 8px;
    }
    
    .calc-input-num {
        width: 80px;
        padding: 10px 12px;
        font-size: 16px;
    }
    
    .calc-input-group .calc-btn {
        width: 100%;
        margin-top: 8px;
    }
}

/* ==========================================================================
   STEP CONTENT - BETTER FORMATTING (NO EXCESSIVE BULLETS)
   ========================================================================== */

.step-content {
    padding: 0;
}

.step-content p {
    margin: 0 0 8px 0;
    line-height: 1.6;
    color: var(--text);
}

.step-content p:last-child {
    margin-bottom: 0;
}

.step-content .step-label {
    font-weight: 600;
    color: var(--text);
    margin-top: 12px;
}

.step-content .step-calc {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    background: var(--bg);
    padding: 6px 12px;
    margin: 4px 0;
    border-radius: var(--radius);
    display: inline-block;
    font-size: 15px;
}

.step-content .step-highlight {
    background: var(--primary-bg);
    padding: 10px 15px;
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
    margin: 12px 0;
}

.step-content .step-result {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-top: 10px;
}

/* ==========================================================================
   CALCULATOR GRID FOR INDEX PAGES
   ========================================================================== */

.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin: 25px 0;
}

.calc-card {
    display: block;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all var(--transition);
}

.calc-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.calc-card-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.calc-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.calc-card-desc {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.5;
}

/* Quick table for factorial, etc. */
.quick-table {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin: 15px 0;
}

.quick-table div {
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius);
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 14px;
}

@media (max-width: 600px) {
    .calc-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   DARK MODE - Autocomplete & Quick Examples
   ========================================================================== */

.dark-mode .autocomplete-dropdown {
    background: var(--card-bg);
    border-color: var(--border);
}

.dark-mode .autocomplete-item {
    border-bottom-color: var(--border);
}

.dark-mode .autocomplete-item:hover,
.dark-mode .autocomplete-item.selected {
    background: var(--bg);
}

.dark-mode .autocomplete-item .ac-text {
    color: var(--text);
}

.dark-mode .quick-examples button {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text);
}

.dark-mode .quick-examples button:hover {
    background: var(--primary);
    color: var(--white);
}

.dark-mode .error-suggestions {
    background: var(--card-bg);
}

.dark-mode .error-suggestions .suggestion-btn {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

.dark-mode .error-suggestions .suggestion-btn:hover {
    background: var(--primary);
    color: var(--white);
}

/* ==========================================================================
   MOBILE LAYOUT IMPROVEMENTS v2.1
   - Reduced padding on mobile
   - Better input field sizing
   - Stacked layout for forms
   ========================================================================== */

/* Tablet improvements */
@media (max-width: 900px) {
    .content-wrap {
        padding: 20px 15px;
        gap: 20px;
    }
    
    .container {
        padding: 0 15px;
    }
}

/* Mobile improvements - padding reductions */
@media (max-width: 600px) {
    /* Remove extra padding on mobile */
    .content-wrap {
        padding: 15px 10px;
        gap: 15px;
    }
    
    .container {
        padding: 0 10px;
    }
    
    .header-inner {
        padding: 0 10px;
    }
    
    /* Calculator box - reduced padding */
    .calc-box {
        padding: 0;
        border-radius: var(--radius);
    }
    
    .calc-box .calc-section {
        padding: 15px;
    }
    
    .calc-box .steps-section {
        padding: 15px;
    }
    
    .calc-box .calc-section form {
        margin-bottom: 15px;
    }
    
    .input-row-inline .calc-input {
        padding: 14px 16px;
        min-height: 52px;
    }
    
    .input-row-inline .calc-btn {
        padding: 14px 20px;
    }
    
    /* Result display */
    .result-box {
        padding: 15px;
    }
    
    /* Answer display */
    .answer-display {
        padding: 12px 15px;
        margin-top: 12px;
    }
    
    /* Steps section */
    .step-item {
        padding: 12px;
        margin-bottom: 10px;
    }
    
    .step-header {
        gap: 8px;
        margin-bottom: 8px;
    }
    
    .step-formula {
        padding: 10px 12px;
    }
    
    /* Info sections */
    .info-section {
        padding: 15px;
        margin-top: 20px;
    }
    
    /* Related calculators */
    .related-section {
        margin-top: 20px;
    }
    
    .related-links {
        gap: 8px;
    }
    
    .related-links a {
        padding: 6px 12px;
    }
    
    /* Quick examples */
    .quick-examples {
        margin-top: 12px;
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .quick-examples a {
        padding: 6px 10px;
    }
    
    /* Home page list */
    .home-list li {
        padding: 8px 0;
    }
    
    .cat-header {
        padding: 10px 12px;
        margin-top: 20px;
    }
    
    /* Links grid */
    .links-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .link-card {
        padding: 10px 12px;
    }
    
    /* Sidebar on mobile */
    .side-col {
        margin-top: 20px;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    .content-wrap {
        padding: 10px 8px;
    }
    
    .container {
        padding: 0 8px;
    }
    
    .header-inner {
        padding: 0 8px;
    }
    
    .calc-box .calc-section {
        padding: 12px;
    }
    
    .calc-box .steps-section {
        padding: 12px;
    }
    
    .input-row-inline .calc-input {
        padding: 12px 14px;
    }
    
    .input-row-inline .calc-btn {
        padding: 12px 16px;
    }
}

/* Prevent iOS zoom on input focus */
@media (max-width: 600px) {
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px !important;
    }
}
