@font-face {
    font-family: Montserrat;
    src: url("montserrat-latin.woff2") format("woff2");
    font-weight: 400 900;
    font-display: swap;
}

:root {
    color-scheme: light;
    touch-action: pan-x pan-y;
    --background: #f4f1ea;
    --card: #fdfbf5;
    --text: #25271f;
    --muted: #555c50;
    --line: #d6d3c7;
    --accent: #4d6344;
    --accent-hover: #3e5236;
    --button-text: #fff;
    --focus: #38677b;
    --error-bg: #fdece7;
    --error-text: #941d31;
    --error-line: #e48b98;
    --error-action: #ae2641;
    --info-bg: #e5f4ff;
    --info-text: #114f7a;
    --info-line: #71b0de;
    --warning-bg: #fff1d5;
    --warning-text: #704000;
    --warning-line: #d9a039;
    --success-bg: #ddf8e9;
    --success-text: #145a3a;
    --success-line: #76bd97;
    --success-action: #167047;
    --feedback-action-text: #fff;
    --label-color: #244f79;
    --shadow: 0 16px 45px #35341e14;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #20241d;
    --card: #292f25;
    --text: #f7f3eb;
    --muted: #c4ccbc;
    --line: #5c6656;
    --accent: #b9cba8;
    --accent-hover: #c8dbb8;
    --button-text: #20241d;
    --focus: #a4cadd;
    --error-bg: #462131;
    --error-text: #ffb9c5;
    --error-line: #db728b;
    --error-action: #ffa2b7;
    --info-bg: #163650;
    --info-text: #b2e0ff;
    --info-line: #569bc6;
    --warning-bg: #423116;
    --warning-text: #ffdb8b;
    --warning-line: #d6a14c;
    --success-bg: #153a2b;
    --success-text: #a5eac6;
    --success-line: #57a47c;
    --success-action: #93e0b7;
    --feedback-action-text: #172920;
    --label-color: #b3d7ff;
    --shadow: 0 16px 45px #11160f40;
}

*, *::before, *::after { box-sizing: border-box; }

#app-initial-loading { display: none; }
html[data-initial-loading] #app-initial-loading { display: grid; }
.app-loading {
    position: fixed; inset: 0; z-index: 90;
    display: grid; place-items: center; padding: 16px;
    background: color-mix(in srgb, var(--background) 84%, transparent);
    color: var(--text); pointer-events: none;
}
.app-loading-panel {
    width: min(100%, 620px); padding: clamp(14px, 4vw, 24px);
    border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow);
}
.app-loading-title { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.app-loading-title > .ui-icon { color: var(--accent); flex: none; }
.app-loading-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
    gap: 10px; margin-top: 14px;
}
.app-loading-cards > div {
    display: grid; gap: 9px; padding: 12px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--background);
}
.app-loading-cards span {
    display: block; width: 100%; height: .65rem; border-radius: 10px;
    background: linear-gradient(100deg, var(--line) 20%, color-mix(in srgb, var(--accent) 25%, var(--line)) 50%, var(--line) 80%);
    background-size: 220% 100%;
}
.app-loading-cards span:first-child { width: 46%; height: .95rem; }
.app-loading-cards span:last-child { width: 73%; }
@media (prefers-reduced-motion: no-preference) {
    .app-loading-cards span { animation: app-loading-shimmer 1.5s linear infinite; }
}
@keyframes app-loading-shimmer { to { background-position: -220% 0; } }

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
        max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    display: grid;
    place-items: center;
    background: var(--background);
    color: var(--text);
    font: 400 1rem/1.55 Montserrat, system-ui, sans-serif;
}

.auth-box {
    position: relative;
    width: min(100%, 460px);
    padding: 42px 32px 32px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.logo {
    display: block;
    width: 195px;
    max-width: 68%;
    height: auto;
    margin: 0 auto 20px;
    filter: brightness(0);
}

[data-theme="dark"] .logo { filter: brightness(0) invert(1); }

.theme-button {
    position: absolute;
    inset: 22px 22px auto auto;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
    color: var(--focus);
    cursor: pointer;
}

.theme-button svg { display: block; width: 19px; height: 19px; margin: auto; }
:root[data-theme="light"] .sun, :root[data-theme="dark"] .moon { display: none; }
.theme-button:hover { border-color: var(--focus); }

h1 {
    margin: 0;
    font-size: clamp(1.35rem, 5vw, 1.7rem);
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -.035em;
    text-align: center;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

.intro {
    margin: 8px 0 24px;
    color: var(--muted);
    text-align: center;
}

.field + .field { margin-top: 16px; }

label {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: .93rem;
    color: var(--label-color);
    text-transform: uppercase;
}

label svg, .action svg { width: 17px; height: 17px; flex: none; }
label svg { color: var(--focus); }

input:not([type="hidden"], .settings-file-input) {
    display: block;
    width: 100%;
    min-height: 50px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
    font: inherit;
    color: var(--text);
}

#usuario { text-transform: uppercase; }
small { display: block; margin-top: 5px; color: var(--muted); font-size: .79rem; }

:is(button, summary, [role="button"], .action, .settings-action, .settings-secondary, .settings-danger, .settings-file, .workspace-nav) {
    text-transform: uppercase;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

:where(button, [role="button"], .action, .settings-action, .settings-secondary, .settings-danger, .settings-file) {
    max-inline-size: 100%;
}

.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

:where(.action-row, .project-record-actions, .project-collection-links, .project-files > li,
       .chat-management-actions, .overview-links, .chat-rail-heading, .chat-header-actions, .chat-pages,
       .chat-message-attachments > li, .file-card-actions,
       .file-batch-actions, .gallery-actions, .gallery-pagination, .crop-actions, .notification-summary,
       .vida-confirm-actions, .action-result-controls) > :is(button, a, form, .settings-file) {
    flex-shrink: 0;
    max-inline-size: 100%;
}

.action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    min-height: 48px;
    margin-top: 24px;
    padding: 10px 18px;
    border: 0;
    border-radius: 15px;
    background: var(--accent);
    color: var(--button-text);
    font: 700 1rem/1.4 Montserrat, system-ui, sans-serif;
    cursor: pointer;
}

.action:hover { background: var(--accent-hover); }

:where(input, button, a):focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.error {
    margin: 0 0 18px;
    padding: 10px 14px;
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-line);
    border-radius: 12px;
    font-size: .9rem;
}

.offline-box { padding-top: 32px; }
.offline-box .action { text-decoration: none; }
.offline-box .intro { margin-bottom: 0; }

@media (max-width: 430px) {
    .auth-box { padding: 48px 22px 24px; border-radius: 20px; }
    .theme-button { inset: 14px 14px auto auto; }
    .logo { width: 158px; }
}
