/* خطّي — handwriting converter */

:root{
  --bg:#f6f1e7;
  --card:#fffdf9;
  --paper:#fffdf7;
  --ink:#15171c;
  --muted:#6f6b60;
  --faint:#9a9384;
  --line:#e5dccb;
  --line-soft:#efe8da;
  --accent:#2a4b8d;
  --accent-soft:#e7eefb;
  --radius:16px;
  --shadow:0 1px 2px rgba(40,32,18,.05), 0 8px 24px rgba(40,32,18,.06);
}

*{box-sizing:border-box}
html,body{margin:0}
body{
  background:
    radial-gradient(1200px 600px at 80% -10%, #fffaf0 0%, rgba(255,250,240,0) 60%),
    var(--bg);
  color:var(--ink);
  font-family:"IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
  padding-bottom:78px;
}
html[dir="ltr"] body{padding-bottom:0}
button{font-family:inherit}

/* top bar */
.topbar{
  position:sticky; top:0; z-index:30;
  background:rgba(246,241,231,.86);
  backdrop-filter:blur(10px) saturate(120%);
  border-bottom:1px solid var(--line);
}
.topbar-in{
  max-width:1200px; margin:0 auto; padding:10px 18px;
  display:flex; align-items:center; gap:12px;
}
.brand{display:flex; align-items:center; gap:10px; text-decoration:none; color:inherit}
.logo{
  width:38px; height:38px; border-radius:12px; flex:0 0 auto;
  background:linear-gradient(160deg,#22262e,#0f1116);
  color:#fdf8ec; display:grid; place-items:center;
  font-family:"Aref Ruqaa", serif; font-size:23px; line-height:1;
  box-shadow:0 4px 12px rgba(20,18,12,.22);
}
.brand-txt{display:grid; line-height:1.15}
.brand-txt b{font-size:18px; letter-spacing:.2px}
.brand-txt small{font-size:12px; color:var(--muted)}
.spacer{flex:1}
.lang{
  border:1px solid var(--line); background:#fffdf9; color:var(--ink);
  border-radius:10px; padding:7px 13px; font-size:13px; font-weight:600;
  cursor:pointer; transition:.15s;
}
.lang:hover{background:#fff; border-color:#d6cbb6}

/* layout */
.app{
  max-width:1200px; margin:0 auto; padding:18px;
  display:grid; grid-template-columns:376px minmax(0,1fr); gap:20px; align-items:start;
}
@media (max-width:920px){
  .app{grid-template-columns:1fr; padding:12px; gap:14px}
}

/* panel */
.panel{display:grid; gap:12px}
@media (min-width:921px){
  .panel{position:sticky; top:70px; max-height:calc(100vh - 86px); overflow:auto; padding-inline-end:2px}
  .panel::-webkit-scrollbar{width:8px}
  .panel::-webkit-scrollbar-thumb{background:#e2d8c6; border-radius:8px}
}
.card{
  background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
  padding:13px 14px; box-shadow:var(--shadow);
}
.card-head{display:flex; align-items:baseline; justify-content:space-between; gap:8px; margin-bottom:8px}
.card-title{font-size:13px; font-weight:600; color:#3c3a33; letter-spacing:.2px}
.hint{font-size:11.5px; color:var(--faint)}
.card > .card-title{margin-bottom:10px}

textarea{
  width:100%; min-height:158px; resize:vertical;
  border:1px solid var(--line); border-radius:12px; background:#fffefb;
  padding:11px 12px; font-family:inherit; font-size:15px; line-height:1.75; color:var(--ink);
  outline:none; transition:border-color .15s, box-shadow .15s;
}
textarea:focus{border-color:#c9bda6; box-shadow:0 0 0 3px #f3ecdd}
.row{display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:8px}
.meta{font-size:12px; color:var(--faint); font-variant-numeric:tabular-nums}
.mini{display:flex; gap:6px}
.ghost{
  border:1px solid var(--line); background:transparent; color:var(--muted);
  border-radius:9px; padding:5px 10px; font-size:12px; cursor:pointer; transition:.15s;
}
.ghost:hover{background:#fbf7ee; color:var(--ink)}

/* style cards */
.styles{display:grid; grid-template-columns:1fr 1fr; gap:8px}
.style{
  border:1px solid var(--line); background:#fffefb; border-radius:12px;
  padding:9px 10px 7px; text-align:start; cursor:pointer; transition:.15s;
  display:grid; gap:1px; position:relative; overflow:hidden;
}
.style:hover{border-color:#d8ccb6; background:#fff}
.style[aria-pressed="true"]{
  border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); background:#fff;
}
.style .sa{font-size:23px; line-height:1.55; color:#1b1f27; white-space:nowrap; overflow:hidden}
.style .sl{font-size:13px; color:#6f6b60; white-space:nowrap; overflow:hidden; line-height:1.3}
.style .nm{font-size:11px; color:var(--faint); margin-top:2px; letter-spacing:.2px}

/* ink swatches */
.swatches{display:flex; gap:9px; flex-wrap:wrap}
.sw{
  width:32px; height:32px; border-radius:50%; cursor:pointer; padding:0;
  border:2px solid transparent; box-shadow:inset 0 0 0 1px rgba(0,0,0,.08);
  transition:transform .12s, box-shadow .12s; position:relative;
}
.sw:hover{transform:translateY(-1px)}
.sw[aria-pressed="true"]{
  border-color:#fff; box-shadow:0 0 0 2px var(--accent), inset 0 0 0 1px rgba(0,0,0,.08);
}

/* paper chips */
.chips{display:flex; gap:7px; flex-wrap:wrap}
.chip{
  border:1px solid var(--line); background:#fffefb; border-radius:10px;
  padding:7px 11px; font-size:12.5px; color:#4b4841; cursor:pointer;
  display:flex; align-items:center; gap:7px; transition:.15s;
}
.chip:hover{border-color:#d8ccb6; background:#fff}
.chip[aria-pressed="true"]{border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); color:var(--ink); background:#fff}
.chip svg{display:block; opacity:.75}

/* sliders */
.slider-row{display:flex; align-items:center; justify-content:space-between; margin:2px 0 6px}
.slider-row + .slider-row{margin-top:14px}
.slider-row label{font-size:13px; font-weight:600; color:#3c3a33}
.slider-row output{font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; background:#f7f2e6; border-radius:7px; padding:1px 7px}
input[type=range]{
  -webkit-appearance:none; appearance:none; width:100%; height:22px; background:transparent; cursor:pointer; margin:0;
}
input[type=range]::-webkit-slider-runnable-track{height:4px; background:#e8e0cf; border-radius:4px}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none; width:18px; height:18px; border-radius:50%; background:#fff;
  border:2px solid var(--accent); margin-top:-7px; box-shadow:0 1px 4px rgba(0,0,0,.15);
}
input[type=range]::-moz-range-track{height:4px; background:#e8e0cf; border-radius:4px}
input[type=range]::-moz-range-thumb{width:16px; height:16px; border-radius:50%; background:#fff; border:2px solid var(--accent)}

/* switches */
.switch{display:flex; align-items:flex-start; gap:10px; cursor:pointer; padding:5px 0}
.switch + .switch{margin-top:4px}
.switch input{position:absolute; opacity:0; width:0; height:0}
.track{
  width:38px; height:22px; border-radius:22px; background:#e4dccb; flex:0 0 auto;
  position:relative; transition:background .16s; margin-top:1px;
}
.track::after{
  content:""; position:absolute; top:3px; inset-inline-start:3px;
  width:16px; height:16px; border-radius:50%; background:#fff;
  box-shadow:0 1px 3px rgba(0,0,0,.2); transition:transform .16s;
}
.switch input:checked + .track{background:var(--accent)}
.switch input:checked + .track::after{transform:translateX(16px)}
html[dir="rtl"] .switch input:checked + .track::after{transform:translateX(-16px)}
.sw-txt{display:grid; line-height:1.35}
.sw-txt b{font-size:13px; font-weight:600; color:#3c3a33}
.sw-txt small{font-size:11.5px; color:var(--faint)}

/* buttons */
.export{display:grid; gap:8px}
.btn{
  border:1px solid var(--line); background:#fffefb; color:var(--ink);
  border-radius:12px; padding:11px 14px; font-size:14px; font-weight:600;
  cursor:pointer; transition:.15s; width:100%;
}
.btn:hover{background:#fff; border-color:#d6cbb6}
.btn.primary{
  background:linear-gradient(180deg,#31538f,#274579); color:#fff; border-color:#223d6b;
  box-shadow:0 6px 16px rgba(38,64,110,.22);
}
.btn.primary:hover{background:linear-gradient(180deg,#365b9c,#2a4a80)}
.btn:disabled{opacity:.55; cursor:default}
.privacy{margin:2px 0 0; font-size:11.5px; color:var(--faint); line-height:1.6}

/* preview */
.preview{min-width:0}
.preview-head{display:flex; align-items:baseline; justify-content:space-between; margin:0 4px 10px}
.preview-head h2{margin:0; font-size:14px; font-weight:600; color:#3c3a33}
.pages{display:grid; gap:20px; justify-items:center}
.page{
  position:relative; width:100%; max-width:794px; background:#fff;
  border-radius:8px; overflow:hidden;
  box-shadow:0 1px 1px rgba(40,32,18,.06), 0 14px 34px rgba(40,32,18,.13);
  border:1px solid #eee6d6;
}
.page canvas{display:block; width:100%; height:auto}
.pnum{
  position:absolute; top:8px; inset-inline-end:8px;
  font-size:11.5px; color:#7c7667; background:rgba(255,253,247,.9);
  border:1px solid #ece3d2; border-radius:7px; padding:1px 7px;
  font-variant-numeric:tabular-nums; pointer-events:none;
}
.pdl{
  position:absolute; top:8px; inset-inline-start:8px;
  display:flex; align-items:center; gap:5px;
  border:1px solid #ece3d2; background:rgba(255,253,247,.94); color:#4a4740;
  border-radius:8px; padding:4px 9px; font-size:11.5px; cursor:pointer;
  opacity:0; transition:opacity .15s, background .15s;
}
.page:hover .pdl, .pdl:focus-visible{opacity:1}
.pdl:hover{background:#fff; color:var(--accent)}
@media (hover:none){.pdl{opacity:1}}

/* footer */
.foot{border-top:1px solid var(--line); margin-top:26px; background:rgba(255,253,249,.6)}
.foot-in{max-width:1200px; margin:0 auto; padding:22px 18px 30px}
.steps{display:flex; gap:26px; flex-wrap:wrap}
.step{display:flex; align-items:center; gap:9px; font-size:13px; color:#4b4841}
.step b{
  width:24px; height:24px; border-radius:50%; background:#fffdf9; border:1px solid var(--line);
  display:grid; place-items:center; font-size:12px; color:var(--accent); font-weight:600;
}
.foot-note{margin:14px 0 0; font-size:12px; color:var(--faint)}

/* mobile action bar */
.mobilebar{
  display:none; position:fixed; inset-inline:0; bottom:0; z-index:40;
  background:rgba(255,253,249,.95); backdrop-filter:blur(10px);
  border-top:1px solid var(--line); padding:9px 12px calc(9px + env(safe-area-inset-bottom));
  gap:8px; align-items:center;
}
.mobilebar .mb-meta{font-size:12px; color:var(--faint); flex:1; font-variant-numeric:tabular-nums}
.mobilebar .btn{width:auto; padding:9px 16px; font-size:13px}
@media (max-width:920px){.mobilebar{display:flex}}
html[dir="ltr"] .mobilebar{display:none}

/* toast */
.toast{
  position:fixed; inset-inline:0; bottom:84px; margin:0 auto; width:max-content; max-width:90vw;
  background:#1b1f27; color:#fdf8ec; font-size:13px; padding:9px 16px; border-radius:11px;
  opacity:0; transform:translateY(8px); transition:.2s; pointer-events:none; z-index:50;
}
.toast.on{opacity:1; transform:translateY(0)}

@media (prefers-reduced-motion:reduce){*{transition:none!important}}
