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

/* CSS Variables for Light and Dark Mode */
:root {
    /* Light Mode Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f6f8fa;
    --text-primary: #000000;
    --text-secondary: #586069;
    --text-tertiary: #6a737d;
    --border-color: #e1e4e8;
    --border-light: #d1d5da;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --input-bg: #ffffff;
    --input-border: #d1d5da;
    --button-primary-bg: #000000;
    --button-primary-text: #ffffff;
    --button-secondary-bg: #f6f8fa;
    --button-secondary-text: #24292e;
    --accent-color: #000000;
    --message-user-bg: #f6f8fa;
    --message-assistant-bg: #ffffff;
    --loading-overlay: rgba(255, 255, 255, 0.95);
    --inverted-img: invert(0);
    --logo: block;
    --logo-dark: none;
}

/* Dark Mode - Apply to both html and body to prevent flash */
:root.dark-mode,
html.dark-mode,
body.dark-mode {
    /* Dark Mode Colors - True Black Theme */
    --bg-primary: #000000;
    --bg-secondary: #181818;
    --bg-tertiary: #1d1d1d;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-tertiary: #8a8a8a;
    --border-color: #1d1d1d;
    --border-light: #2a2a2a;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --shadow-hover: rgba(0, 0, 0, 0.7);
    --input-bg: #181818;
    --input-border: #1d1d1d;
    --button-primary-bg: #ffffff;
    --button-primary-text: #000000;
    --button-secondary-bg: #181818;
    --button-secondary-text: #ffffff;
    --accent-color: #ffffff;
    --message-user-bg: #181818;
    --message-assistant-bg: #000000;
    --loading-overlay: rgba(0, 0, 0, 0.95);
    --inverted-img: invert(1);
    --logo: none;
    --logo-dark: block;
}
.svg-light-mode{
    display: var(--logo);
}
.svg-dark-mode{
    display: var(--logo-dark);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    overflow: auto;
    /* iOS Safari specific fixes */
    -webkit-overflow-scrolling: touch;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Splash Screen */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.splash-logo {
    max-width: 300px;
    width: 80%;
    height: auto;
    border-radius: 18px;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-secondary);
    border-radius: 8px;
}

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 8px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.app-title {
    margin-top: -12px;
    margin-left: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 5px;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-color);
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 20px;
}

.new-chat-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-light);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.loading-conversations {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.conversation-item {
    padding: 12px;
    padding-right: 60px;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    position: relative;
}

.conversation-item:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-light);
}

.conversation-item.active {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

.conversation-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}

.conversation-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Action buttons container */
.conversation-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.conversation-item:hover .conversation-actions {
    opacity: 1;
}

/* 3-dot menu button */
.conversation-menu-btn {
    padding: 4px 8px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.conversation-menu-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--button-secondary-text);
}

/* Dropdown menu */
.conversation-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow-color);
    min-width: 150px;
    z-index: 1000;
    display: none;
}

.conversation-menu-dropdown.active {
    display: block;
}

.conversation-menu-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--button-secondary-text);
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.conversation-menu-item:first-child {
    border-radius: 6px 6px 0 0;
}

.conversation-menu-item:last-child {
    border-bottom: none;
    border-radius: 0 0 6px 6px;
}

.conversation-menu-item:hover {
    background-color: var(--bg-tertiary);
}

.conversation-menu-item.danger {
    color: #d73a49;
}

.conversation-menu-item.danger:hover {
    background-color: #ffeef0;
}

/* Edit mode styles */
.conversation-edit-container {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 4px;
}

.conversation-title-input {
    flex: 1;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    font-family: inherit;
}

.conversation-title-input:focus {
    outline: none;
    border-color: #0366d6;
}

.conversation-save,
.conversation-cancel {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.conversation-save {
    background-color: var(--button-primary-bg);
    color: var(--button-primary-text);
}

.conversation-save:hover {
    background-color: var(--button-primary-bg);
}

.conversation-cancel {
    background-color: var(--text-tertiary);
    color: var(--button-primary-text);
}

.conversation-cancel:hover {
    background-color: var(--text-secondary);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-light);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 13px;
    transition: background-color 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-tertiary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
}

.chat-header {
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    padding: 12px 24px;
}

.settings-panel {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-group-model {
    flex: 1;
}

.swap-languages-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    margin-bottom: 0;
    border: 1px solid var(--bg-primary);
    border-radius: 6px;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 40px;
    height: 34px;
}

.swap-languages-btn:active {
    background-color: var(--border-light);
    transform: scale(0.95);
}

.swap-languages-btn svg {
    display: block;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    margin-bottom: 0;
    border: 2px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-secondary);
    background-color: var(--input-bg);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 40px;
    height: 34px;
    position: relative;
}

.theme-toggle-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-color);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

.theme-icon-sun,
.theme-icon-moon {
    position: absolute;
    transition: opacity 0.3s, transform 0.3s;
}

body:not(.dark-mode) .theme-icon-sun {
    opacity: 1;
    transform: rotate(0deg);
}

body:not(.dark-mode) .theme-icon-moon {
    opacity: 0;
    transform: rotate(180deg);
}

body.dark-mode .theme-icon-sun {
    opacity: 0;
    transform: rotate(-180deg);
}

body.dark-mode .theme-icon-moon {
    opacity: 1;
    transform: rotate(0deg);
}

.layout-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    margin-bottom: 0;
    border: 2px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-secondary);
    background-color: var(--input-bg);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 40px;
    height: 34px;
    position: relative;
}

.layout-toggle-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-color);
}

.layout-toggle-btn:active {
    transform: scale(0.95);
}

.layout-icon-chat,
.layout-icon-sidebyside {
    position: absolute;
    transition: opacity 0.3s, transform 0.3s;
}

/* Layout Container Visibility */
/* In chat layout: show chat container, hide side-by-side container */
html:not(.layout-sidebyside) .chat-container {
    display: flex;
}

html:not(.layout-sidebyside) .input-container {
    display: block;
}

html:not(.layout-sidebyside) .sidebyside-translation-container {
    display: none;
}

/* In side-by-side layout: hide chat container, show side-by-side container */
html.layout-sidebyside .chat-container {
    display: none;
}

html.layout-sidebyside .input-container {
    display: none;
}

html.layout-sidebyside .sidebyside-translation-container {
    display: flex;
}

/* Show side-by-side icon in chat layout (to switch to side-by-side) */
html:not(.layout-sidebyside) .layout-icon-chat {
    opacity: 0;
    transform: scale(0.8);
}

html:not(.layout-sidebyside) .layout-icon-sidebyside {
    opacity: 1;
    transform: scale(1);
}

/* Show chat icon in side-by-side layout (to switch to chat) */
html.layout-sidebyside .layout-icon-chat {
    opacity: 1;
    transform: scale(1);
}

html.layout-sidebyside .layout-icon-sidebyside {
    opacity: 0;
    transform: scale(0.8);
}

/* Side-by-Side Translation Layout Styles */
html.layout-sidebyside .sidebyside-translation-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    min-height: 30vh;
    padding: 16px;
}

html.layout-sidebyside .sidebyside-panel {
    display: flex;
    flex-direction: column;
    background: var(--secondary-color);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

html.layout-sidebyside .source-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 2px solid var(--border-color);
}

html.layout-sidebyside .translation-panel {
    display: flex;
    flex-direction: column;
}

html.layout-sidebyside .sidebyside-textarea {
    color: var(--text-color);
    background: var(--secondary-color);
    border: none;
    outline: none;
    padding: 20px;
    font-size: 16px;
    line-height: 1.6;
    resize: none;
    font-family: inherit;
    min-height: 100px;
    height: 100%;
    overflow-y: auto;
}

html.layout-sidebyside .sidebyside-output {
    flex: 1;
    padding: 20px;
    font-size: 16px;
    line-height: 1.6;
    overflow-y: auto;
}

html.layout-sidebyside .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9aa0a6;
    text-align: center;
}

html.layout-sidebyside .empty-state img {
    margin-bottom: 16px;
    opacity: 0.6;
    border-radius: 8px;
}

html.layout-sidebyside .sidebyside-divider {
    width: 1px;
    margin: 0 16px;
}

html.layout-sidebyside .sidebyside-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 2px solid var(--border-color);
    min-height: 54px;
}

html.layout-sidebyside .sidebyside-footer-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

html.layout-sidebyside .char-count {
    font-size: 12px;
    color: #5f6368;
}

html.layout-sidebyside .detected-lang {
    font-size: 11px;
    color: var(--text-tertiary);
    font-style: italic;
    padding: 2px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
}

html.layout-sidebyside .clear-btn-sbs,
html.layout-sidebyside .copy-btn-sbs,
html.layout-sidebyside .speaker-btn-sbs {
    padding: 6px 16px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--secondary-color);
    color: var(--text-color);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

html.layout-sidebyside .clear-btn-sbs:hover,
html.layout-sidebyside .copy-btn-sbs:hover,
html.layout-sidebyside .speaker-btn-sbs:hover {
    background: var(--secondary-color);
}

html.layout-sidebyside .speaker-btn-sbs.speaking {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

html.layout-sidebyside .speaker-btn-sbs svg {
    flex-shrink: 0;
}

html.layout-sidebyside .send-btn {
    display: none;
}

html.layout-sidebyside .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #5f6368;
}

html.layout-sidebyside .loading-state img {
    width: 120px;
    margin-bottom: 16px;
}

.setting-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.setting-group select {
    padding: 8px 12px;
    border: 2px solid var(--input-border);
    border-radius: 6px;
    background-color: var(--input-bg);
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s;
    min-width: 120px;
}

.setting-group-model select {
    min-width: 200px;
    max-width: 250px;
}

.setting-group select:hover {
    border-color: #959da5;
}

.setting-group select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.chat-container {
    margin: auto;
    width: 800px;
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
    padding: 24px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}
.header-img{
    border-radius: 12px;
    width: 300px;
    max-width: 100%;
    height: auto;
    margin-bottom: 10px;
}
.welcome-message {
    text-align: center;
    margin: auto;
    max-width: 600px;
}

.welcome-message h2 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.welcome-message p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.header-img {
    max-width: 200px;
    height: auto;
    margin-bottom: 20px;
}

/* Chat Messages */
.message {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    position: relative;
    overflow: visible;
}

.message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.message.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

/* Nested/threaded messages */
.message.nested {
    margin-left: 40px;
    position: relative;
}

.message.nested::before {
    content: '';
    position: absolute;
    left: -30px;
    top: 20px;
    width: 20px;
    height: 2px;
    background-color: var(--border-light);
}

.message.nested::after {
    content: '';
    position: absolute;
    left: -30px;
    top: 0;
    width: 2px;
    height: 20px;
    background-color: var(--border-light);
}

.message-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: visible;
}

.message.user .message-header {
    justify-content: flex-end;
}

/* Message Copy Button */
.message-copy-btn {
    padding: 4px 6px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s, opacity 0.2s, max-width 0.3s ease, margin-left 0.3s ease;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 0;
    overflow: hidden;
    margin-left: 0;
}

.message:hover .message-copy-btn {
    opacity: 1;
    max-width: 30px;
    margin-left: 6px;
}

.message-copy-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--button-secondary-text);
}

.message-copy-btn:active {
    transform: scale(0.95);
}

/* Message Speaker Button */
.message-speaker-btn {
    padding: 4px 6px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s, opacity 0.2s, max-width 0.3s ease, margin-left 0.3s ease;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 0;
    overflow: hidden;
    margin-left: 0;
}

.message:hover .message-speaker-btn {
    opacity: 1;
    max-width: 30px;
    margin-left: 6px;
}

.message-speaker-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--button-secondary-text);
}

.message-speaker-btn:active {
    transform: scale(0.95);
}

.message-speaker-btn.speaking {
    opacity: 1;
    color: var(--primary-color);
}

/* Message Menu (3-dot button) */
.message-menu {
    position: relative;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s;
}

.message.assistant:hover .message-menu {
    opacity: 1;
}

.message-menu-btn {
    padding: 2px 6px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.message-menu-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--button-secondary-text);
}

.message-menu-dropdown {
    position: absolute;
    top: 100%;
    right: auto;
    left: 0;
    margin-top: 4px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow-color);
    min-width: 180px;
    z-index: 10002;
    display: none;
}

.message-menu-dropdown.active {
    display: block;
}

.message-menu-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--button-secondary-text);
    transition: background-color 0.2s;
    white-space: nowrap;
}

.message-menu-item:first-child {
    border-radius: 6px 6px 0 0;
}

.message-menu-item:last-child {
    border-radius: 0 0 6px 6px;
}

.message-menu-item:hover {
    background-color: var(--bg-tertiary);
}

.message-menu-item.danger {
    color: #d73a49;
}

.message-menu-item.danger:hover {
    background-color: #ffeef0;
}

.message-content {
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-width: 100%;
}

.message.user .message-content {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.message.assistant .message-content {
    background-color: var(--message-assistant-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.message-footer {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: #959da5;
    margin-top: 6px;
    flex-wrap: wrap;
}

.message-footer-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-footer-separator {
    color: var(--border-light);
}

.message-transliteration-container {
    margin-top: 8px;
}

.transliteration-header {
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.transliteration-header-text {
    /* No flex, stays natural width */
    display: flex;
    align-items: center;
    gap: 4px;
}

.transliteration-header-text::before {
    content: '▼';
    font-size: 9px;
    transition: transform 0.3s;
    display: inline-block;
}

.message-transliteration-container.collapsed .transliteration-header-text::before {
    transform: rotate(-90deg);
}

.transliteration-header-spacer {
    flex: 1;
}

.transliteration-copy-btn {
    padding: 4px 6px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s, opacity 0.2s, max-width 0.3s ease, margin-left 0.3s ease;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 0;
    overflow: hidden;
    margin-left: 0;
}

.message-transliteration-container:hover .transliteration-copy-btn {
    opacity: 1;
    max-width: 30px;
    margin-left: 6px;
}

.transliteration-copy-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--button-secondary-text);
}

.transliteration-copy-btn:active {
    transform: scale(0.95);
}

.transliteration-toggle-icon {
    transition: transform 0.3s;
    flex-shrink: 0;
}

.message-transliteration-container.collapsed .transliteration-toggle-icon {
    transform: rotate(-90deg);
}

.message-transliteration {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-tertiary);
    font-style: italic;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.loading-indicator {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background-color: var(--bg-primary);
    /*border: 1px solid var(--border-color);*/
    border-radius: 12px;
    font-size: 15px;
    color: var(--text-secondary);
}

.loading-dots {
    display: inline-flex;
    margin-left: 8px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    margin: 0 2px;
    background-color: #959da5;
    border-radius: 50%;
    animation: loading 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loading {
    0%, 80%, 100% {
        opacity: 0.3;
    }
    40% {
        opacity: 1;
    }
}

/* Input Container */
.input-container {
    padding: 0 20px 24px 20px;
    background-color: var(--bg-primary);
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--input-bg);
    border: 2px solid var(--input-border);
    border-radius: 12px;
    padding: 12px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent-color);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: transparent;
    max-height: 200px;
    overflow-y: auto;
    /* iOS specific fixes */
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.input-wrapper textarea::placeholder {
    color: #959da5;
}

.send-btn {
    background-color: #000000;
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background-color: #000000;
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn svg {
    color: var(--button-primary-text);
}

/* Microphone Button */
.mic-btn {
    background-color: transparent;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    color: var(--text-color);
    position: relative;
}

.mic-btn:hover {
    background-color: var(--bg-secondary);
    border-color: var(--primary-color);
}

.mic-btn.listening {
    background-color: #ef4444;
    border-color: #ef4444;
    color: white;
}

.mic-btn .mic-icon {
    display: block;
}

.mic-btn .mic-listening {
    display: none;
}

.mic-btn.listening .mic-icon {
    display: none;
}

.mic-btn.listening .mic-listening {
    display: block;
}

/* Side-by-side mic button */
.mic-btn-sbs {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 10;
}

.sidebyside-textarea-wrapper {
    position: relative;
    flex: 1;
}

html.layout-sidebyside .sidebyside-textarea-wrapper .sidebyside-textarea {
    padding-right: 56px; /* Make room for mic button */
}

/* Error Message */
.error-message {
    padding: 12px 16px;
    background-color: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: 8px;
    color: #c53030;
    font-size: 14px;
    margin-bottom: 16px;
}

/* History page styles */
.history-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.history-container h2 {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 24px;
}

.history-nav {
    margin-bottom: 24px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background-color: var(--button-primary-bg);
    border: 1px solid var(--button-primary-bg);
    border-radius: 6px;
    text-decoration: none;
    color: var(--button-primary-text);
    font-size: 14px;
    transition: background-color 0.2s;
    cursor: pointer;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.history-table th,
.history-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.history-table th {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-table tr:hover {
    background-color: var(--bg-tertiary);
}

.no-history {
    padding: 60px 40px;
    text-align: center;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 15px;
}

.lang-tag {
    display: inline-block;
    padding: 4px 10px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-container {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    min-width: 400px;
    max-width: 500px;
    box-shadow: 0 8px 24px var(--shadow-hover);
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.show .modal-container {
    transform: scale(1);
}

.modal-header {
    font-size: 18px;
    font-weight: 600;
    color: var(--button-secondary-text);
    margin-bottom: 12px;
}

.modal-body {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 14px;
    color: #000000;
    font-family: inherit;
    margin-bottom: 16px;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 16px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.modal-btn.primary {
    background-color: var(--button-secondary-text);
    color: var(--button-primary-text);
    border-color: var(--button-secondary-text);
}

.modal-btn.primary:hover {
    background-color: #1a1f23;
}

.modal-btn.danger {
    background-color: #d73a49;
    color: #ffffff;
    border-color: #d73a49;
}

.modal-btn.danger:hover {
    background-color: #cb2431;
}

.modal-btn.secondary {
    background-color: var(--bg-primary);
    color: var(--button-secondary-text);
}

.modal-btn.secondary:hover {
    background-color: var(--bg-tertiary);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 150;
    padding: 8px 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    color: var(--button-secondary-text);
    transition: background-color 0.2s;
}

.mobile-menu-btn:hover {
    background-color: var(--bg-tertiary);
}

/* Mobile Settings Button */
.mobile-settings-btn {
    display: none;
    width: 100%;
    padding: 10px 16px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--button-secondary-text);
    transition: background-color 0.2s;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mobile-settings-btn:hover {
    background-color: var(--bg-tertiary);
}

.mobile-settings-btn svg {
    flex-shrink: 0;
}

/* Mobile Theme Toggle Button */
.mobile-theme-toggle-btn {
    display: none;
    padding: 10px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    position: relative;
}

.mobile-theme-toggle-btn:hover {
    background-color: var(--bg-tertiary);
}

.mobile-theme-toggle-btn:active {
    transform: scale(0.95);
}

.mobile-layout-toggle-btn {
    display: none;
    padding: 10px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    position: relative;
}

.mobile-layout-toggle-btn:hover {
    background-color: var(--bg-tertiary);
}

.mobile-layout-toggle-btn:active {
    transform: scale(0.95);
}

/* Settings Modal */
.settings-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.2s;
}

.settings-modal-overlay.show {
    display: flex;
    opacity: 1;
}

.settings-modal-container {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 24px var(--shadow-hover);
    transform: scale(0.95);
    transition: transform 0.2s;
}

.settings-modal-overlay.show .settings-modal-container {
    transform: scale(1);
}

.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.settings-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--button-secondary-text);
    margin: 0;
}

.settings-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.settings-modal-close:hover {
    background-color: var(--bg-tertiary);
    color: var(--button-secondary-text);
}

.settings-modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-modal-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-modal-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--button-secondary-text);
}

.settings-modal-select {
    padding: 10px 12px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background-color: var(--input-bg);
    font-size: 14px;
    color: var(--button-secondary-text);
    cursor: pointer;
    transition: border-color 0.2s;
    font-family: inherit;
}

.settings-modal-select:hover {
    border-color: #959da5;
}

.settings-modal-select:focus {
    outline: none;
    border-color: #000000;
}

.swap-languages-btn-modal {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    margin: 12px 0;
    background-color: var(--bg-secondary);
    border: none;
    border-radius: 6px;
    color: var(--button-secondary-text);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    min-height: 44px;
}

.swap-languages-btn-modal:hover {
    background-color: #e1e4e8;
    color: #24292e;
    border-color: #959da5;
}

.swap-languages-btn-modal:active {
    background-color: #d1d5da;
    transform: scale(0.98);
}

.swap-languages-btn-modal svg {
    display: block;
}

.settings-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.mobile-overlay.active {
    display: block;
}

/* Mobile keyboard handling */
body.keyboard-open {
    position: fixed;
    width: 100%;
    overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        position: fixed;
        width: 100%;
    }

    .sidebar-header {
        text-align: right;
    }
    .svg-dark-mode {
        float: right;
    }
    .svg-light-mode {
        float: right;
    }
    .mobile-menu-btn {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }

    /* Use dvh if supported */
    @supports (height: 100dvh) {
        .sidebar {
            height: 100dvh;
        }
    }

    .sidebar.open {
        left: 0;
    }

    /* Ensure sidebar content is scrollable */
    .sidebar-content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100vh - 160px); /* Account for header and footer */
    }

    @supports (height: 100dvh) {
        .sidebar-content {
            max-height: calc(100dvh - 160px);
        }
    }

    .main-content {
        width: 100%;
        height: 100vh;
        display: flex;
        flex-direction: column;
        position: relative;
    }

    @supports (height: 100dvh) {
        .main-content {
            height: 100dvh;
        }
    }

    .chat-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        padding: 12px 16px;
        padding-left: 60px; /* Make room for hamburger menu */
        flex-shrink: 0;
        z-index: 40;
        background-color: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        transform: translateZ(0); /* Force hardware acceleration */
        -webkit-transform: translateZ(0);
        display: flex;
        gap: 8px;
        align-items: center;
    }

    /* Hide desktop settings panel on mobile */
    .settings-panel {
        display: none !important;
    }

    /* Show mobile settings button */
    .mobile-settings-btn {
        display: flex;
        flex: 1;
    }

    /* Show mobile theme toggle button */
    .mobile-theme-toggle-btn {
        display: flex;
    }

    .mobile-layout-toggle-btn {
        display: flex;
    }

    .chat-container {
        width: 100%;
        padding: 16px;
        padding-top: 70px; /* Space for fixed header */
        padding-bottom: 100px; /* Space for fixed input */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        min-height: 100vh;
        min-height: 100dvh;
        overscroll-behavior: contain; /* Prevent pull-to-refresh and scroll chaining */
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure chat container is the only scrolling element when keyboard is open */
    body.keyboard-open .chat-container {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y; /* Only allow vertical scrolling */
    }

    .message {
        max-width: 100%;
    }

    .input-container {
        border-radius: 50px 50px 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom)); /* iOS safe area */
        background-color: var(--bg-primary);
        z-index: 50;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 10px var(--shadow-color);
        transform: translateZ(0); /* Force hardware acceleration */
        -webkit-transform: translateZ(0);
    }

    .input-wrapper {
        max-width: 100%;
    }

    /* Modal responsive */
    .modal-container {
        min-width: auto;
        width: 90%;
        max-width: 400px;
        margin: 0 16px;
    }

    /* Welcome message */
    .welcome-message {
        padding: 0 16px;
    }

    .welcome-message h2 {
        font-size: 24px;
    }

    .welcome-message p {
        font-size: 14px;
    }

    .header-img {
        max-width: 150px;
    }

    /* Side-by-side mobile layout */
    html.layout-sidebyside .sidebyside-translation-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
        min-height: calc(100vh - 200px);
        min-height: calc(100dvh - 200px);
        padding-top: 80px; /* Space for fixed header */
    }

    html.layout-sidebyside .sidebyside-divider {
        width: 100%;
        height: 1px;
        margin: 16px 0;
    }

    html.layout-sidebyside .sidebyside-panel {
        min-height: 250px;
    }

    /* Ensure textarea stays accessible when keyboard appears */
    html.layout-sidebyside .sidebyside-textarea {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .mobile-menu-btn {
        top: 10px;
        left: 12px;
        padding: 6px 10px;
        font-size: 18px;
    }

    .chat-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        padding: 10px 12px;
        padding-left: 60px;
        z-index: 40;
        background-color: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        transform: translateZ(0); /* Force hardware acceleration */
        -webkit-transform: translateZ(0);
        display: flex;
        gap: 6px;
        align-items: center;
    }

    .settings-panel {
        gap: 8px;
    }

    .setting-group select {
        font-size: 12px;
        padding: 6px 10px;
    }

    .chat-container {
        padding: 12px;
        padding-top: 60px; /* Space for fixed header */
        padding-bottom: 90px; /* Smaller padding for small devices */
        min-height: 100vh;
        min-height: 100dvh;
    }

    .message-content {
        font-size: 14px;
        padding: 12px 14px;
    }

    .message-footer {
        font-size: 10px;
    }

    .input-container {
        padding: 0 12px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }

    .input-wrapper {
        padding: 8px;
        gap: 8px;
    }

    .input-wrapper textarea {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    .send-btn {
        padding: 8px;
    }

    /* Prevent body scroll when sidebar is open */
    body.sidebar-open {
        overflow: hidden;
    }

    .modal-container {
        width: 95%;
        padding: 20px;
    }

    .modal-header {
        font-size: 16px;
    }

    .modal-body {
        font-size: 13px;
    }

    .modal-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .welcome-message h2 {
        font-size: 20px;
    }

    .welcome-message p {
        font-size: 13px;
    }
}

/* Dictionary Panel */
.dictionary-panel {
    border-radius: 15px;
    position: fixed;
    right: -400px;
    top: 20px;
    bottom: 20px;
    width: 400px;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    z-index: 1000;
}

.dictionary-panel.open {
    right: 0;
}

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

.dictionary-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.dictionary-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--button-secondary-text);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.dictionary-close-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--button-secondary-text);
}

.dictionary-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px 20px;
    color: var(--text-primary);
}

.dictionary-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    color: #586069;
}

.dictionary-empty svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.dictionary-empty p {
    margin: 0;
    font-size: 14px;
}

.dictionary-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.dictionary-loading p {
    margin-top: 16px;
    color: var(--text-primary);
    font-size: 14px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e1e4e8;
    border-top-color: #000000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.dictionary-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 20px;
    color: #d73a49;
}

.dictionary-error svg {
    margin-bottom: 16px;
}

.dictionary-error h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #24292e;
}

.dictionary-error p {
    margin: 0;
    font-size: 13px;
    color: #586069;
}

.dictionary-result {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dictionary-word-header {
    background: var(--bg-secondary);
    top: 0;
    position: sticky;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 16px 0 16px 0;
    border-bottom: 2px solid var(--border-color);
    flex-direction: row-reverse;
    align-items: flex-end;
}

.dictionary-word-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #24292e;
}

.dictionary-language {
    display: inline-block;
    padding: 4px 12px;
    background-color: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #586069;
}

.dictionary-definition {
    font-size: 14px;
    color: var(--text-primary);
}

.dictionary-definition strong {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
}

.dictionary-definition br + strong {
}

/* Dictionary Sections Styling */
.dict-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dict-section {
    background: #f6f8fa;
    border-radius: 8px;
    padding: 16px;
    border-left: 4px solid #000000;
}

/* Special styling for NOTE section */
.dict-note {
    background: #fff8e6;
    border-left-color: #f0ad4e;
}

.dict-note .dict-section-title {
    color: #d68000;
}

.dict-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #000000;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dict-section-content {
    font-size: 14px;
    color: #586069;
    line-height: 1.7;
}

.dict-word-value {
    font-size: 18px;
    font-weight: 600;
    color: #000000;
}

.dict-pos {
    font-style: italic;
    color: #6a737d;
}

.dict-pronunciation {
    font-family: 'Courier New', monospace;
    background: #ffffff;
    padding: 8px 12px;
    border-radius: 6px;
    display: inline-block;
}

.dict-etymology {
    font-style: italic;
}

.dict-list {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.dict-list li {
    margin-bottom: 8px;
    color: #586069;
    line-height: 1.6;
}

.dict-fallback {
    line-height: 1.7;
    color: #586069;
}

/* Clickable Words */
.clickable-word {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: #959da5;
    text-underline-offset: 2px;
    transition: all 0.2s;
}

.clickable-word:hover {
    color: var(--text-primary);
    text-decoration-color: var(--text-primary);
    text-decoration-style: solid;
}

/* Mobile Dictionary Panel */
@media (max-width: 768px) {
    .dictionary-panel {
        top: 0;
        bottom: 0;
        border-radius: 0;
        width: 100%;
        right: -100%;
    }

    .dictionary-panel.open {
        right: 0;
    }
}

@media (max-width: 480px) {
    .dictionary-header h3 {
        font-size: 16px;
    }

    .dictionary-word-header h3 {
        font-size: 20px;
    }

    .dictionary-content {
        padding: 0 16px 16px 16px;
    }
}

/* User Authentication Styles */
.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-btn-primary,
.auth-btn-secondary {
    padding: 10px 16px;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: block;
}

.auth-btn-primary {
    background-color: #000000;
    color: white;
    border: 1px solid #000000;
}

.auth-btn-primary:hover {
    background-color: #000000;
}

.auth-btn-secondary {
    background-color: white;
    color: #000000;
    border: 1px solid #e1e4e8;
}

.auth-btn-secondary:hover {
    background-color: #f8f9fa;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background-color: var(--bg-secondary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-menu-btn:hover {
    background-color: var(--bg-secondary);
}

.user-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    text-align: left;
    overflow: hidden;
}

.user-email {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: 11px;
    color: var(--text-secondary);
}

.user-dropdown {
    position: absolute;
    bottom: 100%;
    left: 12px;
    right: 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    display: none;
    z-index: 1000;
}

.user-dropdown.active {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.dropdown-item:hover {
    background-color: var(--bg-secondary);
}

.dropdown-item svg {
    flex-shrink: 0;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--bg-secondary);
    margin: 4px 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #e1e4e8;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: #586069;
    font-size: 14px;
}

.info-value {
    color: #000000;
    font-weight: 500;
    font-size: 14px;
}
