/* Global Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans KR', 'Roboto', sans-serif;
}

body {
    background-color: #ffffff;
    /* Slightly cooler grey for more premium feel -> Changed to white */
    color: #222;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

button {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 30px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    /* Softer border */
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: 700;
    color: #222;
}

.logo-icon {
    background: linear-gradient(135deg, #12FFAA 0%, #1664FF 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-right: 6px;
    font-size: 24px;
    font-weight: 800;
}

.logo-text {
    background: linear-gradient(135deg, #12FFAA 0%, #1664FF 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    font-size: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Tool Bar */
.tool-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 24px 0 20px;
    background-color: transparent;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 500;
    color: #5f6368;
    background: #fff;
    border: 1px solid #dadce0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tool-btn:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.tool-btn.active {
    background-color: #e8f0fe;
    color: #1967d2;
    border-color: #1967d2;
    font-weight: 600;
}

/* Main Container */
.main-container {
    padding: 0 20px 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

/* Translator Box layout */
.translator-box {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
    align-items: stretch;
}

.panel {
    background: #fff;
    border: 1px solid #dadce0;
    border-radius: 16px;
    flex: 1;
    /* Grow and shrink equally */
    flex-basis: 0;
    /* Start from 0 width to ensure even distribution */
    min-width: 0;
    /* Prevent content from forcing width */
    min-height: 450px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    position: relative;
    transition: all 0.3s ease;
}

.panel:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
    border-color: #c0c4cc;
}

.panel.source-panel:focus-within {
    border-color: #1664FF;
    box-shadow: 0 0 0 2px rgba(22, 100, 255, 0.1);
}

/* Panel Header */
.panel-header {
    padding: 16px 24px;
    border-bottom: 1px solid #f1f3f4;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.select-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-start;
    /* Ensure left alignment is kept */
}

.lang-select {
    font-size: 14px;
    font-weight: 600;
    color: #3c4043;
    border: none;
    background: transparent;
    cursor: pointer;
    outline: none;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.lang-select:hover {
    background: #f1f3f4;
}

/* Panel Body */
.panel-body {
    flex: 1;
    padding: 30px 24px 24px;
    /* Increased top padding to make room for X button */
    position: relative;
    display: flex;
    flex-direction: column;
}

textarea {
    width: 100%;
    height: 100%;
    border: none;
    resize: none;
    font-size: 20px;
    color: #202124;
    outline: none;
    background: transparent;
    line-height: 1.6;
    font-weight: 400;
}

textarea::placeholder {
    color: #bdc1c6;
}

.output-content {
    font-size: 20px;
    color: #202124;
    line-height: 1.6;
    white-space: pre-wrap;
    /* Essential for line breaks */
    height: 100%;
    overflow-y: auto;
}

.output-content.placeholder {
    color: #bdc1c6;
}

/* Clear Button */
/* Clear Button */
.clear-btn {
    position: absolute;
    top: 6px;
    /* Moved up */
    right: 6px;
    /* Moved right */
    color: #9aa0a6;
    background: transparent;
    border-radius: 50%;
    padding: 6px;
    /* Smaller touch target visual, but compact */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.clear-btn:hover {
    background: #f1f3f4;
    color: #5f6368;
}

.hidden {
    display: none !important;
}

/* Panel Footer */
.panel-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f1f3f4;
    background: #fff;
    border-radius: 0 0 16px 16px;
}

/* Action Buttons */
.footer-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.char-count {
    font-size: 12px;
    color: #9aa0a6;
    font-feature-settings: "tnum";
}

.translate-btn {
    background: linear-gradient(135deg, #12FFAA 0%, #1664FF 100%);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    padding: 10px 24px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(22, 100, 255, 0.25);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
}

.translate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(22, 100, 255, 0.35);
}

.translate-btn:active {
    transform: translateY(0);
}

.icon-action-btn {
    color: #5f6368;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.icon-action-btn:hover {
    color: #202124;
    background-color: #f1f3f4;
}

/* Honorific Switch / Language Wrapper */
.lang-select-wrapper {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    align-items: center;
}

/* Promo Banner */
.promo-banner {
    background-color: #fff;
    padding: 16px 24px;
    border-radius: 12px;
    margin-bottom: 40px;
    align-items: center;
}

/* Footer */
.main-footer {
    border-top: 1px solid #dadce0;
    padding: 40px 0;
    margin-top: auto;
    background: #fff;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    /* Removed center alignment to match original left-aligned look */
}

.app-download {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    /* Reverted to 4px */
    font-size: 22px;
    /* Reverted to 22px */
    font-weight: 700;
    color: #333;
    /* Reverted to #333 */
    margin-bottom: 10px;
    /* Reverted to 10px */
}

.footer-logo {
    height: 32px;
    width: auto;
}

/* Responsive Media Queries */
@media (max-width: 900px) {
    .main-container {
        padding: 0 16px 24px;
    }

    .translator-box {
        flex-direction: column;
        gap: 20px;
    }

    .panel {
        width: 100%;
        min-height: 350px;
    }

    textarea,
    .output-content {
        font-size: 18px;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 8px 16px;
        /* Reduced top/bottom padding to move logo up */
    }

    .header-left {
        gap: 12px;
    }

    .logo-text {
        font-size: 14px;
    }

    .tool-bar {
        padding: 4px 0 8px;
        /* Compact toolbar */
    }

    .main-container {
        /* Reduced top padding */
        padding: 0 16px;
        /* Keep bottom padding for keyboard interaction if needed, or reduce it if it pushes footer away?
           Padding accounts for space *after* content. Leaving it is fine for scrolling. */
        padding-bottom: 100px;
    }

    .translator-box {
        gap: 12px;
        /* Reduce gap between panels */
        margin-bottom: 12px;
    }

    .panel-header {
        padding: 10px 16px;
        /* Compact header */
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .select-group {
        width: 100%;
        justify-content: flex-start;
        /* Align to left instead of spreading apart */
        gap: 12px;
    }

    .panel-body {
        padding: 20px 16px 12px;
        /* Restore padding but keep it tight */
    }

    /* Adjust Selects for mobile touch targets */
    select.lang-select {
        min-height: 40px;
    }

    /* Mobile-specific adjustments */
    .panel {
        /* Allow panel to grow naturally, but keep min-height for empty state */
        flex: none;
        /* Disable flex growing */
        width: 100%;
        min-height: 120px;
        /* Removed max-height and fixed height to allow external scrolling */
        height: auto;
        display: flex;
        flex-direction: column;
        margin-bottom: 0;
        /* Handled by gap */
    }

    .panel-body {
        flex: 1;
        padding: 30px 16px 16px;
        /* Tightened top padding */
        overflow: visible;
    }

    textarea,
    .output-content {
        font-size: 16px;
        line-height: 1.5;
        min-height: 80px;
        /* Ensure editable area has size */
        height: auto;
        /* Remove internal scroll constraints */
        overflow-y: visible;
        -webkit-overflow-scrolling: auto;
        overscroll-behavior: auto;
        /* Prevents scroll chaining to body */
        display: block;
        width: 100%;
    }

    .panel-footer {
        padding: 8px 16px;
        /* Compact footer */
    }

    .translate-btn {
        padding: 8px 20px;
        font-size: 13px;
    }

    .promo-banner {
        background-color: transparent;
        /* Remove white box visual to separate from panels */
        margin-top: 0px;
        /* Remove margin */
        padding: 10px 16px;
        /* Reduced padding */
        border: none;
    }

    /* Ensure footer doesn't float too close */
    .main-footer {
        padding-top: 0px;
        /* Remove padding */
        border: none;
        margin-top: 0;
        padding-bottom: 40px;
        /* Add some space at very bottom */
    }
}