/* Kibo v2 — shared utilities + control kit (token-based). See regole_sviluppo_ui.md §4,§8. */

.mono { font-family: var(--font-mono); }

.font-head { font-family: var(--font-head); letter-spacing: -.3px; }

.k-btn {
    font-size: 12px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink-soft);
    cursor: pointer;
    transition: .15s;
}
.k-btn:hover { border-color: var(--ink); color: var(--ink); }
.k-btn.pri { background: var(--human); border-color: var(--human); color: #fff; }
.k-btn.pri:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }

.sw2 {
    position: relative;
    width: 32px;
    height: 18px;
    border-radius: 10px;
    background: var(--line);
    transition: .15s;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}
.sw2::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--card);
    transition: .15s;
}
.sw2.on { background: var(--human); }
.sw2.on::after { left: 16px; }

.mrow {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 4px 0;
}
.mrow .md { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.mrow label { flex: 1; }

.k-search {
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px 10px;
    background: var(--paper);
}
.k-search input { border: none; outline: none; background: none; font-size: 12.5px; width: 140px; color: var(--ink); }

.seg { display: flex; gap: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { font-size: 12px; font-weight: 600; color: var(--ink-soft); padding: 6px 11px; border-radius: 8px; white-space: nowrap; border: none; background: none; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.k-chip {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .78rem; font-weight: 600; line-height: 1.2;
    padding: 6px 11px; border-radius: 9px;
    border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
    white-space: nowrap; cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.k-chip:hover:not(:disabled) { background: var(--we); color: var(--ink); }
.k-chip.on { background: var(--human-soft); color: var(--human-text); border-color: var(--human); }
.k-chip:disabled { opacity: .5; cursor: default; }
.k-chip-icon { padding: .18rem .4rem; }

.tag { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 7px; background: var(--paper); color: var(--ink-soft); }
.tag.cat { background: var(--human-soft); color: var(--human-text); }

.jstat { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 7px; }
.jstat.ok  { background: var(--focus-soft); color: var(--focus-text); }
.jstat.run { background: var(--human-soft); color: var(--human-text); }
.jstat.off { background: var(--paper); color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

.k-btn.sm     { padding: 5px 10px; font-size: 11.5px; border-radius: 9px; }
.k-btn:disabled { opacity: .5; cursor: default; }
.k-btn.accent { color: var(--human); border-color: var(--human); background: var(--card); }
.k-btn.accent:hover { background: var(--human); border-color: var(--human); color: #fff; }
.k-btn.danger { color: var(--alert-text); border-color: var(--alert); background: var(--card); }
.k-btn.danger:hover { background: var(--alert); border-color: var(--alert); color: #fff; }

.k-field {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: .5rem .7rem;
    font-size: .9rem;
    line-height: 1.4;
    background: var(--field);
    color: var(--ink);
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.k-field:focus {
    border-color: var(--human);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--human) 18%, transparent);
}
.k-field::placeholder { color: var(--ink-soft); }
.k-field:disabled { background: var(--paper); color: var(--ink-soft); cursor: not-allowed; }

.k-switch {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    width: 34px;
    height: 19px;
    border-radius: 10px;
    background: var(--line);
    position: relative;
    cursor: pointer;
    flex: 0 0 auto;
    border: none;
    transition: background .15s;
}
.k-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--card);
    transition: left .15s;
}
.k-switch:checked { background: var(--human); }
.k-switch:checked::after { left: 17px; }

.k-badge {
    display: inline-block;
    padding: .25em .6em;
    font-size: .72rem;
    font-weight: 600;
    border-radius: 7px;
    line-height: 1;
    white-space: nowrap;
}

.k-alert { padding: .5rem .7rem; border-radius: 9px; font-size: .82rem; }
.k-alert.error { background: var(--alert-soft); color: var(--alert-text); border: 1px solid var(--alert); }

.k-muted { color: var(--ink-soft); }

.k-label { display: block; margin: .75rem 0 .25rem; font-size: .8rem; font-weight: 600; color: var(--ink-soft); }

.k-spin {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: k-spin .7s linear infinite;
    vertical-align: -2px;
    margin-right: .4rem;
    flex: 0 0 auto;
}
@keyframes k-spin { to { transform: rotate(360deg); } }

.k-right { text-align: right; }

.k-badge.ok    { background: var(--focus-soft); color: var(--focus-text); }
.k-badge.warn  { background: var(--amber-soft); color: var(--amber-text); }
.k-badge.info  { background: var(--human-soft); color: var(--human-text); }
.k-badge.muted { background: var(--paper); color: var(--ink-soft); border: 1px solid var(--line); }

.k-btn.warn { color: var(--amber-text); border-color: var(--amber); background: var(--card); }
.k-btn.warn:hover { background: var(--amber); border-color: var(--amber); color: #fff; }

.k-table-wrap { overflow-x: auto; }
.k-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.k-table th, .k-table td { padding: .45rem .6rem; text-align: left; border-bottom: 1px solid var(--line); }
.k-table th { font-weight: 600; color: var(--ink-soft); font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; }
.k-table tbody tr:hover { background: var(--paper); }

.k-modal-backdrop {
    position: fixed; inset: 0; z-index: 1050;
    background: var(--scrim);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.k-modal {
    background: var(--card); color: var(--ink);
    border: 1px solid var(--line); border-radius: 14px;
    box-shadow: var(--shadow);
    width: min(440px, 94vw); max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
}
.k-modal.lg { width: min(640px, 94vw); }
.k-modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.1rem .7rem; border-bottom: 1px solid var(--line);
}
.k-modal-head h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.k-modal-body { padding: 1rem 1.1rem; overflow-y: auto; }
/* Dialog message text (DialogHost) — reset default <p> margins, honour line breaks. */
.k-dialog-msg { margin: 0; line-height: 1.5; white-space: pre-wrap; }
.k-modal-foot {
    display: flex; justify-content: flex-end; gap: .5rem;
    padding: .7rem 1.1rem 1rem; border-top: 1px solid var(--line);
}
.k-modal-close {
    width: 30px; height: 30px; border-radius: 9px; border: none;
    background: var(--paper); color: var(--ink-soft);
    font-size: 1.1rem; line-height: 1; cursor: pointer;
    display: grid; place-items: center;
}
.k-modal-close:hover { color: var(--ink); }

.k-ml-auto { margin-left: auto; }
.k-ml-1    { margin-left: .25rem; }
.k-table-wrap { margin-bottom: 1rem; }

.k-check {
    appearance: none; -webkit-appearance: none; margin: 0;
    width: 18px; height: 18px;
    border: 1.5px solid var(--line); border-radius: 5px;
    background: var(--card); cursor: pointer; flex: 0 0 auto;
    position: relative; transition: background .15s, border-color .15s;
}
.k-check:checked { background: var(--human); border-color: var(--human); }
.k-check:checked::after {
    content: ""; position: absolute; left: 5px; top: 2px;
    width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.k-alert.danger,
.k-alert.error   { background: var(--alert-soft); color: var(--alert-text); border: 1px solid var(--alert); }
.k-alert.success { background: var(--human-soft); color: var(--human-text); border: 1px solid var(--human); }
.k-alert.warn    { background: var(--amber-soft); color: var(--amber-text); border: 1px solid var(--amber); }
.k-alert.info    { background: var(--focus-soft); color: var(--focus-text); border: 1px solid var(--focus); }

.k-btn.lg { padding: .6rem 1.1rem; font-size: .95rem; border-radius: 11px; }

.k-center    { text-align: center; }
.k-w-100     { width: 100%; }
.k-list-plain { list-style: none; padding: 0; margin: 0; }
.k-warn-text { color: var(--amber-text); }

.k-modal-title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.k-modal-inner { display: contents; }

.k-small { font-size: .875em; }
.k-mb-0 { margin-bottom: 0; }
.k-mb-1 { margin-bottom: .25rem; }
.k-mb-2 { margin-bottom: .5rem; }
.k-mb-3 { margin-bottom: 1rem; }
.k-mb-4 { margin-bottom: 1.5rem; }
.k-mt-1 { margin-top: .25rem; }
.k-mt-2 { margin-top: .5rem; }
.k-mt-3 { margin-top: 1rem; }
.k-py-2 { padding-top: .5rem; padding-bottom: .5rem; }
.k-py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

.k-switch-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.k-check-label  { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.k-check-row    { display: flex; align-items: center; gap: .5rem; }
.k-check-text   { cursor: pointer; }
.k-flex  { display: flex; }
.k-gap-1 { gap: .25rem; }

.k-mb-5 { margin-bottom: 3rem; }
.k-mt-0 { margin-top: 0; }
.k-mt-4 { margin-top: 1.5rem; }
.k-mt-5 { margin-top: 3rem; }
.k-me-1 { margin-right: .25rem; }
.k-me-2 { margin-right: .5rem; }
.k-me-3 { margin-right: 1rem; }
.k-ml-2 { margin-left: .5rem; }
.k-ml-3 { margin-left: 1rem; }
.k-py-1 { padding-top: .25rem; padding-bottom: .25rem; }
.k-py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.k-px-1 { padding-left: .25rem; padding-right: .25rem; }
.k-px-2 { padding-left: .5rem; padding-right: .5rem; }
.k-px-3 { padding-left: 1rem; padding-right: 1rem; }
.k-px-4 { padding-left: 1.5rem; padding-right: 1.5rem; }
.k-gap-2 { gap: .5rem; }
.k-gap-3 { gap: 1rem; }
.k-fw-semibold { font-weight: 600; }
.k-fw-bold { font-weight: 700; }
.k-rounded { border-radius: .375rem; }
.k-align-center { align-items: center; }

.k-p-3 { padding: 1rem; }

.k-field.sm { padding: 6px 10px; font-size: .78rem; border-radius: 9px; }

/* A little breathing room at the bottom so a view's content never sits flush against the window
   edge — that made a finished list/board look as if more content were hidden below (KBW-0068). */
/* The page owns the vertical scroll (KBW-0139): .app-main clips its overflow, so a page whose content
   is taller than the window (trash list, task detail, a long settings tab) was simply cut off with no
   way to reach the rest. Views that run their own scroll container (task list, kanban, calendar…) are
   unaffected: a flex item with `overflow` set can shrink to the available height, so it keeps
   scrolling internally and this container never overflows. */
.k-page { display: flex; flex-direction: column; height: 100%; padding: 1rem 1.25rem .85rem; box-sizing: border-box; overflow-y: auto; overflow-x: hidden; }
.k-page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .35rem 1rem; margin-bottom: .5rem; flex: 0 0 auto; }
.k-page-title { margin: 0; font-size: 1.4rem; font-weight: 600; color: var(--ink); }
/* Subtitle claims its own full-width row below the title + actions (flex-basis:100% forces the wrap),
   so it can't be squeezed into a narrow column and wrap every few words on iPad/responsive (KBW-0062). */
.k-page-sub { margin: 0; font-size: .85rem; color: var(--ink-soft); flex: 1 0 100%; }
.k-page-actions { display: flex; gap: .5rem; flex: 0 0 auto; justify-content: flex-end; flex-wrap: wrap; }

/* ≤1024 both edge tabs are fixed and overlap the top of the page: the drawer handle on the left, the
   task dock's chevron on the right (KBW-0028). Reserve the gutter on the WHOLE head row, not just the
   title — the title was nudged clear but the view switcher and page actions next to it still ran
   underneath the right-hand tab (KBW-0152). Shared by every .k-page screen (Tasks / Memory / Jobs /
   Notifications); Settings clears on its own wider padding. */
@media (max-width: 1024px) {
    .k-page-head { padding-left: 26px; padding-right: 26px; }
}

@media (max-width: 640px) {
    .k-page-head { flex-direction: column; align-items: stretch; gap: .5rem; }
    /* Column direction: flex-basis:100% would target the main (vertical) axis — reset it. */
    .k-page-sub { flex: 0 0 auto; }
}

/* ── Resizer ──────────────────────────────────────────────────────────────
   Generic drag handle for resizing a panel, with a centred grip that turns agent-violet on
   hover/drag. Used by the task dock (right edge) and the Gantt name pane (KBW-0034). Pair it with
   .k-resize-overlay, rendered only while dragging, so a fast drag off the thin handle keeps the
   gesture instead of dropping it.
   The host positions the handle; this only styles it. */
.k-resizer {
    position: relative;
    flex: 0 0 auto;
    width: 6px;
    /* Anchor the drag on a non-selectable element so dragging never starts a native text selection
       that sweeps the panel content. */
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    cursor: col-resize;
}
.k-resizer-grip {
    position: absolute; inset: 0; margin: auto;
    width: 3px; height: 48px; border-radius: 99px;
    background: var(--line);
    transition: background .15s, height .15s;
}
.k-resizer:hover .k-resizer-grip,
.k-resizer.dragging .k-resizer-grip { background: var(--agent); height: 64px; }

/* Transparent full-viewport layer that captures pointer move/up during a resize drag. */
.k-resize-overlay {
    position: fixed; inset: 0; z-index: 90; cursor: col-resize;
    -webkit-user-select: none; user-select: none; touch-action: none;
}

/* A 6px handle is not a touch target, and touch surfaces get scrolling affordances instead. */
@media (pointer: coarse) {
    .k-resizer { display: none; }
}
