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

::selection {
    background: #b3d7ff;
    color: #000;
}

::-moz-selection {
    background: #b3d7ff;
    color: #000;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    color: #333;
    padding-top: 0;
}

/* Microsoft Word Style Toolbar */
.toolbar {
    background: #2b579a;
    color: white;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toolbar-header {
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.quick-access-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: fit-content;
}

.quick-btn {
    background: transparent;
    border: 1px solid transparent;
    color: white;
    padding: 3px 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
}

.quick-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

.quick-btn:active {
    background: rgba(255, 255, 255, 0.25);
}

.source {
    flex: 1;
    text-align: center;
    color: white;
    font-size: 16px;
    font-weight: 500;
}

.search-box-header {
    display: flex;
    margin: 3px 0;
    gap: 8px;
    align-items: center;
    min-width: fit-content;
}

#search-box {
    position: relative;
    display: inline-flex;
    align-items: center;
}

#search-box i {
    position: absolute;
    left: 10px;
    color: #ffffff;
    opacity: 0.9;
    pointer-events: none;
}

.search-box-header input {
    padding: 4px 12px 4px 34px;
    /* space for icon */
    border: none;
    border-radius: 1px;
    background: #1f4073;
    font-size: 14px;
    width: 320px;
    color: white;
}

.search-box-header input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-box-header input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    caret-color: white;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.search-box-header button {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.search-box-header button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.toolbar-header h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Tabs */
.toolbar-tabs {
    display: flex;
    gap: 0;
    padding: 0 16px;
    background: #2b579a;
}

.tab-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 4px 16px;
    border-radius: 3px 3px 0 0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
    color: #2b579a;
    background-color: #F5F5F5;
}

.toolbar-section {
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid lightgray;
    background-color: #F5F5F5;
}

.toolbar-row-top {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Clipboard group */
.clipboard-group {
    display: flex;
    gap: 6px;
    align-items: flex-start;
}

.clipboard-btn-large-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.clipboard-label {
    font-size: 11px;
    color: #555;
    font-weight: 600;
    white-space: nowrap;
}

.clipboard-column {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.clipboard-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.clipboard-btn.large {
    padding: 4px 8px;
    font-size: 50px;
    min-height: 48px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clipboard-btn.small {
    padding: 2px 2px;
    font-size: 18px;
    min-width: 32px;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clipboard-btn:hover {
    color: black;
    background: lightgray;
}

.clipboard-btn:active {
    background: #d0d0d0;
}

/* Formatting icons group - horizontal row matching clipboard height */
.formatting-icons-group {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-wrap: wrap;
    height: 48px;
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: #555;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    color: black;
    background: lightgray;
}

.toolbar-btn.active {
    background-color: lightgray;
    color: black;
}

/* Styles Group */
.styles-group {
    display: flex;
    flex-direction: column;
    overflow-x: auto;
    gap: 6px;
    padding: 0 8px;
}

.styles-header {
    font-size: 12px;
    color: black;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.5px;
}

.styles-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.style-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: white;
    border: 1px solid #d0d0d0;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 70px;
}

.style-btn:hover {
    border-color: #2b579a;
    background: #f0f6ff;
}

.style-btn.active {
    border: 2px solid #2b579a;
    background: #e8f1f8;
}

.style-preview {
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.style-name {
    font-size: 11px;
    color: #666;
    white-space: nowrap;
}

.toolbar-separator {
    width: 1px;
    height: 80px;
    background: rgba(255, 255, 255, 0.3);
    margin: 0 4px;
    border-right: 1px solid black;
}

.toolbar-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #555;
    font-size: 13px;
}

.row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.toolbar-input-group label {
    font-weight: 600;
}

.toolbar-input-group input {
    width: 50px;
    padding: 4px 8px;
    border: 1px solid lightgray;
    border-radius: 3px;
    background: white;
    color: #555;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.toolbar-input-group select {
    padding: 4px 8px;
    border: 1px solid lightgray;
    border-radius: 3px;
    background: white;
    color: #555;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.toolbar-input-group input:focus,
.toolbar-input-group select:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.toolbar-input-group input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

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

.loading {
    text-align: center;
    padding: 40px 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #333;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.error {
    background: #ffebee;
    color: #c62828;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #c62828;
}

.source {
    text-align: center;
    margin: 0 auto 3px auto;
    padding: 5px;
    font-size: 12px;
    font-weight: 500;
    max-width: fit-content;
    overflow-x: hidden;
}

.word-container {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 40px 40px;
    min-height: 300px;
    line-height: 1.8;
    word-wrap: break-word;
    font-size: 18px;
    max-width: 900px;
    margin: 0 auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-height: 1200px;
}

.word {
    display: inline;
    margin-right: 0;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {

    /* Toolbar Header */
    .toolbar-header {
        padding: 8px 12px;
        gap: 12px;
        flex-wrap: wrap;
    }

    .source {
        font-size: 14px;
        flex: 0;
        order: 3;
        width: 100%;
        text-align: center;
        margin-top: 4px;
    }

    .quick-access-bar {
        gap: 6px;
        order: 1;
    }

    .search-box-header {
        margin: 0;
        gap: 6px;
        order: 2;
        flex: 1;
        min-width: 0;
    }

    .search-box-header input {
        padding: 6px 10px 6px 28px;
        font-size: 14px;
        min-width: 0;
        flex: 1;
    }

    #search-box i {
        left: 8px;
        font-size: 12px;
    }

    /* Tabs */
    .toolbar-tabs {
        overflow-x: auto;
        padding: 6px 8px;
        gap: 4px;
    }

    .tab-btn {
        padding: 6px 10px;
        font-size: 12px;
        min-width: auto;
        white-space: nowrap;
    }

    /* Toolbar Section */
    .toolbar-section {
        padding: 8px 12px;
        gap: 6px;
    }

    .toolbar-row-top {
        gap: 6px;
        flex-wrap: wrap;
    }

    /* Clipboard Group */
    .clipboard-group {
        gap: 4px;
    }

    .clipboard-btn-large-wrapper {
        gap: 1px;
    }

    .clipboard-btn.large {
        min-width: 28px;
        min-height: 28px;
        font-size: 16px;
        padding: 3px;
    }

    .clipboard-label {
        font-size: 9px;
    }

    .clipboard-btn.small {
        padding: 2px 4px;
        font-size: 14px;
        min-width: 24px;
        min-height: 20px;
    }

    /* Separator */
    .toolbar-separator {
        height: 30px;
        margin: 0 2px;
    }

    /* Font Input Group */
    .toolbar-input-group {
        gap: 4px;
    }

    .toolbar-input-group label {
        font-size: 12px;
        min-width: 35px;
    }

    .toolbar-input-group select,
    .toolbar-input-group input {
        padding: 4px 6px;
        font-size: 12px;
        min-width: 60px;
    }

    /* Font Group */
    .font-group {
        gap: 4px;
        flex-wrap: wrap;
        width: 100%;
    }

    .font-group .row {
        gap: 4px;
        flex-wrap: wrap;
    }

    /* Formatting Icons Group */
    .formatting-icons-group {
        gap: 2px;
        height: auto;
        flex-wrap: wrap;
        width: 100%;
    }

    .toolbar-btn {
        padding: 4px;
        font-size: 12px;
        min-width: 28px;
        min-height: 28px;
        border-radius: 3px;
    }

    /* Alignment and Other Controls */
    .toolbar-section>div:nth-child(11) {
        width: 100%;
    }

    .toolbar-section>div:nth-child(11) .row {
        gap: 4px;
        flex-wrap: wrap;
    }

    /* Styles Group */
    .styles-group {
        gap: 4px;
        padding: 0 4px;
        width: 100%;
    }

    .styles-header {
        font-size: 11px;
    }

    .styles-container {
        gap: 4px;
        flex-wrap: wrap;
    }

    .style-btn {
        padding: 4px 6px;
        gap: 2px;
        min-width: 55px;
        font-size: 10px;
    }

    .style-preview {
        font-size: 11px;
    }

    .style-name {
        font-size: 9px;
    }

    /* Container */
    .container {
        max-width: 100%;
        padding: 12px;
        margin: 0;
    }

    /* Word Container */
    .word-container {
        padding: 20px 16px;
        min-height: auto;
        max-width: 100%;
        font-size: 16px;
        line-height: 1.6;
        margin: 0;
        border-radius: 2px;
    }

    /* Images */
    .word-container img {
        max-width: 100%;
        max-height: 300px;
        margin: 12px 0;
    }

    /* Loading and Error */
    .loading {
        padding: 30px 20px;
    }

    .spinner {
        width: 30px;
        height: 30px;
    }

    .error {
        padding: 12px;
        font-size: 14px;
        margin-bottom: 16px;
    }
}