/*
 * Thème « Portulan du navigateur » : la carte marine annotée avant l'expédition. Cartouches à coins coupés,
 * séparateurs en lignes de rhumb, rose des vents à huit branches pour la sélection, chiffres de relevé,
 * jauges graduées comme une échelle de sonde. Pas de rivets, pas d'ombre portée.
 * Polices : Cinzel (titres, noms), IBM Plex Sans (texte), IBM Plex Mono (chiffres, libellés).
 */
:root[data-ui="portulan"] {
  --paper: #e8e1ce; --paper-2: #f0eadb; --paper-3: #d8d0b9;
  --ink: #263b42; --ink-soft: #57696c; --line: #a6a18c; --line-strong: #657c7b;
  --btn-top: #f0eadb; --btn-bot: #f0eadb; --icon: #263b42;
  --rouille: #a44e3b;
  --grid: #a2b1a7; --tile: #c8d2c4; --blocked: #586c68; --rough: #a69b79;
  --player: #b18a36; --bot: #a44e3b; --front: rgba(177, 138, 54, .22); --back: rgba(164, 78, 59, .14);
  --hp: #a34336; --ap: #347a8b; --ep: #b18a36; --accent: #a44e3b;
  --title: "Cinzel", Georgia, serif; --body: "IBM Plex Sans", system-ui, sans-serif;
  --num: "IBM Plex Mono", "Courier New", monospace;
}
:root[data-ui="portulan"][data-theme="dark"] {
    --paper: #182c36; --paper-2: #223c47; --paper-3: #12232b;
    --ink: #e5e1d1; --ink-soft: #a5b6b3; --line: #526a6d; --line-strong: #91aaa4; --icon: #e5e1d1;
    --btn-top: #223c47; --btn-bot: #223c47;
    --rouille: #d77c65;
    --grid: #476365; --tile: #314c4e; --blocked: #0f1d23; --rough: #746d51;
    --player: #e4bd61; --bot: #d77c65; --front: rgba(228, 189, 97, .18); --back: rgba(215, 124, 101, .16);
    --hp: #e47b69; --ap: #70c0ce; --ep: #e4bd61; --accent: #d77c65;
    color-scheme: dark;
}

:root[data-ui="portulan"] {
  --act: var(--choix, var(--rouille)); --on-act: var(--sur-choix, #f4efe2);
  --coupe: polygon(7px 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px), calc(100% - 7px) 100%, 7px 100%, 0 calc(100% - 7px), 0 7px);
  --rose: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 0l2 10 10 2-10 2-2 10-2-10L0 12l10-2z'/%3E%3Cpath d='M12 12l6-6-4 6 4 6zM12 12L6 6l6 4 6-4zM12 12l-6 6 4-6-4-6z' opacity='.55'/%3E%3C/svg%3E");
  --rhumb: repeating-linear-gradient(15deg, transparent 0 22px, color-mix(in srgb, var(--line) 45%, transparent) 22px 23px),
           repeating-linear-gradient(-15deg, transparent 0 22px, color-mix(in srgb, var(--line) 35%, transparent) 22px 23px);
  --sonde: repeating-linear-gradient(90deg, transparent 0 9px, color-mix(in srgb, var(--ink) 55%, transparent) 9px 10px);

  body { background: var(--paper); font-size: 14.5px; }
  h1, h2, .title { font-family: var(--title); font-weight: 500; letter-spacing: .04em; }
  h1 { font-size: 27px; }
  h2 { font-size: 19px; }
  h3 { font: 600 11.5px var(--num); letter-spacing: .14em; text-transform: uppercase; color: var(--line-strong); }
  h3::after { border-top: 1px solid var(--line-strong); }
  a { color: var(--ink); text-decoration-color: var(--act); text-underline-offset: 3px; }
  .muted { color: var(--muted); }
  .small { font-size: 12.5px; color: var(--muted); }
  :focus-visible { outline: 2px dashed var(--act); outline-offset: 2px; }

  /* Boutons : cartouches à coins coupés, une flèche de cap devant le libellé. */
  button, select, input { background: var(--paper-2); border: 1px solid var(--line-strong); border-radius: 0; }
  button { background: var(--paper-3); color: var(--ink); font: 600 13px var(--body); letter-spacing: .03em; clip-path: var(--coupe); }
  button:hover:not(:disabled) { background: var(--paper-2); }
  button:active:not(:disabled) { translate: 0 1px; }
  button:disabled { opacity: .45; }
  button.primary, a.btn.primary { background: var(--act); border-color: var(--act); color: var(--on-act); }
  button.primary::before, a.btn.primary::before { content: "➤ "; font-size: .8em; }
  button.danger { background: var(--paper-2); color: var(--rouille); border-color: var(--rouille); }
  select, input[type="text"], input[type="email"], input[type="number"] { color: var(--ink); font-family: var(--body); }
  input[type="range"], input[type="checkbox"], input[type="radio"] { accent-color: var(--act); border: 0; }
  a.btn { background: var(--paper-3); color: var(--ink); border: 1px solid var(--line-strong); clip-path: var(--coupe); font: 600 13px var(--body); }
  button.link { background: none; border: 0; clip-path: none; color: var(--ink); text-decoration: underline 1px var(--act); font: inherit; }
  button.mini, .small-btn { font-size: 12px; }

  .ibtn { background: none; color: var(--icon); border: 1px solid transparent; clip-path: none; }
  .ibtn:hover:not(:disabled) { border-color: var(--line-strong); }
  .ibtn[aria-current="page"] { background: var(--paper-2); border-color: var(--act); color: var(--act); }

  .pills { gap: 0; }
  .pill { border-left: 1px solid var(--line); font: 500 13px var(--num); padding: 2px 9px; }
  .pill:first-child { border-left: 0; }
  .pill small { font: 500 10.5px var(--num); letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
  .pill.warm, .pill.alert { color: var(--act); }

  /* Panneaux : cartouches, un filet intérieur comme le cadre d'une carte. */
  .paper, .panel, .log, .card-pane { background: var(--paper-2); clip-path: var(--coupe); box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 0 0 4px var(--paper-2), inset 0 0 0 5px var(--line); }
  .notice.quiet { box-shadow: none; }

  .topbar { background: var(--paper-3); background-image: var(--rhumb); border-bottom: 2px solid var(--line-strong); }
  .topbar .muted, .topbar .small { color: var(--muted); }
  .avatar { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line-strong); font: 500 24px var(--title); }
  .hero-name { font: 500 19px/1 var(--title); letter-spacing: .04em; }
  .hero-sub { font: 500 11px var(--num); letter-spacing: .12em; text-transform: uppercase; }
  .where .title { font-size: 16px; }
  .live { color: var(--act); }
  .settings-body { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line-strong); }
  .settings-body label { font: 500 11px var(--num); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
  .settings-body select { color: var(--text); }
  .rail { border-right: 1px solid var(--line-strong); background: var(--paper-3); }
  .rail hr { border: 0; border-top: 1px solid var(--line); }
  @media (max-width: 760px) { .rail { border-right: 0; border-bottom: 1px solid var(--line-strong); } }

  .board { background: var(--paper-2); background-image: var(--rhumb); border: 1px solid var(--line-strong); outline: 1px solid var(--line); outline-offset: 3px; padding: 16px; }
  @media (max-width: 760px) { .board { padding: 8px; } }
  .hint { color: var(--muted); font-size: 12.5px; }
  .flash { color: var(--rouille); font-weight: 600; }
  .flash.ok { color: var(--hp); }

  .minimap { border: 1px solid var(--line-strong); }
  .mm-pulse { border: 2px solid var(--act); border-radius: 50%; }
  .portrait canvas, canvas.skin { background: var(--paper-2); border: 1px solid var(--line-strong); }
  .portrait-name .title { font-size: 28px; }
  .quote { font-style: italic; border-left: 1px solid var(--line-strong); font-size: 13.5px; }
  .message .block + .block { border-top: 1px dashed var(--line); }
  .message .block div:first-child { font-weight: 600; }

  /* Onglets : caps de navigation ; l'actif porte la rose des vents. */
  .side-tabs, .tabs { gap: 2px; border-bottom: 1px solid var(--line-strong); }
  .side-tabs button, .tabs button, .look { background: none; border: 0; clip-path: none; color: var(--muted); font: 600 12.5px var(--title); letter-spacing: .08em; }
  .side-tabs button:active, .tabs button:active, .look:active { translate: none; }
  .side-tabs button[aria-pressed="true"], .tabs button[aria-pressed="true"], .look[aria-pressed="true"] {
    color: var(--ink); box-shadow: inset 0 -2px 0 var(--act); position: relative; }
  .side-tabs button[aria-pressed="true"]::before, .tabs button[aria-pressed="true"]::before, .look[aria-pressed="true"]::before {
    content: ""; position: absolute; left: 2px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
    background: var(--act); -webkit-mask: var(--rose) center/contain no-repeat; mask: var(--rose) center/contain no-repeat; }
  .side-tabs { margin-bottom: 8px; }

  .who strong { font: 500 23px var(--title); }
  .tag { font: 500 11px var(--num); letter-spacing: .06em; color: #fff; }

  /* Jauges : échelle de sonde, graduée sur la moitié basse. */
  .bar .label { font: 500 11.5px var(--num); letter-spacing: .06em; }
  .bar .track, .gauge, .wear { background: var(--paper); border: 1px solid var(--line-strong); height: 12px; position: relative; }
  .bar .track::after, .gauge::after, .wear::after { content: ""; position: absolute; inset: 0; background: var(--sonde);
    -webkit-mask: linear-gradient(transparent 55%, #000 55%); mask: linear-gradient(transparent 55%, #000 55%); pointer-events: none; }
  .gauge, .wear { height: 8px; }
  .gauge i { background: var(--ink); }
  .wear i { background: var(--line-strong); }
  .wear i.low { background: var(--rouille); }

  .stats { gap: 6px; }
  .stats div, .derived div { background: var(--paper-2); clip-path: var(--coupe); box-shadow: inset 0 0 0 1px var(--line);
    font: 500 10.5px var(--num); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
  .stats b, .derived b { font: 600 24px/1.1 var(--num); color: var(--ink); letter-spacing: -.02em; }
  .derived b { font-size: 18px; }
  .derived b.over { color: var(--rouille); }

  .log li, .reports li { border-left: 2px solid var(--line); }
  .log li.system { border-color: var(--act); color: var(--muted); font-style: italic; }
  .log li.attack, .reports li.attack { border-color: var(--ink); }
  .log li.defense, .reports li.defense { border-color: var(--rouille); }
  .log li.move, .log li.energy, .log li.info, .reports li.move, .reports li.energy, .reports li.info { color: var(--muted); }
  .log details { font-size: 12.5px; color: var(--muted); }
  .log summary { color: var(--text); font-size: 13.5px; }
  .log .t { font: 500 11px var(--num); color: var(--muted); }
  .reports { font-size: 13.5px; }

  .roster.faded { opacity: .75; }
  .chip { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line-strong); font: 500 15px var(--title); letter-spacing: .02em; }
  .chip:active { translate: none; }
  .chip small { font: 500 10.5px var(--num); letter-spacing: .08em; color: var(--muted); }
  .chip.on { background: var(--act); border-color: var(--act); color: var(--on-act); }
  .chip.on small, .chip.on.map small { color: inherit; opacity: .85; }
  .chip.healing small { color: var(--rouille); }
  .chip.map small { color: var(--hp); }
  table.train { font-size: 13.5px; }
  table.train td { border-bottom: 1px dashed var(--line); }
  table.train td:nth-child(2), table.train tr.muted td { color: var(--muted); }

  .arena-head strong { font: 500 21px var(--title); }
  .companies li { border: 1px solid var(--line-strong); }
  .companies li.mine { background: var(--paper-3); border-color: var(--act); }
  .companies small { color: var(--muted); }
  .dot { background: var(--act); }

  .banner { background: var(--paper-3); background-image: var(--rhumb); border-bottom: 2px solid var(--line-strong); }
  .banner .small, .banner .muted { color: var(--muted); }
  .banner-name { font: 500 32px/1 var(--title); letter-spacing: .05em; }
  .gold-pill { font: 600 22px var(--num); color: var(--ink); }

  /* Mercenaires : cartouches ; le choisi prend la rose des vents. */
  .tile { background: var(--paper-2); color: var(--ink); border: 0; clip-path: var(--coupe); box-shadow: inset 0 0 0 1px var(--line-strong); font: inherit; letter-spacing: 0; text-align: left; }
  .tile:hover:not(:disabled) { background: var(--paper); }
  .tile:active:not(:disabled) { translate: none; }
  .tile.on { background: var(--paper-3); box-shadow: inset 0 0 0 2px var(--act); }
  .tile.on .tile-portrait::after { content: ""; position: absolute; left: 4px; top: 4px; width: 20px; height: 20px;
    background: var(--act); -webkit-mask: var(--rose) center/contain no-repeat; mask: var(--rose) center/contain no-repeat; }
  .tile-portrait { background: var(--paper); background-image: var(--rhumb); border: 1px solid var(--line); }
  .tile canvas.skin { border: 0; background: none; }
  .xp-badge { background: var(--act); color: var(--on-act); font: 600 11px var(--num); }
  .tile-name { font: 500 20px/1.1 var(--title); letter-spacing: .03em; }
  .tile-row { font-size: 12.5px; color: var(--muted); }
  .tile-row b { color: var(--text); font: 600 12.5px var(--num); }
  .tile-empty { background: none; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
  .tile-plus { font: 500 36px var(--title); }

  .sheet-name { font: 500 38px/1 var(--title); letter-spacing: .04em; }
  .train-line { border-bottom: 1px dashed var(--line); }
  .stat-line { font-size: 13.5px; }
  .stat-line > span:nth-child(3) { font: 600 15px var(--num); }
  .trait { font-size: 13.5px; }
  .trait.plus b { color: var(--hp); }
  .trait.minus b { color: var(--rouille); }
  .trait.zero { color: var(--muted); }
  .slot { background: var(--paper-2); border: 1px solid var(--line-strong); }
  .slot-empty, .slot-taken { border-style: dashed; background: none; }

  .status { font: 500 11px var(--num); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .status.map { color: var(--player); }
  .status.ready { color: var(--hp); }
  .status.resting { color: var(--ap); }
  .status.healing { color: var(--rouille); }
  .warn { color: var(--rouille); font-size: 12.5px; }
  .gold { font-family: var(--num); font-weight: 600; }
  .worn { font-size: 13.5px; }
  .worn th, .worn td { border-bottom: 1px dashed var(--line); }
  .worn thead th { font: 500 11px var(--num); letter-spacing: .1em; text-transform: uppercase; color: var(--line-strong); border-bottom: 1px solid var(--line-strong); }
  .item { border-bottom: 1px dashed var(--line); }
  .item:last-child { border-bottom: 0; }

  .brand .title { font: 700 46px/1 var(--title); color: var(--ink); letter-spacing: .06em; }
  .brand .small { font-size: 14px; }
  .page .card { background: var(--paper-2); clip-path: var(--coupe); box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 0 0 5px var(--paper-2), inset 0 0 0 6px var(--line); }
  .page .error { color: var(--rouille); font-weight: 600; }
  .page .ok { color: var(--hp); }
  .page dt { color: var(--muted); font: 500 11px var(--num); letter-spacing: .1em; text-transform: uppercase; }
  .page footer { font-size: 12.5px; color: var(--muted); }
  .skip { border-top: 1px dashed var(--line); }
  .nav { font: 600 12.5px var(--title); letter-spacing: .08em; }
  .nav a { color: var(--muted); text-decoration: none; }
  .nav a[aria-current="page"] { color: var(--ink); text-decoration: underline 2px var(--act); }
}
