body {
    font-family: var(--font-body);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    color: inherit;
}

header, main, footer {
    padding: 20px;
}
#search-bar {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    background-color: #fff;
    color: #333;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
#categories, #popular-tools, #new-tools, #featured-tools {
    margin-bottom: 20px;
}
@media (min-width: 768px) {
    #categories, #popular-tools, #new-tools, #featured-tools {
        display: flex;
        flex-wrap: wrap;
    }
    #categories div, #popular-tools div, #new-tools div, #featured-tools div {
        flex: 1 1 30%;
        margin: 10px;
    }
}

.main-header {
    background-color: #f8f9fa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.search-container {
    display: flex;
    gap: 10px;
    width: 50%;
    position: relative;
    z-index: 100;
}

#search-button {
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

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

.suggestion-item:hover {
    background-color: #f8f9fa;
}

@media (max-width: 767px) {
    .nav-container {
        flex-direction: column;
        padding: 1rem;
        gap: 10px;
    }

    .search-container {
        width: 100%;
        margin: 10px 0;
    }

    #search-bar {
        height: 44px;
        font-size: 16px;
        padding: 8px 12px;
    }

    #search-button {
        height: 44px;
        min-width: 80px;
        font-size: 16px;
    }

    .search-suggestions {
        max-height: 50vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .suggestion-item {
        padding: 12px 15px;
        font-size: 16px;
    }
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.category-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
    z-index: 1;
}

.category-card:hover {
    transform: translateY(-5px);
    z-index: 10;
}

.category-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 100;
    width: 250px;
    display: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.category-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid rgba(0, 0, 0, 0.9);
}

.category-tooltip ul {
    margin: 10px 0 0 0;
    padding-left: 20px;
    list-style-type: disc;
}

.category-tooltip li {
    margin: 5px 0;
    color: #fff;
}

.category-card:hover .category-tooltip {
    display: block;
}

.tool-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.tool-card:hover {
    transform: translateY(-5px);
}

.tool-link {
    display: inline-block;
    padding: 8px 16px;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    margin-top: 10px;
}

.logo a {
    color: #333;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
}

.tool-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.tool-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#tool-interface {
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#tool-result {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 4px;
    min-height: 100px;
}

@media (min-width: 768px) {
    .tool-content {
        grid-template-columns: 1fr 1fr;
    }
}

.converter-container {
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.converter-container textarea {
    width: 100%;
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.form-control {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.form-select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 120px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-primary {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 15px;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin: 0 10px;
}

.swap-icon {
    font-size: 1.2em;
    font-weight: bold;
}

.buttons-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
}

.error {
    color: #dc3545;
    padding: 10px;
    background: #f8d7da;
    border-radius: 4px;
    margin-top: 10px;
}

.loading {
    position: relative;
    min-height: 200px;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.categories-nav {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    overflow-x: auto;
    margin-bottom: 20px;
}

.category-tab {
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
}

.category-tab.active {
    background: #007bff;
    color: white;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.breadcrumb {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 20px;
}

.breadcrumb a {
    color: #007bff;
    text-decoration: none;
}

.breadcrumb span::before {
    content: '/';
    margin: 0 10px;
    color: #6c757d;
}

.usage-count {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 10px;
}

.category-name {
    color: #6c757d;
    font-size: 0.9rem;
    margin-top: 5px;
}

.rate-info {
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9em;
}

.calculator-container {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.calculator-display {
    padding: 20px;
    background: #fff;
}

.calc-display {
    width: 100%;
    height: 60px;
    font-size: 2em;
    text-align: right;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.calculator-keys {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: #ddd;
    padding: 1px;
}

.calc-btn {
    padding: 20px;
    font-size: 1.2em;
    border: none;
    background: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.calc-btn:hover {
    background: #f0f0f0;
}

.calc-btn.operator {
    background: #f8f9fa;
}

.calc-btn.equals {
    background: #007bff;
    color: white;
}

.calc-history {
    font-size: 0.9em;
    color: #6c757d;
    min-height: 20px;
    margin-top: 5px;
}

.calculator-container {
    display: flex;
    max-width: 800px;
    margin: 0 auto;
    gap: 20px;
}

.calculator-history-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    display: none;
}

.calculator-history-panel.show {
    display: block;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.history-list {
    max-height: calc(80vh - 120px);
    overflow-y: auto;
    margin-bottom: 15px;
}

#close-history {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 5px;
}

.history-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}

.history-backdrop.show {
    display: block;
}

.history-item {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.history-item:hover {
    transform: translateX(5px);
    background: #e9ecef;
}

.history-operation {
    font-size: 1.1em;
    color: #333;
    margin-bottom: 5px;
    font-family: monospace;
    white-space: nowrap;
}

.history-timestamp {
    font-size: 0.8em;
    color: #6c757d;
    font-style: italic;
}

.history-expression {
    color: #6c757d;
    font-size: 0.9em;
}

.history-result {
    font-weight: bold;
}

.history-timestamp {
    font-size: 0.8em;
    color: #999;
}

.calculator-main {
    flex: 1;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.calculator-keys.scientific {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(8, 1fr);
}

.sci-btn {
    background: #e9ecef;
    font-size: 1em;
}

.sci-btn:hover {
    background: #dee2e6;
}

.calculator-header {
    padding: 10px;
    text-align: right;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.calculator-history-panel {
    width: 300px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    position: absolute;
    right: -310px;
    top: 0;
    bottom: 0;
    transition: right 0.3s ease;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
}

.calculator-history-panel.show {
    right: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-icon {
    font-size: 1.1em;
    margin-right: 5px;
}

#close-history {
    font-size: 1.5em;
    padding: 0 8px;
    line-height: 1;
}

.calculator-container {
    position: relative;
    overflow: hidden;
}

.calculator-main {
    position: relative;
    z-index: 1;
}

.calculator-history-panel {
    position: fixed;
    width: 320px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    display: none;
    padding: 20px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.history-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.2em;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
    margin: -5px -10px;
    padding: 5px 10px;
}

.history-item {
    padding: 12px 15px;
    border-radius: 8px;
    background: #f8f9fa;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.history-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
}

#clear-history {
    width: 100%;
    margin-top: 15px;
    background: #dc3545;
    border: none;
}

#close-history {
    background: transparent;
    color: #666;
    font-size: 24px;
    padding: 0;
    margin: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

#close-history:hover {
    background: #f0f0f0;
    color: #333;
}

.number-inputs {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.number-inputs .input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.number-inputs label {
    font-weight: bold;
    color: #333;
}

.bit-operations {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.bit-count {
    color: #6c757d;
    font-size: 0.8em;
}

.text-converter {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 20px;
}

.text-input, .text-output {
    grid-column: 1;
}

.conversion-options {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.conversion-options button {
    width: 100%;
    text-align: left;
    padding: 12px 15px;
}

.text-stats {
    display: flex;
    justify-content: space-between;
    color: #6c757d;
    font-size: 0.9em;
    margin-top: 5px;
}

.json-tool {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
}

.json-tool .input-section,
.json-tool .output-section {
    width: 100%;
}

.json-tool textarea,
.json-tool pre {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
}

.json-actions {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.json-output {
    background: #f8f9fa;
    white-space: pre-wrap;
    overflow-x: auto;
}

.format-options {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-left: auto;
}

.error-message {
    color: #dc3545;
    padding: 10px;
    margin-bottom: 10px;
    background: #f8d7da;
    border-radius: 4px;
    display: none;
}

.error-message:not(:empty) {
    display: block;
}

/* JSON Tool specific styles */
.json-actions button {
    margin: 0 5px;
    min-width: 100px;
}

.json-actions button:hover {
    opacity: 0.9;
}

#jsonInput, #jsonOutput {
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
    padding: 15px;
}

#jsonOutput {
    background: #f8f9fa;
    min-height: 100px;
}

.base64-tool {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.base64-tool textarea {
    width: 100%;
    min-height: 200px;
    font-family: monospace;
    margin-bottom: 15px;
}

.base64-actions {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
}

.color-preview {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
}

.color-box {
    width: 100px;
    height: 100px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.color-inputs {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.color-inputs .input-group {
    display: flex;
    align-items: center;
}

.color-inputs label {
    width: 60px;
    font-weight: bold;
}

.color-preview {
    width: 100%;
    margin-bottom: 30px;
}

.preview-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.color-box {
    width: 200px;
    height: 100px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.color-label {
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

#colorPicker {
    width: 200px;
    height: 40px;
    padding: 5px;
    cursor: pointer;
}

.color-inputs {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 20px;
}

.color-inputs .input-group {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.color-inputs label {
    width: 60px;
    font-weight: bold;
    color: #333;
}

.color-inputs input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
}

.unit-type-selector {
    width: 100%;
    margin-bottom: 20px;
    text-align: center;
}

.unit-type-selector select {
    width: 200px;
    padding: 10px;
    font-size: 1.1em;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f8f9fa;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.input-section .input-group {
    display: flex;
    gap: 10px;
    width: 100%;
}

.input-section input[type="number"] {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1.1em;
}

.input-section select {
    min-width: 150px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f8f9fa;
}

#swapUnits {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f8f9fa;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: transform 0.2s;
}

#swapUnits:hover {
    transform: rotate(180deg);
    background: #e9ecef;
}

.conversion-info {
    margin-top: 20px;
    text-align: center;
}

/* Image Base64 Tool Styles */
.image-to-base64-mode,
.base64-to-image-mode {
    width: 100%;
    margin-bottom: 20px;
}

.file-input-section {
    border: 2px dashed #ddd;
    padding: 20px;
    text-align: center;
    border-radius: 8px;
    margin-bottom: 20px;
}

.file-input-section:hover {
    border-color: #007bff;
    background: #f8f9fa;
}

.preview-section {
    max-width: 100%;
    overflow: hidden;
    margin: 20px 0;
    text-align: center;
}

.image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: none;
}

.image-preview.show {
    display: inline-block;
}

#base64Output {
    font-family: monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
}

.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.mode-selector button {
    padding: 10px 20px;
}

.mode-selector button.active {
    background: #0056b3;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px;
}

.tool-count {
    display: inline-block;
    background: #f0f0f0;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    margin-top: 10px;
}
