/* Chantiers — dark theme, same tokens as the game data manager. */
:root {
    color-scheme: dark;
    --bg: #0c1018;
    --panel: #121824;
    --panel-2: #171f2e;
    --panel-3: #202a3b;
    --border: #293449;
    --border-bright: #3b4962;
    --text: #edf2f7;
    --soft: #cfd8e6;
    --muted: #8e9ab0;
    --yellow: #ffd166;
    --orange: #ff9f43;
    --red: #ef476f;
    --green: #62d6a7;
    --blue: #64b5f6;
    --drawer: minmax(440px, 42%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { height: 100%; }
body { height: 100vh; height: 100dvh; margin: 0; background: var(--bg); color: var(--text); overflow: hidden; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ header */
.app-header { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 10px 20px; background: rgba(18, 24, 36, .96); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 18px; line-height: 1.15; margin: 2px 0 0; }
.eyebrow { margin: 0; color: var(--yellow); letter-spacing: .14em; font-size: 10px; font-weight: 800; }
.egg-mark { width: 32px; height: 40px; border-radius: 52% 48% 48% 52% / 62% 62% 38% 38%; background: linear-gradient(145deg, #fff5c4 0 54%, var(--yellow) 55%); transform: rotate(8deg); box-shadow: 0 0 28px rgba(255, 209, 102, .16); }
.views { display: flex; gap: 4px; padding: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 11px; }
.view-tab { border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 750; }
.view-tab span { margin-left: 5px; padding: 1px 7px; border-radius: 99px; background: var(--panel-3); font-size: 11px; }
.view-tab[aria-pressed="true"] { color: #17120a; background: var(--yellow); }
.view-tab[aria-pressed="true"] span { background: rgba(0, 0, 0, .15); }
.header-actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px; }

.button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 9px; padding: 8px 13px; cursor: pointer; font-weight: 750; text-decoration: none; transition: filter .15s ease, transform .15s ease; white-space: nowrap; }
.button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.button:disabled { cursor: default; opacity: .5; transform: none; filter: none; }
.button.primary { background: var(--yellow); color: #17120a; }
.button.secondary { background: var(--panel-3); border-color: var(--border-bright); color: var(--text); }
.button.danger { color: #ff92aa; background: rgba(239, 71, 111, .1); border-color: rgba(239, 71, 111, .35); }
.button.small { padding: 5px 10px; font-size: 12px; }
:is(button, a, input, select, textarea):focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

.save-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 128px; justify-content: flex-end; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.save-state[data-state="saved"] .status-dot { background: var(--green); }
.save-state[data-state="saving"] .status-dot { background: var(--yellow); }
.save-state[data-state="error"] .status-dot { background: var(--red); }
.save-state[data-state="error"] { color: #ff92aa; }

/* ------------------------------------------------------------ layout */
.workspace { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.workspace.with-drawer { grid-template-columns: 264px minmax(0, 1fr) var(--drawer); }
.filters { overflow: auto; padding: 16px; border-right: 1px solid var(--border); background: var(--panel); }
.list-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.list-toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters-toggle { display: none; }
.sort { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.result-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.list { flex: 1 1 auto; overflow: auto; padding: 12px 16px 48px; display: flex; flex-direction: column; gap: 8px; }
.drawer { overflow: auto; border-left: 1px solid var(--border); background: var(--panel); padding: 16px 20px 48px; }

input[type="search"], input[type="text"], input[type="date"], input[type="number"], select, textarea {
    background: var(--bg); border: 1px solid var(--border-bright); border-radius: 9px; padding: 8px 11px; color: var(--text); min-width: 0;
}
#search { flex: 1 1 auto; }
textarea { width: 100%; resize: vertical; line-height: 1.5; }

/* ------------------------------------------------------------ filters */
.filter-group { margin-bottom: 18px; }
.filter-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.filter-title .presets { display: flex; gap: 4px; letter-spacing: 0; text-transform: none; }
.preset { border: 1px solid var(--border-bright); background: transparent; border-radius: 7px; padding: 2px 8px; font-size: 11px; font-weight: 700; color: var(--soft); cursor: pointer; }
.preset[aria-pressed="true"] { border-color: var(--yellow); color: var(--yellow); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle { --c: var(--muted); display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-bright); background: var(--panel-2); border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 650; cursor: pointer; }
.chip-toggle::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: 0 0 auto; }
.chip-toggle[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 20%, var(--panel-2)); }
.chip-toggle .n { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chip-toggle.empty-facet { opacity: .45; }
.filter-hint { color: var(--muted); font-size: 11.5px; line-height: 1.45; margin: 8px 0 0; }
.filters .text-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px 0; font-size: 12px; text-decoration: underline dotted; }
.filters .text-button:hover { color: var(--text); }

/* ------------------------------------------------------------ rows */
.row { --type-color: var(--muted); display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; padding: 11px 14px; background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--type-color); border-radius: 10px; cursor: pointer; }
.row:hover { border-color: var(--border-bright); border-left-color: var(--type-color); background: var(--panel-2); }
.row.selected { box-shadow: 0 0 0 2px var(--yellow); }
.row.trashed { opacity: .6; }
.row-id { font-size: 20px; font-weight: 800; color: var(--soft); font-variant-numeric: tabular-nums; line-height: 1.2; }
.row-id small { display: block; font-size: 10px; letter-spacing: .1em; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.row-main { min-width: 0; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.row-text { margin: 0; color: var(--soft); line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tag { --c: var(--muted); display: inline-block; border-radius: 6px; padding: 2px 8px; background: color-mix(in srgb, var(--c) 17%, transparent); color: color-mix(in srgb, var(--c) 72%, white); font-weight: 700; font-size: 11.5px; white-space: nowrap; }
.prio { --c: var(--muted); display: inline-block; min-width: 26px; text-align: center; border-radius: 6px; padding: 2px 6px; font-weight: 800; font-size: 11.5px; color: #17120a; background: var(--c); }
.status-select { --c: var(--muted); appearance: none; -webkit-appearance: none; cursor: pointer; border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 16%, var(--panel)); color: color-mix(in srgb, var(--c) 78%, white); border-radius: 999px; padding: 4px 14px; font-weight: 750; font-size: 12px; }
.status-select option { background: var(--panel); color: var(--text); }
.line-link { border: 0; padding: 0; background: none; color: var(--yellow); font: inherit; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
.line-link:hover { text-decoration-style: solid; }
.empty { color: var(--muted); padding: 48px 16px; text-align: center; line-height: 1.6; }

/* ------------------------------------------------------------ ideas */
.idea-group { margin-bottom: 18px; }
.idea-group-head { --c: var(--muted); display: flex; align-items: baseline; gap: 10px; margin: 6px 0 10px; padding-left: 10px; border-left: 4px solid var(--c); }
.idea-group-head h2 { margin: 0; font-size: 17px; }
.idea-group-head .count { color: var(--muted); font-size: 12px; }
.idea-family { margin: 12px 0 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.idea-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.idea-card { padding: 11px 13px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.idea-card:hover { border-color: var(--border-bright); background: var(--panel-2); }
.idea-card.selected { box-shadow: 0 0 0 2px var(--yellow); }
.idea-card h3 { margin: 0 0 5px; font-size: 14px; }
.idea-card p { margin: 0; color: var(--soft); font-size: 13px; line-height: 1.45; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.idea-card .idea-meta { margin-top: 6px; color: var(--muted); font-size: 11px; }

/* ------------------------------------------------------------ drawer */
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.drawer-head h2 { margin: 0; font-size: 22px; }
.drawer-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.close-button { border: 1px solid var(--border-bright); background: var(--panel-3); border-radius: 9px; width: 34px; height: 34px; cursor: pointer; font-size: 18px; line-height: 1; flex: 0 0 auto; }
.field { margin-bottom: 15px; }
.field-label { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 7px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.field-label .aside { letter-spacing: 0; text-transform: none; font-weight: 600; }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segment { --c: var(--muted); border: 1px solid var(--border-bright); background: var(--panel-2); border-radius: 9px; padding: 7px 11px; cursor: pointer; font-weight: 700; font-size: 13px; }
.segment:hover { border-color: var(--c); }
.segment[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 24%, var(--panel-2)); box-shadow: inset 0 0 0 1px var(--c); }
.segment.priority { min-width: 46px; text-align: center; }
.segment small { display: block; font-size: 10px; color: var(--muted); font-weight: 600; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 160px; }
.field input[type="text"], .field input[type="date"], .field select { width: 100%; }
textarea.details { min-height: 200px; }
.references { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 20px; }
.drawer-actions .spacer { flex: 1 1 auto; }
.dirty-flag { color: var(--yellow); font-size: 12px; font-weight: 700; }
.banner { border: 1px solid var(--border-bright); background: var(--panel-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; line-height: 1.5; }
.banner.warn { border-color: var(--orange); background: rgba(255, 159, 67, .1); }
.banner.trash { border-color: var(--red); background: rgba(239, 71, 111, .08); }
.banner ul { margin: 6px 0; padding-left: 18px; }
.banner .banner-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.section { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 6px; }
.section h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.notes-list, .history-list, .linked-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notes-list li { background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; white-space: pre-line; overflow-wrap: anywhere; line-height: 1.45; font-size: 13px; }
.notes-list .who, .history-list .who { display: block; color: var(--muted); font-size: 11px; margin-bottom: 3px; white-space: normal; }
.history-list li { font-size: 12px; color: var(--soft); }
.linked-list li button { border: 0; background: none; color: var(--soft); cursor: pointer; text-align: left; padding: 0; font: inherit; font-size: 13px; }
.linked-list li button:hover { color: var(--yellow); }
.linked-list .family { color: var(--muted); font-size: 11px; margin-right: 6px; }
details.history summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 8px; }

/* ------------------------------------------------------------ settings */
.settings-dialog { width: min(920px, 94vw); max-height: 88vh; padding: 0; background: var(--panel); color: var(--text); border: 1px solid var(--border-bright); border-radius: 14px; }
.settings-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.settings-inner { display: flex; flex-direction: column; max-height: 88vh; }
.settings-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.settings-head h2 { margin: 0 auto 0 0; font-size: 18px; }
.settings-tabs { display: flex; gap: 4px; padding: 10px 18px 0; }
.settings-body { overflow: auto; padding: 12px 18px; }
.settings-help { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 0 0 12px; }
.settings-row { display: grid; grid-template-columns: auto 44px minmax(150px, 1.2fr) minmax(120px, 1fr) 96px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.settings-row input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border-bright); border-radius: 8px; background: var(--bg); cursor: pointer; }
.settings-row .usage { color: var(--muted); font-size: 12px; text-align: right; }
.settings-row .move { display: flex; gap: 2px; }
.settings-row .move button, .settings-row .remove { border: 1px solid var(--border-bright); background: var(--panel-3); border-radius: 7px; padding: 4px 8px; cursor: pointer; font-size: 12px; }
.settings-row .remove:disabled, .settings-row .move button:disabled { opacity: .35; cursor: default; }
.settings-row label.open { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--soft); }
.settings-foot { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); }
.settings-foot .error { color: #ff92aa; font-size: 13px; margin-right: auto; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; max-width: min(640px, 92vw); background: var(--panel-3); border: 1px solid var(--border-bright); border-radius: 10px; padding: 10px 16px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.toast.error { border-color: var(--red); color: #ffc2cf; }

/* ------------------------------------------------------------ narrow screens */
@media (max-width: 1180px) {
    .workspace.with-drawer { grid-template-columns: 240px minmax(0, 1fr); }
    .drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100vw); z-index: 40; box-shadow: -20px 0 40px rgba(0, 0, 0, .45); }
}
@media (max-width: 760px) {
    .app-header { padding: 10px 16px; }
    .header-actions { margin-left: 0; justify-content: flex-start; }
    .workspace, .workspace.with-drawer { grid-template-columns: minmax(0, 1fr); }
    .filters { display: none; border-right: 0; border-bottom: 1px solid var(--border); max-height: 50vh; }
    .workspace.filters-open .filters { display: block; }
    .workspace.filters-open { grid-template-rows: auto minmax(0, 1fr); }
    .filters-toggle { display: inline-flex; }
    .list-toolbar { flex-wrap: wrap; padding: 10px 16px; }
    .list { padding: 10px 16px 48px; }
    .row { grid-template-columns: 40px minmax(0, 1fr); }
    .row-status { grid-column: 2; }
    .settings-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
    .settings-row .move, .settings-row .usage { display: none; }
}

/* ------------------------------------------------------------ titles and attachments (ligne 86) */
.row-title { margin: 0 0 4px; font-weight: 750; color: var(--text); overflow-wrap: anywhere; }
.row-text.short { -webkit-line-clamp: 2; }
.drawer.dropping { box-shadow: inset 0 0 0 3px var(--yellow); }
.attachment-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.attachment { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; }
.attachment.pending { border-style: dashed; }
.attachment-open { display: flex; flex-direction: column; gap: 4px; color: var(--soft); text-decoration: none; min-width: 0; }
.attachment-open img { width: 100%; height: 96px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.attachment-icon { display: grid; place-items: center; height: 96px; border-radius: 6px; background: var(--bg); color: var(--muted); font-weight: 800; letter-spacing: .08em; }
.attachment-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { font-size: 11px; color: var(--muted); }
.attachment-remove { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-bright); background: rgba(12, 16, 24, .85); cursor: pointer; line-height: 1; }
