/* واجهة المعلم: تدفق عمودي واحد في عمود قراءة ضيق، بنفس هوية القصة */
.ap { position: relative; z-index: 1; max-width: 46rem; margin-inline: auto; padding-block: 2.4rem 4rem; min-width: 0; }
.ap-brand { text-align: center; margin-bottom: 1.8rem; }
.ap-brand h1 { font-family: var(--f-display); color: var(--gold); font-size: clamp(2.4rem, 9vw, 3.6rem); margin: 0; line-height: 1.4; text-shadow: 0 0 40px rgba(203,164,90,.22); }
.ap-brand p { font-family: var(--f-ui); color: var(--ink-dim); font-size: .92rem; margin: .2rem 0 0; line-height: 1.8; }
.ap-tabs { display: flex; justify-content: center; gap: .5rem; margin-bottom: 2rem; flex-wrap: wrap; }
.ap-tab { font-family: var(--f-ui); font-size: .95rem; color: var(--ink-dim); background: transparent; border: 1px solid transparent; border-bottom-color: var(--gold-line); padding: .6rem 1.3rem; cursor: pointer; min-height: 2.6rem; }
.ap-tab[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }
.ap-tab:focus-visible, .ap-field input:focus-visible, .ap-field textarea:focus-visible, .ap-field select:focus-visible, .ap summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.ap-card { background: var(--panel); border: 1px solid var(--gold-line); border-radius: 3px; padding: clamp(1rem, 4vw, 1.8rem); margin-bottom: 1.2rem; }
.ap-card h2, .ap-card h3 { font-family: var(--f-display); font-weight: 400; color: var(--gold); margin: 0 0 1rem; line-height: 1.5; font-size: 1.5rem; }
.ap-card h3 { font-size: 1.25rem; }
.ap-field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.1rem; min-width: 0; }
.ap-field > label, .ap-field > .lbl { font-family: var(--f-ui); font-size: .88rem; color: var(--ink-dim); }
.ap-field input, .ap-field textarea, .ap-field select { font-family: var(--f-body); font-size: 1.15rem; line-height: 1.8; color: var(--ink); background: var(--bg);
  border: 1px solid var(--gold-line); border-radius: 2px; padding: .6rem .8rem; width: 100%; min-width: 0; }
.ap-field textarea { min-height: 5.5rem; resize: vertical; }
.ap-field textarea.tall { min-height: 14rem; }
.ap-field small { font-family: var(--f-ui); font-size: .78rem; color: var(--ink-dim); line-height: 1.7; }
.ap-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; }
.ap-radios { display: flex; flex-wrap: wrap; gap: .6rem; }
.ap-radios label { font-family: var(--f-ui); font-size: .92rem; color: var(--ink); border: 1px solid var(--gold-line); border-radius: 2px; padding: .55rem 1rem; cursor: pointer; display: flex; gap: .5rem; align-items: center; }
.ap-radios input { width: auto; accent-color: var(--gold); }
.ap-btns { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.ap-status { font-family: var(--f-ui); font-size: .9rem; line-height: 1.8; color: var(--ink-dim); margin: 1rem 0 0; }
.ap-status.err { color: var(--danger); }
.ap-pulse { display: inline-block; width: .55rem; height: .55rem; background: var(--gold); border-radius: 50%; margin-inline-end: .5rem; animation: ap-p 1.2s ease-in-out infinite; }
@keyframes ap-p { 50% { opacity: .25; } }
.ap details { border: 1px solid var(--gold-line); border-radius: 3px; margin-bottom: 1rem; background: var(--panel); }
.ap summary { cursor: pointer; padding: .9rem 1.2rem; font-family: var(--f-display); font-size: 1.3rem; color: var(--gold); line-height: 1.6; }
.ap details > .body { padding: .4rem 1.2rem 1.2rem; }
.ap-opt { border-top: 1px solid var(--gold-line); padding-top: 1rem; margin-top: 1rem; }
.ap-opt .lbl b { color: var(--gold); font-weight: 500; }
.ap-check { display: flex; gap: .5rem; align-items: center; font-family: var(--f-ui); font-size: .88rem; color: var(--ink-dim); }
.ap-check input { width: auto; accent-color: var(--gold); }
.ap-list { display: flex; flex-direction: column; gap: .9rem; }
.ap-item { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; border: 1px solid var(--gold-line); border-radius: 3px; padding: 1rem 1.2rem; background: var(--panel); }
.ap-item .t { font-family: var(--f-display); font-size: 1.4rem; color: var(--ink); line-height: 1.5; }
.ap-item .m { font-family: var(--f-ui); font-size: .8rem; color: var(--ink-dim); }
.ap-item .info { min-width: 0; flex: 1 1 14rem; }
.ap-badge { font-family: var(--f-ui); font-size: .72rem; border: 1px solid var(--gold-line); color: var(--ink-dim); border-radius: 2px; padding: .1rem .5rem; margin-inline-start: .5rem; }
.ap-badge.on { color: #1a1209; background: var(--gold); border-color: var(--gold); }
.ap-small { font-family: var(--f-ui); font-size: .85rem; padding: .5rem 1rem; min-height: 2.4rem; }
.ap-empty { text-align: center; font-family: var(--f-ui); color: var(--ink-dim); line-height: 2; padding: 2rem 0; }
.ap-link { font-family: var(--f-ui); font-size: .85rem; color: var(--ink); background: var(--bg); border: 1px solid var(--gold-line); padding: .6rem .8rem; border-radius: 2px; overflow-wrap: anywhere; direction: ltr; text-align: left; margin: .6rem 0 0; }
.ap-topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 15; background: var(--bg); border-bottom: 1px solid var(--gold-line); padding-block: .7rem; margin-bottom: 1.4rem; display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.th-sw { display: flex; flex-wrap: wrap; gap: .5rem; }
.th-chip { font-family: var(--f-ui); font-size: .88rem; color: var(--ink); background: transparent; border: 1px solid var(--gold-line); border-radius: 2px; padding: .5rem .9rem; min-height: 2.4rem; cursor: pointer; display: inline-flex; align-items: center; gap: .5rem; }
.th-chip[aria-pressed="true"] { border-color: var(--gold); background: var(--panel-hi); color: var(--gold); }
.th-chip:focus-visible, .th-color:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.th-dot { width: .9rem; height: .9rem; border-radius: 50%; display: inline-block; border: 1px solid rgba(255,255,255,.25); }
.th-rainbow { background: conic-gradient(#e0605a, #e0b45a, #7bc17b, #5aa9e0, #a58bdc, #e0605a); }
.th-color { width: 100%; height: 2.6rem; padding: 0; border: 1px solid var(--gold-line); background: transparent; cursor: pointer; }
.th-prev { margin-top: 1rem; padding: 1.2rem; border: 1px solid var(--gold-line); border-radius: 3px; background: var(--bg); color: var(--ink); background-image: radial-gradient(ellipse 80% 70% at 50% 0%, var(--bg-glow), transparent 70%); }
.th-prev .th-t { font-family: var(--f-display); color: var(--gold); font-size: 1.6rem; margin: 0 0 .4rem; }
.th-prev .th-p { font-size: 1.05rem; line-height: 1.9; margin: 0 0 .9rem; color: var(--ink); }
.th-row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.th-o { font-family: var(--f-ui); font-size: .9rem; color: var(--ink); border: 1px solid var(--gold-line); background: var(--panel); border-radius: 2px; padding: .5rem 1rem; }
.th-b { font-family: var(--f-ui); font-size: .9rem; font-weight: 500; color: var(--on-accent); background: var(--gold); border-radius: 2px; padding: .5rem 1.2rem; }
.ap-playbar button { background: rgba(19,14,10,.88); color: #eadfca; border: 1px solid rgba(203,164,90,.4); }
.ap-playbar { position: fixed; top: env(safe-area-inset-top, 0px); inset-inline-start: 0; z-index: 30; padding: .5rem max(16px, env(safe-area-inset-left, 0px)); }

.hm { position: relative; z-index: 1; max-width: 52rem; margin-inline: auto; padding-block: 3.5rem 3rem; min-width: 0; }
.hm-sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.hm-brand { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: clamp(1.2rem, 4vw, 2.6rem); text-align: center; padding-top: .6rem; }
.hm-logo { display: block; width: clamp(5.2rem, 17vw, 7.4rem); height: auto; aspect-ratio: 1; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 60px rgba(203,164,90,.28), 0 0 0 1px var(--gold-line); }
.hm-txt { flex: 1 1 18rem; min-width: 0; }
@media (min-width: 760px) { .hm-brand { flex-wrap: nowrap; text-align: start; } .hm-brand .lead { margin-inline: 0; } }
.hm-moon { width: 3.4rem; height: 3.4rem; margin: 0 auto 1.2rem; border-radius: 50%; box-shadow: inset -.95rem .4rem 0 0 var(--gold); filter: drop-shadow(0 0 14px rgba(203,164,90,.45)); transform: rotate(-18deg); }
.hm-brand h1 { font-family: var(--f-display); font-weight: 700; color: var(--gold); font-size: clamp(3.8rem, 17vw, 6.8rem); line-height: 1.3; margin: 0; text-shadow: 0 0 50px rgba(203,164,90,.35); }
.hm-brand .tag { font-family: var(--f-display); font-size: clamp(1.25rem, 5vw, 1.7rem); color: var(--ink); margin: .3rem 0 0; line-height: 1.8; }
.hm-brand .quote { font-family: var(--f-display); font-size: clamp(1.35rem, 5.2vw, 1.9rem); color: var(--gold); margin: 1rem 0 0; line-height: 1.8; opacity: .95; }
.hm-icon { width: 2.6rem; height: 2.6rem; color: var(--gold); margin-bottom: .2rem; filter: drop-shadow(0 0 10px rgba(203,164,90,.3)); }
.hm-path { transition: border-color .3s, background .3s, box-shadow .3s, transform .3s; border-color: rgba(203,164,90,.38); }
.hm-path:hover, .hm-path:focus-visible { box-shadow: 0 0 34px rgba(203,164,90,.14), inset 0 0 0 1px rgba(203,164,90,.25); transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .hm-path { transition: none; } .hm-path:hover, .hm-path:focus-visible { transform: none; } }
.hm-brand .lead { font-family: var(--f-ui); font-size: .95rem; line-height: 2; color: var(--ink-dim); margin: .9rem auto 0; max-width: 30rem; }
.hm-path { background: rgba(28,21,16,.78); backdrop-filter: blur(3px); }
.hm-paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1.2rem; margin-top: 2.4rem; }
.hm-path { display: flex; flex-direction: column; gap: .9rem; text-align: start; font: inherit; color: inherit; cursor: pointer; background: var(--panel); border: 1px solid var(--gold-line); border-radius: 3px; padding: 1.8rem clamp(1.1rem, 4vw, 1.9rem); min-width: 0; transition: border-color .25s, background .25s; }
.hm-path:hover { border-color: var(--gold); background: var(--panel-hi, var(--panel)); }
.hm-path:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.hm-path .k { font-family: var(--f-ui); font-size: .78rem; letter-spacing: .14em; color: var(--ink-dim); }
.hm-path .n { font-family: var(--f-display); color: var(--gold); font-size: clamp(1.9rem, 6vw, 2.5rem); line-height: 1.5; }
.hm-path .d { font-size: 1.25rem; line-height: 2; }
.hm-path .g { font-family: var(--f-ui); font-size: .95rem; font-weight: 500; color: #1a1209; background: var(--gold); border-radius: 2px; padding: .7rem 1.4rem; align-self: flex-start; margin-top: auto; }
.st-wrap { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--bg); }
.st-bar { flex: 0 0 auto; padding: .5rem max(16px, env(safe-area-inset-left, 0px)); padding-top: max(.5rem, env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--gold-line); }
.st-frame { flex: 1 1 auto; width: 100%; border: 0; background: var(--bg); }

/* سطر الاعتزاز بصاحبة الفكرة: هادئ ولا ينافس الشعار */
.hm-credit { font-family: var(--f-ui); font-size: .92rem; letter-spacing: .04em; color: var(--ink-dim); text-align: center; margin: 2.6rem auto 0; padding-top: 1.1rem; position: relative; max-width: 22rem; }
.hm-credit::before { content: ""; position: absolute; top: 0; left: 50%; width: 3.6rem; height: 1px; transform: translateX(-50%); background: var(--gold-line); }

/* ---- المرحلة ٢: نموذج المعلم ---- */
.ap-sum{display:grid;grid-template-columns:max-content 1fr;gap:.5rem 1rem;margin:1rem 0;font-size:.95rem}
.ap-sum dt{color:var(--gold,#cba45a);font-weight:700}
.ap-sum dd{margin:0;overflow-wrap:anywhere}
.ap-tpl{display:flex;flex-wrap:wrap;gap:.6rem;align-items:center;margin:.4rem 0}
.ap-tpl select{flex:1 1 14rem;min-width:0}
.ap-stop{margin-top:1rem;padding-top:.8rem;border-top:1px dashed rgba(203,164,90,.35)}
.ap-ai{margin-top:1rem}
#f-out h3{margin:1.2rem 0 .5rem;font-size:1.05rem}
@media (max-width:520px){.ap-sum{grid-template-columns:1fr}.ap-sum dt{margin-top:.4rem}}

/* ---- مكتبة الرسومات ---- */
.ap-art{margin:.8rem 0}
.ap-art-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(8.5rem,1fr));gap:.6rem;margin:.6rem 0}
.ap-art-item{padding:0;border:1px solid var(--gold-line,rgba(203,164,90,.35));background:transparent;color:inherit;cursor:pointer;display:flex;flex-direction:column;border-radius:3px;overflow:hidden;font:inherit}
.ap-art-item svg{display:block;width:100%;height:auto;aspect-ratio:3/2}
.ap-art-item span{font-size:.78rem;padding:.3rem .4rem;text-align:center}
.ap-art-item:hover,.ap-art-item:focus-visible,.ap-art-item[aria-pressed="true"]{outline:2px solid var(--gold,#cba45a);outline-offset:-2px}
