/* Finition UX/UI — chargée en dernier pour unifier les styles historiques. */
:root {
  --ui-bg: #f5f1e8;
  --ui-surface: #fffdf9;
  --ui-surface-strong: #ffffff;
  --ui-ink: #183034;
  --ui-muted: #617277;
  --ui-primary: #195c60;
  --ui-primary-hover: #10494c;
  --ui-primary-soft: #dcebea;
  --ui-accent: #e0ad58;
  --ui-border: #ded8ca;
  --ui-danger: #b54f3d;
  --ui-success: #2f806d;
  --ui-radius-sm: 12px;
  --ui-radius-md: 18px;
  --ui-radius-lg: 26px;
  --ui-shadow-sm: 0 6px 20px rgba(24, 48, 52, .055);
  --ui-shadow-md: 0 16px 42px rgba(24, 48, 52, .09);
  --ui-shadow-lg: 0 28px 80px rgba(24, 48, 52, .14);
  --ui-focus: 0 0 0 4px rgba(35, 109, 112, .22);
}

html { color-scheme: light; scroll-behavior: smooth; }
body {
  color: var(--ui-ink);
  background:
    radial-gradient(circle at 95% 0%, rgba(220, 235, 234, .46), transparent 28rem),
    var(--ui-bg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select, a { -webkit-tap-highlight-color: transparent; }
button { min-height: 42px; }
button, a, input, textarea, select, summary { outline: none; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex="0"]:focus-visible {
  box-shadow: var(--ui-focus) !important;
  outline: 2px solid var(--ui-primary) !important;
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 50%;
  padding: 11px 17px;
  border-radius: 12px;
  color: #fff;
  background: var(--ui-primary);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  transform: translate(-50%, -160%);
  transition: transform .18s ease;
}
.skip-link:focus { transform: translate(-50%, 0); }

/* Page publique et connexion */
.landing-screen { background: transparent; }
.landing-header { height: 88px; }
.landing-brand strong { font-size: 16px; letter-spacing: -.025em; }
.landing-login { min-height: 44px; padding-inline: 19px; font-size: 13px; }
.landing-copy h1 { color: var(--ui-ink); text-wrap: balance; }
.landing-copy > p:not(.landing-kicker) { color: var(--ui-muted); }
.landing-primary { min-height: 58px; border-radius: 17px; background: var(--ui-primary); }
.landing-primary:hover { background: var(--ui-primary-hover); box-shadow: var(--ui-shadow-md); }
.landing-copy > small { font-size: 12px; }
.landing-preview { border-radius: 32px; box-shadow: var(--ui-shadow-lg); }
.landing-features h2 { font-size: 17px; }
.landing-features p, .landing-trust p { font-size: 13px; }
.landing-features article { gap: 16px; padding: 34px 28px; }
.landing-trust { border-radius: 24px; background: var(--ui-primary); box-shadow: var(--ui-shadow-md); }
.landing-footer { font-size: 11px; }
.auth-screen { background: radial-gradient(circle at 50% 18%, #fff 0, transparent 34rem), var(--ui-bg); }
.auth-card { border: 1px solid rgba(24, 48, 52, .09); box-shadow: var(--ui-shadow-lg); }
.auth-card > p:not(.auth-eyebrow):not(.auth-error) { font-size: 14px; }
.google-login-option { border-radius: 18px; }

/* Structure applicative */
.app-shell { background: transparent; }
.app-sidebar {
  border-right-color: rgba(24, 48, 52, .08);
  background: rgba(255, 253, 249, .96);
  box-shadow: 14px 0 40px rgba(24, 48, 52, .035);
  backdrop-filter: blur(20px);
}
.sidebar-brand { padding-bottom: 27px; }
.sidebar-brand strong { font-size: 16px; }
.sidebar-brand small { font-size: 11px; }
.desktop-nav { gap: 7px; }
.desktop-nav button { min-height: 54px; padding-right: 14px; border-radius: 16px; }
.desktop-nav button > span { width: 34px; height: 34px; font-size: 18px; }
.desktop-nav button strong { font-size: 13px; }
.desktop-nav button.active { box-shadow: 0 12px 30px rgba(23, 79, 82, .18); }
.sidebar-create { min-height: 50px; border-radius: 16px; font-size: 13px; }
.sidebar-note { padding: 15px; }
.sidebar-note strong { font-size: 12px; }
.sidebar-note small { font-size: 10px; }
.main-header {
  border-bottom-color: rgba(24, 48, 52, .075);
  background: rgba(245, 241, 232, .88);
  box-shadow: 0 8px 30px rgba(24, 48, 52, .025);
}
.page-context small { font-size: 10px; }
.page-context strong { font-size: 19px; }
.account-menu .account-button { min-height: 46px; border-radius: 15px; }
.account-menu .account-button span { font-size: 12px; }
.account-menu .account-button small { font-size: 10px; }

/* Accueil */
.dashboard-intro .greeting { font-size: 12px; }
.dashboard-intro h1 { max-width: 870px; }
.dashboard-intro > p:last-child { max-width: 680px; font-size: 15px; }
.dashboard-grid { gap: 20px; }
.dashboard-grid .create-hero { border-radius: 30px; box-shadow: 0 22px 54px rgba(23, 79, 82, .18); }
.dashboard-grid .create-hero strong { font-size: 25px; }
.dashboard-grid .create-hero em { font-size: 13px; }
.dashboard-grid .active-child-card { border-radius: 27px; box-shadow: var(--ui-shadow-sm); }
.dashboard-grid .active-child-card > span { font-size: 10px; }
.dashboard-grid .active-child-card strong { font-size: 22px; }
.dashboard-grid .active-child-card small, .dashboard-grid .active-child-card i { font-size: 12px; }
.suggestions-heading small, .page-heading p, .account-section-title small, .data-actions small { font-size: 10px; }
.suggestions-heading h2 { font-size: 25px; }
.suggestions button {
  min-height: 78px;
  padding: 15px 17px;
  border-radius: 19px;
  font-size: 14px;
  line-height: 1.38;
  box-shadow: var(--ui-shadow-sm);
}
.suggestions.loading { position: relative; min-height: 168px; overflow: hidden; }
.suggestions.loading > * { visibility: hidden; }
.suggestions.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--ui-border);
  border-radius: 20px;
  background-color: #e9e5dc;
}
.suggestion-icon { width: 39px; height: 39px; font-size: 20px; }
.dashboard-links > button { min-height: 110px; border-radius: 21px; box-shadow: var(--ui-shadow-sm); }
.dashboard-links small { font-size: 9px; }
.dashboard-links strong { font-size: 15px; }
.dashboard-links em { font-size: 11px; }
.trust-card p, .info-banner p { font-size: 13px; }
.trust-card strong, .info-banner strong { font-size: 14px; }

/* Pages de collection */
.page-heading h1 { text-wrap: balance; }
.page-heading > div > span { font-size: 14px; }
.compact-button { min-height: 48px; font-size: 12px; }
.collection-toolbar { min-height: 58px; border-radius: 17px; box-shadow: var(--ui-shadow-sm); }
.collection-toolbar strong, .collection-toolbar button { font-size: 12px; }
.story-card, .community-card {
  isolation: isolate;
  border-radius: 25px;
  box-shadow: var(--ui-shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.story-card::after, .community-card::after {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0;
  border: 2px solid transparent;
  border-radius: inherit;
  pointer-events: none;
}
.story-card:hover, .community-card:hover { border-color: rgba(25, 92, 96, .32); box-shadow: var(--ui-shadow-md); transform: translateY(-3px); }
.story-card img, .community-card img { transition: transform .3s ease; }
.story-card:hover img, .community-card:hover img { transform: scale(1.025); }
.story-card-copy, .community-card-copy { position: relative; z-index: 2; background: var(--ui-surface); }
.story-card h3, .community-card h3 { font-size: 17px; letter-spacing: -.025em; }
.story-card p, .community-card p { font-size: 13px; line-height: 1.48; }
.story-card-meta { flex-wrap: wrap; }
.story-card-meta span, .metadata span { font-size: 10px; }
.delete-story { z-index: 3; width: 40px; height: 40px; border: 1px solid rgba(181, 79, 61, .15); color: var(--ui-danger); box-shadow: var(--ui-shadow-sm); }
.delete-story:hover { color: #fff; border-color: var(--ui-danger); background: var(--ui-danger); }
.recovery-card { border-radius: 22px; box-shadow: var(--ui-shadow-sm); }
.recovery-card h3 { font-size: 16px; }
.recovery-card p { font-size: 13px; }
.empty-library,
.empty-state {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  min-height: 270px;
  padding: 42px 28px;
  border: 1px dashed rgba(25, 92, 96, .27);
  border-radius: 26px;
  color: var(--ui-muted);
  background: rgba(255, 253, 249, .66);
  text-align: center;
}
.empty-state-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 20px; color: var(--ui-primary); background: var(--ui-primary-soft); font-size: 25px; }
.empty-state h2 { margin: 18px 0 6px; color: var(--ui-ink); font-size: 22px; }
.empty-state p { max-width: 480px; margin: 0; font-size: 14px; }
.empty-state button { width: auto; min-width: 190px; margin-top: 22px; }
.community-safety { border-radius: 19px; }
.community-safety strong { font-size: 13px; }
.community-safety p { font-size: 12px; }

/* Squelettes de chargement */
.skeleton-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.skeleton-card { overflow: hidden; min-height: 285px; border: 1px solid var(--ui-border); border-radius: 25px; background: var(--ui-surface); }
.skeleton-card::before { content: ''; display: block; height: 178px; background: #e8e4da; }
.skeleton-card::after { content: ''; display: block; width: 68%; height: 46px; margin: 20px; border-radius: 12px; background: #ebe7de; }
.skeleton-card::before, .skeleton-card::after, .suggestions.loading::after {
  background-image: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.72) 42%, transparent 64%);
  background-size: 220% 100%;
  animation: ui-shimmer 1.25s linear infinite;
}
@keyframes ui-shimmer { to { background-position-x: -220%; } }

/* Création */
.flow-header { min-height: 76px; }
.flow-header > strong { font-size: 19px; }
.flow-header > #creationBack[hidden] { display: block; visibility: hidden; pointer-events: none; }
.step-progress { margin-top: 4px; }
.step-progress span { height: 6px; }
.flow-page { padding-bottom: 128px; }
.flow-page > h1 { text-wrap: balance; }
.lead { color: var(--ui-muted); font-size: 16px; }
fieldset { margin-bottom: 30px; }
legend, label { font-size: 16px; }
.fieldset-help { max-width: 760px; font-size: 13px; line-height: 1.5; }
textarea, input, select { min-height: 48px; border-radius: 15px; font-size: 15px; }
textarea { line-height: 1.55; }
.idea-composer textarea { min-height: 170px; padding: 20px; font-size: 17px; }
.choice-row button, .slide-count-grid button, .option-button, .sensitive-choice { min-height: 46px; font-size: 13px; }
.choice-row button.selected, .slide-count-grid button.selected, .option-button.selected, .sensitive-choice.selected { box-shadow: 0 0 0 2px rgba(25, 92, 96, .1); }
.creation-profile-tile { min-height: 124px; box-shadow: var(--ui-shadow-sm); }
.image-style-choice { box-shadow: var(--ui-shadow-sm); }
.image-style-choice strong { font-size: 14px; }
.image-style-choice small { font-size: 11px; }
.voice-input-button { min-height: 50px; }
.voice-input-status { font-size: 12px; }
.bottom-action, .editor-actions { box-shadow: 0 -12px 34px rgba(24, 48, 52, .07); }
.primary-button, .secondary-button, .danger-button { min-height: 50px; border-radius: 15px; font-size: 14px; }
.primary-button { background: var(--ui-primary); box-shadow: 0 9px 24px rgba(25, 92, 96, .16); }
.primary-button:hover { background: var(--ui-primary-hover); }
.analysis-panel, .question-card { box-shadow: var(--ui-shadow-sm); }
.analysis-panel h2 { font-size: 23px; }
.analysis-panel p, .question-card p { font-size: 14px; }
.question-card h3 { font-size: 16px; }
.community-consent { border-radius: 20px; }
.community-consent strong { font-size: 14px; }
.community-consent small { font-size: 12px; }

/* Génération, édition et compte */
.generation-page h2 { font-size: 27px; }
.generation-page > p { max-width: 530px; font-size: 14px; line-height: 1.5; }
.generation-item { min-height: 42px; font-size: 13px; }
.generation-standard { width: 100%; display: flex; flex-direction: column; align-items: center; }
.generation-standard > p { max-width: 530px; color: var(--ui-muted); font-size: 14px; line-height: 1.5; }
.generation-standard > small { margin-top: 23px; color: var(--ui-muted); }
.generation-page.reviewing-plan { display: block; max-width: 880px; padding: 26px 20px 110px; text-align: left; }
.visual-plan-review { width: 100%; }
.visual-plan-review > header { max-width: 700px; margin-bottom: 24px; }
.visual-plan-review > header h2 { margin: 12px 0 7px; font-size: clamp(25px, 4vw, 36px); }
.visual-plan-review > header p { margin: 0; color: var(--ui-muted); line-height: 1.55; }
.visual-reference-summary { padding: 18px; margin-bottom: 18px; border: 1px solid var(--ui-border); border-radius: 20px; background: #fff; box-shadow: var(--ui-shadow-sm); }
.visual-reference-summary h3 { margin: 0; font-size: 15px; }
.visual-reference-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.visual-reference-chips span, .visual-plan-meta span { padding: 7px 9px; border-radius: 99px; background: var(--lavender); color: var(--ui-primary); font-size: 11px; font-weight: 800; }
.visual-plan-slides { display: grid; gap: 15px; margin-bottom: 18px; }
.visual-plan-card { padding: 20px; border: 1px solid var(--ui-border); border-radius: 22px; background: #fff; box-shadow: var(--ui-shadow-sm); }
.visual-plan-card > header { display: grid; grid-template-columns: 42px 1fr; gap: 12px; align-items: start; }
.visual-plan-card > header > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--ui-primary); color: #fff; font-size: 12px; font-weight: 900; }
.visual-plan-card h3 { margin: 1px 0 5px; font-size: 17px; }
.visual-plan-card header p { display: -webkit-box; margin: 0 0 15px; overflow: hidden; color: var(--ui-muted); font-size: 12px; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.visual-plan-card label { margin: 8px 0 0; font-size: 12px; }
.visual-plan-card textarea { min-height: 105px; margin-top: 8px; border-radius: 15px; font-size: 14px; line-height: 1.5; }
.visual-plan-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.visual-plan-review > .primary-button { margin-top: 18px; }
.story-summary-card, .quality-panel, .learning-plan, .source-panel, .account-section { box-shadow: var(--ui-shadow-sm); }
.slide-editor-card { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.slide-editor-card:hover { transform: translateY(-2px); }
.slide-card-actions button { min-height: 40px; }
.account-section { border-radius: 25px; }
.account-section-title h3, .data-actions h3 { font-size: 21px; }
.account-section-title p, .data-actions p { font-size: 13px; }
.child-card, .session-list article { border-radius: 19px; }
.child-card strong, .session-list article strong { font-size: 14px; }
.child-card p, .session-list article p { font-size: 12px; }

/* Dialogues, notifications et activité finale */
dialog { max-width: calc(100vw - 24px); border-radius: 27px; box-shadow: var(--ui-shadow-lg); }
dialog::backdrop { background: rgba(11, 30, 33, .62); backdrop-filter: blur(7px); }
.dialog-close, dialog header > button { min-height: 40px; }
.toast {
  bottom: max(24px, env(safe-area-inset-bottom));
  max-width: min(520px, calc(100vw - 28px));
  padding: 14px 18px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 16px;
  background: #153f42;
  box-shadow: 0 18px 50px rgba(10, 31, 34, .28);
  font-size: 13px;
  line-height: 1.4;
}
.ending-screen .ending-content { border-radius: 30px; box-shadow: var(--ui-shadow-lg); }
.ending-screen .ending-content h2 { text-wrap: balance; }
.ending-quiz-options button { min-height: 58px; padding: 13px 15px; font-size: 14px; }
.ending-quiz-options button strong { font-size: 14px; }
.ending-quiz-options.image-options button { min-height: 0; }

/* Survol uniquement sur les appareils qui en possèdent un. */
@media (hover: hover) {
  button:not(:disabled):hover { transform: translateY(-1px); }
  .desktop-nav button.active:hover { transform: none; }
}

@media (max-width: 1100px) {
  .skeleton-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  body.app-open { background: var(--ui-bg); }
  .main-header { min-height: 68px; background: rgba(255, 253, 249, .94); }
  .page-context strong { font-size: 16px; }
  .mobile-nav {
    --mobile-nav-height: 82px;
    padding-top: 8px;
    border-radius: 22px 22px 0 0;
    background: rgba(255, 253, 249, .97);
    box-shadow: 0 -14px 40px rgba(24, 48, 52, .1);
  }
  .mobile-nav button { min-height: 56px; gap: 4px; }
  .mobile-nav button > span { width: 34px; height: 32px; font-size: 19px; }
  .mobile-nav button > strong { font-size: 10px; letter-spacing: -.01em; }
  .mobile-nav .mobile-create { position: relative; }
  .mobile-nav .mobile-create > span { width: 52px; height: 52px; margin-top: -25px; border-radius: 18px; }
  .mobile-nav .mobile-create > strong { margin-top: -4px; color: var(--ui-primary); }
  .page-content, .home-content { padding-top: 34px; }
  .dashboard-intro h1 { font-size: clamp(38px, 10vw, 54px); }
  .dashboard-intro > p:last-child { font-size: 14px; }
  .dashboard-grid .create-hero strong { font-size: 23px; }
  .collection-content .story-library, .collection-content .community-library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skeleton-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toast { bottom: calc(94px + env(safe-area-inset-bottom)); }
  .app-shell.focus-mode .toast { bottom: max(20px, env(safe-area-inset-bottom)); }
}

@media (max-width: 620px) {
  .landing-copy h1 { font-size: clamp(39px, 12vw, 52px); }
  .landing-copy > p:not(.landing-kicker) { font-size: 16px; }
  .landing-features article { padding-inline: 10px; }
  .landing-trust { padding: 24px; }
  .page-content, .home-content { padding-inline: 16px; }
  .page-heading h1 { font-size: clamp(37px, 12vw, 48px); }
  .page-heading > div > span { font-size: 13px; }
  .collection-content .story-library, .collection-content .community-library, .skeleton-grid { grid-template-columns: 1fr; }
  .story-card, .community-card { display: grid; grid-template-columns: 128px minmax(0, 1fr); min-height: 154px !important; }
  .story-card img, .community-card img { width: 128px; height: 100% !important; min-height: 154px; }
  .story-card-copy, .community-card-copy { align-content: center; display: grid; padding: 17px; }
  .story-card h3, .community-card h3 { margin-right: 0; font-size: 16px; }
  .story-card p, .community-card p { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .story-card-meta span:nth-child(n + 4) { display: none; }
  .delete-story { top: 8px; right: 8px; width: 36px; height: 36px; }
  .skeleton-card { display: grid; grid-template-columns: 128px 1fr; min-height: 154px; }
  .skeleton-card::before { height: 100%; min-height: 154px; }
  .skeleton-card::after { width: auto; margin: 25px 18px; }
  .flow-page { padding-top: 31px; padding-inline: 16px; }
  .flow-page > h1 { font-size: clamp(31px, 9vw, 39px); }
  .idea-composer textarea { min-height: 150px; font-size: 16px; }
  .choice-row:not(.scroll-row) { display: grid; grid-template-columns: 1fr 1fr; }
  .choice-row:not(.scroll-row) button { width: 100%; }
  .slide-count-grid { grid-template-columns: repeat(4, 1fr); }
  .image-style-grid { grid-template-columns: 1fr; }
  .image-style-choice { min-height: 104px; }
  .ending-quiz-options.image-options { grid-template-columns: 1fr; }
  .empty-state { min-height: 240px; padding: 34px 20px; }
  dialog:not(.slide-studio-dialog) { width: calc(100% - 16px); max-height: calc(100dvh - 16px); border-radius: 24px; }
}

@media (max-width: 390px) {
  .page-content, .home-content, .flow-page { padding-inline: 12px; }
  .mobile-nav button > strong { font-size: 9px; }
  .story-card, .community-card { grid-template-columns: 108px minmax(0, 1fr); }
  .story-card img, .community-card img { width: 108px; }
  .story-card-copy, .community-card-copy { padding: 14px; }
  .story-card-meta { gap: 4px; }
  .story-card-meta span { padding: 5px 7px; font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (prefers-contrast: more) {
  :root { --ui-border: #9b968b; --line: #9b968b; }
  .desktop-nav button.active, .primary-button, .landing-primary { outline: 2px solid currentColor; outline-offset: -4px; }
}
