/* Arabic RTL friendly clean UI */
:root{
  --radius: 18px;
  --shadow: 0 6px 20px rgba(0,0,0,.08);
  --fg: #1b1b1f;
  --bg: #f7f7fb;
  --muted: #6b7280;
  --green:#4CAF50;
  --blue:#2196F3;
  --red:#F44336;
  --amber:#FFC107;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Naskh Arabic UI", "Tajawal", Arial, sans-serif;
  color:var(--fg);
  background:var(--bg);
}

.app-header{
  position: sticky;
  top:0;
  display:flex; align-items:center; gap:8px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index:10;
}
.app-header h1{margin:0; font-size:20px; font-weight:700; flex:1; text-align:center}
.back-btn{
  border:none; background:#f1f3f5; padding:8px 12px; border-radius:999px; cursor:pointer;
}
.install-btn{border:none;background:#eef2ff;padding:8px 10px;border-radius:12px;cursor:pointer}
.container{padding:16px 12px 96px}
.view{display:none}
.view.active{display:block}

.grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:14px}
.stack{display:flex; flex-direction:column; gap:12px}

.empty{display:grid;place-items:center;padding:40px;color:var(--muted)}

.card{
  border-radius: var(--radius);
  background:#fff;
  box-shadow: var(--shadow);
  padding:14px;
  display:flex; flex-direction:column; gap:8px;
  cursor:pointer;
  position:relative;
}
.card .row{display:flex; align-items:center; gap:8px}
.badge{border-radius:999px; padding:4px 8px; background:#f3f4f6; font-size:12px; color:#111}

.subject-chip{
  display:flex; align-items:center; gap:10px;
  font-weight:700;
  padding:10px 14px;
  border-radius:999px;
  background:#fff;
  box-shadow:var(--shadow);
  max-width:100%;
}
.subject-header{
  display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px;
}
.btn{border:none; padding:8px 12px; border-radius:10px; cursor:pointer; font-weight:600}
.subtle{background:#f3f4f6; color:#111}
.danger{background:#fee2e2}

.tabs{
  display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin:12px 0;
}
.tab{
  border:none; padding:10px; border-radius:12px; cursor:pointer; font-weight:700; background:#fff; box-shadow:var(--shadow);
}
.tab.active{outline:3px solid rgba(0,0,0,.06)}

.panel{display:none}
.panel.active{display:block}

.fab{
  position: fixed;
  right: 16px; bottom: 16px;
  width:56px; height:56px; border-radius:999px; border:none; font-size:28px; font-weight:700;
  background: #111; color:#fff; box-shadow: var(--shadow); cursor:pointer;
}

.dialog{
  border:none; border-radius:20px; width:min(560px,92vw);
  padding:0;
}
.dialog::backdrop{background:rgba(0,0,0,.3)}
.form{padding:18px; display:flex; flex-direction:column; gap:12px}
.form h3{margin:0 0 6px}
label{display:flex; flex-direction:column; gap:6px; font-weight:600}
input, textarea{
  border:1px solid #e5e7eb; border-radius:12px; padding:10px 12px; font:inherit; background:#fff;
}
textarea{resize:vertical}
.icon-grid, .level-grid{display:grid; grid-template-columns:repeat(8,1fr); gap:8px}
.icon-grid .icon-opt, .level-grid button{
  border:1px solid #e5e7eb; background:#fff; border-radius:12px; padding:8px; cursor:pointer; font-size:20px;
}
.icon-grid .icon-opt.active, .level-grid button.active{outline:3px solid #6366f1}
.dialog-actions{display:flex; gap:8px; justify-content:flex-end; padding-top:8px}

.note-chip{
  background:#fff; border-radius:16px; padding:12px; box-shadow:var(--shadow); min-height:86px;
  display:flex; flex-direction:column; gap:8px;
}
.note-chip h4{margin:0 0 4px; font-size:16px}
.note-chip p{margin:0; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}

.item-row{
  display:flex; align-items:center; gap:12px; background:#fff; padding:12px; border-radius:16px; box-shadow:var(--shadow)
}
.item-row .mono{font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size:12px; color:var(--muted)}

.board-tile{
  display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px; border-radius:16px; box-shadow:var(--shadow); background:#fff;
}
.thumb-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:6px}
.thumb-grid img{width:100%; aspect-ratio:1/1; object-fit:cover; border-radius:10px; cursor:pointer}

.image-viewer{
  position:fixed; inset:0; background:rgba(0,0,0,.92); display:none; align-items:center; justify-content:center; z-index:50;
}
.image-viewer.active{display:flex}
.image-viewer img{max-width:95vw; max-height:90vh; border-radius:12px}

audio{width:100%}
.small{font-size:12px; color:var(--muted)}

.longpress-hint{
  position:absolute; inset-inline-start:10px; inset-block-end:10px; font-size:12px; color:#6b7280;
}

.hidden{display:none}
