:root {
    --ink: #17191c;
    --muted: #747c87;
    --faint: #a1a8b2;
    --canvas: #f5f6f7;
    --card: #fff;
    --soft: #f2f4f5;
    --line: #e0e3e6;
    --danger: #c3483b;
    --danger-bg: #fff1ef;
    --radius: 16px;
    --shadow: 0 1px 2px rgb(17 24 32 / 3%), 0 7px 24px rgb(17 24 32 / 4%);
    --body: "Aptos", "Helvetica Neue", "Hiragino Sans", "Yu Gothic UI", "Noto Sans CJK JP", sans-serif;
    --data: "SFMono-Regular", "Roboto Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--body);
}

body { margin: 0; min-height: 100vh; }

button, select, textarea { color: inherit; font: inherit; }
button, select { cursor: pointer; }

button:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
    outline: 3px solid rgb(79 115 255 / 24%);
    outline-offset: 2px;
}

.sr-only {
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    position: absolute;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.topbar {
    height: 56px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgb(255 255 255 / 96%);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.brand-name { font-size: 15px; font-weight: 800; letter-spacing: -.02em; }
.brand-tagline { color: var(--faint); font: 600 10px/1 var(--data); letter-spacing: .2em; }

.locale-switcher {
    display: flex;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
}

.locale-switcher a {
    min-width: 38px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: var(--muted);
    font: 600 11px/1 var(--data);
    text-decoration: none;
}

.locale-switcher a.is-active { background: var(--ink); color: #fff; }

.workspace {
    width: 100%;
    padding: 26px 24px 48px;
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}

.input-panel {
    min-height: calc(100vh - 108px);
    padding: 22px;
    position: sticky;
    top: 20px;
}

.workspace-intro {
    margin: 0 0 19px;
    padding: 0 1px 18px;
    border-bottom: 1px solid var(--line);
}

.workspace-intro h1 {
    max-width: 340px;
    margin: 0;
    font-size: clamp(19px, 2vw, 24px);
    line-height: 1.15;
    letter-spacing: -.035em;
}

.workspace-intro p {
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
}

.language-route {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
    gap: 7px;
    align-items: center;
}

select {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 32px 0 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--soft);
    font-size: 13px;
    font-weight: 700;
}

select:hover { border-color: #d5d9dd; }

.swap-button {
    width: 28px;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--faint);
    font-size: 17px;
}

.swap-button:hover { color: var(--ink); transform: translateX(2px); }

textarea {
    width: 100%;
    min-height: 220px;
    margin-top: 17px;
    padding: 0;
    resize: vertical;
    border: 0;
    background: transparent;
    font-size: 17px;
    line-height: 1.75;
}

textarea::placeholder { color: #b3b8bf; }
textarea.is-invalid { box-shadow: inset 0 -2px 0 var(--danger); }

.input-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 0 13px;
    border-bottom: 1px solid var(--line);
    color: var(--faint);
    font-size: 11px;
}

.input-meta strong { font: inherit; }
.input-meta.is-over-limit { color: var(--danger); }

.input-limit-message {
    margin: 9px 0 -5px;
    color: var(--danger);
    font-size: 11px;
    line-height: 1.4;
}

.text-button, .copy-button {
    padding: 4px;
    border: 0;
    background: transparent;
    color: var(--faint);
}

.text-button { font-size: 11px; }
.text-button:hover, .copy-button:hover:not(:disabled) { color: var(--ink); }

.primary-button {
    width: 100%;
    height: 50px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: 11px;
    background: var(--ink);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    transition: transform .16s, opacity .16s;
}

.primary-button:hover:not(:disabled) { transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: .7; }
.primary-button.is-loading:disabled { cursor: wait; }

.button-progress {
    width: 14px;
    height: 14px;
    display: none;
    border: 2px solid rgb(255 255 255 / 35%);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.primary-button.is-loading .button-progress { display: block; }

.privacy-note {
    margin: 11px 0 0;
    color: var(--faint);
    font-size: 10px;
    line-height: 1.4;
    text-align: center;
}

.history {
    margin-top: 21px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.history h2 {
    margin: 0 0 8px;
    color: var(--faint);
    font-size: 11px;
    letter-spacing: .05em;
}

.history-list { display: grid; }

.history-item {
    min-width: 0;
    padding: 10px 4px;
    display: grid;
    grid-template-columns: 17px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    border-radius: 7px;
    cursor: pointer;
}

.history-item:hover { background: var(--soft); }
.history-clock { color: var(--faint); font: 11px/1 var(--data); }

.history-item strong {
    min-width: 0;
    overflow: hidden;
    color: #42474e;
    font-size: 12px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-route { color: var(--faint); font: 9px/1 var(--data); white-space: nowrap; }
.history-empty { margin: 12px 4px 0; color: var(--faint); font-size: 11px; }

.comparison { min-width: 0; }

.comparison-header {
    min-height: 44px;
    padding: 0 3px 11px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.comparison-header h2 { margin: 0; font-size: 14px; }
.comparison-header p { margin: 0; color: var(--faint); font-size: 11px; }
.comparison-header strong { font-weight: 600; }

.model-picker {
    margin-bottom: 16px;
    padding: 15px 17px;
}

.model-picker-heading {
    margin-bottom: 11px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.model-picker-heading h3 { margin: 0; font-size: 12px; }
.model-picker-heading p { margin: 0; color: var(--faint); font-size: 10px; }
.model-picker-heading p.is-warning { color: var(--danger); }

.model-options {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.model-option {
    min-height: 30px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
    font-size: 10px;
    transition: border-color .15s, background .15s, color .15s;
}

.model-option input { position: absolute; opacity: 0; pointer-events: none; }
.model-option i { width: 6px; height: 6px; border-radius: 50%; background: var(--model-accent); }
.model-option:has(input:checked) { border-color: #aeb6bf; background: var(--soft); color: var(--ink); }
.model-option:has(input:focus-visible) { outline: 3px solid rgb(79 115 255 / 24%); outline-offset: 2px; }
.model-option.is-unavailable { cursor: not-allowed; opacity: .42; }

.model-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.model-card {
    min-width: 0;
    min-height: 260px;
    overflow: hidden;
}

.model-card[hidden] { display: none; }

.model-header {
    height: 48px;
    margin: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
}

.model-name, .model-actions { display: flex; align-items: center; }
.model-name { min-width: 0; gap: 9px; }

.model-name i {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--model-accent);
}

.model-name h3 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-actions { gap: 8px; }
.model-duration { color: var(--faint); font: 10px/1 var(--data); white-space: nowrap; }
.copy-button { width: 25px; height: 28px; font-size: 15px; }
.copy-button:disabled { cursor: default; opacity: .42; }

.model-body { min-height: 210px; padding: 18px; }

.model-ready {
    min-height: 174px;
    display: grid;
    place-content: center;
    text-align: center;
}

.model-ready::before {
    content: "";
    width: 24px;
    height: 2px;
    margin: 0 auto 15px;
    background: var(--model-accent);
}

.model-ready strong { font-size: 13px; }
.model-ready p { max-width: 260px; margin: 7px auto 0; color: var(--faint); font-size: 11px; line-height: 1.55; }

.model-loading {
    min-height: 174px;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.model-loading:not([hidden]) { display: flex; }
.model-loading span { width: 6px; height: 6px; border-radius: 50%; background: var(--model-accent); animation: pulse 1s ease-in-out infinite; }
.model-loading span:nth-child(2) { animation-delay: .14s; }
.model-loading span:nth-child(3) { animation-delay: .28s; }

.model-result { animation: reveal .28s ease both; }

.source-preview {
    margin: 0 0 12px;
    padding-bottom: 12px;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
    color: var(--faint);
    font-size: 11px;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.translated-text {
    min-height: 92px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 15px;
    font-weight: 540;
    line-height: 1.75;
}

.detected-language {
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--faint);
    font: 9px/1.4 var(--data);
    text-transform: uppercase;
}

.model-error {
    min-height: 174px;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.model-error:not([hidden]) { display: flex; }

.error-mark {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--danger-bg);
    color: var(--danger);
    font: 700 14px/1 var(--data);
}

.model-error strong { color: var(--danger); font-size: 12px; }
.model-error p { max-width: 290px; margin: 4px 0; color: #4b5057; font-size: 12px; line-height: 1.5; }
.model-error small { color: var(--faint); font: 9px/1.4 var(--data); }

[hidden] { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 1500px) {
    .model-card { min-height: 286px; }
    .model-body { min-height: 236px; }
}

@media (max-width: 980px) {
    .workspace { grid-template-columns: 340px minmax(0, 1fr); padding-inline: 16px; gap: 16px; }
    .model-grid { grid-template-columns: 1fr; }
    .input-panel { top: 12px; }
}

@media (max-width: 720px) {
    .topbar { position: sticky; top: 0; z-index: 20; }
    .brand-tagline { display: none; }
    .locale-switcher a { min-width: 32px; }
    .workspace { grid-template-columns: 1fr; padding: 14px 10px 36px; }
    .input-panel { min-height: auto; position: static; }
    .workspace-intro h1 { max-width: none; }
    textarea { min-height: 160px; }
    .comparison-header { margin-top: 8px; }
    .model-picker-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
}

@media (max-width: 430px) {
    .input-panel, .model-card { border-radius: 13px; }
    .input-panel { padding: 16px; }
    .comparison-header p { max-width: 150px; text-align: right; }
    .model-grid { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
