/* Reset & Global Styles */
html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    font-size: 52px; /* Consider if this base size is appropriate for all devices; might be very large on some */
    box-sizing: border-box;
    overflow-x: hidden;
    font-family: "Helvetica Neue", Arial, sans-serif;
    background-color: black; 
    
    /* Make html and body take full viewport height for Flexbox to work */
    height: 100%; 
    display: flex; /* Make body a flex container */
    flex-direction: column; /* Arrange children vertically */
}

/* Main wrapper to contain all visible page content */
.page-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* This makes the page-wrapper fill available vertical space */
    width: 100%; /* Default to full width on smaller screens */
    /* Add padding-left/right here to prevent content touching screen edges on smaller screens */
    padding-left: 10px; /* Example padding */
    padding-right: 10px; /* Example padding */
}

/* Container for the buttons (Submit/Clear) side-by-side */
.container {
    display: flex;
    width: 100%;
    white-space: nowrap;
    box-sizing: border-box;
    overflow: hidden;
    margin-top: 10px;
}

/* A sticky header/navigation bar */
#sticky {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    width: 100%; /* Will inherit max-width from .page-wrapper on wider screens */
    z-index: 999; /* Ensures it stays on top */
    flex-shrink: 0;
}

/* Main form container */
form {
    background-color: #ffffff;
    width: 100%; /* Will inherit max-width from .page-wrapper on wider screens */
    box-sizing: border-box;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
    flex-shrink: 0;
}

/* Textarea styling */
textarea {
    padding: 12px 20px;
    box-sizing: border-box;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 46px;
    resize: none;
    overflow: auto;
    width: 100%;
    height: 300px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #fcfcfc;
}

/* Textarea placeholder font-size */
textarea::placeholder {
    font-size: 36px;
    color: #aaa;
}

/* Flatten the textarea on horizontal (landscape) screens */
@media (orientation: landscape) {
    textarea {
        height: 200px;
    }
}

/* Textarea focus effect */
textarea:focus {
    border-color: #3c74cc;
    box-shadow: 0 0 5px rgba(60, 116, 204, 0.2);
}

/* Buttons (Submit, Reset, etc.) */
input[type=button],
input[type=submit],
input[type=reset] {
    display: inline-block;
    flex: 1 1 auto;
    text-align: center;
    white-space: nowrap;
    width: 49.1%;
    height: 93px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 36px;
    background-color: #FAF7F6;
    color: #333;
    margin: 0 5px 0 0;
    transition: background-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

input[type=button]:last-child,
input[type=submit]:last-child,
input[type=reset]:last-child {
    margin-right: 0;
}

/* Button hover and focus effects */
input[type=button]:hover,
input[type=submit]:hover,
input[type=reset]:hover {
    background-color: #f4f4f4;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

input[type=button]:focus,
input[type=submit]:focus,
input[type=reset]:focus {
    outline: none;
    box-shadow: 0 0 5px rgba(60, 116, 204, 0.3);
}

/* Dropdown (dictionary_type) styling */
select {
    width: 100%;
    max-width: 100%;
    border: none;
    cursor: pointer;
    font-size: 46px;
    background-color: #ffffff;
    color: #333;
    text-align: center;
    -webkit-appearance: none; 
    -moz-appearance: none; 
    appearance: none;
    background-image: none;
    margin: 10px 0;
    outline: none;
}

/* Anchor links */
a {
    color: #3c74cc;
    border: none;
    text-decoration: none;
    cursor: pointer;
    font-size: 46px;
    transition: color 0.2s;
}

a:hover {
    color: #3c74cc;
}

/* Specific link style (if needed) */
#link a:link,
#link a:visited {
    color: #3c74cc;
    border: none;
    text-decoration: none;
    cursor: pointer;
    font-size: 46px;
}

/* Dictionary-type select box */
#list {
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

/* Result area styling */
#result {
    font-size: 46px;
    line-height: 1.5;
    font-family: Arial, sans-serif;
    min-height: 100px;
    width: 100%;
    box-sizing: border-box;
    padding: 20px;
    border: 2px solid #ddd;
    border-radius: 6px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background-color: #ffffff;
    /* This is the line to adjust: */
    margin-top: -40px; /* Change from 15px to 0px or a smaller value */
    margin-bottom: 15px; /* Keep or adjust as needed for spacing below result */

    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: auto;
}

/* Top navigation bar */
#bar {
    width: 100%; /* Will inherit max-width from .page-wrapper on wider screens */
    height: auto;
    background-color: #3c74cc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
    color: #fff;
    flex-shrink: 0;
}
#bar img { /* Make logo responsive */
    max-width: 100%;
    height: auto;
    display: block;
    max-height: 80px; /* Adjust as needed for your logo's design */
}

/* Footer */
.footer {
    position: sticky; 
    bottom: 0;
    width: 100%; /* Will inherit max-width from .page-wrapper on wider screens */
    background-color: #ffffff;
    color: #333;
    text-align: right;
    box-sizing: border-box;
    padding: 10px 20px;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.06);
    z-index: 999;
    flex-shrink: 0;
}

/* Social media or any extra floating icons */
#fb {
    position: absolute;
    top: 21px;
    right: 20px;
    /* Consider making these relative to the .page-wrapper on wide screens */
    /* Example adjustment for desktop if they should stay within the centered content */
    /* If they are truly outside and floating relative to viewport, keep as is. */
}

#shortcut {
    position: absolute;
    right: 20px;
    background-color: transparent;
    /* Similar consideration as #fb */
}

/* Drilldown (mobile menu or additional links) */
#drilldown {
    position: absolute;
    /* top: 20px; - This makes it relative to its closest positioned ancestor.
                   If it's a child of body, it's relative to body.
                   If it's relative to #bar, then #bar needs position:relative.
                   Given your JS `toggleDrilldown`, it looks like it just appears
                   on top of everything. Keep absolute for now unless it's misbehaving.
    */
    right: 20px;
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px;
    z-index: 1000;
    display: none;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Turn the list into a flex container, stack items, center them horizontally */
#drilldown ul {
    display: flex;
    flex-direction: column;
    align-items: center;
    list-style-type: none;
    padding: 0;
    margin: 0;
}

/* Remove all margins from li; let <a> control vertical spacing */
#drilldown ul li {
    margin: 0;
    padding: 0;
}

/* Add consistent spacing via anchor elements */
#drilldown ul li a {
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    color:  #333;
    font-size: 46px;
    transition: color 0.2s;
    margin: 10px 0;
    padding: 10px 0;
}

#drilldown ul li a:hover {
    color: #333;
}

/* Drilldown button (hamburger icon) */
#drilldownBtn {
    cursor: pointer;
    font-size: 46px;
    color: white;
    margin-right: 25px;
    transition: color 0.2s;
}

#drilldownBtn:hover {
    color: #c2daf9;
}


/* RWD: Make it "narrow" on wider screens and center it */
@media (min-width: 1024px) {
    .page-wrapper {
        max-width: 700px; /* Adjust this value for your desired "narrowness" */
        margin: 0 auto;   /* Centers the narrow content */
        padding-left: 0;  /* Remove padding when centered */
        padding-right: 0; /* Remove padding when centered */
        box-shadow: 0 0 15px rgba(0,0,0,0.05); /* Optional: add subtle shadow to the whole narrow block */
    }
    body {
        max-width: 50%;
        margin: 0 auto;
    }
}

/* 螢幕寬度 < 1024px 時，維持寬度100% */
@media (max-width: 1023px) {
    body {
        width: 100%;
        margin: 0;
    }
}

/* RWD: Mobile adjustments */
@media (max-width: 600px) {
    #drilldown {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        top: 20px;
    }
    /* You might want to adjust font sizes for very small screens here */
    /* html, body { font-size: 42px; } */
}

/* Potentially adjust padding on form elements if the default 20px becomes too much on very small screens */
@media (max-width: 400px) {
    form {
        padding: 10px; /* Reduce padding for smaller screens */
    }
    textarea {
        padding: 8px 10px; /* Reduce textarea padding */
    }
    input[type=button], input[type=submit], input[type=reset] {
        height: 70px; /* Slightly reduce button height */
        font-size: 30px; /* Adjust button font size */
    }
    #bar {
        padding: 0 10px; /* Reduce bar padding */
    }
    #drilldownBtn {
        margin-right: 15px; /* Adjust button margin */
    }
}