body {
    font-family: Arial, sans-serif;
    padding: 25px;
    line-height: 1.6;
    background: #fafafa;
    color: #222;
}

textarea {
    width: 100%;
    height: 120px;
    font-size: 28px;
    direction: rtl;
    font-family: "Amiri", serif;
    padding: 10px;
}

.arabic {
    font-size: 42px;
    direction: rtl;
    font-family: "Amiri", serif;
    margin: 20px 0;
    background: #fff;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.controls {
    background: #fff;
    border: 1px solid #ddd;
    padding: 14px;
    border-radius: 8px;
    margin-top: 15px;
}

.ayah-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    align-items: end;
    margin: 0 0 14px 0;
}

.ayah-picker label {
    display: block;
    font-size: 14px;
    font-weight: bold;
}

.ayah-picker select {
    min-width: 150px;
    padding: 7px;
    border: 1px solid #bbb;
    border-radius: 6px;
    background: #fff;
}

.ayah-picker .selected-ref {
    font-size: 14px;
    color: #555;
    padding-bottom: 8px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 6px 12px;
}

.checkbox-grid label {
    display: block;
    font-size: 14px;
}

/* Main rule colors */
.qalqalah { color: blue; font-weight: normal; }
.hams { color: green; font-weight: normal; }
.jahr { color: #7b1fa2; font-weight: normal; }

.leen { color: green; }
.madd-tabii { color: red; }
.madd-muttasil { color: crimson; font-weight: normal; }
.madd-munfasil { color: #d35400; font-weight: normal; }

.silah-sughra { color: purple; }
.silah-kubra { color: darkmagenta; font-weight: normal; }

.itbaq { color: #8b0000; font-weight: normal; }
.infitah { color: #555; }
.istilaa { color: orange; font-weight: normal; }
.istifal { color: #607d8b; font-weight: normal; }
.idhlaq { color: #0066cc; }
.asmat { color: #6d4c41; }
.shiddah { color: #c2185b; }
.tawassut { color: #5e35b1; }
.rakhawah { color: #00897b; }

.lips { color: #b000b5; }
.khayshum { color: #795548; }
.tongue { color: #4444aa; }
.jawf { color: red; }
.halaqiyyah { color: #cc0000; }

.harakat { color: #6f42c1; font-weight: normal; }

.mutamathilayn { color: #0d6efd; font-weight: normal; }
.mutajanisayn { color: #198754; font-weight: normal; }
.mutaqaribayn { color: #fd7e14; font-weight: normal; }
.mutabaidayn { color: #6c757d; font-weight: normal; }

/* Noon sākinah / tanwīn rule colors */
.ikhfa { color: green; font-weight: normal; }
.izhar { color: #8a6d00; font-weight: normal; }
.idgham-with-ghunnah { color: #0b7285; font-weight: normal; }
.idgham-without-ghunnah { color: #5f3dc4; font-weight: normal; }
.iqlab { color: #d63384; font-weight: normal; }

.noon-bi-ghunnah {
    color: #0a7a3d;
    font-weight: bold;
    text-decoration: underline;
}

.raa-mufakhkhamah,
.tw-raa-mufakhkhamah {
    color: #e67e22;
    font-weight: normal;
    background: transparent;
}

.raa-muraqqaqah,
.tw-raa-muraqqaqah {
    color: #2c7be5;
    font-weight: normal;
    background: transparent;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 20px;
    background: #fff;
}

th, td {
    border: 1px solid #ccc;
    padding: 10px;
    vertical-align: top;
}

th {
    background: #f3f3f3;
}

.word-cell {
    font-size: 32px;
    direction: rtl;
    font-family: "Amiri", serif;
    white-space: nowrap;
}

.rules-cell {
    font-weight: normal;
}

.rule-pill {
    display: inline-block;
    margin: 0 6px 6px 0;
    font-weight: normal;
}

.comment-block {
    margin-bottom: 8px;
}

.comment-rule {
    font-weight: normal;
}

.comment-text {
    margin-left: 12px;
}

.small-note {
    color: #666;
    font-size: 14px;
}

/* Madd Lāzim */
.madd-lazim,
.tw-madd-lazim {
    color: #b00020;
    font-weight: 700;
    background: transparent;
}

.madd-lazim-letter,
.tw-madd-lazim-letter {
    color: #b00020;
    font-weight: 800;
    text-decoration: overline;
}

/* Ḥurūf Muqaṭṭaʿāt */
.huroof-muqattaat,
.huruf-muqattaat,
.tw-huroof-muqattaat,
.tw-huruf-muqattaat {
    color: #7b1fa2;
    font-weight: 700;
    background: transparent;
}

/* Mīm Sākinah */
.ikhfa-shafawi,
.tw-ikhfa-shafawi{
    color: #198754;
    font-weight: 700;
    background: transparent;
}

.idgham-shafawi,
.tw-idgham-shafawi {
    color: #0d6efd;
    font-weight: 700;
    background: transparent;
}

.tw-izhar-shafawi {
    color: #6f42c1;
    font-weight: 700;
    background: transparent;
}

.meem-sakinah,
.tw-meem-sakinah {
    font-weight: 700;
    background: transparent;
}

.ikhfa-shafawi {
    color: #198754;
    font-weight: normal;
}

.idgham-shafawi {
    color: #0d6efd;
    font-weight: normal;
}

.izhar-shafawi {
    color: #6f42c1;
    font-weight: normal;
}

.huroof-muqattaat {
    color: #7b1fa2;
    font-weight: normal;
}

.madd-lazim {
    color: #b00020;
    font-weight: normal;
}

/* Small learner labels / badges */
.rule-badge.madd-lazim {
    color: #b00020;
    border-color: #b00020;
}

.rule-badge.huroof-muqattaat,
.rule-badge.huruf-muqattaat {
    color: #7b1fa2;
    border-color: #7b1fa2;
}

.rule-badge.ikhfa-shafawi {
    color: #198754;
    border-color: #198754;
}

.rule-badge.idgham-shafawi {
    color: #0d6efd;
    border-color: #0d6efd;
}

.rule-badge.izhar-shafawi {
    color: #6f42c1;
    border-color: #6f42c1;
}