/* ═══════════════════════════════════════════════════
   WP LiùYáo Claude — Styles
   ═══════════════════════════════════════════════════ */

:root {
    --ly-accent:       #8b1a1a;
    --ly-max-width:    900px;
    --ly-yang-color:   #c41e3a;
    --ly-yin-color:    #1a3a8b;
    --ly-moving-color: #d4a017;
    --ly-shi-bg:       #fff8e1;
    --ly-ying-bg:      #e8f5e9;
    --ly-bg:           #faf8f5;
    --ly-border:       #d4c5a9;
    --ly-text:         #2c2418;
    --ly-text-light:   #6b5f4e;
    --ly-font-zh:      'Noto Serif SC', 'SimSun', serif;
    --ly-radius:       4px;
}

/* ── Conteneur principal ── */
/* Wrapper de centrage — fonctionne dans tous les contextes */
.ly-wrapper {
    width: 100%;
    display: block;
    box-sizing: border-box;
}

.liuyao-widget {
    max-width: var(--ly-max-width);
    width: 100%;
    box-sizing: border-box;
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    font-family: var(--ly-font-zh), Georgia, serif;
    color: var(--ly-text);
    background: var(--ly-bg);
    border: 1px solid var(--ly-border);
    border-radius: var(--ly-radius);
    overflow: hidden;
}

/* ── Formulaire de consultation ── */
.ly-form {
    padding: 20px 24px;
}

.ly-form h2 {
    font-size: 1.3em;
    color: var(--ly-accent);
    margin: 0 0 16px;
    border-bottom: 2px solid var(--ly-accent);
    padding-bottom: 8px;
    font-weight: normal;
    letter-spacing: 0.04em;
}

.ly-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
    margin-bottom: 16px;
}

@media (max-width: 600px) {
    .ly-form-grid { grid-template-columns: 1fr; }
}

.ly-field label {
    display: block;
    font-size: 0.78em;
    color: var(--ly-text-light);
    margin-bottom: 4px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.ly-field input,
.ly-field select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--ly-border);
    border-radius: var(--ly-radius);
    background: #fff;
    font-size: 0.92em;
    color: var(--ly-text);
    box-sizing: border-box;
}

.ly-field input:focus,
.ly-field select:focus {
    outline: none;
    border-color: var(--ly-accent);
}

/* ── Méthode de tirage ── */
.ly-method-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--ly-border);
    padding-bottom: 0;
}

.ly-tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 6px 14px 8px;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--ly-text-light);
    transition: color .2s, border-color .2s;
    font-family: inherit;
}

.ly-tab-btn.active,
.ly-tab-btn:hover {
    color: var(--ly-accent);
    border-bottom-color: var(--ly-accent);
}

/* ── Saisie manuelle ── */
.ly-manual-input {
    margin-bottom: 14px;
}

.ly-manual-input p {
    font-size: 0.85em;
    color: var(--ly-text-light);
    margin: 0 0 10px;
}

.ly-lines-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.ly-line-input {
    text-align: center;
}

.ly-line-input label {
    display: block;
    font-size: 0.75em;
    color: var(--ly-text-light);
    margin-bottom: 4px;
}

.ly-line-input select {
    width: 100%;
    padding: 6px 2px;
    text-align: center;
    border: 1px solid var(--ly-border);
    border-radius: var(--ly-radius);
    font-size: 0.9em;
    background: #fff;
    cursor: pointer;
}

/* ── Tirage aléatoire ── */
.ly-random-zone {
    text-align: center;
    padding: 12px 0;
}

.ly-dice-btn {
    background: var(--ly-accent);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: var(--ly-radius);
    font-size: 1em;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.03em;
    transition: opacity .2s;
}

.ly-dice-btn:hover { opacity: .85; }

.ly-coins-display {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin: 10px 0;
    flex-wrap: wrap;
}

.ly-coin {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #c8a84b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    box-shadow: 1px 1px 3px rgba(0,0,0,.2);
    animation: ly-flip .4s ease;
}

@keyframes ly-flip {
    0%  { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100%{ transform: rotateY(0deg); }
}

.ly-lines-preview {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 8px;
    font-size: 0.82em;
    color: var(--ly-text-light);
}

.ly-lines-preview span {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

/* ── Bouton consulter ── */
.ly-submit-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
}

.ly-submit-btn {
    background: var(--ly-accent);
    color: #fff;
    border: none;
    padding: 10px 28px;
    border-radius: var(--ly-radius);
    font-size: 1em;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.05em;
    transition: opacity .2s;
}

.ly-submit-btn:hover { opacity: .85; }
.ly-submit-btn:disabled { opacity: .5; cursor: not-allowed; }

.ly-reset-btn {
    background: none;
    color: var(--ly-text-light);
    border: 1px solid var(--ly-border);
    padding: 10px 18px;
    border-radius: var(--ly-radius);
    font-size: 0.9em;
    cursor: pointer;
    font-family: inherit;
    transition: border-color .2s;
}

.ly-reset-btn:hover { border-color: var(--ly-accent); color: var(--ly-accent); }

/* ── Loading ── */
.ly-loading {
    text-align: center;
    padding: 30px;
    color: var(--ly-text-light);
}

.ly-spinner {
    display: inline-block;
    animation: ly-spin 1s linear infinite;
}

@keyframes ly-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Résultat ── */
.ly-result {
    padding: 20px 24px;
}

/* En-tête résultat */
.ly-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.ly-result-title h3 {
    margin: 0 0 4px;
    font-size: 1.1em;
    color: var(--ly-text-light);
    font-weight: normal;
}

.ly-result-title .ly-datetime {
    font-size: 0.85em;
    color: var(--ly-text-light);
}

.ly-nouvelle-btn {
    background: none;
    border: 1px solid var(--ly-accent);
    color: var(--ly-accent);
    padding: 7px 14px;
    border-radius: var(--ly-radius);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88em;
    transition: background .2s, color .2s;
}

.ly-nouvelle-btn:hover {
    background: var(--ly-accent);
    color: #fff;
}

/* ── Contexte BaZi ── */
.ly-bazi-strip {
    display: flex;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--ly-border);
    border-radius: var(--ly-radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.ly-bazi-strip .ly-pillar {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

.ly-bazi-strip .ly-pillar-label {
    font-size: 0.7em;
    color: var(--ly-text-light);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.ly-bazi-strip .ly-pillar-gz {
    font-size: 1.3em;
    letter-spacing: .05em;
    color: var(--ly-accent);
}

.ly-bazi-strip .ly-pillar-py {
    font-size: 0.72em;
    color: var(--ly-text-light);
    font-style: italic;
}

.ly-bazi-sep {
    color: var(--ly-border);
    font-size: 1.2em;
    align-self: center;
}

.ly-kongwang-badge {
    margin-left: auto;
    font-size: 0.78em;
    color: var(--ly-text-light);
    border: 1px dashed var(--ly-border);
    border-radius: 3px;
    padding: 3px 8px;
}

/* ── Hexagrammes ── */
.ly-hexagrams-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: start;
    margin-bottom: 20px;
}

@media (max-width: 640px) {
    .ly-hexagrams-row { grid-template-columns: 1fr; }
    .ly-arrow { display: none; }
}

.ly-gua-block {
    background: #fff;
    border: 1px solid var(--ly-border);
    border-radius: var(--ly-radius);
    overflow: hidden;
}

.ly-gua-header {
    background: var(--ly-accent);
    color: #fff;
    padding: 8px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ly-gua-type {
    font-size: 0.75em;
    opacity: .85;
    letter-spacing: .05em;
}

.ly-gua-name {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ly-gua-name .ly-zh {
    font-size: 1.5em;
    letter-spacing: .08em;
    line-height: 1.1;
}

.ly-gua-name .ly-py {
    font-size: 0.78em;
    opacity: .85;
    font-style: italic;
}

.ly-palace-tag {
    font-size: 0.75em;
    background: rgba(255,255,255,.2);
    border-radius: 3px;
    padding: 2px 6px;
    margin-top: 4px;
}

.ly-gua-body {
    padding: 0;
}

/* ── Tableau des Yao ── */
.ly-yao-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
}

.ly-yao-table th {
    font-size: 0.72em;
    color: var(--ly-text-light);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 5px 8px;
    border-bottom: 1px solid var(--ly-border);
    background: #faf8f5;
    text-align: left;
}

.ly-yao-row {
    border-bottom: 1px solid #ede8df;
}

.ly-yao-row:last-child { border-bottom: none; }

.ly-yao-row.ly-shi { background: var(--ly-shi-bg); }
.ly-yao-row.ly-ying { background: var(--ly-ying-bg); }

.ly-yao-row td {
    padding: 6px 8px;
    vertical-align: middle;
}

/* Colonne ligne hexagramme */
.ly-yao-line-cell {
    width: 52px;
    text-align: center;
    padding: 4px !important;
}

.ly-line-svg {
    display: block;
    margin: 0 auto;
}

/* Position */
.ly-yao-pos {
    width: 24px;
    font-weight: bold;
    color: var(--ly-text-light);
    font-size: 0.8em;
    text-align: center;
}

/* LiuQin */
.ly-liuqin-zh {
    font-size: 1.05em;
    color: var(--ly-accent);
    letter-spacing: .04em;
}

.ly-liuqin-fr {
    font-size: 0.72em;
    color: var(--ly-text-light);
}

/* Branche */
.ly-zhi-zh {
    font-size: 1.1em;
    letter-spacing: .04em;
}

.ly-zhi-detail {
    font-size: 0.72em;
    color: var(--ly-text-light);
}

.ly-zhi-elem {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.7em;
    margin-left: 3px;
}

/* LiuShou */
.ly-liushou-zh {
    font-size: 1em;
    letter-spacing: .03em;
}

.ly-liushou-fr {
    font-size: 0.72em;
    color: var(--ly-text-light);
}

/* Badges Shi/Ying */
.ly-badge {
    display: inline-block;
    font-size: 0.72em;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 3px;
    vertical-align: middle;
}

.ly-badge-shi  { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.ly-badge-ying { background: #d1e7dd; color: #0f5132; border: 1px solid #198754; }

/* Ligne mouvante */
.ly-moving-marker {
    color: var(--ly-moving-color);
    font-weight: bold;
    font-size: 0.85em;
}

.ly-yao-row.ly-moving-row {
    border-left: 3px solid var(--ly-moving-color);
}

/* KongWang */
.ly-kongwang-row td {
    opacity: .55;
}

.ly-kw-badge {
    display: inline-block;
    font-size: 0.7em;
    color: #6c757d;
    border: 1px dashed #adb5bd;
    border-radius: 3px;
    padding: 0 4px;
    margin-left: 4px;
}

/* ── Flèche transformation ── */
.ly-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 60px;
    font-size: 1.8em;
    color: var(--ly-moving-color);
}

/* ── Relations ── */
.ly-relations {
    margin-top: 16px;
    background: #fff;
    border: 1px solid var(--ly-border);
    border-radius: var(--ly-radius);
    padding: 12px 16px;
}

.ly-relations h4 {
    margin: 0 0 10px;
    font-size: 0.85em;
    color: var(--ly-text-light);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: normal;
}

.ly-relation-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.ly-relation-tag {
    font-size: 0.85em;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
    line-height: 1.4;
}

.ly-relation-tag.ly-he    { background: #e8f4fd; color: #0c63a4; border-color: #bee3f8; }
.ly-relation-tag.ly-chong { background: #fce8e8; color: #9b1c1c; border-color: #f8b4b4; }

/* ── Couleurs éléments ── */
/* Couleurs éléments — fond (badges, titres) */
.ly-elem-bois  { background: var(--ly-color-bois-bg,  #e8f5e9); color: var(--ly-color-bois,  #2e7d32); }
.ly-elem-feu   { background: var(--ly-color-feu-bg,   #ffebee); color: var(--ly-color-feu,   #c62828); }
.ly-elem-terre { background: var(--ly-color-terre-bg, #fff8e1); color: var(--ly-color-terre, #795548); }
.ly-elem-metal { background: var(--ly-color-metal-bg, #f5f5f5); color: var(--ly-color-metal, #424242); }
.ly-elem-eau   { background: var(--ly-color-eau-bg,   #e3f2fd); color: var(--ly-color-eau,   #1565c0); }

/* Couleurs éléments — texte inline (troncs/branches dans les lignes) */
.ly-zhi-colored.ly-elem-bois  { color: var(--ly-color-bois,  #2e7d32); background: none; }
.ly-zhi-colored.ly-elem-feu   { color: var(--ly-color-feu,   #c62828); background: none; }
.ly-zhi-colored.ly-elem-terre { color: var(--ly-color-terre, #795548); background: none; }
.ly-zhi-colored.ly-elem-metal { color: var(--ly-color-metal, #424242); background: none; }
.ly-zhi-colored.ly-elem-eau   { color: var(--ly-color-eau,   #1565c0); background: none; }

/* ── Erreur ── */
.ly-error {
    background: #fce8e8;
    border: 1px solid #f8b4b4;
    color: #9b1c1c;
    padding: 12px 16px;
    border-radius: var(--ly-radius);
    font-size: 0.9em;
    margin: 16px 24px;
}

/* ── Géolocalisation ──────────────────────────────────────────────────────── */
.ly-geo-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    margin-bottom: 10px;
    align-items: end;
}
@media (max-width: 600px) { .ly-geo-row { grid-template-columns: 1fr; } }

.ly-geocode-wrap { position: relative; }

.ly-city-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--ly-border);
    border-radius: var(--ly-radius);
    font-size: .92em;
    box-sizing: border-box;
}
.ly-city-search:focus { outline: none; border-color: var(--ly-accent); }

.ly-geocode-spinner { position: absolute; right: 8px; top: 8px; font-size: .85em; }

.ly-selected-city {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #f0f7f0;
    border: 1px solid #b2dfdb;
    border-radius: var(--ly-radius);
    font-size: .88em;
}
.ly-selected-name { flex: 1; color: var(--ly-text); }
.ly-clear-city { background: none; border: none; cursor: pointer; color: var(--ly-text-light); font-size: 1em; padding: 0 2px; }
.ly-clear-city:hover { color: var(--ly-accent); }

.ly-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 999;
    background: #fff;
    border: 1px solid var(--ly-border);
    border-radius: var(--ly-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    list-style: none;
    margin: 2px 0 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}
.ly-suggestions li {
    padding: .5rem .75rem;
    cursor: pointer;
    border-bottom: 1px solid #f0ece4;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: baseline;
}
.ly-suggestions li:last-child { border-bottom: none; }
.ly-suggestions li:hover, .ly-suggestions li.active { background: #faf0e6; }
.ly-sugg-name   { font-weight: 500; font-size: .9em; }
.ly-sugg-detail { font-size: .78em; color: var(--ly-text-light); }
.ly-sugg-coords { font-size: .72em; color: #aaa; margin-left: auto; }

.ly-field-tz { min-width: 140px; }
.ly-tz-display { display: inline-block; font-size: .88em; color: var(--ly-accent); padding: 7px 0; }

.ly-coords-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}
@media (max-width: 500px) { .ly-coords-row { grid-template-columns: 1fr 1fr; } }

/* ── Nouvelles colonnes tableau Yao ─────────────────────────────────────── */
.ly-col-liushou { min-width: 70px; }
.ly-col-canggan { min-width: 54px; text-align: center; }
.ly-col-liuqin  { min-width: 68px; }
.ly-col-zhi     { min-width: 58px; }
.ly-col-shiying { min-width: 36px; text-align: center; }

.ly-small-text { font-size: .7em; color: var(--ly-text-light); font-style: normal; line-height: 1.2; }

/* CangGan */
.ly-cg-item {
    display: inline-block;
    font-size: .95em;
    letter-spacing: .04em;
    color: #5c3d1e;
    background: #fef9f0;
    border: 1px solid #e8d5b0;
    border-radius: 3px;
    padding: 0 3px;
    margin: 1px;
}
.ly-cg-empty { color: #ccc; font-size: .85em; }

/* Ligne hexagramme plus visible */
.ly-yao-line-cell { width: 56px; text-align: center; padding: 4px 2px !important; }
.ly-line-svg { display: block; margin: 0 auto; }
.ly-moving-val { font-size: .72em; color: var(--ly-moving-color); font-weight: bold; line-height: 1; margin-top: 1px; }

/* Tableau plus compact pour Zhi Gua */
.ly-gua-block .ly-yao-table th { font-size: .68em; padding: 4px 6px; }
.ly-gua-block .ly-yao-table td { padding: 5px 6px; }

/* ── FuShén / FēiShén ────────────────────────────────────────────────────── */
.ly-fushen-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: 3px;
    padding: 2px 5px;
    background: #fef3cd;
    border: 1px solid #f0c040;
    border-radius: 3px;
    font-size: .75em;
}
.ly-fushen-lbl {
    color: #a06000;
    font-weight: bold;
    font-size: .9em;
}
.ly-fushen-zhi {
    font-size: 1.05em;
    color: #5c3a00;
    letter-spacing: .03em;
}
.ly-fushen-lq {
    color: #7a4f00;
    font-size: .85em;
}

.ly-fushen-section {
    margin-top: 14px;
    background: #fffbf0;
    border: 1px solid #f0c040;
    border-radius: var(--ly-radius);
    padding: 10px 16px;
}
.ly-fushen-section h4 {
    margin: 0 0 8px;
    font-size: .82em;
    color: #a06000;
    font-weight: normal;
    letter-spacing: .04em;
}
.ly-fushen-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.ly-fushen-recap {
    font-size: .85em;
    color: var(--ly-text);
    padding: 3px 10px;
    background: #fff8e0;
    border: 1px solid #e8c84a;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.ly-fushen-recap .ly-fushen-zhi {
    font-size: 1.1em;
    color: #5c3a00;
}

/* Relations ke et sheng */
.ly-relation-tag.ly-sheng { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.ly-relation-tag.ly-ke    { background: #fce4ec; color: #880e4f; border-color: #f48fb1; }

/* ── GuàShēn 卦身 ─────────────────────────────────────────────────────── */
.ly-guashen-badge {
    margin-left: 8px;
    font-size: .78em;
    color: #6b21a8;
    border: 1px solid #c084fc;
    border-radius: 3px;
    padding: 2px 8px;
    background: #faf5ff;
}
.ly-guashen-section {
    margin-top: 10px;
    background: #faf5ff;
    border: 1px solid #c084fc;
    border-radius: var(--ly-radius);
    padding: 8px 16px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.ly-guashen-section h4 {
    margin: 0;
    font-size: .82em;
    color: #6b21a8;
    font-weight: normal;
    letter-spacing: .04em;
}
.ly-guashen-tag {
    font-size: 1.1em;
    color: #6b21a8;
    letter-spacing: .04em;
}
.ly-guashen-tag em { font-size: .78em; color: #9333ea; margin-left: 4px; }

/* FuShen pinyin */
.ly-fushen-py { font-size: .72em; color: #92400e; font-style: italic; margin-left: 3px; }
.ly-fushen-lqzh { font-size: .85em; color: #7a4f00; }

/* ── ShénShà 神煞 — Étoiles auxiliaires ─────────────────────────────────── */
.ly-ss-badge {
    display: inline-block;
    font-size: .7em;
    font-family: var(--ly-font-zh, serif);
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 2px;
    vertical-align: middle;
    cursor: default;
    line-height: 1.4;
}
/* 天乙貴人 — Or : protection, noblesse */
.ly-ss-guiren {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fcd34d;
}
/* 驛馬 — Bleu : mouvement, voyage */
.ly-ss-yima {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}
/* 桃花 — Rose : romance, attraction */
.ly-ss-taohua {
    background: #fce7f3;
    color: #9d174d;
    border: 1px solid #f9a8d4;
}

/* ══════════════════════════════════════════════════════════════════
   Style technique — Rendu résultat
   ══════════════════════════════════════════════════════════════════ */

/* ── En-tête résultat ── */
.ly-result-tech {
    padding: 16px 20px;
    font-family: 'Noto Serif SC', 'SimSun', Georgia, serif;
    background: #fff;
    color: #000;
}

.ly-tech-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    border-bottom: 1px solid #000;
    padding-bottom: 6px;
}

.ly-tech-datetime {
    font-size: .82em;
    font-family: monospace;
    letter-spacing: .04em;
    color: #333;
}

/* ── BaZi ligne ── */
.ly-bazi-tech {
    font-size: .88em;
    margin-bottom: 14px;
    padding: 6px 0;
    border-bottom: 1px solid #ccc;
    display: flex;
    align-items: baseline;
    gap: 0;
    flex-wrap: wrap;
}

.ly-bazi-label {
    font-size: .7em;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #666;
    margin-right: 10px;
}

.ly-bazi-gz {
    font-size: var(--ly-size-bazi-gz, 1.1em);
    font-weight: bold;
    letter-spacing: .06em;
}

.ly-bazi-pillar-label {
    font-size: .65em;
    color: #777;
    margin-right: 12px;
    margin-left: 2px;
    vertical-align: super;
}

.ly-bazi-kw, .ly-bazi-gs {
    font-size: .78em;
    color: #555;
    border: 1px solid #bbb;
    padding: 1px 6px;
    border-radius: 2px;
    margin-left: 4px;
}

/* ── Conteneur des deux gua ── */
.ly-tech-row-guas {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.ly-tech-deux .ly-tech-gua {
    flex: 0 0 auto;
    min-width: 200px;
}

.ly-tech-arrow {
    font-size: 1.4em;
    padding-top: 40px;
    color: #333;
    flex-shrink: 0;
}

/* ── Gua ── */
.ly-tech-gua {
    flex: 0 0 auto;
}

.ly-tech-titre {
    margin-bottom: 8px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    border-bottom: 1px solid #000;
    padding-bottom: 4px;
}

.ly-tech-gua-num {
    font-size: .8em;
    color: #999;
    font-variant-numeric: tabular-nums;
    margin-right: 4px;
    align-self: center;
}

.ly-tech-gua-zh {
    font-size: var(--ly-size-gua-zh, 1.3em);
    font-weight: bold;
    letter-spacing: .05em;
}

.ly-tech-gua-py {
    font-size: .78em;
    color: #444;
    font-style: italic;
}

.ly-tech-gua-palais {
    font-size: .7em;
    color: #666;
    margin-left: auto;
    border: 1px solid #ccc;
    padding: 1px 5px;
}

/* ── Lignes ── */
.ly-tech-lignes {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Ben Gua : LiuShou | LiuQin+Zhi | SVG | mark | Shi/Ying */
.ly-tech-row-ben {
    display: grid;
    /* Base : LiuShou | LiuQin+Zhi | SVG | shiying */
    grid-template-columns: 2.8em max-content 88px 1.8em;
    align-items: center;
    gap: 0 var(--ly-col-gap, 10px);
    padding: 2px 0;
}
.ly-tech-row-ben.has-ss {
    grid-template-columns: 2.8em 2.4em max-content 88px 1.8em;
}
.ly-tech-row-ben.has-fus {
    grid-template-columns: 2.8em 7em max-content 88px 1.8em;
}
.ly-tech-row-ben.has-ss.has-fus {
    grid-template-columns: 2.8em 2.4em 7em max-content 88px 1.8em;
}

/* Zhi Gua : LiuQin+Zhi | SVG | mark | (vide) */
.ly-tech-row-zhi {
    display: grid;
    /* LiuQin+Zhi | SVG | shiying */
    grid-template-columns: max-content 88px 1.8em;
    align-items: center;
    gap: 0 var(--ly-col-gap, 10px);
    padding: 2px 0;
}

.ly-tech-row {
    display: grid;
    align-items: start;
    gap: 4px;
    padding: 2px 0;
}

.ly-tech-row.ly-tech-mov {
    background: #f7f7f7;
}

.ly-tech-row.ly-tech-shi-row {
    /* discret soulignement */
}

.ly-tech-liushou {
    font-size: var(--ly-size-liushou, .8em);
    color: #333;
    white-space: nowrap;
    text-align: right;
    padding-right: 4px;
}

.ly-tech-lqzhi {
    font-size: var(--ly-size-lqzhi, .82em);
    white-space: nowrap;
    letter-spacing: .02em;
    text-align: left;
    line-height: 1.5;
}

/* SVG ligne */
.ly-line-tech {
    display: block;
}

.ly-tech-movmark {
    display: none; /* marqueur intégré dans le SVG */
}

.ly-tech-shi {
    font-size: var(--ly-size-shiying, .75em);
    font-weight: bold;
    border: 1px solid #000;
    padding: 0 3px;
}

.ly-tech-ying {
    font-size: var(--ly-size-shiying, .75em);
    font-weight: bold;
    border: 1px solid #555;
    padding: 0 3px;
    color: #555;
}

.ly-tech-kw {
    font-size: .7em;
    color: #888;
    margin-left: 2px;
    text-decoration: line-through;
}

/* FuShén inline sur la même ligne */
.ly-tech-shensha-col {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: flex-start;
}

.ly-tech-fus-col {
    font-size: var(--ly-size-fus, .78em);
    color: #555;
    font-style: normal;
    white-space: nowrap;
    padding: 0 4px;
    text-align: left;
}

.ly-tech-fus-empty {
    /* vide — occupe l'espace mais invisible */
}

/* FuShen récap bas */
.ly-tech-bas {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed #bbb;
    font-size: var(--ly-size-bas, .75em);
    color: #555;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ly-tech-fus-recap {
    font-style: italic;
    color: #666;
}

/* ShénShà inline */
.ly-tech-ss {
    font-size: var(--ly-size-shiying, .75em);
    font-weight: bold;
    padding: 0 3px;
    border-radius: 2px;
    vertical-align: middle;
    border: 1px solid;
}

.ly-tech-ss.guiren { background: #fef9c3; color: #854d0e; border-color: #d97706; }
.ly-tech-ss.yima   { background: #dbeafe; color: #1e40af; border-color: #3b82f6; }
.ly-tech-ss.taohua { background: #fce7f3; color: #9d174d; border-color: #ec4899; }

/* Shiying en grid */
.ly-tech-shiying {
    text-align: center;
}

/* Bouton retour */
.ly-nouvelle-btn {
    background: none;
    border: 1px solid #000;
    padding: 3px 10px;
    font-size: .78em;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: .04em;
}

.ly-nouvelle-btn:hover {
    background: #000;
    color: #fff;
}

/* ── Texte de l'hexagramme ─────────────────────────────────────────────── */
.ly-hex-text {
    margin-top: var(--ly-hex-text-gap, 24px);
    padding-top: var(--ly-hex-text-gap, 20px);
    border-top: 1px solid #ddd;
}

.ly-hex-text-inner {
    font-family: var(--ly-font-serif, 'Noto Serif SC', serif);
    font-size: var(--ly-size-hex-text, .92em);
    line-height: 1.8;
    color: #333;
    max-width: 720px;
    text-align: justify;
}

.ly-hex-text-inner strong { font-weight: 700; }
.ly-hex-text-inner em     { font-style: italic; color: #555; }

/* ── Analyse structurelle ──────────────────────────────────────────────── */
.ly-struct {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.ly-struct-header {
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.ly-struct-title {
    font-weight: bold;
    font-size: .9em;
    color: #1e3a5f;
    letter-spacing: .03em;
}

.ly-struct-ref {
    font-size: .8em;
    color: #666;
}

.ly-struct-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--ly-size-struct-table, .82em);
}

.ly-struct-table th {
    background: #f0f4f8;
    color: #1e3a5f;
    font-weight: 600;
    padding: 4px 8px;
    text-align: left;
    border-bottom: 2px solid #c5d5e8;
    white-space: nowrap;
    font-size: 1em;   /* relatif au tableau — uniforme */
}

.ly-struct-table td {
    padding: 4px 8px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
    white-space: nowrap;
    font-size: 1em;   /* relatif au tableau — uniforme */
}

.ly-struct-table tr:hover td { background: #f8fbff; }

/* Force */
.ly-struct-strong { color: #2e7d32; font-weight: bold; }   /* vert maître — 旺/相 */
.ly-struct-mid    { color: #666; }
.ly-struct-weak   { color: #b71c1c; font-style: italic; }  /* rouge brique — 死/囚 */
.ly-struct-po {
    display: inline-block;
    color: #c62828;
    font-weight: 600;
    border: 1.5px solid #e53935;
    border-radius: 2px;
    padding: 0 3px;
    font-size: 1em;
}

/* Badges */
.ly-struct-badge {
    display: inline-block;
    font-size: .85em;   /* légèrement réduit pour ne pas déborder — relatif au tableau */
    font-weight: bold;
    padding: 0 3px;
    border-radius: 2px;
    margin-left: 3px;
    vertical-align: middle;
    border: 1px solid;
}
.ly-struct-badge.shi  { background: #fff3bf; color: #7a5900; border-color: #d4a017; }
.ly-struct-badge.ying { background: #e8f4fd; color: #1a5276; border-color: #5dade2; }
.ly-struct-badge.mov  { background: #fdebd0; color: #a04000; border-color: #e59866; }

/* État */
.ly-struct-kw {
    display: inline-block;
    font-size: 1em;
    color: #888;
    text-decoration: line-through;
    margin-right: 4px;
}

.ly-struct-dayimp {
    display: inline-block;
    font-size: 1em;
    padding: 0 4px;
    border-radius: 2px;
    font-weight: 600;
}
.ly-struct-dayimp.andong { background: #fdebd0; color: #a04000; }
.ly-struct-dayimp.ripo   { background: #fce4e4; color: #c92a2a; }

/* ── Toggle 简/繁 compact ───────────────────────────────────────────────── */
.ly-field-script {
    display: flex;
    gap: 2px;
    align-items: center;
    margin-left: auto;
}

.ly-script-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px 7px;
    font-size: .8em;
    cursor: pointer;
    font-family: inherit;
    color: #666;
    line-height: 1.4;
}

.ly-script-btn.active {
    background: var(--ly-accent, #8b1a1a);
    border-color: var(--ly-accent, #8b1a1a);
    color: #fff;
}

.ly-script-btn:hover:not(.active) {
    border-color: #999;
    color: #333;
}

/* ── Compléments analyse structurelle ──────────────────────────────────── */

/* Badge 身 (GuàShēn) — aligné avec 世 et 應 */
.ly-struct-badge.shen {
    background: #f3e5f5;
    color:      #7b1fa2;
    border-color: #ce93d8;
}

/* Info-ligne du header struct */
.ly-struct-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Guashen badge renforcé (écrase le style générique) */
.ly-struct-info .ly-guashen-badge {
    background: #f3e5f5;
    color: #7b1fa2;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
    border: 1px solid #ce93d8;
    font-size: .82em;
}

/* Guashen absent */
.ly-guashen-badge.ly-guashen-absent {
    color: #aaa;
    background: #f5f5f5;
    border-color: #ddd;
    font-weight: normal;
}

/* Titre section relations */
.ly-relations-title {
    font-size: .85em;
    color: #666;
    margin: 0 0 8px;
    font-weight: 500;
}

/* Colonne Yao — alignement badges sur une seule ligne */
.ly-struct-col-yao {
    white-space: nowrap;
    padding: 4px 8px;
}
.ly-struct-col-yao .ly-struct-badge {
    margin-left: 3px;
    vertical-align: middle;
}

/* Ligne mouvante — fond très léger pour la distinguer */
.ly-struct-row-moving td {
    background: #fffbf0;
}
.ly-struct-row-moving td:first-child {
    font-weight: 600;
}

/* Relation impliquant la ligne Shi — bordure renforcée */
.ly-relation-tag.ly-relation-shi {
    border-width: 2px;
    font-weight: 600;
}

/* ── Douze stades de vie (十二運) ──────────────────────────────────────── */
.ly-stage-life {
    font-size: 1em;
    color: #555;
    text-align: center;
    white-space: nowrap;
}
/* 長生 / 帝旺 — vitalité haute */
.ly-stage-life.ly-stage-pos {
    color: #2e7d32;
    font-weight: bold;
}
/* 墓 / 絕 — stades critiques */
.ly-stage-life.ly-stage-neg {
    color: #6d4c41;
    background: #efebe9;
    border-radius: 3px;
    padding: 0 4px;
    font-weight: 600;
}

/* ── Fù Shén (伏神) — colonne avec contexte FēiShén ──────────────────── */

/* Colonne FùShén — affiche FēiShén→FùShén sur les lignes concernées */
.ly-tech-fushen-col {
    vertical-align: middle;
    white-space: nowrap;
}
/* Paire FēiShén → FùShén */
.ly-fushen-pair {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 1em;
}
.ly-feishen-ref {
    color: #aaa;          /* discret — c'est la "maison" */
    font-size: 1em;
}
.ly-fushen-arrow {
    color: #bbb;
    font-size: .85em;
}
.ly-fushen-inline {
    font-weight: bold;
    color: var(--ly-accent);
    font-size: 1em;
}
/* Ligne sans FùShén */
.ly-fushen-empty {
    color: #ddd;
    font-size: 1em;
}

/* ── Sélecteur Yòng Shén (用神) ────────────────────────────────────────── */
.ly-yongshen-section {
    margin-top: 20px;
    border: 1px solid #e0e8f0;
    border-radius: 6px;
    padding: 16px;
    background: #fafcff;
}
.ly-yongshen-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.ly-yongshen-title {
    font-weight: 700;
    font-size: 1em;
    color: #1e3a5f;
}
.ly-yongshen-hint {
    font-size: .8em;
    color: #999;
    font-style: italic;
}
.ly-yongshen-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.ly-ys-btn {
    padding: 5px 14px;
    border: 1px solid #c5d5e8;
    border-radius: 20px;
    background: #fff;
    color: #1e3a5f;
    font-size: .88em;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ly-ys-btn:hover { background: #e8f0fa; }
.ly-ys-btn.active {
    background: var(--ly-accent, #8b1a1a);
    color: #fff;
    border-color: var(--ly-accent, #8b1a1a);
}
.ly-ys-btn-moving {
    border-color: #e59866;
    color: #a04000;
}
.ly-ys-btn-fushen {
    border-style: dashed;
    color: #7b1fa2;
    border-color: #ce93d8;
    background: #fdf4ff;
}
.ly-ys-count {
    background: var(--ly-accent, #8b1a1a);
    color: #fff;
    border-radius: 10px;
    font-size: .72em;
    padding: 0 5px;
    line-height: 1.5;
}
.ly-ys-btn.active .ly-ys-count {
    background: rgba(255,255,255,.3);
}

/* Zone diagnostic */
.ly-yongshen-diag {
    border-top: 1px solid #e0e8f0;
    padding-top: 14px;
    margin-top: 4px;
}
.ly-ys-diag-inner {}
.ly-ys-diag-title {
    font-size: .95em;
    font-weight: 700;
    color: #1e3a5f;
    margin: 0 0 10px;
}
.ly-ys-diag-block {
    margin-bottom: 10px;
}
.ly-ys-diag-label {
    display: block;
    font-size: .78em;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 4px;
}
.ly-ys-diag-block p {
    margin: 0;
    font-size: .88em;
    line-height: 1.6;
}

/* Alertes */
.ly-ys-alerts { display: flex; flex-direction: column; gap: 6px; }
.ly-ys-alert {
    display: block;
    font-size: .85em;
    padding: 5px 10px;
    border-radius: 4px;
    line-height: 1.5;
}
.ly-ys-alert.alert-po     { background: #fff0f0; color: #c62828; border-left: 3px solid #e53935; }
.ly-ys-alert.alert-kw     { background: #fff8e1; color: #f57f17; border-left: 3px solid #ffca28; }
.ly-ys-alert.alert-andong { background: #fff3e0; color: #a04000; border-left: 3px solid #e59866; }
.ly-ys-alert.alert-he     { background: #e8f5e9; color: #2e7d32; border-left: 3px solid #66bb6a; }

/* Liste relations filtrées */
.ly-ys-rel-list {
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.ly-ys-rel-list li {
    font-size: .85em;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
}
.ly-ys-rel-list .ly-relation-tag {
    flex-shrink: 0;
}

/* Boutons de choix en cas de doublon */
.ly-ys-choice-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.ly-ys-choice-btn {
    padding: 6px 16px;
    border: 1px solid #c5d5e8;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: .88em;
    color: #1e3a5f;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.ly-ys-choice-btn small {
    font-size: .78em;
    color: #a04000;
    margin-top: 2px;
}
.ly-ys-choice-btn:hover { background: #e8f0fa; }

/* ── Relations avancées : 三合 / 半合 / 刑 ─────────────────────────────── */
.ly-relation-tag.ly-sanhe {
    background: #fffde7;
    color: #f57f17;
    border-color: #ffca28;
    font-weight: 700;
}
.ly-relation-tag.ly-banhe {
    background: #fff8e1;
    color: #ff8f00;
    border-color: #ffe082;
}
.ly-relation-tag.ly-xing {
    background: #fce4ec;
    color: #880e4f;
    border-color: #f48fb1;
    font-weight: 600;
}

/* Bloc sanhe dans le diagnostic */
.ly-ys-sanhe-block {
    border-left: 3px solid #ffca28;
    padding-left: 10px;
}
.ly-ys-alert.alert-sanhe {
    background: #fffde7;
    color: #795500;
    border-left: 3px solid #ffca28;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ly-ys-alert.alert-xing {
    background: #fce4ec;
    color: #880e4f;
    border-left: 3px solid #f48fb1;
}

/* ── 變化 Biàn Huà — Mutation ──────────────────────────────────────────── */
.ly-ys-mutation-block {
    border-left: 3px solid #7b1fa2;
    padding-left: 10px;
}
.ly-ys-mutation-synthesis {
    font-size: .88em;
    margin: 0 0 8px;
    line-height: 1.6;
}
/* 回頭克 — rouge danger */
.ly-ys-alert.alert-huitouke {
    background: #fce4ec;
    color: #880e4f;
    border-left: 3px solid #e91e63;
}
/* 回頭生 — vert succès */
.ly-ys-alert.alert-huitousheng {
    background: #e8f5e9;
    color: #1b5e20;
    border-left: 3px solid #43a047;
}
/* 化進 — bleu progression */
.ly-ys-alert.alert-huajin {
    background: #e3f2fd;
    color: #0d47a1;
    border-left: 3px solid #1976d2;
}
/* 化退 — gris régression */
.ly-ys-alert.alert-huatui {
    background: #f5f5f5;
    color: #616161;
    border-left: 3px solid #9e9e9e;
}

/* ── Boutons segmentés (type d'heure, calendrier) ───────────────────────── */
.ly-form-seg-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.ly-field-seg {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ly-field-seg label {
    font-size: .82em;
    color: var(--ly-text-light, #666);
    font-weight: 500;
}

.ly-seg-group {
    display: flex;
    gap: 2px;
}

.ly-seg-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 4px 12px;
    font-size: .85em;
    cursor: pointer;
    font-family: inherit;
    color: #555;
    line-height: 1.4;
    white-space: nowrap;
    transition: background .12s, color .12s, border-color .12s;
}

.ly-seg-btn.active {
    background: var(--ly-accent, #8b1a1a);
    border-color: var(--ly-accent, #8b1a1a);
    color: #fff;
}

.ly-seg-btn:hover:not(.active) {
    border-color: #999;
    color: #333;
}

/* ── Vitalité Dynamique (🧬 十二運 exégèse) ────────────────────────────── */
.ly-ys-stage-block {
    border-left: 3px solid #ccc;
    padding-left: 10px;
}
/* Stades fastes : 長生, 冠帶, 臨官, 帝旺 */
.ly-ys-stage-block.stage-pos {
    border-color: #c9a84c;
    background: #fffdf0;
}
/* Stades neutres : 沐浴, 衰, 胎, 養 */
.ly-ys-stage-block.stage-mid {
    border-color: #bdbdbd;
    background: #fafafa;
}
/* Stades négatifs : 病, 死, 絕 */
.ly-ys-stage-block.stage-neg {
    border-color: #6d4c41;
    background: #efebe9;
}
/* 墓 — spécial : couleur propre, peut être libéré */
.ly-ys-stage-block.stage-neg-mou {
    border-color: #4e342e;
    background: #f3e5dc;
}
.ly-ys-stage-name {
    font-size: 1em;
    font-weight: 700;
    margin: 2px 0 4px;
    color: inherit;
}
.ly-ys-stage-desc {
    font-size: .85em;
    line-height: 1.6;
    margin: 0;
    color: #444;
}

/* ── Six Animaux — Nature du Sujet ─────────────────────────────────────── */
.ly-ys-animal-block {
    border-left: 3px solid #ccc;
    padding-left: 10px;
}
.ly-ys-animal-name {
    font-size: 1em;
    font-weight: 700;
    margin: 2px 0 4px;
}
.ly-ys-animal-fr {
    font-size: .82em;
    font-weight: 400;
    color: #888;
    margin-left: 6px;
}
/* Couleurs par animal */
.animal-dragon  { border-color: #2e7d32; background: #f1f8f1; } /* vert — faste     */
.animal-zhuque  { border-color: #c62828; background: #fff5f5; } /* rouge — feu       */
.animal-gouchen { border-color: #795548; background: #f5f0ec; } /* brun — terre      */
.animal-tengshe { border-color: #6a1b9a; background: #f8f0ff; } /* violet — mystère  */
.animal-baihu   { border-color: #424242; background: #f5f5f5; } /* noir — force      */
.animal-xuanwu  { border-color: #1565c0; background: #f0f4ff; } /* bleu — eau/secret */
