/* KIProtect design language, as used on the KIProtect website (KIProtect
   Design System: tokens/colors.css, typography.css, spacing.css and
   base/utilities.css): a cool near-white page, white cards with a hairline
   border and a 14px radius, soft low-spread shadows, the logo blue as the one
   accent, Geist for text and Geist Mono for labels and metadata.

   Token names and values are taken from that source; change them there first.
   Fonts and the logo are part of this bundle, nothing is loaded from other
   hosts. */

@font-face {
    font-family: "Geist";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("assets/geist-latin.woff2") format("woff2");
}

@font-face {
    font-family: "Geist Mono";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("assets/geist-mono-latin.woff2") format("woff2");
}

:root {
    color-scheme: light dark;

    --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    /* Surfaces */
    --bg: oklch(98.8% 0.004 250);
    --bg-elev: oklch(100% 0 0);
    --bg-subtle: oklch(96.5% 0.006 250);
    --bg-tint: oklch(94% 0.01 250);

    /* Foreground */
    --fg: oklch(18% 0.04 260);
    --fg-muted: oklch(40% 0.03 258);
    --fg-soft: oklch(52% 0.02 258);
    --fg-faint: oklch(72% 0.015 258);

    /* Borders */
    --line: oklch(90% 0.01 255);
    --line-strong: oklch(82% 0.015 255);

    /* Brand, from the logo */
    --brand: #2e5baa;
    --brand-deep: #1f3f7a;
    --brand-green: #7fb069;

    --accent: var(--brand);
    --accent-hover: var(--brand-deep);
    --accent-text: var(--brand);
    --accent-soft: color-mix(in srgb, #2e5baa 9%, transparent);
    --accent-ring: color-mix(in srgb, #2e5baa 22%, transparent);

    /* Status. The logo green is too light for text on white, so text and
       borders use a darker step of the same hue. */
    --success: var(--brand-green);
    --success-text: oklch(42% 0.1 140);
    --success-soft: color-mix(in srgb, #7fb069 14%, transparent);
    --success-line: color-mix(in srgb, #7fb069 55%, transparent);
    --danger: oklch(50% 0.18 25);
    --danger-hover: oklch(43% 0.17 25);
    --danger-soft: color-mix(in oklch, oklch(58% 0.18 25) 8%, transparent);
    --danger-line: color-mix(in oklch, oklch(58% 0.18 25) 40%, transparent);
    --warn-text: oklch(42% 0.1 65);
    --warn-soft: color-mix(in oklch, oklch(75% 0.15 75) 14%, transparent);
    --warn-line: color-mix(in oklch, oklch(70% 0.15 70) 55%, transparent);

    --scrim: rgba(15, 23, 42, 0.45);

    /* Radii */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 14px;
    --radius-pill: 100px;

    /* Elevation: cool, low-spread, never coloured */
    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 16px 40px -20px rgba(15, 23, 42, 0.16);
    --shadow-float: 0 32px 60px -24px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(15, 23, 42, 0.04);

    /* Motion: one curve */
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --dur-fast: 0.15s;
    --dur: 0.2s;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: oklch(14% 0.025 260);
        --bg-elev: oklch(17% 0.03 260);
        --bg-subtle: oklch(19% 0.03 260);
        --bg-tint: oklch(22% 0.035 260);
        --fg: oklch(96% 0.005 250);
        --fg-muted: oklch(78% 0.015 250);
        --fg-soft: oklch(66% 0.02 255);
        --fg-faint: oklch(48% 0.025 255);
        --line: oklch(26% 0.025 260);
        --line-strong: oklch(34% 0.03 260);
        --accent: #3d6fc4;
        --accent-hover: #4f7fd0;
        --accent-text: #8fb1e8;
        --accent-soft: oklch(24% 0.06 255);
        --accent-ring: color-mix(in srgb, #8fb1e8 30%, transparent);
        --success-text: var(--brand-green);
        --danger: oklch(72% 0.14 25);
        --danger-hover: oklch(78% 0.12 25);
        --warn-text: oklch(82% 0.11 80);
        --scrim: rgba(3, 6, 12, 0.65);
        --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -20px rgba(0, 0, 0, 0.6);
        --shadow-float: 0 32px 60px -24px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--line);
    }
    /* The logo is never recoloured; on dark it is shown in white. */
    .brand img {
        filter: brightness(0) invert(1);
    }
}

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

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: -0.005em;
    -webkit-font-smoothing: antialiased;
}

h1 {
    margin: 0 0 10px;
    font-size: 28px;
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: -0.015em;
    overflow-wrap: anywhere;
}

h3 {
    margin: 0 0 8px;
    color: var(--fg-soft);
    font: 500 12px var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

p {
    margin: 0 0 12px;
    color: var(--fg-muted);
}

:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.mono {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0;
}

.muted {
    color: var(--fg-soft);
}

.small {
    font-size: 14px;
}

/* ── Controls ──────────────────────────────────────── */

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--bg-elev);
    color: var(--fg);
    font: 500 15px var(--font-sans);
    cursor: pointer;
    transition:
        background-color var(--dur-fast) var(--ease),
        border-color var(--dur-fast) var(--ease);
}

button:hover {
    background: var(--bg-subtle);
}

button:disabled {
    opacity: 0.5;
    cursor: default;
}

button.primary {
    border-color: transparent;
    background: var(--accent);
    color: #fff;
}

button.primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

button.danger {
    border-color: var(--danger-line);
    color: var(--danger);
}

button.danger:hover {
    background: var(--danger-soft);
}

button.quiet {
    padding: 4px 8px;
    border-color: transparent;
    background: transparent;
    color: var(--fg-soft);
    font-size: 14px;
}

button.quiet:hover {
    background: var(--bg-tint);
    color: var(--fg);
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--bg-elev);
    color: var(--fg);
    font: 16px var(--font-sans);
}

input:focus,
textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}

label {
    display: block;
    margin: 14px 0 6px;
    color: var(--fg-muted);
    font-size: 14px;
    font-weight: 500;
}

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

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--bg-subtle);
    color: var(--fg-muted);
    font: 500 12px var(--font-mono);
    white-space: nowrap;
}

.pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--fg-faint);
}

.pill.ok {
    border-color: var(--success-line);
    background: var(--success-soft);
    color: var(--success-text);
}

.pill.ok::before {
    background: var(--success);
}

.pill.warn {
    border-color: var(--warn-line);
    background: var(--warn-soft);
    color: var(--warn-text);
}

.pill.warn::before {
    background: var(--warn-text);
}

.notice {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--warn-line);
    border-radius: var(--radius);
    background: var(--warn-soft);
    color: var(--warn-text);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.notice.error {
    border-color: var(--danger-line);
    background: var(--danger-soft);
    color: var(--danger);
}

.code {
    display: block;
    margin: 8px 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-subtle);
    color: var(--fg);
    font: 13px/1.5 var(--font-mono);
    overflow-wrap: anywhere;
    user-select: all;
}

/* ── Shell ─────────────────────────────────────────── */

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.topbar {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 60px;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elev);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand img {
    display: block;
    width: auto;
    height: 22px;
}

.brand-product {
    padding-left: 14px;
    border-left: 1px solid var(--line-strong);
    color: var(--fg-muted);
    font-weight: 500;
    white-space: nowrap;
}

/* Sign-in and the other single-card pages */
.center {
    flex: 1;
    overflow: auto;
    padding: 48px 16px;
}

.card {
    max-width: 520px;
    margin: 0 auto;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--bg-elev);
    box-shadow: var(--shadow-card);
}

.workspace {
    display: grid;
    flex: 1;
    grid-template-columns: 250px minmax(0, 1fr) 310px;
    min-height: 0;
}

.sidebar,
.panel {
    overflow: auto;
    padding: 16px;
    background: var(--bg-elev);
}

.sidebar {
    border-right: 1px solid var(--line);
}

.panel {
    border-left: 1px solid var(--line);
}

.panel section {
    margin-bottom: 24px;
}

.channel-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 12px;
}

.channel-list button {
    justify-content: space-between;
    width: 100%;
    padding: 8px 10px;
    border-color: transparent;
    background: transparent;
    font-weight: 400;
    text-align: left;
}

.channel-list button:hover {
    background: var(--bg-subtle);
}

.channel-list button[aria-current="true"] {
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 500;
}

.channel-list .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unread {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

/* ── Channel ───────────────────────────────────────── */

.channel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.channel-head {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}

.timeline {
    flex: 1;
    overflow: auto;
    padding: 20px;
}

.empty {
    max-width: 440px;
    margin: 12vh auto 0;
    text-align: center;
}

.message {
    max-width: 760px;
    margin: 0 0 14px;
}

.message .meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 2px;
}

.message .author {
    font-weight: 500;
}

.message.self .author {
    color: var(--accent-text);
}

.message .time,
.system .time {
    color: var(--fg-faint);
    font: 12px var(--font-mono);
}

.message .text {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.file {
    margin-top: 6px;
    font-size: 14px;
}

.system {
    margin: 0 0 14px;
    color: var(--fg-soft);
    font-size: 14px;
}

.composer {
    flex: none;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--line);
    background: var(--bg-elev);
}

.composer textarea {
    display: block;
    min-height: 44px;
    max-height: 200px;
    resize: vertical;
}

.composer .row {
    justify-content: space-between;
    margin-top: 8px;
}

.attachments {
    color: var(--fg-soft);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.member {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.member:last-child {
    border-bottom: 0;
}

.member .row {
    justify-content: space-between;
    gap: 6px;
}

.member .name {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.member .mono {
    color: var(--fg-soft);
    font-size: 11.5px;
}

dialog {
    width: min(560px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--bg-elev);
    color: var(--fg);
    box-shadow: var(--shadow-float);
}

dialog::backdrop {
    background: var(--scrim);
}

@media (max-width: 980px) {
    .topbar .pill {
        display: none;
    }
    .workspace {
        grid-template-columns: minmax(0, 1fr);
        overflow: auto;
    }
    .sidebar,
    .panel {
        border: 0;
        border-bottom: 1px solid var(--line);
        overflow: visible;
    }
    .channel {
        min-height: 70vh;
    }
    .panel {
        order: 3;
        border-top: 1px solid var(--line);
    }
}

/* The instruction sheet for an agent: kept as typed, scrolls sideways. */
pre.sheet {
    white-space: pre;
    overflow-x: auto;
    max-height: 50vh;
    font-size: 12px;
    line-height: 1.5;
    text-align: left;
}
