:root {
  --color-primary: #7367f0;
  --color-primary-dark: #7c4ddb;
  --color-bg: #f6f5fb;
  --color-surface: #ffffff;
  --color-text: #2b2b3c;
  --color-text-muted: #6b6b80;
  --color-border: #e6e4f5;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  /* 100% (וגם 100vh הישן) עוקב בזמן אמת אחרי הופעה/היעלמות של סרגל
     הכתובת בדפדפן מובייל - אם זה קורה תוך כדי גלילה, גובה כל .reel
     (שנגזר מהגובה הזה דרך flexbox) משתנה אחרי שנקודות ה-scroll-snap
     כבר חושבו, וה-viewport נשאר "תקוע" בין שני reels חלקיים. 100svh
     הוא גובה יציב (המינימום האפשרי, כשה-toolbar גלוי במלואו) שלא
     משתנה תוך כדי גלילה, אז אין דה-סינכרון.
  */
  height: 100svh;
  margin: 0;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

.app-header {
  flex: 0 0 auto;
  position: relative;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 20;
}

.app-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
}

.app-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary-dark);
}

.settings-toggle {
  border: none;
  background: var(--color-bg);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.source-tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
  overflow-x: auto;
}

.tab {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.tab.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

.settings-panel {
  position: absolute;
  top: 100%;
  inset-inline: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 8px 20px rgba(43, 43, 60, 0.15);
  padding: 14px 16px 16px;
  z-index: 30;
}

.settings-panel__title {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.speed-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.speed-btn {
  flex: 1 1 auto;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.85rem;
  cursor: pointer;
}

.speed-btn.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

.settings-panel__updated {
  margin: 12px 0 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.reels {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
}

.reels::-webkit-scrollbar {
  display: none;
}

.status-message {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 24px;
  color: var(--color-text-muted);
  scroll-snap-align: start;
}

.reel {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  height: 100%;
  min-height: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 28px 24px calc(28px + env(safe-area-inset-bottom));
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: relative;
  overflow-y: auto;
  touch-action: pan-y;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.reel.is-swiping {
  transition: none;
}

.reel__link {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-decoration: none;
  color: inherit;
}

.reel__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reel__source {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: 999px;
}

.reel__time {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.reel__title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--color-text);
}

.reel__summary {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.reel__hint {
  position: absolute;
  bottom: calc(14px + env(safe-area-inset-bottom));
  inset-inline: 0;
  text-align: center;
  font-size: 1.2rem;
  color: var(--color-border);
  animation: bounce 1.6s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-6px); opacity: 1; }
}

@media (min-width: 700px) {
  .reel__title {
    font-size: 2rem;
  }
}

.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.confirm-dialog[hidden] {
  display: none;
}

.confirm-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 30, 0.55);
  backdrop-filter: blur(2px);
  animation: confirm-backdrop-in 0.18s ease;
}

.confirm-dialog__card {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: var(--color-surface);
  border-radius: 22px;
  padding: 28px 24px 20px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(20, 18, 30, 0.32);
  animation: confirm-card-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes confirm-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes confirm-card-in {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.confirm-dialog__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: #fee2e2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-dialog__icon svg {
  width: 26px;
  height: 26px;
}

.confirm-dialog__title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-text);
}

.confirm-dialog__desc {
  margin: 0 0 22px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.confirm-dialog__actions {
  display: flex;
  gap: 10px;
}

.confirm-dialog__cancel,
.confirm-dialog__confirm {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
}

.confirm-dialog__cancel {
  background: var(--color-bg);
  color: var(--color-text);
}

.confirm-dialog__confirm {
  background: #dc2626;
  color: #fff;
}

.reel__decode {
  align-self: flex-start;
  max-width: 100%;
}

.reel__decode-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--color-primary);
  background: transparent;
  color: var(--color-primary-dark);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.reel__decode-loading {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.reel__decode-answer {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f3f1fd;
  border-inline-start: 3px solid var(--color-primary);
  color: var(--color-text);
  font-size: 0.9rem;
  line-height: 1.55;
  font-weight: 600;
}

.reel__decode-error {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.reel__decode-retry {
  flex: none;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.78rem;
  cursor: pointer;
}
