:root {
    color-scheme: dark;
    --bg: #242326;
    --surface: #2c2a2e;
    --surface-soft: #353237;
    --primary: #d17b62;
    --primary-hover: #bb6952;
    --accent: #a4ad7d;
    --text: #f0e9e1;
    --muted: #b1a8a2;
    --danger: #e27a73;
    --border: #484348;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", sans-serif;
    color: var(--text);
    background:
        radial-gradient(ellipse at 50% -30%, #43363c 0%, transparent 55%),
        var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: min(1100px, 100% - 2rem);
    margin: 0 auto;
}

.topbar {
    position: static;
}

.topbar-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 0 0;
}

.brand {
    text-align: center;
}

.brand h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #e59a7e;
}

.brand p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    gap: 0.6rem;
}

.partner-logo {
    display: block;
    width: min(100%, 450px);
    height: auto;
    aspect-ratio: 3 / 1;
    object-fit: contain;
}

.tradux-logo {
    display: block;
    width: 150px;
    height: auto;
    object-fit: contain;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    border: 1px solid #536354;
    color: #c0ca9a;
    background: #343b34;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.main-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0 1.5rem;
}

.controls-card,
.panel,
.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
}

.controls-card {
    padding: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
}

.lang-switch {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    background: #302e32;
    padding: 0.25rem;
    border-radius: 12px;
    gap: 0.25rem;
}

.lang-btn,
.swap-btn {
    border: 0;
    border-radius: 10px;
    padding: 0.55rem 0.8rem;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
}

.swap-btn {
    cursor: pointer;
}

.lang-btn.active {
    background: #57413d;
    color: #f1b29a;
}

.swap-btn:hover {
    color: var(--primary);
}

.style-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.style-selector label {
    font-size: 0.8rem;
    color: var(--muted);
}

.style-selector select {
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 0.5rem 0.65rem;
    color: var(--text);
    background: var(--surface-soft);
}

.model-selector-help {
    flex-basis: 100%;
    margin: -0.35rem 0 0;
    color: var(--muted);
    font-size: 0.72rem;
}

.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

.panel {
    min-height: 330px;
    padding: 0.85rem;
    position: relative;
    display: flex;
    flex-direction: column;
}

.panel-head,
.panel-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.panel-head {
    border-bottom: 1px solid #484348;
    padding-bottom: 0.55rem;
    margin-bottom: 0.5rem;
}

.panel-foot {
    border-top: 1px solid #484348;
    padding-top: 0.55rem;
    margin-top: 0.5rem;
}

textarea {
    width: 100%;
    border: 0;
    resize: none;
    flex: 1;
    font: inherit;
    color: var(--text);
    background: transparent;
    outline: none;
    line-height: 1.5;
}

.output-text {
    flex: 1;
    overflow: auto;
    line-height: 1.5;
    white-space: pre-wrap;
}

.placeholder {
    color: #a89d99;
    font-style: italic;
}

.panel-actions {
    display: flex;
    gap: 0.35rem;
}

.icon-btn,
.mini-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    border-radius: 10px;
    cursor: pointer;
}

.icon-btn {
    width: 30px;
    height: 30px;
}

.mini-btn {
    padding: 0.35rem 0.6rem;
}

.icon-btn:hover,
.mini-btn:hover {
    border-color: var(--border);
    background: #413c42;
}

.centered {
    display: flex;
    justify-content: center;
}

.btn {
    border: 0;
    border-radius: 11px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.btn-primary {
    padding: 0.8rem 1.25rem;
    color: #fff;
    background: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    padding: 0.5rem 0.8rem;
    color: var(--text);
    border: 1px solid var(--border);
    background: var(--surface-soft);
}

.history-card {
    padding: 0.9rem;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.86rem;
    color: var(--muted);
    cursor: pointer;
}

.history-badge {
    margin-left: 0.4rem;
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    font-size: 0.72rem;
}

.history-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-list {
    margin-top: 0.8rem;
    max-height: 220px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.history-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    padding: 0.6rem;
    cursor: pointer;
}

.history-item small {
    color: var(--muted);
}

.history-item p {
    margin: 0.2rem 0;
    font-size: 0.84rem;
    line-height: 1.35;
}

.history-item .source {
    color: var(--text);
}

.history-item .target {
    color: #e59a7e;
}

.empty-history {
    color: var(--muted);
    text-align: center;
}

.loading-overlay {
    position: absolute;
    inset: 0.85rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: center;
    justify-content: center;
    background: rgba(44, 42, 46, 0.96);
    color: #e7a089;
    font-size: 0.83rem;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #5a4d52;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.footer {
    text-align: center;
    padding: 0.9rem 0 1rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.footer a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover,
.footer a:focus-visible {
    color: #e53935;
}

.toast-container {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 50;
}

.toast {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.8rem;
    border-radius: 12px;
    background: #57413d;
    color: #fff;
    font-size: 0.8rem;
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28);
}

.hidden {
    display: none !important;
}

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

@media (max-width: 720px) {
    .container {
        width: 100%;
    }

    .topbar-content {
        padding: 0.75rem 0.75rem 0;
    }

    .main-layout {
        padding: 0.75rem 0.75rem 1.25rem;
    }

    .grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .panel {
        min-height: 290px;
    }

    .partner-logo {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 420px) {
    .topbar-content {
        gap: 0.5rem;
    }

    .topbar-actions {
        gap: 0.35rem;
    }

    .status-badge {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }

    .controls-card {
        padding: 0.7rem;
    }

    .style-selector {
        width: 100%;
        justify-content: space-between;
    }

    .style-selector select {
        max-width: 68%;
    }

    .main-layout {
        padding-inline: 0.6rem;
    }
}