/* Tuto Otopia — thème sombre, épuré */
:root {
  --bg: #0e0e0d;
  --surface: #161615;
  --surface-2: #1d1d1b;
  --text: #ecebe6;
  --muted: #8d8b84;
  --line: #262624;
  --line-strong: #363633;
  --accent: #d9ff43;
  --on-accent: #111;
  --danger: #ff8a6a;
  --radius: 10px;
  --width: 960px;
  --gutter: 20px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 15px/1.6 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
img, iframe { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.02em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.skip-link { position: absolute; left: 12px; top: -50px; z-index: 100; padding: 8px 12px; background: var(--accent); color: var(--on-accent); }
.skip-link:focus { top: 12px; }

/* ---------- En-tête ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(14, 14, 13, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: var(--width); margin: 0 auto; padding: 0 var(--gutter); height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 700; }
.main-nav { display: flex; gap: 22px; }
.main-nav a { color: var(--muted); text-decoration: none; font-size: 14px; transition: color .15s; }
.main-nav a:hover, .main-nav a[aria-current] { color: var(--text); }
.account-button { margin-left: auto; display: flex; align-items: center; gap: 8px; max-width: 170px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: none; font-size: 14px; }
.account-button:hover { border-color: var(--muted); }
#account-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.account-button.connected .account-dot { background: var(--accent); }

/* ---------- Mise en page ---------- */
main { flex: 1; width: 100%; max-width: var(--width); margin: 0 auto; padding: 64px var(--gutter) 80px; }
.page { animation: fade .25s ease; }
.intro { margin-bottom: 48px; }
.kicker { margin: 0 0 12px; color: var(--accent); font-size: 13px; font-weight: 500; }
.intro h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.15; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.page-head h1 { font-size: clamp(26px, 4vw, 34px); }
.lead { margin: 10px 0 0; color: var(--muted); font-size: 16px; max-width: 560px; }
.empty { margin: 0; padding: 48px 0; color: var(--muted); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.footer { padding: 28px var(--gutter); text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

/* Index de l'accueil */
.index-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.index-list a { display: grid; grid-template-columns: 200px 1fr auto auto; align-items: center; gap: 16px; padding: 20px 4px; border-bottom: 1px solid var(--line); text-decoration: none; transition: padding .15s, background .15s; }
.index-list a::after { content: "→"; grid-column: 4; color: var(--muted); transition: color .15s, transform .15s; }
.index-list a:hover { background: var(--surface); padding-left: 14px; padding-right: 14px; }
.index-list a:hover::after { color: var(--accent); transform: translateX(3px); }
.index-name { font-weight: 600; font-size: 16px; }
.index-desc, .index-meta { color: var(--muted); font-size: 14px; }
.index-meta { font-variant-numeric: tabular-nums; }

/* ---------- Petits éléments ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border: 1px solid var(--line-strong); border-radius: 8px; background: none; font-weight: 500; text-decoration: none; transition: border-color .15s, background .15s; }
.button:hover:not(:disabled) { border-color: var(--muted); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button.primary:hover:not(:disabled) { background: #e6ff7a; }
.button.danger { color: var(--danger); border-color: rgba(255, 138, 106, .4); }
.add-button { flex: none; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 8px; background: none; font-size: 14px; color: var(--accent); }
.add-button:hover { border-color: var(--accent); }
.text-link { color: var(--accent); text-decoration: none; font-size: 14px; }
.text-link:hover { text-decoration: underline; }
.text-button { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 4px; }
.text-button:hover { color: var(--text); }
.edit-button { flex: none; padding: 2px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: none; color: var(--muted); font-size: 12px; opacity: 0; transition: opacity .15s, color .15s; }
article:hover .edit-button, li:hover .edit-button, .edit-button:focus-visible { opacity: 1; }
.edit-button:hover { color: var(--text); }
@media (hover: none) { .edit-button { opacity: 1; } }
.pill { display: inline-block; padding: 1px 8px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 12px; }
.pill.accent { border-color: rgba(217, 255, 67, .5); color: var(--accent); }
.byline { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.item-head h3 { font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.item-body { margin: 6px 0 0; color: #b9b7b0; white-space: pre-line; overflow-wrap: anywhere; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: none; color: var(--muted); font-size: 13px; transition: color .15s, border-color .15s; }
.chips button:hover { color: var(--text); }
.chips button.active { color: var(--on-accent); background: var(--text); border-color: var(--text); }
.search input { width: 220px; max-width: 100%; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font-size: 14px; }
.search input:focus { outline: none; border-color: var(--muted); }

/* ---------- Tutos ---------- */
.video-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 36px 24px; }
.video-media { position: relative; aspect-ratio: 16 / 9; margin-bottom: 14px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.video-media img, .video-media iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; }
.video-media .play { position: relative; z-index: 1; display: grid; place-items: center; width: 52px; height: 52px; border: 0; border-radius: 50%; background: rgba(14, 14, 13, .75); color: var(--text); font-size: 16px; text-decoration: none; backdrop-filter: blur(4px); transition: background .15s, color .15s, transform .15s; }
.video-media .play:hover { background: var(--accent); color: var(--on-accent); transform: scale(1.05); }
.duration { position: absolute; right: 8px; bottom: 8px; z-index: 1; padding: 1px 6px; border-radius: 4px; background: rgba(0, 0, 0, .75); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- Harbourg ---------- */
.tool-frame iframe { display: block; width: 100%; height: 80vh; border: 0; }
/* Les outils ont besoin de plus de largeur que le texte. */
.tool-frame.wide { width: min(1360px, calc(100vw - 2 * var(--gutter))); margin-left: 50%; transform: translateX(-50%); }

/* ---------- Stuff ---------- */
.stuff-list { border-top: 1px solid var(--line); }
.stuff { display: grid; grid-template-columns: 56px 1fr auto; gap: 20px; align-items: start; padding: 22px 0; border-bottom: 1px solid var(--line); }
.stuff-level { display: grid; justify-items: center; padding: 8px 0; border: 1px solid var(--line-strong); border-radius: 8px; line-height: 1.1; }
.stuff-level span { color: var(--muted); font-size: 11px; }
.stuff-level strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 4px; color: var(--muted); font-size: 13px; }
.difficulty { display: inline-flex; align-items: center; gap: 3px; }
.difficulty i { width: 10px; height: 4px; border-radius: 2px; background: var(--line-strong); }
.difficulty i.on { background: var(--accent); }
.stuff-link { align-self: center; color: var(--accent); text-decoration: none; font-size: 14px; white-space: nowrap; }
.stuff-link:hover { text-decoration: underline; }

/* ---------- Astuces ---------- */
.tip-list { border-top: 1px solid var(--line); }
.tip { display: grid; grid-template-columns: 110px 1fr; gap: 20px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.tip-category { color: var(--accent); font-size: 13px; font-weight: 500; padding-top: 1px; }
.tip .text-link { display: inline-block; margin-top: 6px; }
.tip { align-items: baseline; }
.tip-text { margin: 0; font-size: 16px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- Fenêtres ---------- */
.dialog { width: min(calc(100vw - 32px), 460px); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--text); overflow: auto; }
.dialog[open] { animation: fade .2s ease; }
.dialog::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 17px; overflow-wrap: anywhere; }
.dialog-close { border: 0; background: none; color: var(--muted); font-size: 24px; line-height: 1; padding: 0 4px; }
.dialog-close:hover { color: var(--text); }

.tabs { display: flex; gap: 4px; padding: 14px 22px 0; }
.tabs button { padding: 6px 12px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 14px; }
.tabs button.active { background: var(--surface-2); color: var(--text); }

.form { padding: 18px 22px 6px; }
.form label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.form input:not([type="checkbox"]), .form select, .form textarea { display: block; width: 100%; margin-top: 6px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 15px; }
.form textarea { resize: vertical; min-height: 90px; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.form label.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.form-row { display: flex; gap: 12px; }
.form-row > label { flex: 1; min-width: 0; }
.form-row.checks { gap: 20px; }
.form-row.checks > label { flex: none; }
.form > .button { width: 100%; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-actions .primary { flex: 1; }
.hint { margin: -2px 0 14px; color: var(--muted); font-size: 13px; }
.form-message { min-height: 20px; margin: 0; padding: 4px 22px 16px; color: var(--danger); font-size: 13px; }
.form .form-message { padding: 8px 0 8px; }

.member { padding: 20px 22px 4px; }
.member-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.member-head strong { display: block; font-size: 17px; overflow-wrap: anywhere; }
.avatar { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 18px; }
.role-badge { display: inline-block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.role-badge[data-role="admin"], .role-badge[data-role="right_hand"], .role-badge[data-role="member"] { color: var(--accent); }
.member > .button { width: 100%; margin-top: 14px; }
.fold { border-top: 1px solid var(--line); }
.fold:last-of-type { border-bottom: 1px solid var(--line); }
.fold summary { padding: 12px 0; font-size: 14px; cursor: pointer; }
.fold summary:hover { color: var(--accent); }
.fold .form { padding: 4px 0 12px; }
.manager-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.manager-tools .search { flex: 1; }
.manager-tools .search input { width: 100%; }
#user-list { max-height: 300px; overflow: auto; padding-bottom: 10px; }
.user-row { display: grid; grid-template-columns: 1fr 120px 30px; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); }
.user-row > div { min-width: 0; }
.user-row strong, .user-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row strong { font-size: 14px; font-weight: 500; }
.user-row small { color: var(--muted); font-size: 11px; }
.user-row select { min-width: 0; padding: 5px 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); font-size: 13px; }
.icon-button { width: 30px; height: 30px; border: 1px solid var(--line-strong); border-radius: 6px; background: none; color: var(--muted); }
.icon-button:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); }

.toast { position: fixed; left: 50%; bottom: 20px; z-index: 60; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: fade .2s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .topbar-inner { height: auto; flex-wrap: wrap; gap: 0 16px; padding-top: 10px; }
  .main-nav { order: 3; width: 100%; gap: 20px; overflow-x: auto; padding: 10px 0 12px; scrollbar-width: none; }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav a { white-space: nowrap; }
  .main-nav a[aria-current] { color: var(--accent); }
  main { padding-top: 40px; }
  .index-list a { grid-template-columns: 1fr auto auto; gap: 2px 12px; }
  .index-name { grid-column: 1; }
  .index-desc { grid-column: 1; grid-row: 2; }
  .index-meta { grid-column: 2; grid-row: 1 / 3; }
  .index-list a::after { grid-column: 3; grid-row: 1 / 3; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .add-button { align-self: flex-start; }
  .video-grid { grid-template-columns: 1fr; }
  .search, .search input { width: 100%; }
  .stuff { grid-template-columns: 48px 1fr; gap: 14px; }
  .stuff-link { grid-column: 2; justify-self: start; }
  .tip { grid-template-columns: 1fr; gap: 4px; }
  .form-row { flex-wrap: wrap; }
  .form-row > label { flex-basis: 40%; }
}
