@font-face {
  font-family: "OpenDyslexic";
  src: url("font/OpenDyslexic-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Luciole";
  src: url("font/Luciole-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson";
  src: url("font/AtkinsonHyperlegibleNext-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Andika";
  src: url("font/Andika-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Accessible";
  src: url("font/AccessibleDfA-VF.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --primary: #1c76d2;
  --secondary: #17876d;
  --accent: #f8b84f;
  --ui-bg: #eef3f8;
  --card-bg: #ffffff;
  --border: #d9e2ec;
  --text: #0f172a;
  --muted: #5b6778;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --focus: rgba(28, 118, 210, 0.25);
  --panel-bg: #f7fafc;
  --header-gradient: linear-gradient(120deg, rgba(28, 118, 210, 0.08), rgba(23, 135, 109, 0.08));

  --font-size: 16px;
  --font-weight: 400;
  --line-height: 1.5;
  --letter-spacing: 0.035em;
  --word-spacing: 0.06em;
  --para-spacing: 12px;
  --line-width-ch: 68;
  --line-width-enabled: 1;
  --paper-bg: #f9f5ef;
  --paper-text: #1f2937;
  --side-band: #f1f4f8;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Atkinson", "Luciole", "Verdana", sans-serif;
  background: radial-gradient(circle at top, #f7fbff 0%, var(--ui-bg) 45%, #eef1f6 100%);
  color: var(--text);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  background-image: var(--header-gradient);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-mark {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
}

.brand-link {
  font-weight: 600;
  font-size: 14px;
  color: var(--primary);
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(28, 118, 210, 0.2);
  background: rgba(28, 118, 210, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(28, 118, 210, 0.18);
}

.brand-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
}

.brand-sub {
  font-size: 13px;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.profile-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.profile-btn.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(28, 118, 210, 0.24);
}

.profile-btn:hover {
  transform: translateY(-1px);
}

.profile-more {
  position: relative;
}

.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  display: grid;
  gap: 6px;
  min-width: 180px;
  z-index: 20;
}

.profile-menu .profile-btn {
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.2fr);
  gap: 18px;
  padding: 18px 24px 24px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.profile-panel h2 {
  margin: 0 0 6px 0;
}

.editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.editor label {
  font-weight: 600;
  color: var(--muted);
}

textarea {
  flex: 1;
  min-height: 320px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
}

textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
  border-color: var(--primary);
}

.editor-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.btn.is-active {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(28, 118, 210, 0.2);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
}

.btn:hover {
  transform: translateY(-1px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.field.compact {
  max-width: 160px;
}

.field select,
.field input[type="range"],
.field input[type="color"] {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

.field input[type="range"] {
  padding: 0;
}

.field output {
  align-self: flex-end;
  font-weight: 600;
  color: var(--text);
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel-bg);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.settings-header h2 {
  margin: 0;
  font-size: 18px;
}

.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-left: auto;
}

.icon-btn:hover {
  transform: translateY(-1px);
}

.settings-body {
  display: grid;
  gap: 14px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.control-row.colors {
  justify-content: flex-start;
  gap: 12px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: #f1f5f9;
}

.seg {
  border: none;
  background: transparent;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.seg.is-active {
  background: var(--primary);
  color: #fff;
}

.swatches {
  display: inline-flex;
  gap: 8px;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--swatch-bg, #fff);
  color: var(--swatch-text, #1f2937);
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
}

.swatch.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(28, 118, 210, 0.2);
}

.swatch::after {
  content: "A";
}

.swatch[data-theme="doux"] {
  --swatch-bg: #f9f5ef;
  --swatch-text: #1f2937;
}

.swatch[data-theme="clair"] {
  --swatch-bg: #ffffff;
  --swatch-text: #111827;
}

.swatch[data-theme="sable"] {
  --swatch-bg: #f4efe6;
  --swatch-text: #1f2937;
}

.swatch[data-theme="brume"] {
  --swatch-bg: #eef2f7;
  --swatch-text: #1f2937;
}

.swatch[data-theme="nuit"] {
  --swatch-bg: #0f172a;
  --swatch-text: #e2e8f0;
}

.swatch[data-theme="encre"] {
  --swatch-bg: #111827;
  --swatch-text: #f8fafc;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.toggle input {
  display: none;
}

.toggle .track {
  width: 42px;
  height: 22px;
  background: #e2e8f0;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle .track::after {
  content: "";
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
}

.toggle input:checked + .track {
  background: rgba(27, 141, 120, 0.2);
}

.toggle input:checked + .track::after {
  transform: translateX(20px);
  background: var(--secondary);
}

.preview-shell {
  height: 100%;
  background: var(--side-band);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
}

.preview {
  background: var(--paper-bg);
  color: var(--paper-text);
  font-family: var(--preview-font, "Verdana");
  font-size: var(--font-size);
  font-weight: var(--font-weight);
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  word-spacing: var(--word-spacing);
  text-align: left;
  border-radius: var(--radius-sm);
  padding: 24px;
  min-height: 420px;
  box-shadow: var(--shadow);
  max-width: 100%;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

.preview[data-width="on"] {
  max-width: calc(var(--line-width-ch) * 1ch);
}

.preview p {
  margin: 0 0 var(--para-spacing) 0;
}

.preview h3 {
  margin: 0 0 12px 0;
  font-size: 1.08em;
}


.block {
  margin-bottom: var(--para-spacing);
}

.block:last-child {
  margin-bottom: 0;
}

.block.heading {
  font-weight: 600;
}

.line {
  display: block;
  line-height: inherit;
  padding: 0 2px;
  border-radius: 4px;
  color: inherit;
  white-space: nowrap;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: var(--para-spacing);
}

.list:last-child {
  margin-bottom: 0;
}

.list-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
}

.list-marker {
  width: 1.4em;
  flex: 0 0 1.4em;
  text-align: right;
  font-weight: 600;
}

.list-body {
  flex: 1;
  min-width: 0;
}

.mobile-nav {
  display: none;
  padding: 10px 16px 16px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  gap: 10px;
  justify-content: center;
}

.nav-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}

.nav-btn.is-active {
  background: var(--secondary);
  color: #fff;
  border-color: transparent;
}

.app[data-settings="open"] .editor {
  display: none;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .left-panel {
    display: none;
  }

  .mobile-nav {
    display: flex;
  }

  .app[data-view="edit"] .left-panel,
  .app[data-view="settings"] .left-panel {
    display: flex;
  }

  .app[data-view="profile"] .left-panel {
    display: flex;
  }

  .app[data-view="edit"] .right-panel {
    display: none;
  }

  .app[data-view="settings"] .right-panel {
    display: none;
  }

  .app[data-view="profile"] .right-panel {
    display: none;
  }

  .app[data-view="settings"] .editor {
    display: none;
  }

  .app[data-view="edit"] #settingsPanel {
    display: none;
  }

  .app[data-view="profile"] .editor,
  .app[data-view="profile"] #settingsPanel {
    display: none;
  }

  .app[data-view="profile"] #profilePanel {
    display: flex;
  }
}

@media (max-width: 680px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .profile-tabs {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .left-panel,
  .mobile-nav {
    display: none;
  }

  .layout {
    padding: 0;
  }

  .preview-shell {
    border: none;
    padding: 0;
  }

  .preview {
    box-shadow: none;
    max-width: none;
    min-height: auto;
  }
}
