:root {
    --bg-surface: #fff;
    --bg-surface-hover: hsl(212 30% 96%);
    --color-text: #111;
    --color-text-readonly: #888;

    --color-heading-accent: hsl(212 25% 82%);

    --color-text-muted: #888;
    --color-border-muted: rgba(0, 0, 0, 0.1);
    --color-border-editable: #777a78;

    /* App shell color tokens */
    --bg-header: hsl(212.6 40% 92%);
    --bg-actions: #f7f9fc;
    --bg-nav: hsl(212.6 40% 92%);
    --bg-nav-subtle: hsl(212.6deg 40% 92% / 26%);
    --bg-nav-hover: hsl(213 56% 96%);
    --bg-nav-active: hsl(212.6 56% 84%);
    --bg-main: #ffffff;
    --bg-footer: #f3f5f7;
    --color-border-shell: hsl(212 25% 82%);

    /* Content background tokens */
    --bg-subtle: #f6f8fa;

    /* state colors */
    --color-state-modified:#6aa6ff;
    --color-state-modified-shadow: rgba(106, 166, 255, 0.25);

    /* action colors */
    --color-action-primary-bg: #0078d4;
    --color-action-primary-bg-hover: #0063b1;
    --color-action-primary-text: #ffffff;

    --color-action-secondary-bg: transparent;
    --color-action-secondary-bg-hover: rgba(0, 120, 212, 0.08);
    --color-action-secondary-text: #0078d4;
    --color-action-secondary-border: #0078d4;

    --color-action-danger-bg: #c62828;
    --color-action-danger-bg-hover: #b71c1c;
    --color-action-danger-text: #ffffff;

    --color-action-disabled-bg: hsl(212 30% 90%);
    --color-action-disabled-text: hsl(212 15% 70%);

    /* state colors */
    --color-info:    #0078d4;
    --color-success: #00c997;
    --color-warning: #d97706;
    --color-error:   #c62828;
    --color-info-bg:    hsl(210 75% 95%);
    --color-success-bg: hsl(160 55% 95%);
    --color-warning-bg: hsl(40  85% 96%);
    --color-error-bg:   hsl(0   70% 96%);

    /* chat colors */
    --chat-alldonet-accent: hsl(210 70% 45%);
    --chat-alldonet-bg: hsl(210 60% 97%);
    --chat-customer-accent: hsl(4 45% 45%);
    --chat-customer-bg: hsl(4 45% 97%);

    /* spacing scale (4px base)
     *
     * Recommended default relationship:
     * - Padding should usually be larger than gap
     * - Rule of thumb: padding = 2 × gap
     */
    --space-xxs: 4px;
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-xxl: 48px;

    --focus-ring-size: 2px;

    /* ============================================================
     * Responsive breakpoints
     * Use with @media or @container queries
     *
     *   narrow:  < 640px
     *   medium: ≥ 640px
     *   wide:   ≥ 1024px
     *
     * Usage: @media (max-width: 640px) {
     *            ...
     *        }
     *
     * Note: CSS custom properties (var(--…)) cannot be used in media
     *       queries or container queries.
     * ============================================================ */

    /* typographie */
    --font-weight-base: 400;
    --font-size-base: 1rem;        /* 16px */
    --font-size-sm: 0.875rem;      /* 14px */
    --font-size-xs: 0.8125rem;     /* 13px */
    --line-height-base: 1.5;
    --line-height-tight: 1.3;

    --font-mono: monospace;

    font-size: var(--font-size-base);
    font-weight: var(--font-weight-base);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Hiragino Sans",
        "Hiragino Kaku Gothic ProN",
        "Yu Gothic",
        "YuGothic",
        "Meiryo",
        sans-serif;
}


/* ============================================================
 * Utility classes
 * Small, single-purpose helpers intended for composition
 * ============================================================ */

.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }


/*
 * Container-based responsiveness
 *
 * In order to enable container queries,
 * set `container-type: inline-size;` in the container element.
 * (you can use shortcut CSS class .enable-container-queries for this purpose)
 */
.enable-container-queries {
    container-type: inline-size;
    container-name: content;
}
.br-wide { display: none; }
.br-narrow { display: block; }

@container content (min-width: 640px) {
  .br-wide { display: block; }
  .br-narrow { display: none; }
}

body {
    background: var(--bg-surface);
    color: var(--color-text);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
}

.small { font-size: var(--font-size-sm); }
.caption { font-size: var(--font-size-xs); }


a.button,
a.button:visited,
a.button:hover,
a.button:active,
a.button:focus {
    color: inherit;
    text-decoration: none;
}


button, a.button {
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid #bbb;
    border-radius: 12px;
    background: var(--bg-surface);
    color: var(--color-text);
    cursor: pointer;
    font-weight: 600;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;

    &:hover {
        background: var(--bg-surface-hover);
    }

    &.small {
        padding: var(--space-xxs) var(--space-xs);
        border-radius: 6px;
        font-size: var(--font-size-sm);
    }

    &.primary {
        background: var(--color-action-primary-bg);
        color: var(--color-action-primary-text);

        &:hover:not(:disabled) {
            background: var(--color-action-primary-bg-hover);
        }
    }

    &.secondary {
        background: var(--color-action-secondary-bg);
        color: var(--color-action-secondary-text);
        border: 1px solid var(--color-action-secondary-border);

        &:hover:not(:disabled) {
            background: var(--color-action-secondary-bg-hover);
        }
    }

    &.danger {
        background: var(--color-action-danger-bg);
        color: var(--color-action-danger-text);

        &:hover:not(:disabled) {
            background: var(--color-action-danger-bg-hover);
        }
    }

    &[disabled],
    &.disabled {
        pointer-events: none;
        cursor: not-allowed;
        background: var(--color-action-disabled-bg);
        color: var(--color-action-disabled-text);
        border-color: var(--color-action-disabled-bg);
    }
}

div.lite-alert {
    border: 1px solid var(--color-text);
    padding: var(--space-xs);
    border-radius: var(--space-xxs);
    margin-top: 1em;

    &.info {
        color: var(--color-info);
        border-color: var(--color-info);
        background: var(--color-info-bg);
    }

    &.success {
        color: var(--color-success);
        border-color: var(--color-success);
        background: var(--color-success-bg);
    }

    &.warning {
        color: var(--color-warning);
        border-color: var(--color-warning);
        background: var(--color-warning-bg);
    }

    &.error {
        color: var(--color-error);
        border-color: var(--color-error);
        background: var(--color-error-bg);
    }
}

.email-preview {
    background: var(--bg-subtle);
    border: 1px solid var(--color-border-muted);
    border-radius: 12px;
    padding: var(--space-sm) var(--space-md);

    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: var(--space-md);
    row-gap: var(--space-xs);
    align-items: start;

    & .label {
        font-size: var(--font-size-xs);
        color: var(--color-text-muted);
        font-weight: 600;
        line-height: var(--line-height-tight);
        padding-top: 0.2em; /* optical alignment with text */
    }

    & .text {
        font-size: var(--font-size-base);
        color: var(--color-text);
        line-height: var(--line-height-base);
        min-width: 0; /* important in grid to allow wrapping */
        white-space: pre-wrap; /* preserve line breaks from plain text */
        overflow-wrap: anywhere; /* long tokens won't break layout */
    }

    /* make subject feel slightly "header-like" */
    & .subject.text {
        font-weight: 600;
    }

    /* give body a subtle inset surface (helps long text) */
    & .body.text {
        background: var(--bg-surface);
        border: 1px solid var(--color-border-muted);
        border-radius: 10px;
        padding: var(--space-xs) var(--space-sm);
    }

    &.monospace .text {
        font-family: var(--font-mono);
    }
}

/* make each list item look like a "chip row" */
ul.item-list {
    background: var(--bg-subtle);
    border: 1px solid var(--color-border-muted);
    border-radius: 12px;
    padding: var(--space-sm) var(--space-md);

    list-style: none; /* remove bullets */
    display: grid;
    gap: var(--space-xxs); /* tight list */

    & li {
        background: var(--bg-surface);
        border: 1px solid var(--color-border-muted);
        border-radius: 10px;
        padding: var(--space-xxs) var(--space-sm);
        font-size: var(--font-size-sm);
        color: var(--color-text);
        overflow-wrap: anywhere;
    }

    &.monospace li {
        font-family: var(--font-mono);
    }
}

.form-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    background: var(--bg-surface);
    border-radius: 16px;
    padding: var(--space-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);

    h2 {
        font-size: 1.25rem;
        font-weight: 700;
        line-height: 1.3;
    }

    form {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    label {
        display: flex;
        flex-direction: column;
        gap: var(--space-xs);
        font-size: var(--font-size-sm);
        font-weight: 500;

        input, textarea, select {
            font-size: var(--font-size-base);
            font-weight: 400;
        }
    }

    .lite-messages {
        .lite-message {
            &.error { color: var(--color-error); }
        }
    }

    .buttons {
        display: flex;
        padding: 0;
        gap: 0.75rem;
        justify-content: flex-end;
        align-items: center;
        cursor: pointer;
    }
}


/* ------------------------------------------------------------
   Badge / Chip (inline metadata)
   Use for: status, IDs, small labels inside cards
   ------------------------------------------------------------ */
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xxs);
    align-items: center;

    .badge {
        display: inline-flex;
        align-items: center;
        gap: 0.35em;

        padding: 0.12em 0.45em;
        border-radius: 999px;

        font-size: var(--font-size-xs);
        line-height: 1.6;
        font-weight: 600;

        /* Neutral by default: readable on any tinted card */
        background: color-mix(in srgb, var(--bg-surface) 78%, transparent);
        border: 1px solid color-mix(in srgb, var(--color-border-muted) 70%, transparent);
        color: var(--color-text-muted);

        white-space: nowrap;

        .label {
            color: var(--color-text-muted);
            font-weight: 600;
        }

        .value {
            color: var(--color-text);
            font-weight: 700;
        }

        /* Optional: make IDs look technical */
        &:not(.mono) .value {
            font-weight: 600;
        }
        &.mono {
            margin-left: var(--space-xs);
            font-family: var(--font-mono);
            font-weight: 600;
            border-color: var(--color-border-muted);
            color: var(--color-text-muted);

            .value {
                font-weight: 500;
            }
        }

        /* Optional: subtle emphasis variants (still neutral) */

        &.strong {
            color: var(--color-text);
            border-color: color-mix(in srgb, var(--color-border-muted) 100%, transparent);
        }

        &.muted {
            opacity: 0.85;
        }

        /* Optional: clickable badge (e.g., filter links) */

        &.link {
            cursor: pointer;
            text-decoration: none;
        }

        &.link:hover {
            background: color-mix(in srgb, var(--bg-surface-hover) 80%, transparent);
            border-color: color-mix(in srgb, var(--color-border-muted) 90%, transparent);
        }
    }
}
