:root {
  color-scheme: light;
  --ink: #142724;
  --muted: #66746f;
  --paper: #f6f2e9;
  --surface: #fffdf8;
  --line: #ddd8ca;
  --forest: #123c36;
  --forest-2: #1e554d;
  --teal: #2d7165;
  --gold: #c9973f;
  --gold-soft: #f3e4c5;
  --rose: #a85e55;
  --blue: #4e6e80;
  --shadow: 0 18px 50px rgb(26 46 42 / 10%);
  --radius: 18px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 10% 0%, rgb(201 151 63 / 10%), transparent 24rem),
    var(--paper);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
summary,
select,
input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: white;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0.8rem clamp(1rem, 4vw, 3.5rem);
  border-bottom: 1px solid rgb(255 255 255 / 10%);
  background: rgb(16 47 43 / 96%);
  color: white;
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  gap: 0.75rem;
  align-items: center;
  color: white;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 50%;
  color: #edc775;
  font-size: 1.45rem;
}

.brand-logo {
  width: 64px;
  height: 42px;
  border-radius: 7px;
  object-fit: cover;
  object-position: left center;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
}

.brand small {
  margin-top: 0.05rem;
  color: rgb(255 255 255 / 68%);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
}

.topbar nav a {
  color: rgb(255 255 255 / 78%);
  text-decoration: none;
}

.topbar nav a:hover {
  color: white;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.control-panel {
  padding: 2rem clamp(1.25rem, 3vw, 2.25rem) 3rem;
  border-right: 1px solid var(--line);
  background: rgb(255 253 248 / 84%);
}

.panel-heading {
  margin-bottom: 1.7rem;
}

.eyebrow {
  color: var(--teal);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.eyebrow.light {
  color: #e3bd6a;
}

.panel-heading h1 {
  max-width: 18rem;
  margin: 0.55rem 0 0.65rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  font-weight: 500;
  line-height: 1.05;
}

.panel-heading p,
.hero-description {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
.field > span {
  display: block;
  margin-bottom: 0.45rem;
  color: #42534f;
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eee9dd;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 9px;
  color: #6d756f;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--forest);
  box-shadow: 0 2px 9px rgb(19 56 51 / 10%);
}

.segmented input:focus-visible + span {
  outline: 3px solid rgb(45 113 101 / 25%);
}

.field-row {
  display: grid;
  gap: 0.8rem;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field,
.segmented-fieldset,
.options-fieldset,
.advanced-location {
  display: block;
  margin-bottom: 1rem;
}

.field input,
.field select,
.compact-fields input,
.control-panel select {
  width: 100%;
  min-height: 42px;
  padding: 0.62rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.85rem;
}

.field input:focus,
.field select:focus,
.compact-fields input:focus,
.control-panel select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgb(45 113 101 / 12%);
}

.field small {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.advanced-location {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(246 242 233 / 60%);
}

.advanced-location summary {
  padding: 0.8rem;
  color: var(--forest-2);
  font-size: 0.78rem;
  font-weight: 750;
}

.advanced-location[open] summary {
  border-bottom: 1px solid var(--line);
}

.compact-fields {
  padding: 0.9rem 0.9rem 0;
}

.compact-fields .field {
  margin-bottom: 0.25rem;
}

.check-row {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  padding: 0.25rem 0.9rem 0.9rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.options-fieldset {
  margin-top: 1.25rem;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.toggle-grid label {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  min-height: 36px;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: #53615e;
  font-size: 0.72rem;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--teal);
}

.primary-actions {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 0.65rem;
  margin-top: 1.3rem;
}

.button {
  display: inline-flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.7rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  transition: 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button.primary {
  background: var(--forest);
  color: white;
  box-shadow: 0 8px 22px rgb(18 60 54 / 20%);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--forest);
}

.button.full {
  width: 100%;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 750;
}

.account-card {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.account-card > summary {
  padding: 1rem 0;
  list-style: none;
}

.account-card > summary::-webkit-details-marker {
  display: none;
}

.account-card > summary strong,
.account-card > summary small {
  display: block;
}

.account-card > summary strong {
  color: var(--forest);
  font-size: 0.82rem;
}

.account-card > summary small {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.account-body {
  padding: 0.2rem 0 0.75rem;
}

.auth-mode {
  margin-bottom: 1rem;
}

.signed-user {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

#logout-button {
  display: block;
  margin: 0.9rem auto 0;
}

.calendar-stage {
  min-width: 0;
  padding: clamp(1.25rem, 3vw, 2.75rem);
}

.stage-hero {
  position: relative;
  display: flex;
  overflow: hidden;
  align-items: center;
  justify-content: space-between;
  min-height: 190px;
  padding: clamp(1.5rem, 4vw, 3rem);
  border-radius: 24px;
  background:
    linear-gradient(115deg, rgb(11 43 39 / 98%), rgb(31 81 72 / 92%)),
    var(--forest);
  color: white;
  box-shadow: var(--shadow);
}

.stage-hero::after {
  position: absolute;
  right: -3rem;
  bottom: -8rem;
  width: 22rem;
  height: 22rem;
  border: 1px solid rgb(224 188 106 / 22%);
  border-radius: 50%;
  box-shadow:
    0 0 0 3rem rgb(224 188 106 / 5%),
    0 0 0 7rem rgb(224 188 106 / 3%);
  content: "";
}

.stage-hero h2 {
  position: relative;
  z-index: 1;
  max-width: 38rem;
  margin: 0.65rem 0 0.55rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 3.25rem);
  font-weight: 400;
  line-height: 1.05;
}

.stage-hero p {
  position: relative;
  z-index: 1;
  max-width: 40rem;
  margin: 0;
  color: rgb(255 255 255 / 72%);
  font-size: 0.9rem;
}

.hebrew-seal {
  position: relative;
  z-index: 1;
  display: grid;
  flex: 0 0 116px;
  width: 116px;
  height: 116px;
  margin-left: 1.5rem;
  place-content: center;
  border: 1px solid rgb(226 190 106 / 48%);
  border-radius: 50%;
  background: rgb(255 255 255 / 5%);
  text-align: center;
}

.hebrew-seal span {
  color: #e3bd6a;
  font-family: Georgia, serif;
  font-size: 1rem;
}

.hebrew-seal strong {
  max-width: 80px;
  margin-top: 0.2rem;
  color: white;
  font-family: Georgia, serif;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.25;
}

.summary-strip {
  display: grid;
  grid-template-columns: 1.1fr 0.75fr 0.75fr 1.25fr;
  gap: 1px;
  overflow: hidden;
  margin: 1.2rem 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--line);
}

.summary-strip article {
  min-width: 0;
  padding: 0.9rem 1rem;
  background: var(--surface);
}

.summary-strip span,
.summary-strip strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-strip span {
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.summary-strip strong {
  color: var(--forest);
  font-family: Georgia, serif;
  font-size: 1rem;
  font-weight: 500;
}

.calendar-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 35px rgb(26 46 42 / 6%);
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.calendar-toolbar span {
  color: var(--teal);
  font-family: Georgia, serif;
  font-size: 0.78rem;
}

.calendar-toolbar h3 {
  margin: 0.2rem 0 0;
  font-family: Georgia, serif;
  font-size: 1.35rem;
  font-weight: 500;
  text-transform: capitalize;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--forest);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  border-bottom: 1px solid var(--line);
  background: #f8f5ed;
}

.weekday-row span {
  padding: 0.65rem 0.35rem;
  color: var(--muted);
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-align: center;
  text-transform: uppercase;
}

.calendar-grid {
  background: var(--line);
  gap: 1px;
}

.day-cell {
  position: relative;
  min-width: 0;
  min-height: 128px;
  padding: 0.55rem;
  border: 0;
  outline-offset: -3px;
  background: var(--surface);
  color: inherit;
  text-align: left;
}

.day-cell:hover {
  background: #fbf7ee;
}

.day-cell.selected {
  background: #f5eddd;
  box-shadow: inset 0 0 0 2px var(--gold);
}

.day-cell.shabbat {
  background: #f5f8f6;
}

.day-cell.empty {
  background: #f1eee6;
}

.day-number-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.day-number {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 800;
}

.day-cell.today .day-number {
  background: var(--forest);
  color: white;
}

.hebrew-day {
  overflow: hidden;
  max-width: 66%;
  color: var(--teal);
  font-family: Georgia, serif;
  font-size: 0.67rem;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-events {
  display: grid;
  gap: 0.28rem;
}

.event-chip {
  overflow: hidden;
  padding: 0.25rem 0.35rem;
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  background: var(--gold-soft);
  color: #624c24;
  font-size: 0.61rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-chip.parashat {
  border-color: var(--teal);
  background: #e2efeb;
  color: #285c53;
}

.event-chip.candles,
.event-chip.havdalah {
  border-color: var(--rose);
  background: #f4e7e4;
  color: #7e4943;
}

.event-chip.roshchodesh,
.event-chip.omer {
  border-color: var(--blue);
  background: #e8eef1;
  color: #465f6c;
}

.more-events {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 700;
}

.agenda-section {
  margin-top: 2rem;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.section-heading h3 {
  margin: 0.25rem 0 0;
  font-family: Georgia, serif;
  font-size: 1.5rem;
  font-weight: 500;
}

.agenda-list {
  display: grid;
  gap: 0.65rem;
}

.agenda-item {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.agenda-date {
  padding-right: 0.8rem;
  border-right: 1px solid var(--line);
  text-align: center;
}

.agenda-date strong,
.agenda-date span {
  display: block;
}

.agenda-date strong {
  color: var(--forest);
  font-family: Georgia, serif;
  font-size: 1.35rem;
  font-weight: 500;
}

.agenda-date span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
}

.agenda-copy {
  min-width: 0;
}

.agenda-copy strong,
.agenda-copy small {
  display: block;
}

.agenda-copy strong {
  overflow: hidden;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agenda-copy small {
  margin-top: 0.25rem;
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 0.72rem;
}

.agenda-time {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
}

.agenda-empty {
  padding: 1.5rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.halachic-note {
  margin: 1.5rem 0 0;
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--gold);
  background: rgb(243 228 197 / 40%);
  color: #685d47;
  font-size: 0.72rem;
  line-height: 1.5;
}

.empty-state,
.loading-state {
  display: grid;
  min-height: 320px;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.empty-state > span {
  color: var(--gold);
  font-size: 2rem;
}

.empty-state h3 {
  margin: 0.6rem 0 0.3rem;
  color: var(--forest);
  font-family: Georgia, serif;
  font-size: 1.35rem;
  font-weight: 500;
}

.empty-state p,
.loading-state p {
  max-width: 26rem;
  margin: 0;
  font-size: 0.84rem;
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 0.8rem;
  border: 3px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 1rem;
  bottom: 1rem;
  max-width: min(380px, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: var(--forest);
  color: white;
  box-shadow: var(--shadow);
  font-size: 0.8rem;
}

.toast.error {
  background: #853d38;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .day-cell {
    min-height: 112px;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .topbar {
    position: static;
  }

  .topbar nav a:first-child {
    display: none;
  }

  .workspace {
    display: block;
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .panel-heading h1 {
    max-width: none;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 64px;
    padding: 0.7rem 1rem;
  }

  .topbar nav {
    gap: 0.75rem;
  }

  .calendar-stage {
    padding: 1rem;
  }

  .stage-hero {
    min-height: 170px;
    padding: 1.5rem;
  }

  .hebrew-seal {
    display: none;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .weekday-row span {
    font-size: 0.54rem;
  }

  .day-cell {
    min-height: 76px;
    padding: 0.35rem;
  }

  .hebrew-day {
    display: none;
  }

  .day-events .event-chip:nth-child(n + 2) {
    display: none;
  }

  .event-chip {
    padding: 0.2rem;
    font-size: 0;
  }

  .event-chip::before {
    font-size: 0.65rem;
    content: "• Evento";
  }

  .agenda-item {
    grid-template-columns: 54px 1fr;
    gap: 0.7rem;
  }

  .agenda-time {
    grid-column: 2;
  }
}

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