/* ── Reset ── */
:root { --sidebar-width: 264px; }
*, *::before, *::after { box-sizing: border-box; }
::selection { background: #ffc3c3; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Poppins', sans-serif;
  background: #1a1b2e;
  color: #222;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app-content {
  position: fixed;
  top: 36px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
}

/* ── Titlebar ── */
#titlebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: #1a1b2e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  user-select: none;
  -webkit-user-select: none;
}

#titlebar-title {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.titlebar-controls {
  position: absolute;
  right: 0;
  top: 0;
  height: 36px;
  display: flex;
  align-items: center;
}

.titlebar-controls button {
  width: 46px;
  height: 36px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.titlebar-controls button:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
}

#titlebar-close:hover {
  background: #e81123 !important;
  color: #fff !important;
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Home view ── */
#view-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: #1a1b2e;
}

.home-logo {
  width: 160px;
  height: 160px;
  object-fit: contain;
  margin: 0 0 16px;
}

.home-title {
  color: #fff;
  font-size: 4rem;
  font-weight: 700;
  margin: 0 0 48px;
  letter-spacing: -0.02em;
}

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 320px;
}

.home-buttons button {
  background: #ff5577;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px 24px;
  font-family: 'Poppins', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.home-buttons button:hover {
  background: #ff3355;
  transform: translateY(-1px);
}

.home-buttons button:active {
  transform: translateY(0);
}

/* ── Home recents ── */
.home-recents {
  margin-top: 40px;
  width: 320px;
}

.home-recents__label {
  color: rgba(255,255,255,0.3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
}

.home-recents__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.home-recents__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
  background: rgba(255,255,255,0.04);
  border: none;
  width: 100%;
  font-family: 'Poppins', sans-serif;
}

.home-recents__item:hover {
  background: rgba(255,255,255,0.08);
}

.home-recents__item__icon {
  font-size: 15px;
  flex-shrink: 0;
  opacity: 0.7;
}

.home-recents__item__info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.home-recents__item__name {
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-recents__item__path {
  color: rgba(255,255,255,0.3);
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 36px;
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - 36px);
  background: #1a1b2e;
  display: flex;
  flex-direction: column;
  z-index: 99;
  overflow: hidden;
}

/* Poignée de redimensionnement */
.sidebar__resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 100;
  background: transparent;
  transition: background 0.15s;
}
.sidebar__resizer:hover,
.sidebar__resizer.is-dragging { background: rgba(129, 140, 248, 0.4); }
body.is-resizing-sidebar { cursor: col-resize; user-select: none; }

.sidebar__scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 4px 0 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar__title-block {
  margin: 32px 24px 8px;
  flex-shrink: 0;
}
.sidebar__title-block a {
  text-decoration: none;
}
.sidebar__title-block__title {
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.25;
  pointer-events: none;
}
.sidebar__title-block__version {
  color: rgba(255,255,255,0.3);
  font-size: 14px;
  font-weight: 700;
  display: block;
  margin-bottom: 24px;
}

/* ── Sidebar menu ── */
.sidebar__menu {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  flex: 1;
  overflow-y: auto;
}
.sidebar__menu::-webkit-scrollbar { width: 0; }

.sidebar__menu__group-label {
  display: block;
  padding: 16px 24px 6px;
  color: rgba(255,255,255,0.35);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar__menu__first-level-title { margin: 0; }
.sidebar__menu__first-level-title__link {
  display: block;
  padding: 7px 24px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  transition: color 0.2s;
}
.sidebar__menu__first-level-title__link:hover { color: #ff5577; }
.sidebar__menu__first-level-title__link.active {
  color: #ff5577;
  font-weight: 500;
}

.sidebar__menu__second-level { list-style: none; padding: 0; margin: 0; }
.sidebar__menu__second-level-title { margin: 0; }
.sidebar__menu__second-level-title__link {
  display: block;
  padding: 5px 24px 5px 36px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  transition: color 0.2s;
}
.sidebar__menu__second-level-title__link:hover { color: #ff5577; }
.sidebar__menu__second-level-title__link.active {
  color: #ff5577;
  opacity: 1;
}

/* ── Tree nav ── */
.nav-tree { list-style: none; margin: 0; padding: 0; }
.nav-tree li { margin: 0; }

.nav-root-link {
  display: block;
  padding: 6px 24px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  transition: color 0.2s;
}
.nav-root-link:hover { color: #ff5577; }
.nav-root-link.active {
  color: #818cf8;
  background: rgba(129, 140, 248, 0.08);
  font-weight: 500;
}

.nav-folder { margin: 0; }
.nav-folder > summary {
  display: flex;
  align-items: center;
  list-style: none;
  cursor: default;
  user-select: none;
  padding: 0;
}
.nav-folder > summary::-webkit-details-marker { display: none; }

.nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  font-size: 9px;
  opacity: 0.4;
  cursor: pointer;
  transition: transform 0.18s, opacity 0.2s;
  border-radius: 4px;
  color: rgba(255,255,255,0.7);
}
.nav-arrow:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.nav-folder[open] > summary .nav-arrow { transform: rotate(90deg); opacity: 0.8; }

/* Les libellés de dossiers partagent la même police que les fichiers :
   même taille (14px), même graisse (400), sans majuscules. Seule la flèche ▶
   distingue visuellement un dossier d'un fichier. */
.nav-folder-link, .nav-folder-name {
  flex: 1;
  display: block;
  padding: 6px 24px 6px 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  transition: color 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-folder-link:hover { color: #ff5577; }
.nav-folder-link.active { color: #ff5577; }

/* Dossiers imbriqués : même style que les fichiers imbriqués (couleur atténuée). */
.nav-folder .nav-folder > summary .nav-folder-link,
.nav-folder .nav-folder > summary .nav-folder-name {
  color: rgba(255,255,255,0.55);
}
.nav-folder .nav-folder > summary .nav-folder-link:hover { color: #ff5577; }

.nav-file-link {
  display: block;
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: rgba(255,255,255,0.55);
  transition: color 0.2s;
}
.nav-file-link:hover { color: #ff5577; }
.nav-file-link.active {
  color: #818cf8;
  background: rgba(129, 140, 248, 0.08);
  font-weight: 500;
}

.nav-depth-1 > .nav-file-link { padding: 6px 24px 6px 52px; }
.nav-depth-1 > .nav-folder > summary { padding-left: 24px; }
.nav-depth-2 > .nav-file-link { padding: 6px 24px 6px 68px; }
.nav-depth-2 > .nav-folder > summary { padding-left: 40px; }
.nav-depth-3 > .nav-file-link { padding: 6px 24px 6px 84px; }
.nav-depth-3 > .nav-folder > summary { padding-left: 56px; }

/* ── Content ── */
.content {
  margin-left: var(--sidebar-width);
  padding-top: 48px;
  padding-right: 72px;
  padding-bottom: 96px;
  padding-left: 72px;
  max-width: 1080px;
  min-height: 100%;
  background: #fff;
}

/* ── Typography ── */
.content a { color: #0000ee; text-decoration: none; transition: color 0.16s; }
.content a:hover { color: #ff5577; }
.content a:visited { color: #551a8b; }
.content a:visited:hover { color: #ff5577; }

.content h1, .content h2, .content h3,
.content h4, .content h5, .content h6 {
  color: #222;
  margin-top: 48px;
  margin-bottom: 12px;
  line-height: 1.3;
}
.content h1 { font-size: 2em; margin-top: 0; }
.content h2 { font-size: 1.5em; }
.content h3 { font-size: 1.25em; }

.content hr { margin: 72px 0; border: none; border-top: 1px solid rgba(34,34,34,0.15); }

.content p { color: #222; font-size: 1em; line-height: 1.64em; margin: 0 0 1em; }

.content code {
  font-family: 'Roboto Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 85%;
  font-weight: 700;
  background: #f4f4f7;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  line-height: 1.4;
}
.content pre { padding: 20px 24px; border-radius: 6px; overflow-x: auto; margin: 16px 0; }
.content pre:not(.syntax-highlighting) { background: #f4f4f7; }
.content pre code { background: none; padding: 0; font-weight: 400; font-size: 13px; border: none; border-radius: 0; color: inherit; }

/* ── Bouton « copier » des blocs de code ── */
.content .code-block { position: relative; }
.content .code-block .copy-code-btn {
  position: absolute;
  top: 24px;
  right: 12px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.2;
  color: #c0c5ce;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.content .code-block:hover .copy-code-btn,
.content .code-block .copy-code-btn:focus-visible { opacity: 1; }
.content .code-block .copy-code-btn:hover { background: rgba(255, 255, 255, 0.18); }
.content .code-block .copy-code-btn.copied { color: #a3be8c; border-color: rgba(163, 190, 140, 0.5); }

/* ── Coloration syntaxique (base16-ocean.dark) ── */
.syntax-highlighting {
 color: #c0c5ce;
 background-color: #2b303b;
}
.syntax-highlighting .variable.parameter.function { color: #c0c5ce; }
.syntax-highlighting .comment, .syntax-highlighting .punctuation.definition.comment { color: #65737e; }
.syntax-highlighting .punctuation.definition.string, .syntax-highlighting .punctuation.definition.variable, .syntax-highlighting .punctuation.definition.parameters, .syntax-highlighting .punctuation.definition.array { color: #c0c5ce; }
.syntax-highlighting .keyword.operator { color: #c0c5ce; }
.syntax-highlighting .keyword { color: #b48ead; }
.syntax-highlighting .variable, .syntax-highlighting .variable.other.dollar.only.js { color: #bf616a; }
.syntax-highlighting .entity.name.function, .syntax-highlighting .meta.require, .syntax-highlighting .support.function.any-method, .syntax-highlighting .variable.function { color: #8fa1b3; }
.syntax-highlighting .support.class, .syntax-highlighting .entity.name.class, .syntax-highlighting .entity.name.type.class { color: #ebcb8b; }
.syntax-highlighting .meta.class { color: #eff1f5; }
.syntax-highlighting .keyword.other.special-method { color: #8fa1b3; }
.syntax-highlighting .storage { color: #b48ead; }
.syntax-highlighting .support.function { color: #96b5b4; }
.syntax-highlighting .string, .syntax-highlighting .constant.other.symbol, .syntax-highlighting .entity.other.inherited-class { color: #a3be8c; }
.syntax-highlighting .constant.numeric, .syntax-highlighting .constant { color: #d08770; }
.syntax-highlighting .entity.name.tag { color: #bf616a; }
.syntax-highlighting .entity.other.attribute-name { color: #d08770; }
.syntax-highlighting .entity.other.attribute-name.id, .syntax-highlighting .punctuation.definition.entity { color: #8fa1b3; }
.syntax-highlighting .meta.selector { color: #b48ead; }
.syntax-highlighting .markup.heading .punctuation.definition.heading, .syntax-highlighting .entity.name.section { color: #8fa1b3; }
.syntax-highlighting .keyword.other.unit { color: #d08770; }
.syntax-highlighting .markup.bold, .syntax-highlighting .punctuation.definition.bold { color: #ebcb8b; font-weight: bold; }
.syntax-highlighting .markup.italic, .syntax-highlighting .punctuation.definition.italic { color: #b48ead; font-style: italic; }
.syntax-highlighting .markup.raw.inline { color: #a3be8c; }
.syntax-highlighting .string.other.link { color: #bf616a; }
.syntax-highlighting .meta.separator { color: #c0c5ce; background-color: #4f5b66; }
.syntax-highlighting .markup.inserted, .syntax-highlighting .markup.inserted.git_gutter { color: #a3be8c; }
.syntax-highlighting .markup.deleted, .syntax-highlighting .markup.deleted.git_gutter { color: #bf616a; }
.syntax-highlighting .markup.changed, .syntax-highlighting .markup.changed.git_gutter { color: #b48ead; }
.syntax-highlighting .constant.other.color, .syntax-highlighting .string.regexp, .syntax-highlighting .constant.character.escape { color: #96b5b4; }
.syntax-highlighting .punctuation.section.embedded, .syntax-highlighting .variable.interpolation { color: #ab7967; }
.syntax-highlighting .invalid.illegal { color: #2b303b; background-color: #bf616a; }

.content blockquote {
  border-left: 3px solid rgba(34,34,34,0.25);
  margin: 24px 0;
  padding: 4px 24px;
  color: rgba(34,34,34,0.65);
}

.content img { max-width: 100%; margin: 8px 0; }

.content table {
  width: 100%;
  border-spacing: 0;
  border-collapse: collapse;
  margin: 24px 0 48px;
  font-size: 14px;
  color: #222;
}
.content table th {
  border-bottom: 1px solid #ff5577;
  padding: 10px;
  text-align: left;
  font-weight: 600;
}
.content table td {
  border-bottom: 1px solid rgba(255,85,119,0.25);
  padding: 10px;
}

.content ul li, .content ol li {
  color: #222;
  font-size: 1em;
  line-height: 1.64em;
  margin-bottom: 8px;
}
.content ul li code, .content ol li code { font-weight: 700; }

/* ── Customize CSS button ── */
.btn-customize-css {
  width: calc(100% - 24px);
  margin: 4px 12px 0;
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 8px 16px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.btn-customize-css:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.06);
}
.btn-customize-css__icon { flex-shrink: 0; opacity: 0.8; }

/* ── CSS modal ── */
.css-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.css-modal {
  width: 580px;
  max-height: 82vh;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.45);
}
.css-modal__header {
  background: #1a1b2e;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.css-modal__title {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
.css-modal__close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 14px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.css-modal__close:hover { color: #fff; background: rgba(255,255,255,0.1); }
.css-modal__tabs {
  display: flex;
  border-bottom: 1px solid #e8e8ee;
  background: #f6f6fa;
  flex-shrink: 0;
}
.css-modal__tab {
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.css-modal__tab:hover { color: #444; }
.css-modal__tab.active { color: #ff5577; border-bottom-color: #ff5577; font-weight: 600; }
.css-modal__body {
  padding: 18px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.css-modal__description {
  font-size: 12px;
  color: #999;
  margin: 0;
  line-height: 1.5;
}
.css-modal__editor {
  flex: 1;
  min-height: 200px;
  background: #1e1e2e;
  border: none;
  border-radius: 6px;
  color: #cdd6f4;
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  line-height: 1.65;
  padding: 14px 16px;
  resize: none;
  outline: none;
}
.css-modal__editor::placeholder { color: rgba(255,255,255,0.18); }
.css-modal__footer {
  padding: 12px 20px;
  border-top: 1px solid #e8e8ee;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: #fafafa;
}
.css-modal__config-name {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 7px 12px;
  font-family: 'Poppins', sans-serif;
  font-size: 12px;
  color: #444;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}
.css-modal__config-name:focus { border-color: #ff5577; }
.css-modal__config-name::placeholder { color: #bbb; }
.css-modal__footer-actions { display: flex; gap: 8px; flex-shrink: 0; }
.css-modal__btn {
  padding: 7px 16px;
  border-radius: 6px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.css-modal__btn--primary { background: #ff5577; color: #fff; }
.css-modal__btn--primary:hover { background: #ff3355; }
.css-modal__btn--ghost { background: transparent; color: #777; border: 1px solid #ddd; }
.css-modal__btn--ghost:hover { background: #f0f0f4; color: #444; }

/* ── Quick themes ── */
.css-modal__quick-themes { flex-shrink: 0; }
.css-modal__quick-themes-label {
  font-size: 11px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
}
.css-modal__quick-themes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.css-modal__theme-badge {
  padding: 6px 14px;
  border: 1px solid #ddd;
  border-radius: 999px;
  background: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: #555;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.css-modal__theme-badge:hover { border-color: #bbb; color: #222; background: #f8f8f8; }
.css-modal__theme-badge.active {
  border-color: #ff5577;
  color: #ff5577;
  background: rgba(255, 85, 119, 0.06);
}

/* ── Back button ── */
.btn-back {
  width: 100%;
  background: transparent;
  color: rgba(255,255,255,0.45);
  border: none;
  padding: 8px 24px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: color 0.2s;
}
.btn-back:hover { color: #ff5577; }

/* ── Responsive ── */
@media screen and (max-width: 1020px) {
  .sidebar {
    left: -300px;
    transition: left 0.2s cubic-bezier(0.09, 0.46, 0.45, 0.94);
  }
  .content { margin-left: 0; padding: 32px 24px 64px; }
}
@media screen and (max-width: 540px) {
  .content { padding: 68px 16px 48px; }
}
