/* Carnet de jeu -- portage de la maquette Claude Design « Carnet de jeu v3 ».
   Les valeurs viennent telles quelles des styles en ligne de la maquette ; elles
   sont seulement rangees en jetons et en classes. */

:root {
  --ink: #1f2b5e;
  --red: #d8574f;
  --yel: #fbe38e;
  --paper: #fff;
  --grid: rgba(70, 110, 190, .13);
  --line: rgba(31, 43, 94, .18);
  --line-2: rgba(31, 43, 94, .3);
  --line-3: rgba(31, 43, 94, .5);
  --veil: rgba(31, 43, 94, .18);
  --hand: 'Patrick Hand', cursive;
  --serif: 'Source Serif 4', serif;
  --mark: linear-gradient(transparent 55%, var(--yel) 55%);
  --hl-idee: #e3e0d6;
  --hl-proto: #cfe0fb;
  --hl-test: #fbe38e;
  --hl-ok: #c8ecc0;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--serif); }
a { color: var(--ink); text-decoration-color: var(--red); }
a:hover { color: var(--red); }
::selection { background: var(--yel); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--red); outline-offset: 2px;
}
button { font: inherit; color: var(--ink); }
[hidden] { display: none !important; }
.hand { font-family: var(--hand); }

/* -- Coquille ----------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) clamp(340px, 34vw, 460px);
  height: 100vh; min-height: 560px;
  font-size: 13.5px; position: relative;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
}
.app.no-detail { grid-template-columns: 240px minmax(0, 1fr); }

.side {
  border-right: 2px solid var(--red); padding: 24px 18px;
  display: flex; flex-direction: column; gap: 24px;
  background: rgba(255, 255, 255, .85); overflow: auto;
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand-kicker { font-family: var(--hand); font-size: 15px; color: var(--red); }
.brand-title { font-family: var(--hand); font-size: 28px; line-height: 1.05; }
.brand-sub { font-size: 12px; opacity: .7; line-height: 1.45; margin-top: 4px; text-wrap: pretty; }
.cats { display: flex; flex-direction: column; gap: 2px; }
.cat {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 4px 8px; border: 0; background: transparent; font-size: 13.5px;
  cursor: pointer; text-align: left; flex-shrink: 0;
}
.cat:hover { color: var(--red); }
.cat.on { background: linear-gradient(transparent 45%, var(--yel) 45%); font-weight: 600; }
.cat-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-family: var(--hand); font-size: 15px; opacity: .7; font-weight: 400; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-repo { font-size: 11.5px; opacity: .7; }
.side-links { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.side-user { font-size: 11.5px; opacity: .7; display: flex; gap: 6px; flex-wrap: wrap; }

.btn-sketch {
  font-weight: 500; height: 36px; border-radius: 3px; border: 1.5px solid var(--ink);
  background: var(--paper); box-shadow: 2px 2px 0 var(--ink); cursor: pointer;
}
.btn-sketch:hover { background: var(--yel); }
.btn-sketch:active { box-shadow: 0 0 0 var(--ink); transform: translate(2px, 2px); }

.link-btn {
  font-size: 12.5px; border: 0; padding: 0; background: transparent; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px;
}
.link-btn:hover { color: var(--red); }

.btn {
  font-size: 12.5px; height: 30px; padding: 0 12px; border-radius: 3px;
  border: 1.5px solid var(--ink); background: transparent; cursor: pointer;
}
.btn:hover { background: rgba(251, 227, 142, .4); }
.btn:active { transform: translate(1px, 1px); }
.btn.primary { font-weight: 600; background: var(--yel); }
.btn.lg { font-size: 13px; height: 34px; padding: 0 14px; }
.btn:disabled { opacity: .45; cursor: default; }

/* -- Colonne centrale ---------------------------------------------------- */

.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; position: relative; }
.main-head { padding: 24px 30px 14px; display: flex; flex-direction: column; gap: 14px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.heading { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.heading h2 { margin: 0; font-family: var(--hand); font-weight: 400; font-size: 37px; line-height: 1; }
.heading .count { font-family: var(--hand); font-size: 17px; color: var(--red); }
.search {
  display: flex; align-items: center; gap: 8px; width: 220px; padding: 4px 2px;
  border-bottom: 1.5px solid var(--line-3);
}
.search:focus-within { border-color: var(--red); }
.search input { border: 0; background: transparent; font: inherit; outline: none; color: var(--ink); width: 100%; }
.views { display: flex; gap: 14px; font-weight: 500; }
.view-btn { font-weight: 500; border: 0; padding: 0 3px; background: transparent; opacity: .55; cursor: pointer; }
.view-btn:hover { opacity: 1; }
.view-btn.on { background: var(--mark); opacity: 1; }
.status-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.sf {
  font-size: 12.5px; padding: 2px 10px; border: 1.5px solid var(--line-2);
  border-radius: 14px 10px 12px 9px; background: var(--paper); cursor: pointer;
}
.sf:hover, .sf.on { border-color: var(--red); }

.content { flex: 1; overflow: auto; min-height: 0; }
.list { padding: 4px 30px 110px; display: flex; flex-direction: column; gap: 8px; }
.card {
  width: 100%; flex-shrink: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px; padding: 10px 14px; text-align: left; background: var(--paper);
  border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(31, 43, 94, .12); cursor: pointer;
}
.card:hover { border-color: var(--line-3); }
.card.on { box-shadow: 3px 3px 0 var(--ink); }
.card-title { font-size: 15px; font-weight: 600; text-wrap: pretty; }
.card-date { font-family: var(--hand); font-size: 15px; opacity: .7; white-space: nowrap; }
.card-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.muted { opacity: .7; }
.status-mark { padding: 0 3px; font-weight: 500; }
.proto-label { font-family: var(--hand); font-size: 15px; color: var(--red); }
.empty { padding: 48px 0; text-align: center; font-family: var(--hand); font-size: 20px; opacity: .6; }

/* Kanban */
.kanban {
  padding: 6px 30px 110px; display: grid; grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 14px; align-items: stretch; min-width: 840px;
}
.col {
  display: flex; flex-direction: column; gap: 10px; padding: 10px;
  border: 1.5px dashed var(--line-2); background: rgba(255, 255, 255, .55); min-height: 420px;
}
.col.over { border-color: var(--red); background: rgba(251, 227, 142, .22); }
.col-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0 2px 4px; border-bottom: 1.5px solid var(--red);
}
.col-name { font-family: var(--hand); font-size: 22px; padding: 0 3px; }
.col-count { font-family: var(--hand); font-size: 17px; color: var(--red); }
.kcard {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; background: var(--paper);
  border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(31, 43, 94, .12); cursor: grab; text-align: left;
}
.kcard:hover { border-color: var(--line-3); }
.kcard.on { box-shadow: 3px 3px 0 var(--ink); }
.kcard.dragging { opacity: .4; }
.kcard-cat { font-size: 11.5px; opacity: .7; }
.kcard-title { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.kcard-foot { display: flex; justify-content: space-between; gap: 8px; font-family: var(--hand); font-size: 14px; }
.col-hint { flex: 1; display: grid; place-items: center; font-family: var(--hand); font-size: 17px; opacity: .5; padding: 16px; }

/* Tableau blanc */
.board-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.board-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 8px 30px;
  border-top: 1.5px dashed var(--line-2); border-bottom: 1.5px dashed var(--line-2);
  background: rgba(255, 255, 255, .85);
}
.tools { display: flex; gap: 10px; }
.tool { font-family: var(--hand); font-size: 17px; border: 0; padding: 0 4px; background: transparent; opacity: .55; cursor: pointer; }
.tool.on { background: var(--mark); opacity: 1; }
.inks { display: flex; gap: 6px; align-items: center; }
.ink {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer; background: var(--paper);
  border: 1.5px solid rgba(31, 43, 94, .2); display: grid; place-items: center; padding: 0;
}
.ink.on { border-color: var(--ink); }
.ink span { width: 12px; height: 12px; border-radius: 50%; }
.board-bar select {
  margin-left: auto; font: inherit; font-size: 12.5px; height: 30px; max-width: 240px;
  border: 1.5px solid var(--ink); border-radius: 3px; background: var(--paper); color: var(--ink); padding: 0 6px;
}
.board-scroll { flex: 1; min-height: 0; overflow: auto; }
.board { position: relative; width: 2400px; height: 1600px; touch-action: none; user-select: none; }
.board.pen { cursor: crosshair; }
.board.erase { cursor: cell; }
.board svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.board.erase svg path { pointer-events: stroke; cursor: pointer; }
.bcard {
  position: absolute; width: 230px; display: flex; flex-direction: column; gap: 5px;
  padding: 14px 12px 10px; background: var(--paper); border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(31, 43, 94, .12); cursor: grab;
}
.board.pen .bcard, .board.erase .bcard { pointer-events: none; }
.bcard.on { box-shadow: 3px 3px 0 var(--ink); }
.bcard.dragging { cursor: grabbing; box-shadow: 6px 8px 0 rgba(31, 43, 94, .25); transform: none !important; }
.tape { position: absolute; top: -8px; left: 38%; width: 24%; height: 14px; background: rgba(251, 227, 142, .85); }
.bcard-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.x-btn { border: 0; background: transparent; cursor: pointer; opacity: .45; font-size: 15px; line-height: 1; padding: 2px 4px; }
.x-btn:hover { opacity: 1; color: var(--red); }
.board-empty { position: absolute; left: 80px; top: 80px; font-family: var(--hand); font-size: 24px; opacity: .5; }
.board-foot {
  padding: 6px 30px; border-top: 1.5px dashed var(--line-2); background: rgba(255, 255, 255, .85);
  font-family: var(--hand); font-size: 14px; opacity: .75;
}

.fab {
  position: absolute; right: 28px; bottom: 28px; display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 18px; border-radius: 4px; border: 2px solid var(--ink); background: var(--yel);
  font-family: var(--hand); font-size: 21px; box-shadow: 3px 3px 0 var(--ink); transform: rotate(-1deg);
  cursor: pointer; z-index: 5;
}
.fab:hover { transform: rotate(0deg); }
.fab:active { box-shadow: 0 0 0 var(--ink); transform: translate(3px, 3px); }
.kbd { font-family: var(--serif); font-size: 11px; border: 1px solid var(--ink); border-radius: 3px; padding: 0 5px; }

/* -- Fiche -------------------------------------------------------------- */

.detail { border-left: 1.5px dashed rgba(31, 43, 94, .35); background: rgba(255, 255, 255, .7); overflow: auto; min-height: 0; }
.detail-inner { padding: 24px 26px 40px; display: flex; flex-direction: column; gap: 14px; }
.detail-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.pill { border: 1.5px solid var(--ink); border-radius: 12px 9px 11px 8px; padding: 1px 9px; }
select.pill { font: inherit; font-size: 12px; background: transparent; color: var(--ink); cursor: pointer; }
.detail-date { font-family: var(--hand); font-size: 15px; opacity: .7; }
.detail-actions { margin-left: auto; display: flex; gap: 10px; }
.title-edit {
  margin: 0; font-family: var(--hand); font-weight: 400; font-size: 37px; line-height: 1.1; text-wrap: pretty;
  border: 0; background: transparent; color: var(--ink); width: 100%; resize: none; outline: none; padding: 0;
  field-sizing: content;
}
.status-opts { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 500; }
.status-opt {
  font-weight: 500; padding: 1px 10px; border: 2px solid transparent; border-radius: 50% 45% 50% 40%;
  background: transparent; opacity: .45; cursor: pointer;
}
.status-opt:hover { opacity: 1; }
.status-opt.on { border-color: var(--red); color: var(--red); opacity: 1; }
.body-edit {
  font: inherit; font-size: 14px; line-height: 22px; color: var(--ink); background: transparent; border: 0;
  border-top: 1px solid rgba(31, 43, 94, .2); border-bottom: 1px solid rgba(31, 43, 94, .2);
  padding: 10px 0; resize: vertical; outline: none; min-height: 140px;
}
.code-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }
.code-row input {
  font: inherit; font-size: 12.5px; border: 0; border-bottom: 1px dashed var(--line-2); background: transparent;
  color: var(--ink); outline: none; padding: 1px 0; min-width: 0; flex: 1;
}
.save-state { font-family: var(--hand); font-size: 14px; opacity: .6; min-height: 1em; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.sec-title { font-family: var(--hand); font-size: 22px; }
.sec-add { font-family: var(--hand); font-size: 16px; color: var(--red); border: 0; background: transparent; cursor: pointer; }
.sec-add:hover { text-decoration: underline; }

.refs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 12px; }
.polaroid {
  aspect-ratio: 1; background: var(--paper); padding: 6px 6px 18px; box-shadow: 0 2px 6px rgba(31, 43, 94, .18);
  position: relative; border: 0; cursor: zoom-in;
}
.polaroid .tape { left: 30%; width: 40%; z-index: 1; }
.polaroid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.polaroid .x-btn { position: absolute; right: 2px; bottom: 0; z-index: 2; background: var(--paper); }
.drop-slot {
  aspect-ratio: 1; border: 1.5px dashed rgba(31, 43, 94, .4); background: rgba(255, 255, 255, .6);
  display: grid; place-items: center; text-align: center; padding: 8px; cursor: pointer;
  font-family: var(--hand); font-size: 15px; opacity: .7;
}
.drop-slot:hover, .drop-slot.over { border-color: var(--red); opacity: 1; }

.proto-empty {
  color: var(--ink); background: var(--paper); border: 1.5px dashed rgba(31, 43, 94, .4); padding: 24px 16px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.proto-empty:hover { border-color: var(--red); }
.proto {
  background: var(--paper); border: 1.5px solid var(--ink); box-shadow: 3px 3px 0 rgba(31, 43, 94, .9);
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.proto-thumb {
  aspect-ratio: 16 / 7; border: 1px dashed rgba(31, 43, 94, .4); background: transparent; display: block;
  width: 100%; padding: 0; overflow: hidden; position: relative; cursor: zoom-in;
}
.proto-thumb:hover { border-color: var(--red); }
.proto-thumb iframe {
  width: 400%; height: 400%; transform: scale(.25); transform-origin: 0 0; border: 0; pointer-events: none;
}
.proto-thumb .thumb-label {
  position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--hand); font-size: 16px; opacity: .6;
}
.proto-name { font-weight: 600; font-size: 15px; }
.proto-cur { font-family: var(--hand); font-size: 17px; color: var(--red); }
.versions { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid rgba(31, 43, 94, .2); padding-top: 6px; }
.version { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; font-size: 12.5px; }
.version.old { opacity: .55; }
.version.old .v-note { text-decoration: line-through; }
.version button { font-weight: 600; border: 0; padding: 0; background: transparent; cursor: pointer; text-align: left; }
.version button:hover { color: var(--red); }
.v-date { font-family: var(--hand); font-size: 14px; opacity: .8; }
.pages { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid rgba(31, 43, 94, .2); padding-top: 6px; }
.page-row { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.page-row button {
  flex: 1; min-width: 0; text-align: left; border: 0; padding: 1px 0; background: transparent; cursor: zoom-in;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px;
}
.page-row button:hover, .page-row a:hover { color: var(--red); }
.page-row a { text-decoration: none; font-size: 14px; opacity: .7; }
.published { font-size: 12px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.published .badge { background: linear-gradient(transparent 50%, var(--hl-ok) 50%); padding: 0 3px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* -- Fenetres ----------------------------------------------------------- */

.veil {
  position: fixed; inset: 0; background: var(--veil); display: grid; place-items: center;
  padding: 24px; z-index: 30;
}
.veil.top { place-items: start center; padding-top: 14vh; z-index: 20; }
.sheet {
  width: min(480px, 100%); background: var(--paper); border: 1.5px solid var(--ink); box-shadow: 5px 5px 0 var(--ink);
  padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; color: var(--ink);
  max-height: calc(100vh - 48px); overflow: auto;
}
.sheet-title { font-family: var(--hand); font-size: 30px; line-height: 1; }
.sheet-sub { font-size: 13.5px; line-height: 1.5; opacity: .8; text-wrap: pretty; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-family: var(--hand); font-size: 16px; }
.field input, .field select { font: inherit; color: var(--ink); }
.field input[type=text], .field input[type=url], .field input:not([type]) {
  border: 0; border-bottom: 1.5px solid rgba(31, 43, 94, .4); background: transparent; padding: 4px 0; outline: none;
}
.field select { height: 32px; border: 1.5px solid var(--ink); border-radius: 3px; background: var(--paper); padding: 0 6px; }
.dropzone {
  border: 1.5px dashed rgba(31, 43, 94, .4); padding: 14px; text-align: center; font-size: 13px; opacity: .75; cursor: pointer;
}
.dropzone:hover, .dropzone.over { border-color: var(--red); opacity: 1; }
.dropzone.has { opacity: 1; border-style: solid; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--red); width: 16px; height: 16px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.form-error { color: var(--red); font-size: 12.5px; }

.palette { width: min(620px, 92vw); background: var(--paper); border: 1.5px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); }
.palette textarea {
  display: block; width: 100%; font-family: var(--hand); font-size: 28px; line-height: 1.25; border: 0;
  background: transparent; color: var(--ink); resize: none; outline: none; padding: 18px 24px;
}
.palette-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 24px; border-top: 1px dashed var(--line-2); }
.chip {
  font-size: 12px; padding: 2px 9px; border-radius: 12px 9px 11px 8px; cursor: pointer;
  background: var(--paper); border: 1.5px solid var(--line-2);
}
.chip.on { background: var(--yel); border-color: var(--ink); }
.palette-foot {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 24px;
  border-top: 1px dashed var(--line-2); font-size: 12px;
}

.viewer {
  width: min(1100px, 92vw); height: min(720px, 84vh); background: var(--paper); border: 1.5px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink); display: flex; flex-direction: column; overflow: hidden; color: var(--ink);
}
.viewer.wide { width: 96vw; height: 92vh; }
.viewer-bar {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1.5px dashed var(--line-2); font-size: 13px;
}
.viewer-name { font-family: var(--hand); font-size: 21px; white-space: nowrap; }
.viewer-bar select { font: inherit; font-size: 12.5px; height: 30px; border: 1.5px solid var(--ink); border-radius: 3px; background: var(--paper); color: var(--ink); max-width: 260px; }
.viewer-file { flex: 1; min-width: 0; opacity: .6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer iframe { flex: 1; border: 0; width: 100%; background: #fff; }
.viewer img { flex: 1; min-height: 0; object-fit: contain; width: 100%; background: #fff; }

.toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%) rotate(-.5deg); background: var(--paper);
  border: 1.5px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 8px 16px; font-family: var(--hand);
  font-size: 17px; z-index: 40; max-width: calc(100vw - 32px);
}
.toast.err { border-color: var(--red); box-shadow: 3px 3px 0 var(--red); }

.splash { height: 100vh; display: grid; place-items: center; font-family: var(--hand); font-size: 24px; opacity: .6; }

/* -- Petits ecrans ------------------------------------------------------- */

@media (max-width: 1100px) {
  .app, .app.no-detail { grid-template-columns: 200px minmax(0, 1fr); }
  .detail {
    position: fixed; inset: 0 0 0 auto; width: min(460px, 100vw); z-index: 15; background: var(--paper);
    box-shadow: -4px 0 0 rgba(31, 43, 94, .08);
  }
  .detail:not(.open) { display: none; }
  .detail-close { display: inline-block !important; }
}
@media (max-width: 720px) {
  .app, .app.no-detail { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 100vh; }
  .side { border-right: 0; border-bottom: 2px solid var(--red); padding: 16px; gap: 12px; }
  .cats { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 0; }
  .main { overflow: visible; }
  .main-head { padding: 16px; }
  .list { padding: 4px 16px 110px; }
  .kanban { padding: 6px 16px 110px; }
  .search { width: 100%; }
  .fab { position: fixed; right: 16px; bottom: 16px; }
}
.detail-close { display: none; }
