* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-color: #1f2937;
    --light-color: #f3f4f6;
    --border-color: #e5e7eb;
    --text-color: #374151;
    --text-light: #6b7280;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #ffffff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation */
.navbar {
    background-color: #ffffff;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 1rem 0;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 800;
}

.subtitle {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

.hero-features {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    font-size: 1rem;
}

.hero-features span {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

/* Calculator Section */
.calculator-section {
    padding: 3rem 0;
}

.calculator-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    max-width: 900px;
    margin: 0 auto;
}

.calculator-card h2 {
    text-align: center;
    color: var(--dark-color);
    margin-bottom: 2rem;
    font-size: 2rem;
}

.input-group {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.input-wrapper {
    flex: 1;
    min-width: 200px;
}

.input-wrapper label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 600;
}

.input-wrapper input {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.125rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.division-symbol {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.calculator-options {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    min-width: 150px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: var(--text-light);
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-tertiary {
    background-color: var(--success-color);
    color: white;
}

.btn-tertiary:hover {
    background-color: #059669;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-width: auto;
}

/* Result Container */
.result-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: var(--light-color);
    border-radius: 8px;
    display: none;
}

.result-container.active {
    display: block;
}

.result-summary {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 1rem;
    text-align: center;
}

.result-details {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.result-details h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.division-steps {
    margin-top: 1rem;
}

.step-item {
    padding: 1rem;
    background-color: var(--light-color);
    margin-bottom: 0.5rem;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-number {
    display: inline-block;
    width: 30px;
    height: 30px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 30px;
    margin-right: 0.5rem;
    font-weight: bold;
}

/* Visualization */
.visualization-container {
    margin-top: 2rem;
    display: none;
}

.visualization-container.active {
    display: block;
}

.long-division-visual {
    font-family: 'Courier New', monospace;
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 1.125rem;
    line-height: 1.8;
    border: 2px solid var(--border-color);
}

/* Mode Switcher */
.mode-switcher {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background-color: var(--light-color);
    padding: 0.5rem;
    border-radius: 8px;
}

.mode-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    background-color: transparent;
    color: var(--text-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.mode-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.mode-btn:hover:not(.active) {
    background-color: rgba(37, 99, 235, 0.1);
}

.calculation-mode {
    display: none;
}

.calculation-mode.active {
    display: block;
}

.input-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Quick Calculations */
.quick-calculations {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.quick-calc-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.quick-tab {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background-color: white;
    color: var(--text-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.quick-tab.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.quick-tab:hover:not(.active) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.quick-calculations h3 {
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.quick-calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.quick-calc-btn {
    padding: 1rem;
    background-color: var(--light-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 1rem;
}

.quick-calc-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* History Section */
.history-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.history-section h3 {
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.history-item {
    padding: 0.75rem;
    background-color: var(--light-color);
    margin-bottom: 0.5rem;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
}

.history-item:hover {
    background-color: #e5e7eb;
}

.history-item-content {
    font-weight: 500;
}

.history-item-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Features Section */
.features-section {
    padding: 4rem 0;
    background-color: var(--light-color);
}

.features-section h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: var(--dark-color);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    color: var(--dark-color);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.feature-card p {
    color: var(--text-light);
    line-height: 1.6;
}

/* Content Sections */
.content-section {
    padding: 4rem 0;
}

.content-section.bg-light {
    background-color: var(--light-color);
}

.content-section h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--dark-color);
    text-align: center;
}

.content-section h3 {
    font-size: 1.75rem;
    margin: 2rem 0 1rem;
    color: var(--dark-color);
}

.content-box {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 900px;
    margin: 0 auto;
}

.content-box p {
    margin-bottom: 1rem;
    line-height: 1.8;
    color: var(--text-color);
}

.content-box ul {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.content-box li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

/* Steps Container */
.steps-container {
    max-width: 800px;
    margin: 2rem auto;
}

.step {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.step .step-number {
    width: 50px;
    height: 50px;
    line-height: 50px;
    flex-shrink: 0;
    font-size: 1.5rem;
}

.step-content h3 {
    color: var(--dark-color);
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
}

.step-content p {
    color: var(--text-light);
    margin: 0;
}

.tips-box {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 2rem auto;
}

.tips-box ul {
    list-style: none;
}

.tips-box li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.tips-box li:before {
    content: "💡 ";
    margin-right: 0.5rem;
}

.tips-box li:last-child {
    border-bottom: none;
}

/* Examples */
.example-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.example-card h3 {
    color: var(--primary-color);
    margin: 0 0 1rem 0;
}

.example-content p {
    margin-bottom: 0.5rem;
}

.example-content ol {
    margin: 1rem 0 1rem 2rem;
}

.example-content li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

/* FAQ Section */
.faq-container {
    max-width: 900px;
    margin: 0 auto;
}

.faq-item {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: box-shadow 0.3s;
}

.faq-item:hover {
    box-shadow: var(--shadow-lg);
}

.faq-question {
    color: var(--dark-color);
    margin: 0;
    font-size: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-question:after {
    content: "▼";
    font-size: 0.875rem;
    color: var(--primary-color);
    transition: transform 0.3s;
}

.faq-item.active .faq-question:after {
    transform: rotate(180deg);
}

.faq-answer {
    margin-top: 1rem;
    color: var(--text-light);
    line-height: 1.8;
    display: none;
}

.faq-item.active .faq-answer {
    display: block;
}

/* Tips Grid */
.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    max-width: 1000px;
    margin: 2rem auto;
}

.tip-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.tip-card h3 {
    color: var(--dark-color);
    font-size: 1.125rem;
    margin: 0 0 0.75rem 0;
}

.tip-card p {
    color: var(--text-light);
    margin: 0;
    line-height: 1.6;
    font-size: 0.9375rem;
}

/* Related Section */
.related-section {
    padding: 4rem 0;
    background-color: var(--light-color);
}

.related-section h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: var(--dark-color);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.related-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s;
    cursor: pointer;
}

.related-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.related-card h3 {
    color: var(--primary-color);
    margin: 0 0 1rem 0;
}

.related-card p {
    color: var(--text-light);
    margin: 0;
}

/* Footer */
footer {
    background-color: var(--dark-color);
    color: white;
    padding: 3rem 0 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3,
.footer-section h4 {
    margin-bottom: 1rem;
    color: white;
}

.footer-section p {
    color: #d1d5db;
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: #d1d5db;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-section ul li a:hover {
    color: white;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #374151;
    color: #9ca3af;
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 1rem;
        box-shadow: var(--shadow-lg);
        gap: 0;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links li {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-links li:last-child {
        border-bottom: none;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .hero-features {
        flex-direction: column;
        gap: 0.5rem;
    }

    .input-group {
        flex-direction: column;
    }

    .division-symbol {
        transform: rotate(90deg);
        margin: 0;
    }

    .calculator-options {
        flex-direction: column;
        gap: 0.5rem;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .features-grid,
    .tips-grid,
    .related-grid {
        grid-template-columns: 1fr;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .calculator-card {
        padding: 1.5rem;
    }

    .hero {
        padding: 2rem 0;
    }

    .content-section h2 {
        font-size: 1.75rem;
    }

    .long-division-visual {
        font-size: 0.875rem;
        padding: 1rem;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .button-group,
    .quick-calculations,
    .history-section,
    .mobile-menu-toggle,
    footer {
        display: none;
    }

    .result-container {
        box-shadow: none;
    }
}

/* Accessibility */
.btn:focus,
input:focus,
.quick-calc-btn:focus,
.history-item:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error States */
.error {
    border-color: var(--danger-color) !important;
}

.error-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.success-message {
    color: var(--success-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

