h1 {
	font-family: 'Piazzolla', serif;
	margin-bottom: -10px;
}
body {
    font-family: Arial, sans-serif;
    margin: 20px;
    background-color: gray;
}
#analyzerContainer {
    max-width: 600px;
    margin: 0 auto;
    padding: 0px 20px 20px 20px; /* Modified: top padding set to 0px */
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    background-color: white;
}
input[type="text"] { /* Changed from textarea to input[type="text"] */
    width: 100%;
    height: 40px; /* Adjusted height for a single line */
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    resize: none; /* Prevent resizing */
    overflow: hidden; /* Hide overflow content */
    white-space: nowrap; /* Keep text on a single line */
}
button {
    padding: 10px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    /* Added for flexbox sizing */
    flex-shrink: 0; /* Prevent the button from shrinking much, allowing its text to remain */
    min-width: fit-content; /* Ensure button content always fits if possible */
}
button:hover {
    background-color: #0056b3;
}
#resultsContainer {
    margin-top: 20px;
    padding: 10px 15px; /* Modified padding */
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 4px;
}
.error {
    color: red;
    font-weight: bold;
}
.success {
    color: green;
}
/* Styles for expandable details - NO LONGER USED FOR NEW DISPLAY */
.morpheme-item {
    display: none; /* Hide old display */
}
.details-content {
    display: none; /* Hide old display */
}

/* NEW STYLES FOR PARSING BOX AND COLORED DISPLAY */
.parsing-result-box {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 20px;
    background-color: #fdfdfd;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.parsing-result-box:last-of-type {
    margin-bottom: 0;
}

.morphemeColoredDisplay { /* Changed from ID to class */
    display: inline-flex; /* Allows spans to sit side-by-side */
    flex-wrap: wrap; /* Allows wrapping if word is too long */
    margin-top: 10px;
    font-size: 24px; /* Larger font for better visibility */
    font-weight: bold;
    margin-bottom: 15px; /* Added margin to separate from translation */
}

.morpheme-segment {
    display: inline-block;
    padding: 2px 4px;
    margin: 1px;
    border-radius: 3px;
    position: relative; /* Needed for absolute positioning of the popup */
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.morpheme-segment:hover {
    transform: translateY(-2px); /* Slight lift on hover */
}

.morpheme-popup {
    position: absolute;
    bottom: 100%; /* Position above the segment */
    margin-bottom: 5px; /* Add some space above the segment */
    left: 50%;
    transform: translateX(-50%); /* Center the popup horizontally */
    display: none; /* Hidden by default */
    background-color: #333;
    color: white;
    border: 1px solid #555;
    padding: 8px 12px;
    border-radius: 5px;
    white-space: nowrap; /* Keep content on one line */
    z-index: 100; /* Ensure it's above other content */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    font-size: 14px;
    font-weight: normal;
    pointer-events: none; /* Allows mouse events to pass through */
    max-width: 300px; /* Limit width */
    text-align: left;
}

.morpheme-popup ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.morpheme-popup li {
    margin-bottom: 2px;
    word-break: break-all; /* Break long words in popup */
}

/* Show popup on hover for desktop */
.morpheme-segment:hover .morpheme-popup {
    display: block;
}

/* Show popup on click/tap for mobile */
.morpheme-segment.active .morpheme-popup {
    display: block;
}

/* Color Key Styles */
#colorKey {
    margin-top: 20px;
    padding: 10px;
    border-top: 1px solid #eee;
    font-size: 0.9em;
}
.color-key-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}
.color-box {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    margin-right: 8px;
    border: 1px solid #ccc; /* Add a subtle border for lighter colors */
}
.morpheme-hint {
    font-size: 0.8em;
    color: #666;
    margin-top: -10px; /* Adjust as needed to pull it closer to the heading */
    margin-bottom: 10px;
    display: block; /* Ensure it takes its own line */
}

.controls {
    display: flex; /* Use flexbox */
    justify-content: space-between; /* Puts items at opposite ends */
    align-items: center; /* Vertically center items */
    margin-bottom: 20px;
    flex-wrap: wrap; /* IMPORTANT: Allows items to wrap to the next line if they don't fit */
}

.orthography-toggle-container {
    display: flex; /* Use flexbox to align inner items horizontally */
    align-items: center; /* Vertically center the inner items */
    gap: 10px; /* Space between the labels and the toggle switch */
    margin-right: 15px; /* Creates the space between the toggle and the button when side-by-side */
    flex-shrink: 1; /* Allows it to shrink */
    flex-grow: 1; /* Allows it to grow */
    min-width: fit-content; /* Ensures content isn't prematurely squished, allows wrapping */
}

.orthography-label {
    font-weight: bold;
    color: #555; /* Default color for labels */
    transition: color 0.3s ease; /* Smooth transition for color change */
    user-select: none; /* Prevent text selection */
    white-space: nowrap; /* Prevent "Classical" and "Modern" from wrapping */
}

.orthography-label.active-orthography {
    color: #000; /* Darker color for the active orthography */
}

/* Toggle Switch Styles */
.toggle-switch {
    position: relative;
    width: 60px; /* Width of the track */
    height: 30px; /* Height of the track */
    display: inline-block;
    vertical-align: middle;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    cursor: pointer;
    flex-shrink: 0; /* Prevent the switch itself from shrinking */
}

.toggle-switch-checkbox {
    display: none;
}

.toggle-switch-label {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #FFC107; /* Default background: Modern (Amber) */
    border-radius: 15px; /* Half of height for rounded ends */
    position: relative;
    transition: background-color 0.3s ease;
}

/* When checked (Classical is active), change background to Classical color */
.toggle-switch-checkbox:checked + .toggle-switch-label {
    background-color: #4CAF50; /* Classical (Green) */
}

.toggle-switch-switch {
    display: block;
    width: 24px; /* Size of the circular thumb */
    height: 24px;
    margin: 3px;
    background: #FFFFFF;
    position: absolute;
    top: 0;
    /* Default position: Right (Modern) */
    left: calc(100% - 24px - 3px);
    border-radius: 50%; /* Make it a circle */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease-in 0s;
}

/* When checked (Classical is active), move to Left */
.toggle-switch-checkbox:checked + .toggle-switch-label .toggle-switch-switch {
    left: 0px; /* Position for "Classical" (left) */
}

/* Hide the inner text that was previously used for "Classical" / "Modern" inside the toggle itself */
.toggle-switch-inner:before, .toggle-switch-inner:after {
    content: none;
}

/* Media query for very small screens to adjust font size and element sizes */
@media (max-width: 380px) {
    .orthography-label {
        font-size: 0.9em; /* Slightly reduce font size for very small screens */
    }
    .toggle-switch {
        width: 50px; /* Slightly reduce toggle width */
        height: 25px; /* Slightly reduce toggle height */
    }
    .toggle-switch-label {
        border-radius: 12.5px;
    }
    .toggle-switch-switch {
        width: 20px;
        height: 20px;
        margin: 2.5px;
    }
    .toggle-switch-checkbox:checked + .toggle-switch-label .toggle-switch-switch {
        left: calc(100% - 20px - 2.5px); /* Adjust based on new thumb size */
    }
    .orthography-toggle-container {
        margin-right: 10px; /* Reduce margin slightly to save space */
    }
    button {
        padding: 8px 12px; /* Slightly reduce button padding */
        font-size: 14px; /* Slightly reduce button font size */
    }
}

/* Media query to stack elements on very small screens */
@media (max-width: 550px) { /* IMPORTANT: Changed breakpoint to 550px */
    .controls {
        flex-direction: column; /* Explicitly stack items vertically for consistency */
        align-items: stretch; /* Stretch items to full width */
        gap: 15px; /* Add vertical space between stacked items */
        flex-wrap: wrap; /* Ensure wrapping is enabled when stacking */
    }

    .orthography-toggle-container {
        margin-right: 0; /* Remove right margin when stacked */
        width: 100%; /* Take full width when stacked */
        justify-content: center; /* Center content within the toggle container */
    }

    button {
        width: 100%; /* Make button full width when stacked */
        margin-left: 0; /* Ensure no left margin when stacked */
    }
}
