/* Base: reset, type, cards, buttons, form controls, states, modal, toast, loader. */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--ink); font: 400 1rem/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 700; line-height: 1.15; letter-spacing: 0; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sr-only:focus { position: fixed; top: 8px; inset-inline-start: 8px; width: auto; height: auto; clip: auto; padding: .6rem 1rem; background: var(--surface); border-radius: 10px; z-index: 100; }

.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--tap); padding: 0 1.5rem; border: 0; border-radius: var(--r-pill); font-weight: 600; transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 16px -6px rgba(58, 53, 232, .6); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 22px -6px rgba(58, 53, 232, .75); }
.btn-ghost { background: var(--surface); color: var(--blue-d); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); border: 0; border-radius: var(--r-pill); background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); transition: background-color .15s ease; }
.icon-btn:hover { background: var(--surface-2); }

/* Segmented choice (shift: morning / night / both) */
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); max-width: 100%; }
.seg-btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; flex: 1 1 auto; min-height: 46px; padding: 0 1.05rem; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2); font-weight: 500; white-space: nowrap; transition: background-color .15s ease, color .15s ease; }
.seg-btn:hover:not(:disabled) { color: var(--ink); }
.seg-btn[aria-pressed="true"] { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 4px 12px -4px rgba(58, 53, 232, .55); }
.seg-btn:disabled { opacity: .45; cursor: default; }
.seg-btn .ic2 { display: inline-flex; gap: 2px; }

/* Filter / choice chips */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: 0 1rem; border: 0; border-radius: var(--r-pill); background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--ink); font-weight: 500; transition: background-color .15s ease; }
.chip:hover { background: var(--surface-2); }
.chip .n { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--blue); color: #fff; box-shadow: none; }
.chip[aria-pressed="true"] .n { color: rgba(255, 255, 255, .8); }
.chip[data-tone="ok"][aria-pressed="true"] { background: var(--ok); }
.chip[data-tone="coral"][aria-pressed="true"] { background: var(--coral); }
.chip[data-tone="sky"][aria-pressed="true"] { background: var(--sky); }
.chip[data-tone="amber"][aria-pressed="true"] { background: var(--amber); }
.chip[data-tone="lilac"][aria-pressed="true"] { background: var(--lilac); }

/* Switch (RTL: thumb starts at the right, moves left when on) */
.switch { display: inline-flex; align-items: center; gap: .65rem; min-height: 44px; padding: 0 .2rem; border: 0; background: none; font-weight: 500; }
.switch .track { position: relative; width: 48px; height: 28px; border-radius: var(--r-pill); background: #c9d0e6; transition: background-color .15s ease; }
.switch .thumb { position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(10, 16, 51, .3); transition: transform .18s ease; }
.switch[aria-checked="true"] .track { background: var(--blue); }
.switch[aria-checked="true"] .thumb { transform: translateX(-20px); }
.switch:disabled { opacity: .5; cursor: default; }

/* Text inputs */
.field { display: grid; gap: .45rem; font-weight: 500; color: var(--ink-2); }
.input, .select { width: 100%; min-height: var(--tap); padding: 0 1rem; border: 0; border-radius: var(--r-ctrl); background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--ink); }
.input::placeholder { color: var(--ink-3); }
.input:focus-visible, .select:focus-visible { outline: 3px solid var(--blue); outline-offset: 1px; }
.select { appearance: none; }
.input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.search { position: relative; }
.search > svg { position: absolute; inset-inline-start: 1rem; top: 50%; margin-top: -10px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-inline-start: 2.9rem; }

.tag { display: inline-flex; align-items: center; min-height: 24px; padding: 0 .65rem; border-radius: var(--r-pill); font-size: .8125rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.tag[data-type="מילואים"] { background: var(--sky-bg); color: var(--sky); }
.tag[data-type="בחיר"] { background: var(--amber-bg); color: var(--amber); }

.save-state { display: inline-flex; align-items: center; min-width: 4.2em; font-size: .875rem; color: var(--ink-2); }
.save-state.saved { color: var(--ok); font-weight: 600; }
.save-state.error { color: var(--coral); font-weight: 600; }

/* Loading, empty, error */
.skeleton { display: grid; }
.sk-row { display: grid; gap: .5rem; padding: 1.1rem 1.25rem; border-top: 1px solid var(--line); }
.sk-line { display: block; height: 14px; border-radius: 7px; background: linear-gradient(90deg, #eceff8 25%, #f8f9fd 50%, #eceff8 75%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
.sk-line.w60 { width: 60%; } .sk-line.w30 { width: 30%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.state { display: grid; justify-items: center; gap: .9rem; padding: 3rem 1.5rem; text-align: center; color: var(--ink-2); }
.state svg { color: var(--amber); }

/* Modal: bottom sheet on phones, side drawer on desktop */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(6, 15, 90, .45); animation: fade .2s ease; }
.modal-panel { width: 100%; max-height: 90vh; max-height: 90dvh; display: flex; flex-direction: column; background: var(--surface); border-radius: 28px 28px 0 0; box-shadow: var(--shadow-lg); animation: rise .24s ease-out; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem .6rem; }
.modal-head h2 { font-size: 1.5rem; }
.modal-body { padding: .5rem 1.25rem 1.5rem; overflow-y: auto; }
.modal-foot { padding: .9rem 1.25rem calc(1rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
@media (min-width: 900px) {
  .modal { align-items: stretch; justify-content: flex-end; padding: 16px; }
  .modal-panel { width: 460px; max-height: none; border-radius: 26px; animation: slide .26s ease-out; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes slide { from { transform: translateX(-40px); opacity: 0; } }

/* Toasts (can carry an undo button) */
#toasts { position: fixed; inset-inline: 0; bottom: calc(104px + env(safe-area-inset-bottom)); z-index: 60; display: grid; justify-items: center; gap: .5rem; pointer-events: none; }
@media (min-width: 720px) { #toasts { bottom: 28px; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 1rem; padding: .7rem 1.3rem; border-radius: var(--r-pill); background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); font-weight: 500; animation: rise .2s ease-out; }
.toast button { border: 0; background: none; color: var(--cyan); font-weight: 700; min-height: 36px; padding: 0 .3rem; }
.toast-error { background: var(--coral); }
.toast.out { opacity: 0; transition: opacity .35s ease; }

/* Full-screen loader: the falcon assembles from its feathers, then hovers */
.loader { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: radial-gradient(900px 640px at 50% 38%, #3342e6 0%, #1522a8 42%, #070e55 100%); opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility .3s; }
.loader.on { opacity: 1; visibility: visible; }
.loader-inner { display: grid; justify-items: center; gap: 1.6rem; }
.loader .bird { width: 150px; height: auto; filter: drop-shadow(0 0 2px rgba(255,255,255,.55)) drop-shadow(0 0 30px rgba(120, 190, 255, .45)); }
.loader-text { font-family: var(--font-display); font-size: 1.4rem; color: #e8edff; }
.bz-s { transform-box: fill-box; transform-origin: center; }
.loader.on .bird { animation: hover 3.2s ease-in-out 1.4s infinite; }
.loader.on .bz-s { opacity: 0; animation: assemble .9s cubic-bezier(.2, .8, .2, 1) forwards; animation-delay: calc(var(--i) * 110ms); }
@keyframes assemble { from { opacity: 0; transform: translate(-70px, 40px) rotate(-14deg) scale(.82); } to { opacity: 1; transform: none; } }
@keyframes hover { 50% { transform: translateY(-9px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
