/* ============================================================
   VARIABLES
   ============================================================ */
:root {
  --bg: #0b0f17;
  --panel: #0f1624;
  --card: #121b2c;
  --text: #e9eefc;
  --muted: #a9b4d0;
  --line: rgba(255, 255, 255, .08);
  --accent: #7c5cff;
  --danger: #ff5c5c;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --radius: 18px;
}

/* ============================================================
   RESET / BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

html {
  background:
    radial-gradient(1200px 600px at 20% 0%, rgba(124, 92, 255, .25), transparent 60%),
    radial-gradient(900px 500px at 80% 10%, rgba(34, 197, 94, .18), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: transparent;
}

/* ============================================================
   HEADER / NAV
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 15, 23, .9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* BRAND */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand__title {
  font-weight: 800;
  font-size: 15px;
}

.brand__subtitle {
  font-size: 12px;
  color: var(--muted);
}

/* NAV */
.nav { display: flex; gap: 4px; }

.nav__link {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  transition: background .15s;
}

.nav__link:hover { background: rgba(255, 255, 255, .06); }

.version-badge {
  font-size: 10px;
  font-family: monospace;
  color: var(--muted);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 4px;
  padding: 2px 7px;
  align-self: center;
  letter-spacing: .03em;
  user-select: none;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.doc {
  padding: 28px;
  border-radius: var(--radius);
  background: rgba(15, 22, 36, .75);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.h1 { margin: 0; font-size: 28px; font-weight: 800; }
.h2 { margin: 0 0 18px; font-size: 17px; font-weight: 700; }
.h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; word-break: break-word; }

/* ============================================================
   SECTIONS
   ============================================================ */
.doc__header {
  padding-bottom: 20px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.section {
  margin-top: 24px;
  padding: 20px 22px;
  border-radius: 14px;
  background: rgba(18, 27, 44, .65);
  border: 1px solid var(--line);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.btn:hover { background: rgba(255, 255, 255, .08); }

.btn--primary {
  background: linear-gradient(135deg, var(--accent), rgba(124, 92, 255, .6));
  border-color: transparent;
}

.btn--primary:hover {
  background: linear-gradient(135deg, #8d70ff, rgba(124, 92, 255, .8));
}

.btn--danger {
  background: rgba(255, 92, 92, .1);
  border-color: rgba(255, 92, 92, .3);
  color: var(--danger);
}

.btn--danger:hover { background: rgba(255, 92, 92, .2); }

/* ============================================================
   PROJECTS LIST (index)
   ============================================================ */
.projects-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.projects-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.project-card-wrap {
  position: relative;
}

.project-card {
  display: block;
  padding: 18px;
  padding-right: 42px;
  border-radius: 14px;
  background: rgba(11, 15, 23, .65);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  transition: background .15s, transform .1s;
}

.project-card:hover {
  background: rgba(11, 15, 23, .9);
  transform: translateY(-1px);
}

.project-card__del {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, opacity .15s;
  opacity: 0;
}

.project-card-wrap:hover .project-card__del {
  opacity: 1;
}

.project-card__del:hover {
  background: rgba(255, 92, 92, .15);
  color: #ff5c5c;
}

.project-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 10px;
}

.project-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(124, 92, 255, .18);
  color: var(--accent);
  font-weight: 500;
}

/* ============================================================
   FORM
   ============================================================ */
.form { display: block; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .02em;
}

.input {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
  resize: vertical;
}

.input::placeholder { color: rgba(169, 180, 208, .45); }

.field-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .12);
}

select.input { cursor: pointer; }

.form__actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ============================================================
   CHECKBOXES
   ============================================================ */
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 14px;
  transition: border-color .15s, background .15s;
  user-select: none;
}

.check:hover { border-color: var(--accent); }

.check input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================
   DIALOGUE
   ============================================================ */
.dialogue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.dialogue-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  transition: border-color .15s, opacity .15s;
}

.dialogue-row.dragging {
  opacity: .45;
  border-color: var(--accent);
}

.dialogue-row.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 92, 255, .2);
}

.drag-handle {
  cursor: grab;
  color: var(--muted);
  padding: 8px 4px;
  align-self: center;
  font-size: 14px;
  letter-spacing: 1px;
  user-select: none;
  flex-shrink: 0;
}

.drag-handle:active { cursor: grabbing; }

.dialogue-qui {
  width: 140px;
  flex-shrink: 0;
}

.dialogue-text {
  flex: 1;
  min-height: 60px;
}

.dialogue-delete {
  flex-shrink: 0;
  align-self: flex-start;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}

.dialogue-delete:hover {
  color: var(--danger);
  background: rgba(255, 92, 92, .1);
  border-color: rgba(255, 92, 92, .25);
}

/* ============================================================
   KEY-VALUE (project view)
   ============================================================ */
.kv { display: flex; flex-direction: column; }

.kv__row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.kv__row:last-child { border-bottom: none; }

.kv__k {
  width: 140px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding-top: 2px;
}

.kv__v { flex: 1; }

/* PILLS */
.pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 20px;
  background: rgba(124, 92, 255, .18);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.pill--muted {
  background: rgba(255, 255, 255, .06);
  color: var(--muted);
}

/* ============================================================
   TABLE (dialogue view in project)
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  background: rgba(18, 27, 44, .9);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:nth-child(even) td { background: rgba(255, 255, 255, .015); }

/* ============================================================
   CHECK LIST (project view)
   ============================================================ */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 14px;
}

.check-ok {
  color: #4ade80;
  font-weight: 700;
  font-size: 13px;
}

.check-no {
  color: var(--muted);
  font-size: 13px;
}

/* ============================================================
   PRINT LAYOUT (project header)
   ============================================================ */
.print__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.print__meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.panel__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============================================================
   THEORY PAGE
   ============================================================ */
.callout {
  background: rgba(124, 92, 255, .08);
  border: 1px solid rgba(124, 92, 255, .25);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.example {
  background: rgba(255, 255, 255, .03);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
  margin: 10px 0;
  font-style: italic;
  color: var(--muted);
}

.box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 12px 0;
}

.accordion { cursor: pointer; }

/* ============================================================
   LOCATION SWITCHER (index)
   ============================================================ */
.location-switcher-section { padding: 14px 18px; }

.location-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.location-switcher__current {
  display: flex;
  align-items: center;
  gap: 10px;
}

.location-icon { font-size: 20px; flex-shrink: 0; }

.location-switcher__name {
  font-weight: 700;
  font-size: 14px;
}

.location-switcher__path,
.location-full {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.location-switcher__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   SETTINGS PAGE — lieux
   ============================================================ */
.location-active {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.location-path {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.location-name {
  font-weight: 700;
  font-size: 16px;
}

.locations-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.location-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  flex-wrap: wrap;
}

.location-row--active {
  border-color: rgba(124, 92, 255, .45);
  background: rgba(124, 92, 255, .07);
}

.location-row__info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.location-row__icon { font-size: 20px; flex-shrink: 0; }

.location-row__name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-row__path {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.location-row__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

code {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 12px;
  font-family: monospace;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state p { margin: 8px 0 20px; }

/* ============================================================
   PRINT MEDIA
   ============================================================ */
@media print {
  html { background: white; }
  body { color: #111; background: white; }

  .topbar { display: none; }
  .panel__actions { display: none; }
  .form__actions { display: none; }

  .doc {
    background: white;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .section {
    background: white;
    border: 1px solid #ddd;
    break-inside: avoid;
  }

  .kv__k { color: #666; }

  .table th {
    background: #f0f0f0;
    color: #444;
  }

  .pill {
    background: #eee;
    color: #333;
    border: 1px solid #ccc;
  }

  .h1, .h2, .h3 { color: #111; }
  .muted { color: #666; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 700px) {
  .shell { padding: 16px 12px 60px; }
  .doc { padding: 16px; }
  .section { padding: 14px 16px; }
  .topbar__inner { padding: 12px 16px; }
  .brand__subtitle { display: none; }
  .kv__k { width: 100px; }
  .dialogue-qui { width: 110px; }
}
