:root {
  --ink: #1d2e2b;
  --ink-soft: #556965;
  --ink-faint: #89a09b;
  --bg: #f4faf9;
  --card: #ffffff;
  --line: #dbe9e5;
  --accent: #17756a;        /* כפתורים וטקסט — ניגודיות תקנית */
  --accent-dark: #115a52;   /* ריחוף וקישורים */
  --accent-bright: #2fb3a0; /* טורקיז לעיטורים */
  --accent-wash: #e4f4f1;
  --shadow: 0 1px 3px rgba(17, 90, 82, .05), 0 6px 20px rgba(17, 90, 82, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Assistant, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); }

/* ---------- מסך כניסה ---------- */

.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}

.auth-card {
  border-top: 3px solid var(--accent-bright);
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 38px 30px 32px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.auth-card .sub {
  margin: 0 0 26px;
  color: var(--ink-soft);
  font-size: 15px;
}

label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 6px;
}

input[type=email], input[type=text] {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  font-size: 16px; /* מונע זום אוטומטי באייפון */
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.field { margin-bottom: 18px; }

.field-hint {
  font-size: 13px;
  color: var(--ink-faint);
  margin-top: 6px;
}

input.code {
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 600;
  text-align: center;
  direction: ltr;
}

button, .btn {
  display: block;
  width: 100%;
  padding: 13px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background .15s;
}

button:hover, .btn:hover { background: var(--accent-dark); }
button:disabled { opacity: .55; cursor: default; }

.alt-link {
  display: block;
  text-align: center;
  margin-top: 18px;
  font-size: 14px;
  color: var(--ink-soft);
}

.msg {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14.5px;
  margin-bottom: 20px;
}

.msg-error { background: #fdf1ee; color: #9a3b23; border: 1px solid #f6dbd3; }
.msg-ok { background: #e4f4f1; color: #115a52; border: 1px solid #bfe3db; }
.msg-info { background: var(--accent-wash); color: var(--accent-dark); border: 1px solid #c9e6df; }

/* ---------- מסגרת האפליקציה ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
}

.topbar-in {
  max-width: 960px;
  margin: 0 auto;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar .brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -.01em;
}

.topbar .spacer { flex: 1; }

.topbar .who {
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}

.topbar a.out {
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
}

.topbar a.out:hover { background: var(--accent-wash); color: var(--accent-dark); }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px calc(60px + env(safe-area-inset-bottom));
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  margin-bottom: 18px;
}

.crumb:hover { color: var(--accent-dark); }

h1.page-title {
  margin: 0 0 6px;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.25;
}

.page-sub {
  margin: 0 0 30px;
  color: var(--ink-soft);
  font-size: 15px;
}

/* ---------- רשימת הקורסים ---------- */

.courses {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.course-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}

.course-card:hover {
  transform: translateY(-2px);
  border-color: #bcdcd4;
}

.course-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -.01em;
}

.pill {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-wash);
  border-radius: 999px;
  padding: 3px 11px;
}

/* ---------- עמוד קורס ---------- */

.chapter { margin-bottom: 30px; }

.chapter > h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink-faint);
}

.lessons {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.lesson-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 18px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--line);
  transition: background .12s;
}

.lesson-row:last-child { border-bottom: 0; }
.lesson-row:hover { background: #f7fcfb; }

.lesson-num {
  flex: 0 0 26px;
  box-shadow: inset 0 0 0 1.5px rgba(47,179,160,.35);
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-dark);
  background: var(--accent-wash);
  border-radius: 50%;
}

.lesson-name {
  flex: 1;
  font-weight: 600;
  font-size: 15.5px;
  line-height: 1.4;
}

.tag {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: #eaf4f1;
  border-radius: 5px;
  padding: 2px 7px;
  white-space: nowrap;
}

.chev { color: var(--ink-faint); flex: 0 0 auto; }

/* ---------- עמוד שיעור ---------- */

.player {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #0f2220;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 26px;
  box-shadow: var(--shadow);
}

.player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.notes {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}

.notes h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink-faint);
}

.notes-body :first-child { margin-top: 0; }
.notes-body :last-child { margin-bottom: 0; }
.notes-body p { margin: 0 0 11px; }
.notes-body a { color: var(--accent-dark); word-break: break-word; }
.notes-body ul, .notes-body ol { margin: 0 0 11px; padding-inline-start: 22px; }

.file-link {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 18px;
  margin-bottom: 22px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: 15px;
}

.file-link:hover { border-color: var(--accent); }
.file-link .ico { color: var(--accent); flex: 0 0 auto; }

.pager {
  display: flex;
  gap: 10px;
  margin-top: 30px;
}

.pager a, .pager span {
  flex: 1;
  padding: 13px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 14.5px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pager a:hover { border-color: var(--accent); color: var(--accent-dark); }
.pager span { opacity: .35; }

.foot {
  margin-top: 46px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--ink-faint);
  text-align: center;
}

.foot a { color: var(--ink-soft); }

@media (max-width: 560px) {
  main { padding-top: 22px; }
  h1.page-title { font-size: 23px; }
  .auth-card { padding: 30px 22px 26px; }
  .courses { grid-template-columns: 1fr; }
  .notes { padding: 18px; }
}

/* ---------- פאנל הניהול ---------- */

.admin-search {
  display: flex;
  gap: 10px;
  margin-bottom: 26px;
}

.admin-search input { flex: 1; }
.admin-search button { width: auto; padding-inline: 26px; }

input[type=search], select {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
}

input[type=search]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-actions form { margin: 0; }
.admin-actions button { width: auto; padding-inline: 20px; }
.admin-actions select { min-width: 240px; flex: 1; }

button.ghost {
  background: #fff;
  color: var(--accent-dark);
  border: 1.5px solid var(--line);
}

button.ghost:hover { background: var(--accent-wash); border-color: var(--accent); }

button.small {
  padding: 6px 14px;
  font-size: 13.5px;
  border-radius: 8px;
}

.course-picks {
  max-height: 260px;
  overflow-y: auto;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  background: #fff;
}

.pick {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 7px;
  font-weight: 400;
  font-size: 14.5px;
  cursor: pointer;
}

.pick:hover { background: var(--accent-wash); }
.pick input { margin-top: 4px; accent-color: var(--accent); flex: 0 0 auto; }

@media (max-width: 560px) {
  .admin-search { flex-direction: column; }
  .admin-search button { width: 100%; }
  .admin-actions select { min-width: 0; }
}
