/*
 * Fakan - feuille de style unique.
 *
 * Reperes visuels releves sur elevenlabs.io (tokens de leur page publique):
 *   fond #FDFCFC, surface #F5F3F1, traits #EBE8E4 et #D7D2CC,
 *   texte #000, texte secondaire #777169, texte tertiaire #A59F97,
 *   bleu #0A59D2 et #052F70, rouge #F41A2F.
 *   Titres fins (graisse 300) a -0.03em, affichage en graisse 700,
 *   corps de texte a 1.0625rem sur 160%, grands rayons (20 a 28px).
 *
 * Leur police de titres, Waldenburg, est une police commerciale: on utilise
 * Inter (licence SIL OFL), qu'ils emploient aussi pour le texte courant.
 */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --page: #FDFCFC;
    --surface: #F5F3F1;
    --border: #EBE8E4;
    --border-strong: #D7D2CC;
    --text: #000000;
    --muted: #777169;
    --faint: #A59F97;
    /* Pas de bleu dans l'interface: du noir, des gris chauds, et le rouge
       uniquement pour ce qui alerte (suppression, enregistrement en cours). */
    --ink-hover: #3A3733;
    --accent: #F41A2F;

    --radius: 20px;
    --radius-lg: 28px;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: var(--sans);
    font-size: 1.0625rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--text); }

h1, h2, h3 {
    font-weight: 300;
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin: 0 0 0.6rem;
}

h1 { font-size: clamp(2.25rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1rem; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---------- Page d'accueil publique ---------- */

/*
 * Un peu de relief, sans rien ajouter a l'ecran: une lueur chaude derriere le
 * titre, le verbe en gris clair pour que le sujet ressorte, et une arrivee en
 * douceur. Tout reste en deux couleurs.
 */
.landing-glow {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(60rem 32rem at 50% -8rem, #F5F3F1 0%, rgba(245, 243, 241, 0) 70%),
        radial-gradient(28rem 20rem at 50% 108%, #FFF9F5 0%, rgba(255, 249, 245, 0) 72%);
}

.landing {
    min-height: calc(100vh - 4.5rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    max-width: 34rem;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* Graisse fine et interlettrage serre: c'est le titre "heading" d'ElevenLabs,
   plus calme a lire que leur affichage en gras. */
.landing h1 {
    font-weight: 700;
    font-size: clamp(2.25rem, 7vw, 4rem);
    line-height: 1.02;
    letter-spacing: -0.035em;
    margin: 0 0 0.75rem;
    max-width: 24ch;
    text-wrap: balance;
}

.h1-soft { color: var(--faint); font-weight: 300; }

.landing-subtitle {
    font-size: clamp(1rem, 2vw, 1.125rem);
    font-weight: 400;
    letter-spacing: -0.01em;
    margin: 0 0 0.35rem;
}

.landing-slogan {
    font-size: 1rem;
    font-weight: 300;
    color: var(--muted);
    letter-spacing: -0.01em;
    margin: 0;
}

.landing-foot {
    margin: 2rem 0 0;
    font-size: 0.9375rem;
}

.landing-foot a.pill {
    display: inline-block;
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 0.3rem 0.9rem;
    color: var(--muted);
    background: #fff;
    text-decoration: none;
    font-size: 0.875rem;
}

.landing-foot a.pill:hover { border-color: var(--text); color: var(--text); }

/* Arrivee en douceur, desactivee pour qui prefere moins d'animation. */
.landing > * {
    animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.landing h1 { animation-delay: 0.04s; }
.landing .landing-subtitle { animation-delay: 0.1s; }
.landing .landing-slogan { animation-delay: 0.16s; }
.landing .landing-foot { animation-delay: 0.24s; }

@keyframes rise {
    from { opacity: 0; transform: translateY(0.6rem); }
    to { opacity: 1; transform: none; }
}

/* Page introuvable: la mise en page de la vitrine, titre plus petit, et le
   code d'erreur annonce en petit au-dessus plutot qu'en chiffres geants. */
.error .error-code {
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    color: var(--faint);
    margin: 0 0 0.9rem;
}

.error h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    max-width: 20ch;
}

.error .landing-subtitle { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
    .landing > * { animation: none; }
    .mic.recording::after { animation: none; }
}

.flag { font-size: 1.1em; line-height: 1; margin-right: 0.4rem; }

/* ---------- Ossature de l'application ---------- */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--page);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar.public {
    border-bottom: none;
    /* Logo et connexion ne collent plus aux bords de l'ecran: ils suivent la
       meme colonne centrale que le titre, donc tout reste groupe. */
    max-width: 34rem;
    margin: 0 auto;
    padding: 1.25rem 1.5rem 0;
}

.brand {
    font-weight: 700;
    font-size: 1.0625rem;
    letter-spacing: -0.02em;
    color: var(--text);
}

.topbar nav { display: flex; gap: 1.25rem; font-size: 0.9375rem; }
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--text); text-decoration: none; }

.wrap { max-width: 64rem; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.narrow { max-width: 26rem; margin: 0 auto; padding: 3rem 1.5rem; }

/* Connexion: un bloc etroit, centre dans l'ecran, aux champs compacts. */
.login {
    min-height: 100vh;
    max-width: 19rem;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-head { text-align: center; margin-bottom: 1.5rem; }
.login-head h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.025em; margin: 0 0 0.3rem; }
.login-head p { font-size: 0.9375rem; margin: 0; }
.login label { font-size: 0.875rem; margin: 0.6rem 0 0.25rem; }
.login input { padding: 0.5rem 0.7rem; border-radius: 10px; font-size: 1rem; }
.login button { width: 100%; margin-top: 1.1rem; padding: 0.55rem 1rem; }
.login .flash { padding: 0.6rem 0.8rem; font-size: 0.875rem; }

.crumbs { font-size: 0.9375rem; color: var(--muted); margin-bottom: 1rem; }
.label { font-size: 0.8125rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }

.box {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    background: #fff;
}

.box h2 { font-size: 1.125rem; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 0.9rem; }
.box h2 code { font-weight: 400; margin-left: 0.4rem; }
.box > p:last-child, .box > table:last-child { margin-bottom: 0; }
.box > p.muted { margin: 0.9rem 0 0; font-size: 0.9375rem; }
.box fieldset { margin: 0.9rem 0; }
.box fieldset label.check { margin: 0.2rem 0.9rem 0.2rem 0; }
.box form + table, .box table + form { margin-top: 1rem; }
.empty { color: var(--faint); padding: 1.5rem 0; }

.flash {
    border-radius: 14px;
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9375rem;
    border: 1px solid var(--border-strong);
    background: var(--surface);
}

.flash-success { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.flash-error { border-color: rgba(244, 26, 47, 0.3); background: #FFF9F5; color: var(--accent); }

/* ---------- Formulaires ---------- */

form { margin: 0 0 1rem; }
form:last-child { margin-bottom: 0; }

/* Une seule respiration partout: 0.75rem entre deux controles. */
form.inline { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 0; }

label { display: block; font-size: 0.9375rem; color: var(--muted); margin: 0.75rem 0 0.3rem; }
label.check { display: inline-flex; align-items: center; gap: 0.45rem; margin: 0; font-size: 0.9375rem; }

input[type=text], input[type=email], input[type=password], input[type=search],
input[type=file], select, textarea {
    font: inherit;
    font-size: 0.9375rem;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 0.45rem 0.7rem;
}

/* Hors ligne, un champ ne prend pas toute la largeur d'un ecran large. */
form:not(.inline) input[type=text], form:not(.inline) input[type=email],
form:not(.inline) input[type=password], form:not(.inline) input[type=search],
form:not(.inline) select, form:not(.inline) textarea {
    width: 100%;
    max-width: 22rem;
}

form:not(.inline) textarea { max-width: 36rem; }

/* Un bouton n'est jamais collé au champ ou au texte qui le precede. */
form:not(.inline) > label.check { display: inline-flex; margin: 0.6rem 1.25rem 0 0; }
form:not(.inline) > button, form:not(.inline) > .button { margin-top: 1.1rem; }
form:not(.inline) > input + button { margin-top: 0.8rem; }

/* Dans une ligne, chaque champ prend la place de son contenu. */
form.inline input, form.inline select { width: auto; min-width: 7rem; }
/* Un champ qui declare sa taille la garde: le navigateur sait la calculer. */
form.inline input[size] { min-width: 0; width: auto; }
form.inline input[type=file] { min-width: 0; font-size: 0.875rem; padding: 0.35rem 0.5rem; }
form.inline input[type=search] { min-width: 12rem; }
form.inline input[maxlength="2"] { min-width: 4rem; width: 4rem; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.07);
}

textarea { min-height: 7rem; resize: vertical; }

button, .button {
    display: inline-flex;
    white-space: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    background: var(--text);
    color: #fff;
    border: 1px solid var(--text);
    border-radius: 9999px;
    padding: 0.6rem 1.25rem;
}

button:hover, .button:hover { background: var(--ink-hover); border-color: var(--ink-hover); text-decoration: none; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.button.ghost, button.ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border-strong);
}

.button.ghost:hover, button.ghost:hover { background: var(--surface); color: var(--text); border-color: var(--text); }
.button.big { font-size: 1.0625rem; padding: 0.8rem 1.6rem; }
.button.small, button.small { font-size: 0.9375rem; padding: 0.45rem 1.1rem; }
.button.small span { opacity: 0.6; transition: transform 0.15s ease; }
.button.small:hover span { transform: translateX(2px); opacity: 1; }

a.link, button.link {
    background: none;
    border: none;
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
    text-underline-offset: 2px;
    padding: 0;
    font-weight: 400;
    border-radius: 0;
}

a.link:hover, button.link:hover { background: none; text-decoration-color: var(--text); }
a.link.danger, button.link.danger, .danger { color: var(--accent); }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 0 0 1rem; }
legend { font-size: 0.9375rem; color: var(--muted); padding: 0 0.4rem; }

/* ---------- Lignes d'action alignees ---------- */
/*
 * Nom a gauche, options au milieu, bouton dans une colonne de largeur fixe:
 * les boutons tombent tous au meme endroit, quelle que soit la longueur du
 * texte qui precede.
 */

.act-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 10rem;
    gap: 1rem;
    align-items: center;
    padding: 0.8rem 0;
    margin: 0;
    border-bottom: 1px solid var(--border);
}

.act-row:last-of-type { border-bottom: none; padding-bottom: 0; }
.act-row:first-of-type { padding-top: 0; }

.act-name { min-width: 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.9375rem; }
.act-name strong { font-weight: 500; }
.act-options { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: flex-end; }
.act-row > button, .act-row > .button { width: 100%; }
.act-row form { margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.act-row form button { width: 100%; }

/* Page Espace serveur: trois chiffres lisibles d'un coup d'oeil. */
.space-stats { font-size: 0.875rem; color: var(--muted); gap: 1.25rem; }
.space-stats em { font-style: normal; font-weight: 500; color: var(--text); }
.confirm-line { font-size: 0.8125rem; color: var(--muted); align-items: flex-start; gap: 0.35rem; }
.small-note { font-size: 0.875rem; text-align: right; }

@media (max-width: 760px) {
    .act-row { grid-template-columns: 1fr; gap: 0.6rem; }
    .act-options { justify-content: flex-start; }
}

/* ---------- Donnees ---------- */

table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; margin-bottom: 1rem; }
th, td { text-align: left; padding: 0.55rem 0.75rem 0.55rem 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-weight: 500; color: var(--faint); font-size: 0.8125rem; letter-spacing: 0.02em; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
td:last-child, th:last-child { text-align: right; padding-right: 0; }
td form, td form.inline { margin: 0; justify-content: flex-end; }

code {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 0.875em;
    background: var(--surface);
    border-radius: 6px;
    padding: 0.1rem 0.35rem;
}

pre {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
}

.stats { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0; margin: 0 0 1rem; }
.stats li { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1.1rem; min-width: 8rem; background: #fff; }
.stats span { display: block; font-size: 0.8125rem; color: var(--faint); }

.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.cards a {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    color: var(--text);
    background: #fff;
}
.cards a:hover { border-color: var(--text); text-decoration: none; }
.cards strong { display: block; font-size: 1.0625rem; margin-bottom: 0.2rem; }

.tree { list-style: none; padding: 0; margin: 0; }
.tree li { border-bottom: 1px solid var(--border); padding: 0.7rem 0; }

.subnav { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.9375rem; border-bottom: 1px solid var(--border); padding-bottom: 0.75rem; margin-bottom: 1.5rem; }
.subnav a { color: var(--muted); }
.subnav a.on { color: var(--text); font-weight: 500; }
.pager { display: flex; gap: 0.75rem; align-items: center; font-size: 0.9375rem; color: var(--muted); }

/* ---------- Ecran d'enregistrement ---------- */
/*
 * Pense pour le telephone: une seule colonne, de grandes cibles tactiles, et
 * surtout une zone d'action a hauteur fixe. Elle ne change pas de taille entre
 * "pret a enregistrer", "en train d'enregistrer" et "ecoute de la prise", donc
 * le bouton reste toujours sous le pouce, au meme endroit.
 */

#card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.25rem 1.25rem;
    text-align: center;
    background: #fff;
}

#position { font-size: 0.9375rem; margin: 0; }

#card .label { display: block; margin: 1.25rem 0 0.35rem; }

#phrase-text {
    font-size: clamp(2rem, 9vw, 3rem);
    font-weight: 300;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 0 0 0.75rem;
}

/* Hauteur reservee une fois pour toutes: rien ne bouge d'un etat a l'autre. */
.take {
    min-height: 15rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 1.25rem 0 0.5rem;
}

.mic {
    width: 7rem;
    height: 7rem;
    padding: 0;
    border-radius: 9999px;
    background: var(--text);
    border: none;
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
    transition: background 0.15s ease;
}

.mic:hover { background: var(--ink-hover); }
.mic svg { width: 2.25rem; height: 2.25rem; display: block; }

.mic.recording { background: var(--accent); }
.mic.recording:hover { background: var(--accent); }

/* L'anneau pulse, le bouton garde sa taille. */
.mic.recording::after {
    content: '';
    position: absolute;
    inset: -0.5rem;
    border-radius: 9999px;
    border: 2px solid var(--accent);
    animation: pulse 1.4s ease-out infinite;
}

.mic { position: relative; }

@keyframes pulse {
    0% { opacity: 0.7; transform: scale(0.96); }
    100% { opacity: 0; transform: scale(1.12); }
}

.mic-label { font-size: 0.9375rem; color: var(--muted); margin: 0; }
.timer { font-size: 1.25rem; font-variant-numeric: tabular-nums; color: var(--accent); margin: 0; }

#review { width: 100%; max-width: 22rem; }
#review audio, #card audio { width: 100%; margin: 0 0 0.75rem; }

.row { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.row button, .row .button { min-width: 8rem; }

.status { font-size: 0.9375rem; color: var(--muted); min-height: 2.5rem; margin: 0.5rem 0 0; }
.status-ok { color: var(--text); }
.status-error { color: var(--accent); }

/* ---------- Telephone ---------- */

@media (max-width: 640px) {
    .wrap { padding: 1.25rem 1rem 3rem; }
    .topbar { padding: 0.75rem 1rem; }
    .topbar nav { gap: 1rem; }

    /* Cibles tactiles confortables partout dans l'application. */
    button, .button { min-height: 2.75rem; padding: 0.7rem 1.25rem; }
    .row button, .row .button { flex: 1 1 8rem; }
    input[type=text], input[type=email], input[type=password], input[type=search], select, textarea { font-size: 1.0625rem; }

    #card { padding: 1.25rem 1rem; border-radius: var(--radius); }
    .box { padding: 1.1rem; }
    .cards { grid-template-columns: 1fr; }
    .stats li { flex: 1 1 8rem; min-width: 0; }

    /* Les tableaux du dashboard defilent au lieu de deborder. */
    table { display: block; overflow-x: auto; white-space: nowrap; }
}
