/* בר המצווה של גיא - RTL, mobile first.
   Hidden elements use display:none only. Never position:absolute with a
   negative `left` - in an RTL document that creates a huge scrollable area to
   the left and Chrome shrinks the whole page to fit it. */

:root {
  --bg:      #f4f6fb;
  --bg2:     #e9edf6;
  --card:    #ffffff;
  --ink:     #16202e;
  --ink2:    #5a6577;
  --line:    #dde3ee;
  --accent:  #1c56a0;
  --accent2: #2a74d0;
  --gold:    #b8801f;
  --gold-bg: #fdf5e5;
  --ok:      #1c7f57;
  --ok-bg:   #e8f6ef;
  --warn:    #a8541a;
  --warn-bg: #fdf0e6;
  --danger:  #b3261e;
  --shadow:  0 1px 2px rgba(18,32,54,.06), 0 6px 18px rgba(18,32,54,.07);
  --r:       14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0a0f16;
    --bg2:     #111926;
    --card:    #151e2b;
    --ink:     #e7edf7;
    --ink2:    #94a1b5;
    --line:    #24303f;
    --accent:  #6ea8f0;
    --accent2: #8dbcf7;
    --gold:    #e0ac52;
    --gold-bg: #241d10;
    --ok:      #57c99a;
    --ok-bg:   #10241c;
    --warn:    #e0a06a;
    --warn-bg: #251a11;
    --danger:  #f08d86;
    --shadow:  0 1px 2px rgba(0,0,0,.3), 0 8px 22px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Assistant', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { font-family: 'Rubik', 'Assistant', sans-serif; line-height: 1.3; }

.hp { display: none !important; }
.muted { color: var(--ink2); }
.small { font-size: .875rem; }

/* ------------------------------------------------------------- login */
.login {
  min-height: 100svh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--bg2), var(--bg));
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px 22px 24px;
  text-align: center;
}
.login-emoji { font-size: 44px; line-height: 1; }
.login-card h1 { margin: 10px 0 2px; font-size: 1.4rem; }
.login-card p { margin: 0 0 18px; }
.login-card label {
  display: block; text-align: right;
  font-size: .875rem; color: var(--ink2);
  margin: 12px 2px 5px;
}

/* ------------------------------------------------------------ inputs */
input[type=text], input[type=password], textarea, select, .inp {
  width: 100%;
  font: inherit;
  font-size: 16px;            /* below 16px iOS Safari zooms on focus */
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  min-height: 46px;
  outline: none;
}
input:focus, textarea:focus, select:focus, .inp:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
textarea, .ta { min-height: 120px; resize: vertical; line-height: 1.6; }
.sel { max-width: 220px; margin: 10px auto 0; }

/* ------------------------------------------------------------ button */
.btn {
  font: inherit; font-weight: 600;
  border-radius: 11px;
  border: 1.5px solid transparent;
  padding: 11px 16px;
  min-height: 46px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: filter .15s, background .15s;
}
.btn:active { filter: brightness(.94); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost   { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg2); }
.btn.danger  { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.lg { width: 100%; margin-top: 18px; }
.btn:disabled { opacity: .5; cursor: default; }
.err { color: var(--danger); font-size: .9rem; margin-top: 12px; min-height: 20px; }

/* ------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 860px; margin: 0 auto;
  padding: 10px 14px 8px;
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-emoji { font-size: 24px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-family: 'Rubik', sans-serif; font-size: 1rem; line-height: 1.2; }
.brand-text small { color: var(--ink2); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sync { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--ink2); white-space: nowrap; }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.sync.saving .dot { background: var(--gold); animation: pulse 1s infinite; }
.sync.off .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

.tabs {
  display: flex; gap: 6px;
  max-width: 860px; margin: 0 auto;
  padding: 0 10px 9px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  font: inherit; font-size: .875rem; font-weight: 600;
  color: var(--ink2);
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  min-height: 38px;
  cursor: pointer;
  white-space: nowrap;
}
.tab.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------ layout */
main { padding: 14px 0 40px; }
.wrap { max-width: 860px; margin: 0 auto 22px; padding: 0 14px; }
.sec-h { font-size: 1.2rem; margin: 6px 0 4px; }
.sub-h { font-size: 1rem; margin: 22px 0 6px; }
.sec-p { color: var(--ink2); margin: 0 0 14px; font-size: .94rem; }

/* --------------------------------------------------------- countdown */
.count-card {
  background: linear-gradient(150deg, var(--accent), #123a5e);
  color: #fff;
  border-radius: 18px;
  padding: 20px 18px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.count-num { font-family: 'Rubik', sans-serif; font-size: 3.1rem; font-weight: 800; line-height: 1; }
.count-lbl { font-size: .95rem; opacity: .92; margin-top: 2px; }
.count-sub { font-size: .8rem; opacity: .72; margin-top: 3px; }
.count-bar { height: 7px; background: rgba(255,255,255,.22); border-radius: 99px; margin: 14px 0 7px; overflow: hidden; }
.count-bar i { display: block; height: 100%; background: #f3c268; border-radius: 99px; transition: width .5s; }
.count-total { font-size: .8rem; opacity: .85; }

/* ------------------------------------------------------------ blocks */
.blk {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.blk-head { display: flex; align-items: center; gap: 10px; padding: 13px 15px 10px; }
.blk-emoji { font-size: 21px; flex: none; }
.blk-titles { flex: 1; min-width: 0; }
.blk-titles h3 { margin: 0; font-size: 1.03rem; }
.blk-titles small { color: var(--ink2); font-size: .78rem; }
.blk-count { font-size: .78rem; color: var(--ink2); white-space: nowrap; flex: none; }
.blk-menu {
  flex: none; background: none; border: none; cursor: pointer;
  font-size: 19px; color: var(--ink2); line-height: 1;
  width: 40px; height: 40px; border-radius: 10px;
}
.blk-menu:hover { background: var(--bg2); }
.prog { height: 4px; background: var(--bg2); }
.prog i { display: block; height: 100%; background: var(--ok); transition: width .35s; }

.items { list-style: none; margin: 0; padding: 4px 0; }
.it { display: flex; align-items: flex-start; gap: 10px; padding: 3px 12px; }
.it-box {
  flex: none; margin-top: 8px;
  width: 24px; height: 24px; border-radius: 7px;
  border: 2px solid var(--line); background: var(--card);
  cursor: pointer; position: relative; padding: 0;
}
.it-box::after {
  content: ''; position: absolute;
  inset-inline-start: 7px; top: 2px;
  width: 6px; height: 11px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg); opacity: 0;
}
.it.done .it-box { background: var(--ok); border-color: var(--ok); }
.it.done .it-box::after { opacity: 1; }
.it-text {
  flex: 1; min-width: 0;
  padding: 8px 2px; margin: 0;
  border: none; background: none; font: inherit; color: var(--ink);
  text-align: right; cursor: text;
  word-break: break-word;
}
.it.done .it-text { color: var(--ink2); text-decoration: line-through; }
.it-x {
  flex: none; margin-top: 6px;
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: none; cursor: pointer;
  color: var(--ink2); font-size: 17px; line-height: 1;
  opacity: .55;
}
.it-x:hover { opacity: 1; background: var(--bg2); color: var(--danger); }

.add-row { display: flex; gap: 8px; padding: 8px 12px 13px; }
.add-row .inp { min-height: 44px; }
.add-row .btn { min-height: 44px; padding: 0 15px; flex: none; }

.block-add { width: 100%; }

/* ------------------------------------------------------------ quotes */
.upl {
  border: 2px dashed var(--line);
  border-radius: var(--r);
  background: var(--card);
  padding: 22px 16px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.upl.drag { border-color: var(--accent); background: var(--bg2); }
.upl-emoji { font-size: 30px; }
.upl-title { font-weight: 600; margin: 4px 0 12px; }
.upl-btns { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }
.upl-hint { color: var(--ink2); font-size: .78rem; margin-top: 12px; }
.paste-box { margin-top: 12px; display: flex; flex-direction: column; gap: 9px; }
.row-btns { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 10px; }

.q {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  margin-top: 13px;
  overflow: hidden;
}
.q-head { display: flex; align-items: center; gap: 10px; padding: 13px 15px; }
.q-head .q-t { flex: 1; min-width: 0; }
.q-t strong { display: block; font-size: 1rem; }
.q-t small { color: var(--ink2); font-size: .78rem; }
.pill {
  flex: none; font-size: .72rem; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.pill.pending  { background: var(--bg2); color: var(--ink2); }
.pill.analyzing{ background: var(--gold-bg); color: var(--gold); }
.pill.done     { background: var(--ok-bg); color: var(--ok); }
.pill.error    { background: #fdecea; color: var(--danger); }
@media (prefers-color-scheme: dark) { .pill.error { background: #2a1615; } }

.q-body { padding: 0 15px 14px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; font-size: .9rem; margin: 10px 0; }
.kv dt { color: var(--ink2); }
.kv dd { margin: 0; }
.price { font-family: 'Rubik', sans-serif; font-size: 1.35rem; font-weight: 700; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0; }
.chip { font-size: .78rem; padding: 3px 9px; border-radius: 8px; background: var(--bg2); color: var(--ink2); }
.flag { background: var(--warn-bg); color: var(--warn); border-radius: 9px; padding: 8px 11px; font-size: .87rem; margin: 5px 0; }
.miss { background: var(--bg2); border-radius: 9px; padding: 8px 11px; font-size: .87rem; margin: 5px 0; }
.q-menu { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 11px; }
.q-menu .btn { min-height: 40px; padding: 0 13px; font-size: .875rem; }

.cmp-bar { margin-top: 16px; }
.cmp {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding: 16px 15px; margin-top: 14px;
}
.cmp h3 { margin: 0 0 10px; font-size: 1.1rem; }
.verdict { background: var(--ok-bg); border-radius: 11px; padding: 12px 14px; margin-top: 13px; }
.best { color: var(--ok); font-weight: 700; }

/* ------------------------------------------------------------- table */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 380px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); }
.tbl th { background: var(--bg2); font-weight: 700; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: none; }

/* ---------------------------------------------------------- answers */
.acc {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  margin-bottom: 11px; overflow: hidden;
}
.acc summary {
  cursor: pointer; padding: 14px 15px;
  font-family: 'Rubik', sans-serif; font-weight: 500; font-size: .98rem;
  list-style: none;
}
.acc summary::-webkit-details-marker { display: none; }
.acc summary::before { content: '＋'; color: var(--accent); font-weight: 700; margin-inline-end: 8px; }
.acc[open] summary::before { content: '−'; }
.acc-body { padding: 0 15px 15px; font-size: .94rem; }
.acc-body p { margin: 0 0 10px; }
.acc-body ul { margin: 0 0 10px; padding-inline-start: 20px; }
.acc-body li { margin-bottom: 5px; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; }
.tip  { background: var(--gold-bg); color: var(--gold); border-radius: 10px; padding: 10px 12px; }

/* --------------------------------------------------------- timeline */
.tl { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--line); }
.tl li { position: relative; padding: 0 20px 20px; }
.tl li::before {
  content: ''; position: absolute;
  inset-inline-start: -7px; top: 7px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
}
.tl-when { font-family: 'Rubik', sans-serif; font-weight: 600; color: var(--accent); font-size: .92rem; }
.tl-what { font-size: .94rem; }
.tl.day li { padding-bottom: 13px; }

/* ------------------------------------------------------------- card */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding: 16px 15px; margin-bottom: 13px;
}
.card h3 { margin: 0 0 7px; font-size: 1.02rem; }
.card .inp { margin-top: 10px; }
.key-state { font-size: .88rem; margin: 8px 0; }
.key-on  { color: var(--ok); font-weight: 600; }
.key-off { color: var(--ink2); }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed; z-index: 60;
  inset-inline: 14px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 460px; margin: 0 auto;
  background: #17202c; color: #fff;
  border-radius: 13px; padding: 12px 15px;
  box-shadow: 0 8px 28px rgba(0,0,0,.3);
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  font-size: .92rem;
}
.toast-btn {
  flex: none; background: none; border: none; cursor: pointer;
  color: #f3c268; font: inherit; font-weight: 700;
  min-height: 34px; padding: 0 4px;
}
.foot { text-align: center; color: var(--ink2); font-size: .76rem; padding: 8px 14px 26px; }

@media (min-width: 720px) {
  .count-num { font-size: 3.6rem; }
  .sec-h { font-size: 1.32rem; }
}
