/* Selected Mercury references: onyx, graphite, ivory, restrained type and pills.
   Application layout, state colors and rich document contents remain independent. */
:root {
    --canvas: #171721;
    --surface: #1e1e2a;
    --control: #272735;
    --ivory: #ededf3;
    --ash: #c3c3cc;
    --cobalt: #5266eb;
    --edge: rgba(226, 227, 237, .16);
}

html { background: var(--canvas); }
body {
    margin: 0;
    min-height: 100vh;
    height: auto;
    isolation: isolate;
    background: var(--canvas);
    color: var(--ivory);
    font-family: 'Inter', 'Segoe UI', sans-serif;
    line-height: 1.5;
    padding: 24px clamp(16px, 3vw, 48px) 40px;
    color-scheme: dark;
}

.site-background {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: var(--canvas);
}
.site-background-layer {
    position: absolute;
    inset: 0;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 1.2s ease;
}
.site-background-layer.is-visible { opacity: 1; }
.site-background::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(23, 23, 33, .38), rgba(23, 23, 33, .64));
}

.top-banner {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 136px;
    margin: 0 0 24px;
    padding: 24px 32px;
    background: rgba(23, 23, 33, .65);
    backdrop-filter: blur(16px);
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
}
.top-banner::before { content: none; }
.banner-content { padding: 0; color: var(--ivory); }
.banner-content h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: .015em;
}
.banner-content p { margin: 8px 0 0; color: var(--ash); font-size: 14px; }
.site-clock-wrap {
    flex-shrink: 0;
    text-align: right;
    padding: 12px 18px;
    border-radius: 12px;
    background: rgba(30, 30, 42, .8);
    border: 1px solid var(--edge);
}
.site-clock-label {
    display: block;
    margin-bottom: 4px;
    font-size: 10px;
    letter-spacing: .12em;
    color: var(--ash);
    font-weight: 400;
}
#site-clock {
    display: block;
    font-size: clamp(22px, 3vw, 28px);
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: .04em;
    font-variant-numeric: tabular-nums;
    color: var(--ivory);
    min-width: 8ch;
}

h2, h3 { font-weight: 500; letter-spacing: .01em; }
.card, #file-page .card {
    background: rgba(30, 30, 42, .94);
    border-radius: 12px;
    border: 1px solid var(--edge);
    padding: 24px 32px;
    box-shadow: none;
    backdrop-filter: blur(12px);
}
.card:hover { transform: none; box-shadow: none; border-color: rgba(226, 227, 237, .28); }
.card b, .card-text b { font-weight: 500; }
.card small, .card-received-time, .empty-upload, .label,
.retranslate-label, #m-meta, .search-icon { color: var(--ash); }
.label, .retranslate-label, .panel-title { font-weight: 500; }
button, input, select, textarea { font-family: inherit; }
button { border-radius: 32px; padding: 9px 16px; font-weight: 500; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:disabled:hover { transform: none; }
button:focus-visible, input:focus-visible, select:focus-visible,
#user-trigger:focus-visible {
    outline: 2px solid var(--ivory);
    outline-offset: 3px;
}
.primary, #process-btn, #text-process-btn {
    background: var(--cobalt);
    color: #fff;
    border-radius: 32px;
    box-shadow: none;
    font-weight: 500;
}
#process-btn:hover, #text-process-btn:hover { box-shadow: none; }
.gray, .countdown button, #m-log-btn {
    background: var(--control);
    color: var(--ivory);
    border: 1px solid var(--edge);
    border-radius: 32px;
}
.tabs { gap: 16px; align-items: center; }
.tab-left { flex-wrap: wrap; gap: 8px; }
.tab { background: rgba(30, 30, 42, .9); color: var(--ash); font-weight: 400; padding: 12px 20px; }
.tab:hover { background: var(--control); color: var(--ivory); font-weight: 400; }
.tab.active { background: var(--ivory); color: var(--canvas); font-weight: 500; box-shadow: none; }
#user-box, #user-trigger { background: var(--surface); color: var(--ivory); }
#user-box { padding: 4px; }
#user-trigger { font-weight: 500; }
#username-display { color: var(--ivory); font-weight: 500; }
#user-menu { background: var(--surface); border-color: var(--edge); box-shadow: none; }
#user-box button, #user-menu button { background: var(--surface); color: var(--ivory); }
#user-menu button:hover { background: var(--control); }
.search-box {
    background: rgba(30, 30, 42, .94);
    border-color: var(--edge);
    border-radius: 32px;
    box-shadow: none;
    height: 56px;
}
.search-box:focus-within { border-color: var(--ash); box-shadow: none; }
#email-search { color: var(--ivory); min-width: 0; }
#email-search::placeholder, .input::placeholder { color: var(--ash); }
#search-clear-btn { color: var(--ash); }
#search-clear-btn:hover { background: var(--control); color: var(--ivory); }
.input, .retranslate-select, .email-input {
    background: var(--control);
    color: var(--ivory);
    border-color: var(--edge);
    border-radius: 32px;
}
.input:focus, .retranslate-select:focus { background: var(--control); border-color: var(--ash); box-shadow: none; }
.email-input input { color: var(--ivory); }
.chip, .countdown, .lang-badge, #m-lang-display {
    background: var(--control);
    color: var(--ash);
    border-color: var(--edge);
    border-radius: 32px;
}
.chip button { color: var(--ivory); }
.retranslate-row { background: rgba(39, 39, 53, .5); border-radius: 12px; padding: 12px; gap: 12px; flex-wrap: wrap; }
.upload-box { background: var(--control); color: var(--ash); border: 1px dashed rgba(226, 227, 237, .35); border-radius: 12px; padding: 24px; }
.upload-box:hover, .upload-box.dragover { background: #303041; color: var(--ivory); border-color: var(--ivory); }
.file-item { background: var(--control); color: var(--ivory); border-color: var(--edge); }
.file-item:hover { border-color: var(--ash); box-shadow: none; }
.modal { background: rgba(12, 12, 20, .7); }
.modal-box, #m-header, .modal-footer { background: var(--surface); color: var(--ivory); box-shadow: none; }
.modal-box { border-radius: 12px; border: 1px solid var(--edge); max-width: 95vw; }
.modal-footer { border-color: var(--edge); gap: 12px; flex-wrap: wrap; }
.divider { background: var(--edge); }
/* Email HTML, translated documents and the editor retain a paper surface. */
#m-body-view, #m-body, #text-result {
    background: #fff;
    color: #1f2937;
    color-scheme: light;
    border-radius: 12px;
    border-color: #e5e7eb;
}
.tox-tinymce { color-scheme: light; }
#scrollTopBtn { background: var(--control); border: 1px solid var(--edge); box-shadow: none; }
.credit {
    position: fixed;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 0;
    width: 100%;
    margin: 0;
    padding: 0 16px;
    text-align: center;
    z-index: 10;
    pointer-events: none;
    color: var(--ash);
}

/* Login shares the same landscape, palette and clock. */
body.login-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100svh;
    padding: 120px 20px 32px;
    backdrop-filter: none;
}
.login-page .site-clock-wrap { position: absolute; top: 24px; right: 24px; }
.login-box {
    width: min(100%, 400px);
    padding: 40px 32px;
    background: rgba(30, 30, 42, .94);
    border: 1px solid var(--edge);
    border-radius: 12px;
    color: var(--ivory);
    box-shadow: none;
    backdrop-filter: blur(12px);
}
.login-box h2 { font-weight: 500; font-size: 24px; line-height: 1.25; }
.input-group input {
    background: var(--control);
    border: 1px solid var(--edge);
    border-radius: 32px;
    color: var(--ivory);
    padding: 12px 16px;
    font-size: 14px;
}
.input-group input::placeholder { color: var(--ash); }
.login-box button { background: var(--cobalt); color: #fff; font-weight: 500; }
.login-box button:hover { background: var(--cobalt); opacity: .9; }
.options, .footer { color: var(--ash); }
.footer a { color: var(--ivory); font-weight: 500; }
.login-page .credit { font-size: 12px; }
.modal-content { background: var(--surface); color: var(--ivory); border: 1px solid var(--edge); border-radius: 12px; max-width: calc(100vw - 32px); }
.modal-content button { background: var(--control); color: var(--ivory); }

@media (max-width: 640px) {
    body { padding: 16px 16px 32px; }
    .top-banner { padding: 20px; min-height: 120px; gap: 16px; flex-wrap: wrap; position: relative; }
    .site-clock-wrap { padding: 10px 12px; margin-left: auto; }
    .site-clock-label { font-size: 9px; }
    .tabs { flex-wrap: wrap; }
    .tab-left { flex: 1 1 100%; }
    .tab { padding: 10px 14px; font-size: 12px; }
    #user-box { margin-left: auto; }
    .card, #file-page .card { padding: 20px; gap: 16px; }
    #list .card { flex-direction: column; align-items: stretch; }
    .card-actions { align-items: flex-end; }
    .card-actions .right { flex-wrap: wrap; justify-content: flex-end; }
    .lang-badge { position: static; align-self: flex-end; }
    .modal-body { padding: 16px; }
    .login-page .site-clock-wrap { top: 16px; right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .site-background-layer { transition: none; }
}
