/* note — design system (accent vert, thème sombre par défaut) */

:root,
[data-theme="dark"] {
  --accent: #3f9463;
  --accent-strong: #5bb883;
  --accent-soft: #1c3a2a;
  --on-accent: #05170d;

  --bg: #14171a;
  --surface: #1b1f23;
  --surface-2: #22262b;
  --surface-3: #2a2f35;
  --on-surface: #e7ebee;
  --on-surface-var: #9aa4ad;

  --outline: #333a41;
  --outline-soft: #262b30;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, .45);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .5);

  --tone-0-bg: #22262b; --tone-0-fg: #9aa4ad;
  --tone-1-bg: #22323a; --tone-1-fg: #7fb3c9;
  --tone-2-bg: #3a3222; --tone-2-fg: #d1b45f;
  --tone-3-bg: var(--accent-soft); --tone-3-fg: var(--accent-strong);
}

[data-theme="light"] {
  --accent: #2f7d4f;
  --accent-strong: #256a41;
  --accent-soft: #dcf0e3;
  --on-accent: #ffffff;

  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f0f1f2;
  --surface-3: #e6e8ea;
  --on-surface: #1c2023;
  --on-surface-var: #5b6570;

  --outline: #d8dbde;
  --outline-soft: #e7e9eb;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .08);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, .1);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .14);

  --tone-0-bg: #eef0f1; --tone-0-fg: #5b6570;
  --tone-1-bg: #e4eef2; --tone-1-fg: #29707f;
  --tone-2-bg: #f5edda; --tone-2-fg: #8a6d1c;
  --tone-3-bg: var(--accent-soft); --tone-3-fg: var(--accent-strong);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --accent: #2f7d4f; --accent-strong: #256a41; --accent-soft: #dcf0e3; --on-accent: #ffffff;
    --bg: #f5f6f7; --surface: #ffffff; --surface-2: #f0f1f2; --surface-3: #e6e8ea;
    --on-surface: #1c2023; --on-surface-var: #5b6570;
    --outline: #d8dbde; --outline-soft: #e7e9eb;
  }
}

* { box-sizing: border-box; }
html { --app-loaded: 1; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--on-surface);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
h1, h2, h3 { font-weight: 600; margin: 0 0 .4em; }
button { font-family: inherit; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* --- Icons --- */
.mi {
  font-family: "Material Icons";
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  user-select: none;
}
body.no-icons .mi { display: none; }

/* --- Splash --- */
#splash {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 999; transition: opacity .4s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-mark {
  width: 64px; height: 64px; border-radius: 16px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.splash-mark .mi { color: var(--on-accent); font-size: 32px; }

/* --- Auth screen --- */
#auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--outline-soft);
  border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow-2); text-align: center;
}
.brand-mark {
  width: 48px; height: 48px; border-radius: 12px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;
}
.brand-mark .mi { color: var(--on-accent); font-size: 26px; }
.brand-mark.small { width: 32px; height: 32px; border-radius: 9px; margin: 0; }
.brand-mark.small .mi { font-size: 18px; }
.auth-card .sub { color: var(--on-surface-var); margin: 0 0 20px; font-size: 13px; }

.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.auth-tab {
  flex: 1; border: none; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer;
  color: var(--on-surface-var); font-size: 13px;
}
.auth-tab.active { background: var(--surface); color: var(--on-surface); box-shadow: var(--shadow-1); }

.auth-form { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.auth-form label { font-size: 12px; color: var(--on-surface-var); margin-top: 6px; }
.auth-form input {
  background: var(--surface-2); border: 1px solid var(--outline); border-radius: 8px;
  padding: 9px 10px; font-size: 14px;
}
.auth-form input:focus { outline: none; border-color: var(--accent); }
.checkbox-line { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 4px; }
.checkbox-line input { width: auto; }

.btn-primary {
  margin-top: 14px; background: var(--accent); color: var(--on-accent); border: none;
  border-radius: 8px; padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-link {
  background: none; border: none; color: var(--on-surface-var); font-size: 12px;
  cursor: pointer; margin-top: 8px; text-decoration: underline;
}
.auth-error { color: #e07070; font-size: 13px; }
.auth-info { color: var(--accent-strong); font-size: 13px; }

/* --- App shell --- */
#app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.appbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-bottom: 1px solid var(--outline-soft); padding: 10px 16px;
}
.appbar button {
  background: none; border: none; border-radius: 8px; padding: 7px; cursor: pointer;
  display: flex; align-items: center;
}
.appbar button:hover { background: var(--surface-2); }
.spacer { flex: 1; }

.day-nav { display: flex; align-items: center; gap: 6px; font-size: 14px; }
#day-label { min-width: 220px; text-align: center; font-weight: 600; }
#nav-today { font-size: 12px; padding: 6px 10px; border: 1px solid var(--outline); border-radius: 20px; }
#nav-date { background: var(--surface-2); border: 1px solid var(--outline); border-radius: 8px; padding: 5px; color: inherit; }

.save-status { font-size: 12px; color: var(--on-surface-var); min-width: 90px; text-align: right; }
.save-status.error { color: #e07070; }
.save-status.saving { color: var(--accent-strong); }

/* --- Pages --- */
#pages-container { max-width: 900px; margin: 0 auto; padding: 20px 16px 96px; width: 100%; flex: 1; }
.page-card {
  background: var(--surface); border: 1px solid var(--outline-soft); border-radius: 12px;
  margin-bottom: 16px; overflow: hidden;
}
.page-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--outline-soft); }
.page-title {
  flex: 1; background: none; border: none; font-weight: 600; font-size: 14px; color: inherit;
  padding: 4px 6px; border-radius: 6px;
}
.page-title:focus { outline: none; background: var(--surface-2); }
.page-actions { display: flex; gap: 2px; }
.page-actions button { background: none; border: none; padding: 5px; border-radius: 6px; cursor: pointer; color: var(--on-surface-var); }
.page-actions button:hover { background: var(--surface-2); color: var(--on-surface); }

.editor-wrap { position: relative; }
.editor-highlight, .editor-input {
  margin: 0; padding: 14px; width: 100%; min-height: 140px;
  font-family: "Roboto Mono", ui-monospace, monospace; font-size: 13.5px; line-height: 1.6;
  max-width: 80ch; white-space: pre-wrap; word-wrap: break-word; border: none;
}
.editor-highlight {
  position: absolute; inset: 0; color: transparent; pointer-events: none; overflow: hidden;
}
.editor-input {
  position: relative; background: transparent; color: var(--on-surface); resize: none;
  overflow: hidden; caret-color: var(--on-surface);
}
.editor-input:focus { outline: none; }

.tok-heading { color: var(--accent-strong); font-weight: 600; }
.tok-bold { font-weight: 700; }
.tok-italic { font-style: italic; }
.tok-list { color: var(--on-surface-var); }
.tok-link { color: #6fa8dc; text-decoration: underline; }
.tok-decision { color: #d1b45f; font-weight: 600; }
.tok-action { color: #7fb3c9; font-weight: 600; }
.tok-question { color: #c98fd1; font-weight: 600; }
.tok-idee { color: var(--accent-strong); font-weight: 600; }
.tok-tag { color: var(--on-surface-var); }

/* --- FAB --- */
.fab {
  position: fixed; right: 24px; bottom: 24px; width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); border: none; box-shadow: var(--shadow-3);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.fab:hover { background: var(--accent-strong); }
.fab .mi { font-size: 26px; }

/* --- Dialogs --- */
dialog {
  border: none; border-radius: 14px; padding: 0; background: var(--surface); color: var(--on-surface);
  box-shadow: var(--shadow-3); width: 100%; max-width: 480px;
}
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--outline-soft); }
.dialog-close { background: none; border: none; cursor: pointer; padding: 4px; border-radius: 6px; color: var(--on-surface-var); }
.dialog-body { padding: 16px 18px; max-height: 60vh; overflow: auto; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--outline-soft); }
.dialog-foot button { background: var(--surface-2); border: 1px solid var(--outline); border-radius: 8px; padding: 7px 14px; cursor: pointer; }

#search-input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--outline); border-radius: 8px;
  padding: 9px 10px; font-size: 14px; margin-bottom: 10px;
}
#search-results { list-style: none; margin: 0; padding: 0; }
#search-results li { padding: 10px; border-radius: 8px; cursor: pointer; }
#search-results li:hover { background: var(--surface-2); }
#search-results .sr-date { font-size: 11px; color: var(--on-surface-var); }
#search-results .sr-title { font-weight: 600; }
#search-results .sr-extract { font-size: 12px; color: var(--on-surface-var); }

/* --- Toast --- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-3); color: var(--on-surface); padding: 10px 18px; border-radius: 10px;
  box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  z-index: 100; font-size: 13px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Raccourcis clavier (aide) --- */
.shortcuts-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.shortcuts-table td { padding: 7px 4px; border-bottom: 1px solid var(--outline-soft); font-size: 13px; }
.shortcuts-table td:first-child { white-space: nowrap; width: 1%; }
.shortcuts-table td:last-child { color: var(--on-surface-var); }
.shortcuts-subhead { font-size: 12px; color: var(--on-surface-var); margin: 16px 0 6px; }
kbd {
  display: inline-block; background: var(--surface-2); border: 1px solid var(--outline);
  border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; font-family: "Roboto Mono", monospace;
  font-size: 12px; line-height: 1.4;
}

/* --- Suggestion des marqueurs (@) --- */
.marker-menu {
  position: fixed; z-index: 200; min-width: 220px; max-width: 280px;
  background: var(--surface-3); border: 1px solid var(--outline); border-radius: 10px;
  box-shadow: var(--shadow-2); padding: 4px; font-size: 13px;
}
.marker-menu-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; cursor: pointer;
}
.marker-menu-item.selected, .marker-menu-item:hover { background: var(--surface-2); }
.marker-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.marker-dot.tok-decision { background: #d1b45f; }
.marker-dot.tok-action { background: #7fb3c9; }
.marker-dot.tok-question { background: #c98fd1; }
.marker-dot.tok-idee { background: var(--accent-strong); }
.marker-key { font-family: "Roboto Mono", monospace; font-weight: 600; flex: none; }
.marker-desc { color: var(--on-surface-var); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#unzip-error { display: none; }
