
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/*
  Layout hierarchy (structure only; tokens/components unchanged):
  html, body → no document scroll (overflow hidden)
  #app.app-root → sole scroll container + page padding
  .app-shell → flex column; max-width + tool header + .layout
  .layout → 3-col grid: sidebar-left | main-content | sidebar-right
*/

:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-elevated: rgba(255, 255, 255, 0.92);
  --border: #dce4ef;
  --text: #0f1728;
  --muted: #64748b;
  --brand: #0b67ff;
  --brand-soft: rgba(11, 103, 255, 0.14);
  --success: #1f9d62;
  --danger: #e5484d;
  --card-shadow: 0 14px 40px rgba(15, 23, 40, 0.08);
  --card-shadow-hover: 0 20px 55px rgba(15, 23, 40, 0.12);
  --radius: 18px;
  --header-height: 92px;
  --header-height-compact: 68px;
  --transition: 220ms cubic-bezier(.2,.8,.2,1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090d14;
  --surface: rgba(17, 24, 39, 0.68);
  --surface-solid: #0e1728;
  --surface-elevated: rgba(15, 23, 42, 0.9);
  --border: rgba(148, 163, 184, 0.25);
  --text: #e5edf8;
  --muted: #93a3bd;
  --brand: #5a9cff;
  --brand-soft: rgba(90, 156, 255, 0.18);
  --success: #4bd188;
  --danger: #ff636d;
  --card-shadow: 0 18px 50px rgba(2, 7, 17, 0.44);
  --card-shadow-hover: 0 28px 60px rgba(2, 7, 17, 0.55);
}

* { box-sizing: border-box; }

/* ========= Layout root (single scroll + flex stack) ========= */
html, body {
  height: 100%;
  overflow: auto;
}

#app.app-root {
  min-height: 20vh;
}



#app.app-root {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
  -webkit-overflow-scrolling: touch;
  isolation: isolate;
}

/* Host wrappers (embed): one scroll stays on #app; avoid height/overflow fights */
#full-screen #app.app-root,
.full-screen #app.app-root,
.guy #app.app-root,
.boy #app.app-root {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: 100%;
}

.app-shell {
  flex: 0 0 auto;
  width: 100%;
  max-width: 1480px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.app-shell > .tool-header {
  flex-shrink: 0;
}

.app-shell > .layout {
  flex: 0 0 auto;
  min-width: 0;
}

.tool-header {
  position: sticky;
  top: 10px;
  z-index: 100;
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
  transition: all var(--transition);
}

.tool-header.compact {
  border-radius: 16px;
}

.header-inner {
  min-height: var(--header-height);
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: min-height var(--transition), padding var(--transition);
}

.tool-header.compact .header-inner {
  min-height: var(--header-height-compact);
  padding: 10px 18px;
}

.brand-block {
  display: grid;
  gap: 4px;
}

.brand-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.tool-title {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.slider:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 4px;
  top: 3px;
  border-radius: 50%;
  background: var(--brand);
  transition: var(--transition);
}

input:checked + .slider:before {
  transform: translateX(21px);
}

.ghost-btn, .primary-btn, .danger-btn {
  border: 1px solid var(--border);
  border-radius: 12px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  font-family: inherit;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
}

.ghost-btn {
  background: var(--surface-solid);
  color: var(--text);
}

.primary-btn {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
}

.danger-btn {
  background: transparent;
  color: var(--danger);
}

.ghost-btn:hover, .primary-btn:hover, .danger-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 23, 40, 0.14);
}

.layout {
  display: grid;
  width: 100%;
  height: auto;
  min-height: 76vh;
  align-items: start;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(280px, 340px);
  gap: 18px;
  transition: opacity var(--transition), box-shadow var(--transition);
}

.layout > .sidebar-left,
.layout > .main-content,
.layout > .sidebar-right {
  min-width: 0;
  min-height: 0;
}

.layout:fullscreen {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: var(--bg);
  padding: 22px;
  overflow: auto;
}

.panel, .card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--card-shadow);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
}

.panel:hover, .card:hover {
  box-shadow: var(--card-shadow-hover);
}

.sidebar-left, .sidebar-right {
  position: sticky;
  top: 122px;
  align-self: start;
  max-height: min(720px, calc(100dvh - 150px));
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.sidebar-title {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar-subtitle {
  margin: 8px 0 18px;
  font-size: 1.12rem;
  font-weight: 700;
}

.control-divider {
  margin: 18px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.controls-inner {
  display: grid;
  gap: 14px;
}

.input-group {
  display: grid;
  gap: 8px;
}

.input-row-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--muted);
}

.input-icon {
  color: var(--brand);
  margin-right: 8px;
}

input[type="number"], select, input[type="text"] {
  width: 100%;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.sidebar-actions {
  display: grid;
  gap: 8px;
}

.main-content {
  display: grid;
  gap: 16px;
  min-height: 0;
}

.quick-summary {
  font-size: 0.92rem;
  color: var(--muted);
  padding: 14px 16px;
}

.card {
  padding: 18px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

#results {
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.metric-inline {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 6px;
}

.chart-wrap {
  height: 320px;
}

.history-empty {
  color: var(--muted);
  text-align: center;
  padding: 20px 0;
}

.history-card {
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition), opacity var(--transition);
}

.history-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(15, 23, 40, 0.12);
}

.history-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft), 0 12px 28px rgba(15, 23, 40, 0.14);
}

.history-card.fade-in {
  animation: cardIn 320ms ease;
}

.history-card.fade-out {
  animation: cardOut 250ms ease forwards;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cardOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.97); }
}

.history-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.history-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.history-date {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

.history-tags {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-tags span {
  font-size: 0.72rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
}

.history-body {
  margin: 10px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.history-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.mini-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 0;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
}

.mini-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

#compareBar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 120;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(14px);
  display: flex;
  gap: 10px;
  padding: 10px;
}

#compareModal {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: rgba(8, 12, 20, 0.6);
  display: grid;
  place-items: center;
  padding: 20px;
  overscroll-behavior: contain;
}

#compareModal .compare-box {
  pointer-events: auto;
}

.compare-box {
  width: min(720px, 100%);
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  padding: 18px;
  box-shadow: var(--card-shadow-hover);
}

.compare-grid {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.compare-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 130px 1fr 1fr 84px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  font-size: 0.82rem;
}

.compare-row.winner-a { border-color: rgba(31, 157, 98, 0.45); }
.compare-row.winner-b { border-color: rgba(229, 72, 77, 0.45); }
.compare-row.equal { border-color: var(--border); }

.compare-note {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#app.app-root > * {
  flex-shrink: 0;
}

@media (max-width: 1160px) {
  .sidebar-left, .sidebar-right {
    position: relative;
    top: 0;
    max-height: none;
  }
}

@media (max-width: 640px) {
  #app.app-root { padding: 14px; }
  .header-inner { padding: 14px; }
  .header-actions { gap: 6px; }
  #compareBar { width: calc(100% - 24px); }
  .compare-row {
    grid-template-columns: 1fr;
    text-align: left;
  }
}



body, html, #app {
  overflow: visible !important;
  height: auto !important;
}





/* =====================================================
   BASE RESET (FIXED SCROLL SYSTEM)
===================================================== */

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;

  /* חשוב: לא לחסום גלילה בצורה אגרסיבית */
  overflow: hidden;
}

/* =====================================================
   APP ROOT (ONLY SCROLL CONTAINER)
===================================================== */

#app.app-root {
  height: 100%;
  min-height: 0;

  display: flex;
  flex-direction: column;

  /* זה מה שמחזיר לך גלילה */
  overflow-y: auto;
  overflow-x: hidden;

  padding: 24px;

  background: var(--bg);

  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;

  isolation: isolate;
}

/* =====================================================
   SAFETY FIX (IMPORTANT)
   מסיר התנגשות עם כל מה ששמת בסוף קודם
===================================================== */
body, html, #app {
  height: 100%;
  overflow: hidden;
}