/*
 * Thème « parchemin » (habillage d'origine, gardé jusqu'au nettoyage final) : fond de papier, cadres
 * biseautés, pastilles et boutons-icônes. Tout est dessiné ici (dégradés, bruit SVG) : aucune image externe.
 * Habillage seulement : la mise en page est dans base.css.
 */
:root[data-ui="parchemin"] {
  --paper: #efe5cf; --paper-2: #f7f0de; --paper-3: #e7d9b8;
  --ink: #3b2a18; --ink-soft: #6e5a40; --line: #c4ab7f; --line-strong: #8f6f43;
  --btn-top: #f8efda; --btn-bot: #e3d0a6; --icon: #5b3c1c;
  --grid: #e2d3b1; --tile: #e9dcbd; --blocked: #6b6052; --rough: #d9cfb6;
  --player: #2f6fb3; --bot: #b03a26; --front: rgba(47, 160, 90, 0.18); --back: rgba(184, 64, 47, 0.12);
  --hp: #3e8a3f; --ap: #c88a1e; --ep: #4f73b8; --accent: #8a5a2b;
  --title: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --warm: #ecd7a6; --quote: #f4e6c4;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --clouds: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='900'%3E%3Cfilter id='c'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.006' numOctaves='4' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .33 0 0 0 0 .16 0 0 0 .22 -.06'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23c)'/%3E%3C/svg%3E");
  /* Arabesque d'angle (une seule, retournée par CSS pour les 4 coins). */
  --corner: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120' fill='none' stroke='%237a5a32' stroke-linecap='round'%3E%3Cpath d='M6 114V40C6 20 20 6 40 6h74' stroke-width='2.2' opacity='.55'/%3E%3Cpath d='M14 104V44c0-17 13-30 30-30h60' stroke-width='1' opacity='.45'/%3E%3Cpath d='M22 60c0-22 16-38 38-38 14 0 22 8 22 18 0 8-6 13-13 13-6 0-10-4-10-9s3-7 7-7' stroke-width='1.6' opacity='.5'/%3E%3Cpath d='M22 60c6-4 12-4 16 1M60 22c-4 6-4 12 1 16' stroke-width='1.2' opacity='.45'/%3E%3Ccircle cx='26' cy='26' r='3.5' fill='%237a5a32' stroke='none' opacity='.5'/%3E%3C/svg%3E");
}
:root[data-ui="parchemin"][data-theme="dark"] {
    --paper: #2a231b; --paper-2: #322a20; --paper-3: #241e17;
    --ink: #eadcc0; --ink-soft: #b49f7e; --line: #5c4a33; --line-strong: #8f7350;
    --btn-top: #3d3226; --btn-bot: #2c241b; --icon: #e2c99a;
    --grid: #3a3026; --tile: #2f271e; --blocked: #0f0e0d; --rough: #4a4234;
    --player: #5b9be0; --bot: #e0705c; --front: rgba(80, 200, 120, 0.18); --back: rgba(224, 112, 92, 0.14);
    --accent: #d8a26a; --warm: #4a3a24; --quote: #3b3022;
    color-scheme: dark;
}

:root[data-ui="parchemin"] {
  body {
    background-color: var(--paper);
    background-image: var(--noise), var(--clouds), radial-gradient(ellipse at center, transparent 55%, rgba(90, 60, 25, .18) 100%);
    background-attachment: fixed;
  }
  h1, h2, .title { font-family: var(--title); font-weight: 600; letter-spacing: .01em; }
  h1 { font-size: 22px; }
  h2 { font-size: 17px; }
  h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
  h3::after { border-top: 1px solid var(--line); }
  a { color: var(--accent); }

  button, select, input {
    background: linear-gradient(var(--btn-top), var(--btn-bot));
    border: 1px solid var(--line-strong); border-radius: 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 1px 2px rgba(60, 40, 15, .18);
  }
  input[type="text"], input[type="email"], input[type="number"] { background: var(--paper-2); box-shadow: inset 0 1px 2px rgba(60, 40, 15, .15); }
  button:hover:not(:disabled) { border-color: var(--accent); filter: brightness(1.04); }
  button:active:not(:disabled) { box-shadow: inset 0 1px 3px rgba(60, 40, 15, .3); }
  button:disabled { opacity: .45; }
  button.primary { background: linear-gradient(#a8743f, #7c4f24); color: #fff8ea; border-color: #5c3a17; font-weight: 600; }
  button.danger { border-color: var(--bot); color: var(--bot); }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  .muted { color: var(--muted); }
  .small { font-size: 12px; color: var(--muted); }

  .ibtn {
    border-radius: 9px; color: var(--icon);
    background: linear-gradient(var(--btn-top), var(--btn-bot)); border: 1px solid var(--line-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 2px 3px rgba(60, 40, 15, .22);
  }
  .ibtn[aria-current="page"] { background: linear-gradient(#b07a43, #82552a); color: #fff6e3; border-color: #5c3a17; }
  .pill {
    border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line-strong);
    font-size: 13px; font-weight: 600; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5);
  }
  .pill small { font-weight: 500; color: var(--muted); font-size: 11px; }
  .pill.warm { background: var(--warm); }
  .pill.alert { border-color: var(--bot); color: var(--bot); }
  .paper, .panel, .log, .card-pane {
    background: var(--paper-2); background-image: var(--noise);
    border: 1px solid var(--line); border-radius: 8px;
    box-shadow: inset 0 0 0 3px var(--paper-2), inset 0 0 0 4px var(--line), 0 2px 6px rgba(60, 40, 15, .12);
  }

  .topbar {
    background: var(--paper-2); background-image: var(--noise), linear-gradient(var(--paper-2), var(--paper));
    border-bottom: 1px solid var(--line-strong); box-shadow: 0 2px 8px rgba(60, 40, 15, .15);
  }
  .avatar {
    border-radius: 50%; border: 2px solid var(--line-strong);
    background: radial-gradient(circle at 40% 35%, var(--paper-2), var(--paper-3));
    box-shadow: 0 1px 3px rgba(60, 40, 15, .3); font-family: var(--title); font-size: 22px; color: var(--icon);
  }
  .hero-name { font-family: var(--title); font-size: 18px; font-weight: 600; line-height: 1.1; color: var(--accent); }
  .hero-sub { font-size: 12px; color: var(--muted); }
  .where .title { font-size: 16px; }
  .live { color: var(--hp); }
  .live.off { color: var(--muted); }
  .settings[open] > summary { border-color: var(--accent); }
  .settings-body label { font-size: 12px; color: var(--muted); }
  .settings-body select { color: var(--text); }
  .rail {
    border-radius: 10px; background: var(--paper-2); background-image: var(--noise);
    border: 1px solid var(--line); box-shadow: 0 2px 6px rgba(60, 40, 15, .12);
  }
  .rail hr { border: 0; border-top: 1px solid var(--line); }

  /* Plateau encadré : parchemin, double filet, arabesques aux 4 coins. */
  .board {
    border-radius: 10px; background: var(--paper-2); background-image: var(--noise), var(--clouds);
    border: 1px solid var(--line-strong);
    box-shadow: inset 0 0 0 5px var(--paper-2), inset 0 0 0 6px var(--line), 0 3px 10px rgba(60, 40, 15, .18);
  }
  .board::before, .board::after, .board > .corner-b::before, .board > .corner-b::after {
    content: ""; position: absolute; width: 110px; height: 110px; pointer-events: none;
    background: var(--corner) no-repeat center / contain;
  }
  .board::before { left: 8px; top: 8px; }
  .board::after { right: 8px; top: 8px; transform: scaleX(-1); }
  .board > .corner-b::before { left: 8px; bottom: 8px; transform: scaleY(-1); }
  .board > .corner-b::after { right: 8px; bottom: 8px; transform: scale(-1, -1); }
  @media (max-width: 760px) {
    .board::before, .board::after, .board > .corner-b::before, .board > .corner-b::after { width: 56px; height: 56px; }
  }
  .hint { color: var(--muted); font-size: 12px; }
  .flash { color: var(--bot); font-weight: 600; }
  .flash.ok { color: var(--hp); }

  button.mini { font-size: 12px; }
  .minimap { border: 2px solid #4a3520; border-radius: 2px; box-shadow: 0 0 0 1px var(--line-strong), 0 2px 6px rgba(30, 20, 8, .3); }
  .mm-pulse { border: 2px solid #ffe08a; border-radius: 50%; box-shadow: 0 0 0 1px rgba(40, 25, 10, .8); }
  .portrait canvas {
    border: 2px solid var(--line-strong); border-radius: 6px;
    background: radial-gradient(circle at 50% 40%, var(--paper-2), var(--paper-3));
  }
  .portrait-name .title { font-size: 24px; }
  .quote { background: var(--quote); border-left: 3px solid var(--line-strong); border-radius: 4px; font-size: 13px; }
  .quote::before { content: "“"; font: 700 28px/1 var(--title); color: var(--line-strong); }
  .message .block + .block { border-top: 1px dashed var(--line); }
  .message .block div:first-child { font-weight: 600; }

  .side-tabs button { font-family: var(--title); font-weight: 600; }
  .side-tabs button[aria-pressed="true"] { background: linear-gradient(#fffaf0, var(--paper-2)); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  .who strong { font-family: var(--title); font-size: 18px; }
  .tag { font-size: 11px; border-radius: 10px; color: #fff; font-weight: 600; }
  .bar .label { font-size: 12px; }
  .bar .track { background: var(--grid); border-radius: 5px; box-shadow: inset 0 1px 2px rgba(60, 40, 15, .25); }
  .bar .fill { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35); }
  .stats div, .derived div { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; font-size: 11px; color: var(--muted); }
  .stats b { font-size: 16px; color: var(--text); font-family: var(--title); }

  .log li { border-left: 3px solid var(--line); }
  .log li.system { border-color: var(--accent); color: var(--muted); }
  .log li.attack { border-color: var(--player); }
  .log li.defense { border-color: var(--bot); }
  .log li.move, .log li.energy, .log li.info { border-color: var(--line); color: var(--muted); }
  .log details { font-size: 12px; color: var(--muted); }
  .log summary { color: var(--text); font-size: 13px; }
  .log .t { font-size: 11px; color: var(--muted); }

  .roster.faded { opacity: .75; }
  .chip { border-radius: 8px; }
  .chip small { font-size: 11px; color: var(--muted); }
  .chip.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  .chip.healing small { color: var(--bot); }
  .chip.map small { color: var(--hp); }
  table.train { font-size: 13px; }
  table.train td { border-bottom: 1px solid var(--grid); }
  table.train td:nth-child(2) { color: var(--muted); }
  table.train tr.muted td { color: var(--muted); }

  .arena-head strong { font-family: var(--title); font-size: 17px; }
  .companies li { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
  .companies li.mine { border-color: var(--player); font-weight: 600; }
  .companies small { color: var(--muted); font-weight: normal; }
  .dot { border-radius: 50%; background: var(--hp); box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
  .notice.quiet { border: 0; background: none; box-shadow: none; }

  .tabs button { font-family: var(--title); font-weight: 600; }
  .tabs button[aria-pressed="true"], .look[aria-pressed="true"] { background: linear-gradient(#b07a43, #82552a); color: #fff6e3; border-color: #5c3a17; }
  .banner-name { font-family: var(--title); font-size: 19px; }
  .gold-pill { border-radius: 999px; background: var(--warm); border: 1px solid var(--line-strong); font-weight: 600; color: var(--ink); }
  a.btn { color: inherit; border-radius: 6px; background: linear-gradient(var(--btn-top), var(--btn-bot)); border: 1px solid var(--line-strong); }
  a.btn.primary { background: linear-gradient(#a8743f, #7c4f24); color: #fff8ea; border-color: #5c3a17; font-weight: 600; }
  button.link { background: none; border: 0; box-shadow: none; color: var(--accent); text-decoration: underline; font-size: 13px; }
  .small-btn { font-size: 12px; }

  .tile { border-radius: 10px; background: var(--paper-2); background-image: var(--noise); border: 1px solid var(--line); }
  .tile:hover:not(:disabled) { border-color: var(--accent); }
  .tile.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(60, 40, 15, .25); }
  .tile-portrait {
    border-radius: 8px; border: 1px solid var(--line);
    background: radial-gradient(ellipse 45% 14% at 50% 86%, rgba(60, 40, 15, .28), transparent 70%), radial-gradient(circle at 50% 40%, var(--paper), var(--paper-3));
  }
  .tile canvas.skin { border: 0; border-radius: 0; background: none; }
  .xp-badge { border-radius: 999px; background: var(--hp); color: #fff; font-size: 11px; font-weight: 700; }
  .tile-name { font-family: var(--title); font-size: 16px; }
  .tile-row { font-size: 12px; color: var(--muted); }
  .tile-row b { color: var(--text); }
  .gauge { background: var(--grid); border-radius: 3px; }
  .gauge i { background: var(--accent); }
  .tile-empty { border-style: dashed; background: transparent; color: var(--muted); }
  .tile-plus { font-size: 34px; font-family: var(--title); }

  .sheet-name { font-family: var(--title); font-size: 22px; }
  .sheet-tabs { border-bottom: 1px solid var(--line); }
  .sheet-tabs button { font-size: 14px; }
  .train-line { border-bottom: 1px solid var(--grid); }
  .stat-line { font-size: 13px; }
  .stat-line > span:nth-child(3) { font-weight: 600; }
  .trait { font-size: 13px; border-radius: 4px; }
  .trait.plus b { color: var(--hp); }
  .trait.minus b { color: var(--bot); }
  .trait.zero { color: var(--muted); }
  .slot { border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
  .slot-empty, .slot-taken { border-style: dashed; background: transparent; }
  .wear { background: var(--grid); border-radius: 3px; }
  .wear i { background: var(--hp); }
  .wear i.low { background: var(--bot); }

  canvas.skin { background: radial-gradient(circle at 50% 40%, var(--paper-2), var(--paper-3)); border: 2px solid var(--line-strong); border-radius: 50%; }
  canvas.skin.big { border-radius: 10px; }
  .status { font-size: 12px; font-weight: 600; color: var(--muted); }
  .status.map { color: var(--player); }
  .status.ready { color: var(--hp); }
  .status.resting { color: var(--ap); }
  .status.healing { color: var(--bot); }
  .derived { font-size: 12px; }
  .derived b { font-size: 15px; color: var(--text); font-family: var(--title); }
  .derived b.over { color: var(--bot); }
  .reports { font-size: 13px; }
  .reports li { border-left: 3px solid var(--line); }
  .reports li.attack { border-color: var(--player); }
  .reports li.defense { border-color: var(--bot); }
  .reports li.move, .reports li.energy, .reports li.info { color: var(--muted); }
  .warn { color: var(--bot); font-size: 12px; font-weight: 600; }
  .gold { color: var(--accent); font-weight: 600; }
  .worn { font-size: 13px; }
  .worn th, .worn td { border-bottom: 1px solid var(--grid); }
  .worn thead th { font-size: 12px; color: var(--muted); font-weight: 600; }
  .item { border-bottom: 1px solid var(--grid); }
  .item:last-child { border-bottom: 0; }

  .brand .title { font-size: 34px; color: var(--accent); text-shadow: 0 1px 0 rgba(255, 255, 255, .6); }
  .brand .small { font-style: italic; }
  .page .card {
    background: var(--paper-2); background-image: var(--noise);
    border: 1px solid var(--line-strong); border-radius: 10px;
    box-shadow: inset 0 0 0 4px var(--paper-2), inset 0 0 0 5px var(--line), 0 4px 14px rgba(60, 40, 15, .18);
  }
  .page .error { color: var(--bot); font-weight: 600; }
  .page .ok { color: var(--hp); }
  .page dt { color: var(--muted); }
  .page footer { font-size: 12px; color: var(--muted); }
  .skip { border-top: 1px dashed var(--line); }
  .nav a[aria-current="page"] { color: var(--text); font-weight: 600; text-decoration: none; }
}
