:root {
    --primary: #2c3e50;
    --secondary: #ff6b6b;
    --accent: #3d5a80;
    --light-bg: #f8f9fa;
    --teal: #4ecdc4;
    --border-color: #e0e0e0;
    --text-color: #000000;
    --text-light: #666;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #000;
    background-color: var(--light-bg);
}

h1 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: #000;
}

h2 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    color: #ff6b6b;
}

h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #000;
}

h4 {
    color: #000;
    font-size: 0.9375rem;
}

@media (min-width: 768px) {
    h1 {
        font-size: 1.5rem;
    }
    h2 {
        font-size: 1.25rem;
    }
    h3 {
        font-size: 1.125rem;
    }
    h4 {
        font-size: 1rem;
    }
}

@media (min-width: 1025px) {
    h2 {
        font-size: 1.375rem;
    }
    h3 {
        font-size: 1.25rem;
    }
    h4 {
        font-size: 1.125rem;
    }
}

.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    padding: 0px 15px;
}

.calculator-container {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    width: 100%;
}

.header {
    background-color: white;
    color: black;
    padding: 0px 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    background-color: var(--light-bg);
    border-bottom: 1px solid var(--border-color);
}

.tab {
    padding: 12px 20px;
    cursor: pointer;
    background-color: transparent;
    border: none;
    font-size: 0.875rem;
    color: #000;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
}

@media (min-width: 1025px) {
    .tab {
        font-size: 1rem;
    }
}

.tab:hover {
    color: var(--accent);
}

.tab.active {
    color: var(--accent);
    border-bottom: 3px solid var(--accent);
    font-weight: bold;
}

.content {
    padding: 20px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.section {
    margin-bottom: 25px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--teal);
    color: #000;
    font-size: 1.25rem;
}

.section-title i {
    color: var(--teal);
    font-size: 1.375rem;
}

.input-group {
    margin-bottom: 20px;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

@media (min-width: 500px) {
    .input-row {
        grid-template-columns: 1fr 1fr;
    }
}

.input-container {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #000;
}

label i {
    font-size: 1.125rem;
}

input, select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    color: #000;
    transition: var(--transition);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(61, 90, 128, 0.2);
}

.collapsible {
    background-color: var(--light-bg);
    padding: 10px 15px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    transition: var(--transition);
    color: #000;
}

.collapsible:hover {
    background-color: #e9ecef;
}

.collapsible-content {
    display: none;
    padding: 15px;
    background-color: var(--light-bg);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    font-size: 1rem;
}

.btn-calculate {
    background-color: var(--accent);
    color: white;
}

.btn-reset {
    background-color: var(--secondary);
    color: white;
}

.btn-export {
    background-color: var(--teal);
    color: white;
}

.results-section {
    display: none;
    margin-top: 30px;
}

.card {
    background-color: var(--light-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.result-value {
    font-size: 1.25rem;
    font-weight: bold;
    text-align: center;
    margin: 15px 0;
    color: #000;
}

.visualization {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 20px 0;
}

@media (min-width: 768px) {
    .visualization {
        grid-template-columns: 1fr 1fr;
    }
}

.chart-container {
    height: 250px;
    background: white;
    padding: 15px;
    border-radius: var(--radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Fix for mobile: horizontal scrolling for fraction details */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin: 15px 0;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Ensure table has a minimum width to enable scrolling */
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: #000;
}

th {
    background-color: var(--light-bg);
    font-weight: bold;
    color: #000;
    font-size: 1rem;
}

tbody tr:hover {
    background-color: rgba(78, 205, 196, 0.05);
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--primary);
    color: white;
    padding: 12px 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ad-container {
    display: none;
    background-color: var(--light-bg);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: #000;
    font-weight: bold;
    text-align: center;
    padding: 20px;
}

/* Fix for tablet: hide mobile ad */
@media (min-width: 768px) {
    #ad-mobile {
        display: none !important;
        
    }
}

.export-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.desktop-sidebar {
    position: sticky;
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.related-tools-section {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin: 20px auto 0; /* auto centers the div horizontally */
    width: 90%; /* or 80% for bigger gaps */
}

.related-tools-section h3 {
    margin-bottom: 15px;
    color: #000;
    border-bottom: 2px solid var(--teal);
    padding-bottom: 8px;
    text-align: center;
}

.simple-tools-list {
    list-style: none;
    padding: 0;
}

.simple-tools-list li {
    margin-bottom: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.simple-tools-list li:last-child {
    border-bottom: none;
}

.simple-tools-list a {
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.simple-tools-list a:hover {
    color: #ff6b6b;
}

.simple-tools-list i {
    color: var(--teal);
    width: 25px;
}

.related-tools-sidebar {
    background: white;
    border-radius: var(--radius);
    padding: 15px;
    box-shadow: var(--shadow);
    display: none;
}

.related-tools-sidebar h4 {
    margin-bottom: 12px;
    color: #000;
    border-bottom: 2px solid var(--teal);
    padding-bottom: 6px;
    text-align: left;
    font-size: 1rem;
}

.simple-tools-list-sidebar {
    list-style: none;
    padding: 0;
}

.simple-tools-list-sidebar li {
    margin-bottom: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #eee;
    font-size: 1rem;
}

.simple-tools-list-sidebar li:last-child {
    border-bottom: none;
}

.simple-tools-list-sidebar a {
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.simple-tools-list-sidebar a:hover {
    color: #ff6b6b;
}

.simple-tools-list-sidebar i {
    color: var(--teal);
    width: 20px;
    font-size: 0.8rem;
}

/* Mobile (≤767px) */
#ad-mobile {
    display: block;
    max-width: 80%;
    margin: 20px auto 0;
}

#ad-mobile .ad-placeholder {
    height: 100px;
}

/* Tablet (768px–1024px) */
@media (min-width: 768px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .input-row {
        grid-template-columns: 1fr 1fr;
    }
    
    #ad-tablet {
        display: block;
        max-width: 300px;
        margin: 30px auto 0;
    }
    
    #ad-tablet .ad-placeholder {
        height: 250px;
    }
    
    /* Hide mobile ad on tablet */
    #ad-mobile {
        display: none;
    }
}

/* Desktop (≥1025px) */
@media (min-width: 1025px) {
    .container {
        grid-template-columns: 300px 1fr 300px;
        gap: 20px;
        align-items: start;
    }
    
    .desktop-sidebar {
        position: sticky;
        top: 10px;
        height: fit-content;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    #ad-left, #ad-right {
        display: block;
    }
    
    #ad-left .ad-placeholder {
        height: 250px;
    }
    
    #ad-right .ad-placeholder {
        height: 600px;
    }
    
    #ad-tablet {
        display: none;
    }
    
    #ad-mobile {
        display: none;
    }
    
    .related-tools-sidebar {
        display: block;
        position: sticky;
        top: 290px; /* Position after the ad (250px height + 20px gap) */
    }

    .related-tools-section {
        display: none;
    }
}

.mixed-fraction-inputs {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

.mixed-fraction-inputs input {
    width: 100%;
    text-align: center;
}

.mixed-fraction-inputs .fraction-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 10px;
    color: #000;
}

.plain-text-report {
    font-family: monospace;
    white-space: pre;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.5;
    color: #000;
}

.conversion-examples {
    margin-top: 15px;
    padding: 12px;
    background-color: #f0f8ff;
    border-radius: 8px;
    border-left: 4px solid #3d5a80;
    font-size: 0.9rem;
    color: #000;
}

.conversion-examples h4 {
    margin-bottom: 8px;
    color: #000;
}

.conversion-examples ul {
    padding-left: 20px;
}

.conversion-examples li {
    margin-bottom: 5px;
    color: #000;
}

.breadcrumb {
    padding: 0px 10px;
    color: #000;
    margin-bottom: 5px;
    font-size: 1rem;
}

.breadcrumb a {
    color: #000;
    text-decoration: none;
    transition: color 0.3s;
}

.breadcrumb a:hover {
    color: var(--secondary);
    text-decoration: underline;
}

.mobile-table {
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid #eee;
    border-radius: 8px;
}

.mobile-table table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
}

.mobile-table th, .mobile-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    color: #000;
}

.mobile-table th {
    background-color: #4ecdc4;
    font-weight: bold;
    font-size: 1rem;
}

.mobile-table tr:nth-child(even) {
    background-color: #fafafa;
}