/* ILYGO application charter, adopted 20 October 2026, Outline revision 9. */

:root {
  color-scheme: light;
  --primary: #213150;
  --primary-deep: #16223a;
  --accent: #1b9fb4;
  --accent-text: #087386;
  --accent-surface: #e4f4f7;
  --bg: #f5f7fb;
  --bg-2: #e9f1fa;
  --panel: #ffffff;
  --panel-2: #e9f1fa;
  --surface-2: #e4f4f7;
  --border: #e5e9f0;
  --border-2: #7b879a;
  --fg: #213150;
  --fg-2: #1f2937;
  --muted: #5b6577;
  --faint: #5b6577;
  --danger: #b42332;
  --ok: #166348;
  --green: #166348;
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body, #root { min-height: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg-2);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--fg); letter-spacing: -0.02em; margin: 0; font-weight: 600; }
h1 { font-size: clamp(24px, 3vw, 32px); line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }

/* ---- App shell (sidebar + content) ---- */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 24px 16px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--primary); font-size: 15px; font-weight: 600; padding: 0 8px 24px; text-align: left; }
.brand img { object-fit: contain; flex-shrink: 0; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); padding: 14px 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; min-height: 44px; text-decoration: none; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13.5px; cursor: pointer;
  transition: background-color .12s, color .12s;
}
.nav-item:hover { color: var(--fg); background: var(--panel); }
.nav-item.active { color: var(--primary); background: var(--accent-surface); box-shadow: inset 3px 0 var(--accent); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.sidebar-user { font-size: 12px; color: var(--muted); padding: 2px 8px 8px; word-break: break-all; }

.content { padding: 40px; max-width: 1280px; width: 100%; min-width: 0; overflow-wrap: anywhere; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ---- Cards ---- */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: 0 6px 20px rgba(33,49,80,.06);
}
.card + .card { margin-top: 14px; }
.card-h { font-size: 13px; font-weight: 600; color: var(--fg); margin-bottom: 12px; }

/* ---- Buttons ---- */
button, .btn {
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  font-family: inherit; font-size: 13px; font-weight: 500;
  border-radius: var(--radius-sm); padding: 10px 16px; min-height: 44px; min-width: 44px; cursor: pointer;
  border: 1px solid transparent; transition: background-color .12s, border-color .12s, color .12s;
  background: var(--primary); color: #fff; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--primary-deep); text-decoration: none; }
button svg, .btn svg { width: 15px; height: 15px; }
button.secondary, .btn.secondary {
  background: transparent; color: var(--fg-2); border-color: var(--border-2);
}
button.secondary:hover, .btn.secondary:hover { border-color: var(--faint); color: var(--fg); background: var(--panel-2); }
button.ghost { background: transparent; color: var(--muted); border-color: transparent; padding: 6px 8px; }
button.ghost:hover { background: var(--panel-2); color: var(--fg); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #fff0f1; border-color: var(--danger); }
button:disabled { opacity: .65; cursor: not-allowed; }
button.sm, .btn.sm { padding: 5px 10px; font-size: 12.5px; }

/* ---- Forms ---- */
label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 5px; }
input, textarea, select {
  width: 100%; background: var(--bg); color: var(--fg-2);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 44px; font-size: 15px; font-family: inherit; outline: none;
  transition: border-color .12s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent-text); }
input[type="checkbox"], input[type="radio"] { min-height: 20px; width: 20px; accent-color: var(--primary); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; }

/* ---- Tabs (workspace bot) ---- */
.tabs { display: flex; overflow-x: auto; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 12px; min-height: 44px; font-size: 13px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent-text); font-weight: 600; }
.tab { flex-shrink: 0; text-decoration: none; }

/* ---- Badges / pills ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
}
.badge .ico { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.badge.on { color: var(--green); border-color: #7b9f90; }
.badge.on .ico { background: var(--green); }
.badge.off { color: var(--faint); }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
.table-scroll { overflow-x: auto; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }

/* ---- Rows (list items) ---- */
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); transition: border-color .12s;
}
.list-item + .list-item { margin-top: 8px; }
.list-item:hover { border-color: var(--border-2); }
.list-item:focus-visible, .tree-node:focus-visible, [role="checkbox"]:focus-visible {
  outline: 3px solid var(--accent-text);
  outline-offset: 2px;
}

/* ---- Tree (memoire / fichiers) ---- */
.tree-node { min-height: 44px; padding: 5px 8px; border-radius: var(--radius-sm); cursor: pointer; color: var(--fg-2); font-size: 13.5px; display: flex; align-items: center; gap: 8px; transition: background-color .1s; }
.tree-node:hover { background: var(--panel-2); }
.tree-node.sel { background: var(--panel-2); color: var(--fg); }
.tree-node svg { width: 15px; height: 15px; color: var(--muted); }
.tree-children { margin-left: 14px; border-left: 1px solid var(--border); padding-left: 8px; }

/* ---- Chat bubbles ---- */
.msg { padding: 9px 13px; border-radius: 12px; margin: 7px 0; max-width: 78%; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.45; }
.msg.user { background: var(--panel-2); margin-left: auto; border: 1px solid var(--border); }
.msg.assistant { background: var(--bg-2); border: 1px solid var(--border); }
.msg.system { background: transparent; color: var(--faint); font-size: 12px; border: 1px dashed var(--border); }
.msg .time { color: var(--faint); font-size: 11px; margin-top: 5px; }

/* ---- Utils ---- */
.muted { color: var(--muted); font-size: 13px; }
.faint { color: var(--faint); }
.err { color: var(--danger); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 16px; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 18px; padding: 24px; text-align: center; }
pre.viewer { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--border); padding: 14px; border-radius: var(--radius-sm); max-height: 540px; overflow: auto; font-size: 12.5px; color: var(--fg-2); }
.empty { color: var(--faint); font-size: 13px; padding: 24px 4px; }
/* Six independent fields remain usable by keyboard, paste and OTP autofill. */
.mfa-fields { border: 0; padding: 0; margin: 12px 0; min-width: 0; }
.mfa-fields legend { margin-bottom: 8px; }
.mfa-digits { display: flex; gap: 6px; max-width: 340px; }
.mfa-digits input { min-width: 0; width: 100%; text-align: center; padding: 10px 0; font-size: 20px; }

:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 3px; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 10000; padding: 12px 20px; background: var(--primary); color: #fff; border-radius: 10px; }
.skip-link:focus { top: 12px; }
.auth-page { min-height: 100vh; display: flex; flex-direction: column; }
.auth-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px max(24px, calc((100vw - 1200px)/2)); background: #fff; border-bottom: 1px solid var(--border); }
.auth-header .brand { padding: 0; }
.auth-header nav { display: flex; gap: 24px; }
.auth-main { flex: 1; width: min(1200px, 100%); margin: auto; padding: 64px 32px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); align-items: center; gap: 80px; }
.auth-intro h1 { font-size: clamp(32px, 4vw, 48px); max-width: 620px; margin: 16px 0 24px; }
.auth-intro > p { color: var(--muted); font-size: 17px; max-width: 500px; }
.eyebrow { color: var(--accent-text); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.feature-list { list-style: none; padding: 0; display: grid; gap: 20px; margin: 32px 0 0; }
.feature-list li { display: flex; gap: 14px; align-items: flex-start; }
.feature-list svg { width: 22px; height: 22px; color: var(--accent-text); flex-shrink: 0; margin-top: 2px; }
.feature-list strong { display: block; color: var(--primary); font-size: 15px; }
.feature-list p { color: var(--muted); font-size: 14px; margin-top: 3px; }
.login-card { padding: 32px; border-radius: 24px; box-shadow: 0 18px 45px rgba(33,49,80,.10); }
.login-card h2 { font-size: 22px; }
.login-card > p { margin-top: 8px; }
.login-card button { width: 100%; }
.login-card .auth-alternate { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.auth-privacy { margin-top: 20px; font-size: 12px; color: var(--muted); }
.public-footer { background: var(--primary-deep); color: #fff; padding: 40px max(24px, calc((100vw - 1136px)/2)); font-size: 13px; }
.public-footer a { display: block; width: fit-content; min-height: 32px; color: #cbd6e8; }
.public-footer :focus-visible { outline-color: #fff; }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 48px; }
.footer-grid strong { display: block; font-size: 15px; margin-bottom: 12px; }
.footer-grid p { max-width: 340px; color: #cbd6e8; margin-bottom: 8px; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; margin-top: 32px; padding-top: 20px; border-top: 1px solid #475369; color: #cbd6e8; }
.footer-bottom > div { display: flex; gap: 24px; }
.footer-note { color: #cbd6e8; margin-top: 12px; font-size: 12px; }
.confirmation-dialog { margin: auto; max-width: min(520px, calc(100vw - 32px)); width: 100%; padding: 32px; border: 1px solid var(--border); border-radius: 24px; background: #fff; color: var(--fg-2); text-align: start; white-space: normal; box-shadow: 0 18px 45px rgba(33,49,80,.10); }
.confirmation-dialog::backdrop { background: rgba(22,34,58,.5); }
.confirmation-dialog p { margin: 16px 0 24px; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 220px minmax(0, 1fr); }
  .content { padding: 24px; }
  .auth-main { gap: 32px; padding: 40px 24px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .app { display: block; }
  .sidebar { position: static; height: auto; padding: 20px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar .brand { padding-bottom: 16px; }
  .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .nav-label { grid-column: 1 / -1; padding-top: 4px; }
  .nav-item { font-size: 13px; gap: 8px; padding: 10px 8px; }
  .sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .sidebar-foot button { width: auto !important; }
  .sidebar-user { min-width: 0; padding: 0; }
  .content { padding: 24px 16px; }
  .page-head { align-items: flex-start; flex-wrap: wrap; }
  .card { padding: 20px; }
  .row { flex-wrap: wrap; }
  .msg { max-width: 95%; }
  .auth-header { padding: 20px; gap: 12px; }
  .auth-header nav { gap: 12px; }
  .auth-main { display: flex; flex-direction: column; align-items: stretch; padding: 32px 20px; gap: 32px; }
  .auth-intro h1 { font-size: 32px; margin-top: 12px; }
  .auth-intro > p { font-size: 15px; }
  .feature-list { gap: 16px; margin-top: 24px; }
  .login-card { padding: 24px; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-bottom > div { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

.context-help { display: flex; justify-content: flex-end; margin-bottom: 12px; font-size: 13px; }
.nav-toggle { display: none; }
@media (max-width: 680px) {
  .nav-toggle { display: flex; margin-bottom: 12px; }
  .nav[data-open="false"] { display: none; }
}

[role="checkbox"] { min-height: 44px; min-width: 44px; }
.auth-header nav { align-items: center; }
.auth-header nav a { display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 680px) { .public-footer a { min-height: 44px; } }

.grid-2 > .card + .card { margin-top: 0; }

/* Scoped API delegation controls: inherited brand tokens and keyboard targets. */
.api-permissions { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 20px 0;
  padding: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 8px 20px; }
.api-permission { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; cursor: pointer; }
.api-permission input { flex: 0 0 20px; }
.api-permission code { display: block; font-size: 12px; color: var(--muted); }
.api-key-value { overflow-wrap: anywhere; font-family: ui-monospace, monospace; }
.api-pagination { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
