/* ============================================================
   מערכת הצלצולים · אורט ק. ביאליק
   שפה עיצובית: טופס בית-ספרי מודפס. נייר, קווי דיו, כחול אורט אחד.
   בלי גרדיאנטים, בלי זכוכית, בלי צללים צבעוניים.
   ============================================================ */

:root {
  --paper:    #faf7f1;
  --paper-2:  #f1ebdf;
  --paper-3:  #e7dfd0;
  --ink:      #16181d;
  --ink-70:   #4a4f5a;
  --ink-45:   #7d838f;
  --ink-25:   #a9aeb8;
  --rule:     #d7cfbe;
  --rule-2:   #c2b8a2;
  --blue:     #0b4da2;
  --blue-dk:  #073a7c;
  --blue-pale:#dce6f4;
  --stamp:    #b8392a;
  --green:    #2c6b46;

  --sans: 'Assistant', 'Segoe UI', 'Arial Hebrew', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; }

/* ספרות ברוחב אחיד בכל מקום שיש בו נתונים או שעון */
.spec dd, .ruler, .time-readout, .nudge-btns, .ticket-id, .class-btn .cc,
.grade-tab small, .stepper li span, .tbl .id, .tbl .muted, .audit time {
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--blue); color: #fff; }

/* ---------------- כותרת עליונה ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 5vw, 56px);
  border-bottom: 1px solid var(--ink);
}

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.brand img { display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.brand-text em {
  font-style: normal;
  font-size: 12px;
  color: var(--ink-45);
  font-family: var(--sans);
}

.link-btn {
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule-2);
  color: var(--ink-70);
  font: inherit;
  font-size: 14px;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: none;
}
.link-btn:hover { color: var(--blue); border-bottom-color: var(--blue); }

/* ---------------- פתיח ---------------- */

.hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(38px, 7vw, 82px) clamp(16px, 5vw, 56px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: clamp(30px, 6vw, 76px);
  align-items: start;
}

.kicker {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--ink-45);
  margin: 0 0 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

.hero h1 {
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(34px, 5.6vw, 60px);
  line-height: 1.1;
  letter-spacing: -1px;
  margin: 0 0 22px;
}
.hero h1 .rule-word {
  border-bottom: 6px solid var(--blue);
  padding-bottom: 2px;
}

.lede {
  margin: 0 0 12px;
  font-size: clamp(16px, 1.5vw, 18px);
  line-height: 1.8;
  color: var(--ink-70);
  max-width: 50ch;
}

.hero-cta { margin-top: 26px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.hero-note { font-size: 13.5px; color: var(--ink-45); }

/* לוח מפרט - טבלת נתונים בטופס, לא שורת סטטיסטיקות */
.spec { border: 1px solid var(--ink); background: #fff; }
.spec-head {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .08em;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
}
.spec dl { margin: 0; }
.spec div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
}
.spec div:last-child { border-bottom: 0; }
.spec dt { color: var(--ink-70); margin: 0; }
.spec dd { margin: 0; font-family: var(--sans); font-size: 13px; color: var(--ink); }

/* ---------------- כפתורים ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font: inherit;
  font-weight: 500;
  font-size: 15px;
  padding: 11px 22px;
  border: 1px solid var(--blue);
  border-radius: 2px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  transition: background .13s, border-color .13s, color .13s;
}
.btn:hover:not(:disabled) { background: var(--blue-dk); border-color: var(--blue-dk); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn-ghost { background: transparent; color: var(--ink-70); border-color: var(--rule-2); }
.btn-ghost:hover:not(:disabled) { background: var(--paper-2); color: var(--ink); border-color: var(--ink); }

.btn-lg { padding: 14px 30px; font-size: 16px; }
.btn-sm { padding: 7px 15px; font-size: 13.5px; }

/* ---------------- אשף ---------------- */

.wizard {
  max-width: 1000px;
  margin: 0 auto;
  padding: clamp(26px, 5vw, 52px) clamp(16px, 5vw, 56px) 80px;
}

/* מדדי שלבים: קו אחד עם שנתות, לא גלולות ממוספרות */
.stepper {
  display: flex;
  list-style: none;
  margin: 0 0 30px;
  padding: 0;
  border-bottom: 1px solid var(--ink);
}
.stepper li {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 0 10px;
  font-size: 14.5px;
  color: var(--ink-25);
  position: relative;
}
.stepper li span { font-family: var(--sans); font-size: 11.5px; }
.stepper li.done { color: var(--ink-70); }
.stepper li.active { color: var(--ink); font-weight: 500; }
.stepper li.active::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: -1px;
  height: 3px;
  background: var(--blue);
}

.panel-head { margin-bottom: 26px; }
.panel-head h2 {
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(23px, 3.2vw, 31px);
  margin: 0 0 8px;
  letter-spacing: -.6px;
}
.panel-head p { margin: 0; color: var(--ink-70); font-size: 15.5px; line-height: 1.7; max-width: 60ch; }
.panel-head b { font-family: var(--sans); font-size: 14px; color: var(--blue); font-weight: 400; }

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  flex-wrap: wrap;
}

/* ---------------- שלב 1: כיתות ---------------- */

.grade-tabs { display: flex; margin-bottom: 22px; border: 1px solid var(--ink); width: fit-content; }
.grade-tab {
  font: inherit;
  font-size: 15px;
  padding: 9px 20px;
  border: 0;
  border-inline-start: 1px solid var(--ink);
  background: transparent;
  color: var(--ink-70);
  cursor: pointer;
  line-height: 1.25;
}
.grade-tab:first-child { border-inline-start: 0; }
.grade-tab small {
  display: block;
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--ink-25);
  direction: ltr;
  margin-top: 1px;
}
.grade-tab:hover { background: var(--paper-2); }
.grade-tab[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.grade-tab[aria-selected="true"] small { color: var(--ink-25); }

/* רשת הכיתות בנויה כמו טבלת מקומות: תאים צמודים עם קווי הפרדה */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  border: 1px solid var(--ink);
  border-block-end: 0;
  border-inline-start: 0;
  background: #fff;
}
.class-btn {
  position: relative;
  font: inherit;
  padding: 13px 6px 11px;
  border: 0;
  border-block-end: 1px solid var(--rule);
  border-inline-start: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}
.class-btn .cn { display: block; font-size: 19px; font-weight: 700; }
.class-btn .cc { display: block; font-family: var(--sans); font-size: 11px; color: var(--ink-45); margin-top: 2px; }
.class-btn:hover:not(:disabled) { background: var(--paper-2); }
.class-btn[aria-pressed="true"] { background: var(--blue); color: #fff; }
.class-btn[aria-pressed="true"] .cc { color: var(--blue-pale); }
.class-btn:disabled { cursor: not-allowed; background: var(--paper-2); color: var(--ink-25); }
.class-btn:disabled .cc { color: var(--ink-25); }
/* קו אלכסוני על כיתה שכבר הגישה - כמו מחיקה בעט על טופס */
.class-btn:disabled::after {
  content: "";
  position: absolute;
  inset: 10px 8px;
  background: linear-gradient(to top left, transparent calc(50% - 1px), var(--rule-2) calc(50% - 1px), var(--rule-2) calc(50% + 1px), transparent calc(50% + 1px));
}

.legend { display: flex; gap: 22px; margin-top: 14px; font-size: 13px; color: var(--ink-45); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.sw { width: 13px; height: 13px; border: 1px solid var(--rule-2); background: #fff; }
.sw-taken { background: var(--paper-3); }

.chosen { font-size: 15px; color: var(--ink-70); }
.chosen b { color: var(--ink); font-family: var(--sans); font-weight: 400; }

/* הקלדת קוד כיתה */
.code-entry { max-width: 420px; }
.code-entry > label {
  display: block;
  font-size: 13.5px;
  color: var(--ink-70);
  margin-bottom: 7px;
}
.code-row { display: flex; gap: 8px; }
#class-code {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 10px;
  text-align: center;
  padding: 10px 12px 10px 22px;
  font-variant-numeric: tabular-nums;
  width: 160px;
  flex: 0 0 auto;
}
#class-code::placeholder { color: var(--rule); letter-spacing: 10px; }
.code-result { margin-top: 10px; font-size: 14px; color: var(--ink-45); min-height: 20px; line-height: 1.6; }
.code-result.bad { color: var(--stamp); }

/* ---------------- שלב 2: מקור ---------------- */

.source-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--ink);
  background: #fff;
}
.source-card { padding: 26px; display: flex; flex-direction: column; gap: 15px; }
.source-card + .source-card { border-inline-start: 1px solid var(--rule); }
.source-title { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.source-title svg { color: var(--blue); }

.yt-row { display: flex; gap: 8px; }
.yt-row input { flex: 1; min-width: 0; }

input[type="url"], input[type="text"], input[type="password"], input[type="search"], select {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--rule-2);
  border-radius: 2px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
input::placeholder { color: var(--ink-25); }

.hint { margin: 0; font-size: 13px; color: var(--ink-45); line-height: 1.65; }
.hint.center { text-align: center; }

.dropzone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 120px;
  border: 1px dashed var(--rule-2);
  background: var(--paper);
  cursor: pointer;
  text-align: center;
  padding: 18px;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.over {
  border-color: var(--blue);
  background: var(--blue-pale);
  outline: none;
}
.dz-main { font-weight: 500; font-size: 15px; }
.dz-sub { font-size: 13px; color: var(--ink-45); }

/* ---------------- שלב 3: עורך ---------------- */

.editor { display: flex; flex-direction: column; gap: 22px; }

.track-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  background: #fff;
}
.track-meta img { width: 60px; height: 40px; object-fit: cover; }
.track-meta > div { flex: 1; min-width: 0; }
.track-name { font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-sub { font-size: 12.5px; color: var(--ink-45); margin-top: 2px; font-family: var(--sans); }

.wave-wrap {
  position: relative;
  border: 1px solid var(--ink);
  background: #fff;
  padding: 16px 16px 0;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  direction: ltr; /* ציר הזמן תמיד משמאל לימין, גם בעמוד RTL */
}
#wave { display: block; width: 100%; height: 200px; cursor: crosshair; }

.region {
  position: absolute;
  top: 16px;
  height: 200px;
  border-inline: 2px solid var(--blue);
  background: rgba(11, 77, 162, .05);
  cursor: grab;
}
.region.dragging { cursor: grabbing; }

.handle { position: absolute; top: 0; bottom: 0; width: 20px; display: grid; place-items: center; cursor: ew-resize; }
.handle-start { inset-inline-start: -11px; }
.handle-end { inset-inline-end: -11px; }
.handle i { width: 11px; height: 40px; background: var(--blue); }
.handle i::after {
  content: "";
  display: block;
  width: 1px;
  height: 16px;
  margin: 12px auto;
  background: rgba(255, 255, 255, .65);
}

/* אזורי המיזוג מסומנים בשרטוט קווים, לא בגרדיאנט */
.fade {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(-45deg, rgba(11,77,162,.14) 0 1px, transparent 1px 6px);
}
.fade-in { inset-inline-start: 0; border-inline-end: 1px dotted rgba(11, 77, 162, .55); }
.fade-out { inset-inline-end: 0; border-inline-start: 1px dotted rgba(11, 77, 162, .55); }
.editor.no-fadevis .fade { display: none; }

.region-badge {
  position: absolute;
  top: 0;
  inset-inline-start: 50%;
  transform: translateX(50%);
  background: var(--blue);
  color: #fff;
  font-family: var(--sans);
  font-size: 11px;
  padding: 3px 8px;
  white-space: nowrap;
  pointer-events: none;
}

.playhead {
  position: absolute;
  top: 16px;
  height: 200px;
  width: 1px;
  background: var(--stamp);
  pointer-events: none;
}

.ruler {
  position: relative;
  height: 24px;
  display: flex;
  justify-content: space-between;
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink-45);
  padding-top: 4px;
  direction: ltr;
  border-top: 1px solid var(--rule);
}

.transport { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.btn-play { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-play:hover:not(:disabled) { background: #000; border-color: #000; }

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink-70); cursor: pointer; }
.switch input { accent-color: var(--blue); width: 15px; height: 15px; }

.time-readout { margin-inline-start: auto; font-family: var(--sans); font-size: 13.5px; color: var(--ink-70); direction: ltr; }

.nudges { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.nudge label { display: block; font-size: 13px; color: var(--ink-45); margin-bottom: 6px; }
.nudge-btns { display: flex; border: 1px solid var(--rule-2); background: #fff; direction: ltr; }
.nudge-btns button {
  font-family: var(--sans);
  font-size: 12.5px;
  min-width: 46px;
  padding: 9px 0;
  border: 0;
  border-inline-end: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-70);
  cursor: pointer;
}
.nudge-btns button:last-child { border-inline-end: 0; }
.nudge-btns button:hover { background: var(--paper-2); color: var(--ink); }
.nudge-btns output {
  flex: 1;
  display: grid;
  place-items: center;
  font-family: var(--sans);
  font-size: 14px;
  border-inline-end: 1px solid var(--rule);
  background: var(--paper);
}

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.field label { display: block; font-size: 13.5px; color: var(--ink-70); margin-bottom: 6px; }
.field label b { color: var(--stamp); }
.field .opt { color: var(--ink-25); }

/* ---------------- שלב 4: אישור ---------------- */

.panel-done { max-width: 560px; margin: 0 auto; text-align: center; }
.panel-done h2 { font-size: clamp(25px, 3.8vw, 33px); margin: 0 0 8px; font-weight: 800; letter-spacing: -.6px; }
.done-sub { margin: 0 0 30px; color: var(--ink-70); font-size: 15.5px; }
.done-mark { color: var(--green); margin-bottom: 14px; }
.done-mark path { stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw .5s .1s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* אישור מסירה - ספח שנתלש */
.ticket { border: 1px solid var(--ink); background: #fff; margin-bottom: 26px; }
.ticket-label {
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--paper);
  background: var(--ink);
  padding: 7px 14px;
}
.ticket-id {
  font-family: var(--sans);
  font-size: clamp(30px, 6vw, 44px);
  letter-spacing: 3px;
  color: var(--blue);
  direction: ltr;
  padding: 22px 14px 10px;
}
.ticket .btn { margin: 0 0 18px; }

.done-list { list-style: none; margin: 0 0 24px; padding: 0; border-top: 1px solid var(--rule); text-align: start; }
.done-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  color: var(--ink-70);
  padding: 11px 2px;
  border-bottom: 1px solid var(--rule);
}
.done-list li b { color: var(--ink); font-weight: 500; text-align: end; }

/* ---------------- כותרת תחתונה ---------------- */

.footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 18px clamp(16px, 5vw, 56px);
  border-top: 1px solid var(--ink);
  font-size: 13px;
  color: var(--ink-45);
}
.footer a { color: var(--ink-45); }

/* ---------------- שכבת המתנה ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(250, 247, 241, .93);
}
.overlay-card {
  text-align: center;
  padding: 30px 44px;
  border: 1px solid var(--ink);
  background: #fff;
  max-width: min(90vw, 380px);
}
.overlay-title { font-size: 18px; font-weight: 700; margin-top: 18px; }
.overlay-sub { font-size: 13.5px; color: var(--ink-45); margin-top: 6px; line-height: 1.6; font-family: var(--sans); }

.loader { display: flex; justify-content: center; gap: 5px; height: 26px; align-items: flex-end; }
.loader span { width: 4px; height: 100%; background: var(--blue); animation: vu .9s ease-in-out infinite; }
.loader span:nth-child(2) { animation-delay: .18s; }
.loader span:nth-child(3) { animation-delay: .36s; }
@keyframes vu { 0%, 100% { height: 22%; } 50% { height: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .loader span { animation: none; height: 60%; }
  .done-mark path { animation: none; stroke-dashoffset: 0; }
}

/* ---------------- הודעות ---------------- */

.toasts {
  position: fixed;
  inset-block-end: 20px;
  inset-inline-start: 20px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(92vw, 380px);
}
.toast {
  display: flex;
  gap: 10px;
  padding: 12px 15px;
  border: 1px solid var(--ink);
  background: #fff;
  font-size: 14px;
  line-height: 1.5;
}
.toast.err::before { content: "✕"; color: var(--stamp); }
.toast.ok::before { content: "✓"; color: var(--green); }

/* ---------------- חלון ---------------- */

.modal {
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  max-width: min(92vw, 400px);
}
.modal::backdrop { background: rgba(22, 24, 29, .3); }
.modal-inner { padding: 24px; display: grid; gap: 14px; }
.modal-inner h3 { margin: 0; font-size: 19px; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-result { font-size: 14px; color: var(--ink-70); line-height: 1.6; min-height: 20px; }
.modal-result b { color: var(--ink); font-weight: 500; }

/* ---------------- מסכים צרים ---------------- */

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .source-grid { grid-template-columns: 1fr; }
  .source-card + .source-card { border-inline-start: 0; border-top: 1px solid var(--rule); }
}

@media (max-width: 620px) {
  .class-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .class-btn { padding: 10px 3px 8px; }
  .class-btn .cn { font-size: 17px; }
  .stepper li span { display: none; }
  .stepper li { font-size: 13px; justify-content: center; }
  .time-readout { margin-inline-start: 0; width: 100%; }
  #wave { height: 150px; }
  .region, .playhead { height: 150px; }
  .grade-tabs { width: 100%; }
  .grade-tab { flex: 1; padding: 9px 6px; }
}
