/* 기기의 밝게/어둡게 설정을 따른다. 인쇄와 원본 양식은 밝은 지면을 유지한다. */
:root {
    color-scheme: light;
    --nx-ceo-muted-foreground: 215 20% 32%;
    --destructive: 0 72% 44%;
    --destructive-foreground: 0 0% 100%;
}
body { background-color: hsl(var(--background)); color: hsl(var(--foreground)); }
.nx-reference, .air-sheet { color-scheme: light; }

@media screen and (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --background: 222 28% 10%;
        --foreground: 210 20% 94%;
        --card: 222 23% 14%;
        --card-foreground: 210 20% 94%;
        --primary: 150 55% 62%;
        --primary-foreground: 150 60% 10%;
        --secondary: 222 20% 20%;
        --secondary-foreground: 210 20% 94%;
        --muted: 222 20% 20%;
        --muted-foreground: 215 18% 76%;
        --nx-ceo-muted-foreground: 215 18% 76%;
        --accent: 222 20% 20%;
        --accent-foreground: 210 20% 94%;
        --border: 216 14% 45%;
        --input: 216 14% 45%;
        --ring: 150 55% 62%;
        --destructive: 0 80% 76%;
        --destructive-foreground: 0 40% 10%;
        --nx-success-bg: 150 35% 20%;
        --nx-success-fg: 150 60% 80%;
        --nx-warning-bg: 38 45% 19%;
        --nx-warning-fg: 43 90% 80%;
        --nx-info-bg: 205 42% 20%;
        --nx-info-fg: 200 80% 82%;
    }
    a { color: hsl(var(--primary)); }
    :where(input, select, textarea) { accent-color: hsl(var(--primary)); }
    .nx-layout :where(input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea) {
        color: hsl(var(--foreground)); background-color: hsl(var(--card)); border-color: hsl(var(--input));
    }
    :where(input, textarea)::placeholder { color: hsl(var(--muted-foreground)); opacity: 1; }
    .nx-btn-primary:hover { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
    /* CI 이미지는 원래 색을 보존하며 밝은 바탕 위에 놓는다. */
    .nx-brand-logo, .login-logo { background: white; padding: 6px; border-radius: 8px; }
    .nx-status-approved { background: hsl(var(--nx-success-bg)); color: hsl(var(--nx-success-fg)); }
    .nx-status-submitted, .nx-status-director_approved, .nx-status-delete_requested, .nx-status-hold {
        background: hsl(var(--nx-warning-bg)); color: hsl(var(--nx-warning-fg));
    }
    .nx-status-await { background: hsl(var(--nx-info-bg)); color: hsl(var(--nx-info-fg)); }
    .nx-status-rejected, .nx-status-deleted { color: hsl(var(--destructive)); }
    .nx-action-approve, .nx-side-nav a.is-active .nx-count-done { color: hsl(var(--primary)); }
    .nx-count-done { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
    .nx-attach-del { color: hsl(var(--destructive-foreground)); }
    .nx-hold-banner, .nx-view-as-banner, .nx-ai-status.is-warn,
    .nx-ai-filled, .nx-table-form input.nx-ai-filled, label.nx-ai-filled {
        background: hsl(var(--nx-warning-bg)); color: hsl(var(--nx-warning-fg)); border-color: hsl(var(--nx-warning-fg) / .45);
    }
    .login-error { color: hsl(var(--destructive)); background: hsl(var(--destructive) / .12); border-color: hsl(var(--destructive) / .5); }
    /* 공통 테마를 공유하는 일지 화면의 흰 배경·고정 글자색도 함께 전환한다. */
    .nx-layout :is(.air-panel, .air-facility, .air-save-bar, .air-review-panel, .air-button) {
        background: hsl(var(--card)); color: hsl(var(--foreground)); border-color: hsl(var(--border));
    }
    .nx-layout .air-field :is(input, select, textarea) { background: hsl(var(--card)); color: hsl(var(--foreground)); border-color: hsl(var(--input)); }
    .nx-layout .air-field input:disabled { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
    .nx-layout :is(.air-field > label, .air-list-table th) { color: hsl(var(--muted-foreground)); }
    .nx-layout :is(.air-facility legend, .air-extra summary, .air-date-link, .air-access-yes) { color: hsl(var(--primary)); }
    .nx-layout :is(.air-note, .air-list-table th, .air-history li p, .air-sheet-preview) { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); border-color: hsl(var(--border)); }
    .nx-layout :is(.air-list-table td, .air-history li) { border-color: hsl(var(--border)); }
    .nx-layout :is(.air-list-table tbody tr:hover, .air-button:hover) { background: hsl(var(--muted)); }
    .nx-layout .air-section-heading > span { background: hsl(var(--nx-success-bg)); color: hsl(var(--nx-success-fg)); }
    .nx-layout .air-status { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
    .nx-layout .air-status--submitted { background: hsl(var(--nx-warning-bg)); color: hsl(var(--nx-warning-fg)); }
    .nx-layout .air-status--completed { background: hsl(var(--nx-success-bg)); color: hsl(var(--nx-success-fg)); }
    .nx-layout :is(.air-button--primary, .air-button--primary:hover) { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }
    .nx-layout :is(.air-required, .air-error, .air-workspace .errorlist) { color: hsl(var(--destructive)); }
    .nx-layout .air-errors { background: hsl(var(--destructive) / .12); color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / .5); }
    .nx-layout .air-field--error :is(input, select, textarea) { border-color: hsl(var(--destructive)) !important; }
    .nx-layout .air-workspace :focus-visible { outline-color: hsl(var(--ring)); }
}
