* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --ink:    #0e0e0e;
    --ink2:   #2a2a2a;
    --muted:  #6b6b6b;
    --faint:  #b0b0b0;
    --bg:     #f5f2ed;
    --bg2:    #edeae3;
    --accent: #1a3a5c;
    --accent-hover: #122b45;
    --accent2:#c8873a;
    --accent-light: #e8f0f8;
    --white:  #ffffff;
    --rule:   #d0cdc6;

    --success-green: #22c55e;
    --warning-orange: #f59e0b;
    --error-red: #ef4444;

    /* Mapped aliases for minimal JS/HTML churn */
    --primary-blue: var(--accent);
    --primary-blue-hover: var(--accent-hover);
    --secondary-blue: var(--accent2);
    --light-blue: var(--accent-light);
    --very-light-blue: var(--bg);
    --text-primary: var(--ink2);
    --text-secondary: var(--muted);
    --text-light: var(--white);
    --background: var(--bg);
    --card-background: var(--white);
    --border-color: var(--rule);
    --border-radius: 0px;
    --shadow: 4px 4px 0 var(--bg2);
    --shadow-hover: 6px 6px 0 var(--bg2);
    --font-family: 'DM Sans', sans-serif;
}

body {
    font-family: var(--font-family);
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    overflow-y: auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =================================================================
   MAIN HEADER (BLUE BAR)
   ================================================================= */
.main-header {
    background: var(--accent);
    color: var(--white);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent-hover);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left svg {
    color: var(--white);
}

.header-left h1 {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.save-indicator {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.03em;
}

/* =================================================================
   ACTION TOOLBAR
   ================================================================= */
.action-toolbar {
    background: var(--white);
    border-bottom: 1px solid var(--rule);
    padding: 12px 16px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.toolbar-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toolbar-api {
    position: relative;
}

.toolbar-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    color: var(--faint);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.toolbar-control {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 13px;
    background: var(--card-background);
    color: var(--text-primary);
    min-width: 120px;
    transition: all 0.2s ease;
}

.toolbar-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: none;
}

.toolbar-api input.toolbar-control {
    min-width: 200px;
    padding-right: 32px;
}

.api-status-icon {
    position: absolute;
    right: 8px;
    bottom: 8px;
    color: var(--success-green);
    font-size: 14px;
}

.toolbar-btn-icon {
    background: var(--very-light-blue);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    align-self: flex-end;
}

.toolbar-btn-icon:hover {
    background: var(--light-blue);
}

.toolbar-divider {
    width: 1px;
    height: 32px;
    background: var(--border-color);
    margin: 0 4px;
}

.toolbar-btn {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    padding: 7px 14px;
    border-radius: var(--border-radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.toolbar-btn:hover:not(:disabled) {
    background: var(--very-light-blue);
    border-color: var(--primary-blue);
}

.toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toolbar-btn svg {
    flex-shrink: 0;
}

.toolbar-spacer {
    flex: 1;
}

.toolbar-btn-primary {
    background: var(--primary-blue);
    color: var(--text-light);
    border: none;
    padding: 8px 24px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
}

.toolbar-btn-primary:hover:not(:disabled) {
    background: var(--primary-blue-hover);
}

.toolbar-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =================================================================
   MAIN CONTAINER (NO SCROLL - children scroll individually)
   ================================================================= */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px;
    gap: 0;
    min-height: 0;
}

/* =================================================================
   CONTEXT PANEL (COLLAPSIBLE)
   ================================================================= */
.context-panel {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    flex-shrink: 0;
    transition: all 0.3s ease;
    margin: 16px 16px 0 16px;
}

.context-panel.collapsed .context-body {
    display: none;
}

.context-panel.collapsed {
    margin-bottom: 0;
}

.context-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--rule);
    background: var(--bg);
}

.context-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'DM Mono', monospace;
    font-weight: 500;
    color: var(--accent);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.context-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.context-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.context-toggle input[type="checkbox"] {
    cursor: pointer;
}

.context-collapse-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.context-collapse-btn:hover {
    color: var(--primary-blue);
}

.context-panel.collapsed .context-collapse-btn svg {
    transform: rotate(180deg);
}

.context-body {
    padding: 12px 16px;
}

.context-body textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: 13px;
    resize: vertical;
    background: var(--very-light-blue);
}

.context-body textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: none;
}

.context-hint {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* =================================================================
   IMAGE PREVIEW SECTION
   ================================================================= */
.image-preview-section {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.section-header {
    margin-bottom: 12px;
}

.section-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.image-preview {
    margin-top: 12px;
}

.image-preview-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
}

.image-preview-item {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--card-background);
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.image-preview-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.image-preview-item img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
}

.image-preview-item .image-caption {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 6px;
    word-break: break-word;
}

.image-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 0;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--rule);
}

.image-status-pill.status-queued {
    background: var(--very-light-blue);
    color: var(--text-secondary);
}

.image-status-pill.status-processing {
    background: #fff7ed;
    color: #ea580c;
    border-color: #fed7aa;
}

.image-status-pill.status-translated {
    background: #ecfdf3;
    color: #15803d;
    border-color: #bbf7d0;
}

.image-status-pill.status-error {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecdd3;
}

.extraction-progress-wrapper {
    margin-top: 12px;
    padding: 12px;
    background: var(--very-light-blue);
    border-radius: var(--border-radius);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.pasted-images-list {
    margin-top: 12px;
    padding: 10px;
    background: var(--very-light-blue);
    border-radius: var(--border-radius);
}

.pasted-images-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.pasted-images-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pasted-image-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0;
    font-size: 11px;
}

.pasted-image-tag .remove-icon {
    cursor: pointer;
    color: var(--error-red);
    font-weight: bold;
    transition: transform 0.2s;
}

.pasted-image-tag .remove-icon:hover {
    transform: scale(1.2);
}

/* =================================================================
   TRANSLATION AREA (MAIN CONTENT - GROWS AND SCROLLS)
   ================================================================= */
.translation-area {
    flex: 1;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 300px;
    margin: 16px;
}

.translation-panels {
    display: flex;
    flex-direction: row;
    gap: 0;
    background: var(--border-color);
    flex: 1;
    overflow: hidden;
    position: relative;
}

.translation-panel {
    background: var(--card-background);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-width: 200px;
}

.resize-handle {
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    user-select: none;
    position: relative;
    flex-shrink: 0;
}

.resize-handle-vertical {
    width: 8px;
    cursor: col-resize;
}

.resize-handle-horizontal {
    height: 8px;
    width: 100%;
    cursor: row-resize;
    flex-shrink: 0;
}

.resize-handle:hover {
    background: var(--primary-blue);
}

.resize-handle:active {
    background: var(--primary-blue-hover);
}

.resize-handle-icon {
    color: var(--text-secondary);
    font-size: 18px;
    pointer-events: none;
}

.resize-handle-vertical .resize-handle-icon {
    transform: rotate(90deg);
}

.resize-handle-horizontal .resize-handle-icon {
    transform: rotate(0deg);
}

.resize-handle:hover .resize-handle-icon {
    color: var(--text-light);
}

.panel-header {
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-header label {
    font-family: 'DM Mono', monospace;
    font-weight: 500;
    font-size: 11px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 6px;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.icon-btn:hover:not(:disabled) {
    background: var(--light-blue);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.char-count {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--faint);
    letter-spacing: 0.05em;
}

.translation-panel textarea {
    flex: 1;
    width: 100%;
    padding: 16px;
    border: none;
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    background: var(--card-background);
    overflow-y: auto;
    min-height: 200px;
    max-height: 100%;
}

.translation-panel textarea:focus {
    outline: none;
}

.translation-panel textarea[readonly] {
    background: var(--very-light-blue);
    cursor: default;
}

/* =================================================================
   HISTORY PANEL (FIXED HEIGHT WITH SCROLL)
   ================================================================= */
.history-panel {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 100px;
    transition: opacity 0.3s ease;
    overflow: hidden;
    margin: 0 16px 16px 16px;
}

.history-panel.collapsed {
    flex: 0 0 48px;
    min-height: 48px;
    max-height: 48px;
}

.history-panel.collapsed .history-list {
    display: none;
}

.history-panel.collapsed #toggleHistoryBtn svg {
    transform: rotate(180deg);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--rule);
    background: var(--bg);
    flex-shrink: 0;
}

.history-header h3 {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0;
}

.history-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon-small {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 4px 6px;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.btn-icon-small:hover {
    background: var(--light-blue);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.btn-icon-small svg {
    transition: transform 0.3s ease;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.history-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-style: italic;
    font-size: 13px;
}

.history-item {
    background: var(--very-light-blue);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: var(--light-blue);
    box-shadow: var(--shadow);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

.history-item-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.history-source, .history-target {
    font-size: 13px;
    line-height: 1.4;
}

.history-source {
    color: var(--text-primary);
    border-right: 1px solid var(--border-color);
    padding-right: 12px;
}

.history-target {
    color: var(--text-secondary);
}

/* RTL support */
.rtl {
    direction: rtl;
    text-align: right;
}

/* =================================================================
   BUTTONS
   ================================================================= */
.btn-primary {
    background: var(--primary-blue);
    color: var(--text-light);
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-blue-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--primary-blue);
    border: 1px solid var(--primary-blue);
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--primary-blue);
    color: var(--text-light);
}

.btn-secondary-small {
    background: transparent;
    color: var(--primary-blue);
    border: 1px solid var(--primary-blue);
    padding: 6px 12px;
    border-radius: var(--border-radius);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary-small:hover {
    background: var(--primary-blue);
    color: var(--text-light);
}

/* =================================================================
   MODALS
   ================================================================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    width: min(500px, 90%);
    max-height: 80vh;
    background: var(--white);
    border-radius: 0;
    border: 1px solid var(--rule);
    box-shadow: 6px 6px 0 var(--bg2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-wide {
    width: min(800px, 90%);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--rule);
    background: var(--bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: 14px;
    resize: vertical;
}

.modal-body textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: none;
}

.prompt-name-row {
    margin-bottom: 16px;
}

.prompt-name-row label,
.modal-body > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.prompt-name-row input,
.prompt-name-row .control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
}

.prompt-name-row input:focus,
.prompt-name-row .control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: none;
}

.inline-image-progress {
    margin: 6px 12px 12px 12px;
    padding: 8px 10px;
    background: var(--very-light-blue);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 10px;
}

.inline-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.inline-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.3s ease;
}

.inline-progress-text {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 140px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--rule);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg);
}

/* Settings Modal */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-section h4 {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent2);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--rule);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.form-control {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: var(--font-family);
    background: var(--card-background);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: none;
}

.form-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Prompts Modal */
.prompts-list-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.prompts-toolbar {
    display: flex;
    justify-content: flex-end;
}

.prompts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.prompts-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-style: italic;
}

.prompt-card {
    background: var(--very-light-blue);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.prompt-card:hover {
    background: var(--light-blue);
    box-shadow: var(--shadow);
}

.prompt-card.active {
    border-color: var(--primary-blue);
    background: var(--light-blue);
}

.prompt-card-content {
    flex: 1;
}

.prompt-card-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.prompt-card-preview {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-card-actions {
    display: flex;
    gap: 6px;
}

/* =================================================================
   TOAST NOTIFICATIONS
   ================================================================= */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--accent);
    color: var(--white);
    padding: 14px 20px;
    border-radius: 0;
    box-shadow: 4px 4px 0 var(--bg2);
    border: 1px solid var(--rule);
    transform: translateX(120%);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 2000;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.toast.success {
    background: var(--success-green);
}

.toast.error {
    background: var(--error-red);
}

.toast.warning {
    background: var(--warning-orange);
}

/* =================================================================
   LOADING SPINNER
   ================================================================= */
.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =================================================================
   IMAGE ZOOM
   ================================================================= */
.image-zoom {
    position: fixed;
    z-index: 9999;
    width: 360px;
    max-width: min(360px, calc(100vw - 24px));
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: 6px 6px 0 var(--bg2);
    overflow: hidden;
    pointer-events: none;
}

.image-zoom img {
    width: 100%;
    height: 240px;
    object-fit: contain;
    display: block;
    background: var(--background);
}

.image-zoom-caption {
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

/* =================================================================
   UTILITY CLASSES
   ================================================================= */
.hidden {
    display: none !important;
}

/* =================================================================
   SCROLLBAR STYLING
   ================================================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--rule);
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* =================================================================
   ALTERNATIVES MODAL
   ================================================================= */
.alternatives-source-preview {
    background: var(--very-light-blue);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alternatives-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alternatives-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 32px 16px;
    font-size: 14px;
}

.alternatives-loading {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.alternative-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: default;
}

.alternative-card:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 1px var(--primary-blue);
}

.alternative-number {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    font-weight: 500;
}

.alternative-content {
    flex: 1;
    min-width: 0;
}

.alternative-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    word-break: break-word;
}

.alternative-actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
}

.alternative-use-btn {
    padding: 6px 14px;
    border: 1px solid var(--primary-blue);
    background: transparent;
    color: var(--primary-blue);
    border-radius: var(--border-radius);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.alternative-use-btn:hover {
    background: var(--primary-blue);
    color: white;
}

.alternative-copy-btn {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.alternative-copy-btn:hover {
    background: var(--very-light-blue);
    color: var(--text-primary);
}

/* =================================================================
   RESPONSIVE DESIGN
   ================================================================= */
@media (max-width: 1200px) {
    .translation-panels {
        grid-template-columns: 1fr;
    }
    
    .history-item-content {
        grid-template-columns: 1fr;
    }
    
    .history-source {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-right: 0;
        padding-bottom: 8px;
        margin-bottom: 4px;
    }
}

@media (max-width: 768px) {
    .action-toolbar {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .main-container {
        padding: 12px;
        gap: 12px;
    }
    
    .toolbar-control {
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .main-header {
        padding: 10px 16px;
    }
    
    .header-left h1 {
        font-size: 16px;
    }
    
    .action-toolbar {
        padding: 10px 12px;
        gap: 8px;
    }
}

/* =================================================================
   AUTH & ACCOUNT UI
   ================================================================= */

/* Plan badge in header */
.plan-badge {
    display: inline-block;
    padding: 2px 10px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--white);
    background: var(--accent);
    border: 1px solid var(--accent);
}

.plan-badge[data-plan="office"] {
    background: var(--accent2);
    border-color: var(--accent2);
}

.plan-badge[data-plan="enterprise"] {
    background: var(--ink);
    border-color: var(--ink);
}

/* Usage badge */
.usage-badge {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    padding: 2px 8px;
    border: 1px solid var(--rule);
    cursor: default;
}

.usage-badge.usage-warning {
    color: var(--warning-orange);
    border-color: var(--warning-orange);
}

.usage-badge.usage-exceeded {
    color: var(--error-red);
    border-color: var(--error-red);
}

/* Login button */
.btn-login {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    padding: 6px 16px;
    background: var(--white);
    color: var(--accent);
    border: 2px solid var(--accent);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-login:hover {
    background: var(--accent);
    color: var(--white);
}

/* User avatar / dropdown */
.user-menu {
    position: relative;
}

.user-avatar-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent2);
    color: var(--white);
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
}

.user-avatar-btn:hover {
    opacity: 0.85;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    background: var(--white);
    border: 1px solid var(--rule);
    box-shadow: var(--shadow);
    z-index: 1000;
}

.dropdown-user-info {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-user-info strong {
    font-size: 14px;
    color: var(--ink);
}

.dropdown-user-info small {
    font-size: 12px;
    color: var(--muted);
}

.dropdown-plan {
    display: inline-block;
    margin-top: 4px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--accent);
    padding: 2px 6px;
    border: 1px solid var(--accent);
    width: fit-content;
}

.dropdown-divider {
    height: 1px;
    background: var(--rule);
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    color: var(--ink2);
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.1s;
}

.dropdown-item:hover {
    background: var(--bg);
}

.dropdown-item-danger {
    color: var(--error-red);
}

.dropdown-item-danger:hover {
    background: #fef2f2;
}

/* Auth modal */
.modal-auth {
    max-width: 400px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-submit-btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 500;
    margin-top: 4px;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    font-family: 'DM Sans', sans-serif;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.15s;
}

.link-btn:hover {
    text-decoration-color: var(--accent);
}

.auth-error {
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid var(--error-red);
    color: var(--error-red);
    font-size: 13px;
}

.auth-success {
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid var(--success-green);
    color: #166534;
    font-size: 13px;
}

/* Devices list */
.devices-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--rule);
}

.device-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.device-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}

.device-meta {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
}

.device-current {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--success-green);
}

.device-remove {
    padding: 4px 10px;
    font-size: 12px;
    color: var(--error-red);
    background: none;
    border: 1px solid var(--error-red);
    cursor: pointer;
    transition: all 0.15s;
}

.device-remove:hover {
    background: var(--error-red);
    color: var(--white);
}

/* Project bar */
.project-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: var(--bg2);
    border-bottom: 1px solid var(--rule);
}

.project-select {
    max-width: 300px;
    font-size: 13px;
}

/* Feature gate overlays */
.feature-locked {
    position: relative;
    pointer-events: none;
    opacity: 0.4;
}

.feature-locked::after {
    content: 'Upgrade to unlock';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(245, 242, 237, 0.7);
    pointer-events: all;
    cursor: pointer;
}
