:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(139, 72, 38, 0.13), transparent 28%),
    radial-gradient(circle at top right, rgba(196, 145, 71, 0.16), transparent 24%),
    linear-gradient(180deg, #f7efdf 0%, #eadcc5 100%);
  color: #3b2417;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

body:has(.image-lightbox) {
  overflow: hidden;
}

a {
  color: #7a4229;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar,
.workspace {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 24px;
  padding: 16px 0 20px;
}

.brand { grid-column: 2; display: flex; align-items: center; }
.brand-logo { width: 220px; height: 96px; object-fit: contain; object-position: center; border-radius: 14px; }

.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: -0.04em;
}

.eyebrow {
  margin: 0 0 6px;
  color: #8b5a35;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  font-weight: 800;
}

.nav {
  grid-column: 3;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(104, 57, 26, 0.14);
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.84);
  box-shadow: 0 10px 24px rgba(70, 39, 21, 0.08);
  justify-content: flex-end;
}

.nav > a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 13px;
  border-radius: 11px;
  color: #6b3824;
  font-weight: 700;
}

.nav > a:hover,
.nav > a:focus-visible { background: #f1e3cc; text-decoration: none; }

.settings-menu { position: relative; }
.settings-menu summary { list-style: none; cursor: pointer; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: #5e2d1d; color: #f9e9c8; font-size: 1.2rem; }
.settings-menu summary::-webkit-details-marker { display: none; }
.settings-popover { position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; padding: 10px; background: #fffaf0; border: 1px solid rgba(88, 45, 25, .16); border-radius: 14px; box-shadow: 0 14px 30px rgba(70, 39, 21, .16); }

.workspace {
  padding-bottom: 40px;
}

.auth-page {
  min-height: 60vh;
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(440px, 100%);
}

.app-shell {
  min-height: 100vh;
}

.panel {
  background: rgba(255, 250, 240, 0.9);
  border: 1px solid rgba(104, 57, 26, 0.14);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(20, 31, 56, 0.08);
  padding: 22px;
  margin-bottom: 18px;
}

.hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
  align-items: start;
}

.hero h2,
.section-head h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.muted,
.message,
.card-subtitle {
  color: #5d6b7f;
}

.stats,
.grid,
.stack {
  display: grid;
  gap: 12px;
}

.stats {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stat {
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, #f7f9fe 0%, #eef3fd 100%);
  border: 1px solid rgba(72, 95, 176, 0.1);
}

.stat strong {
  display: block;
  font-size: 1.8rem;
  margin-bottom: 6px;
}

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

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

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar,
.hero-actions,
.item-head,
.item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar {
  justify-content: flex-end;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #8b4b2f 0%, #612c1d 100%);
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.button-link.secondary {
  background: #f1e3cc;
  color: #6b3824;
}

.button-link:hover {
  text-decoration: none;
}

.create-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.create-button span { font-size: 1.25em; line-height: .8; }
.language-picker { display: grid; gap: 5px; min-width: 180px; padding: 4px; color: #425065; font-size: .85rem; font-weight: 700; }
.settings-popover { display: grid; gap: 10px; }
.app-version { color: #6b3824; font-size: .85rem; font-weight: 700; padding: 4px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.item {
  border: 1px solid rgba(34, 48, 79, 0.09);
  border-radius: 16px;
  background: #fffdf8;
  padding: 14px 16px;
}

.person-card { cursor: pointer; transition: transform .16s ease, box-shadow .16s ease; }
.person-card:hover, .person-card:focus-visible { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(88, 45, 25, .11); outline: none; }
.interaction-index { margin-top: 18px; }
.interaction-index h3 { margin-bottom: 8px; }
.interaction-index-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.interaction-index-actions { display: flex; align-items: center; gap: 10px; }
.history-details { position: relative; }
.history-details summary { cursor: pointer; color: #7a4229; font-size: .86rem; }
.history-entry { margin-top: 8px; padding: 8px; max-width: 340px; background: #f6ead6; border-radius: 8px; font-size: .84rem; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 10px; background: #f8efdf; border-radius: 10px; }
.checkbox-grid label { display: flex; align-items: center; gap: 5px; }
.reaction-person .tag { margin-top: 4px; }
.reaction-person { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reaction-person > a { min-width: 0; }
.wizard { display: grid; gap: 16px; }
.wizard-progress { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid rgba(104, 57, 26, .14); color: #6b3824; }
.interaction-type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.interaction-type-tile { min-height: 72px; background: #fffdf8; color: #6b3824; border: 1px solid rgba(104, 57, 26, .18); }
.interaction-type-tile:hover { background: #f1e3cc; }
.wizard-actions { display: flex; justify-content: space-between; gap: 10px; }
.preview-card { display: grid; gap: 8px; padding: 16px; border-radius: 14px; background: #f8efdf; }
.birthday-actions { align-items: center; }

.item h3,
.item p {
  margin: 0;
}

.item h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.item-head {
  justify-content: space-between;
  align-items: start;
}

.item-actions {
  justify-content: flex-end;
}

.item .meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #60708a;
  font-size: 0.92rem;
}

.pill,
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f2e3ca;
  color: #754126;
  font-size: 0.8rem;
  font-weight: 700;
}

.meta .tag + .tag, .meta .pill + .pill { margin-left: 4px; }

.tag {
  background: #f1e0c4;
  color: #80552b;
}

form {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: #425065;
  font-size: 0.94rem;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #cad4e4;
  border-radius: 12px;
  background: white;
  color: #132033;
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  background: linear-gradient(180deg, #8b4b2f 0%, #612c1d 100%);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: #f1e3cc;
  color: #6b3824;
}

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

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.actions .message {
  margin-left: 4px;
}

.search {
  min-width: 220px;
}

.stack .item {
  display: grid;
  gap: 6px;
}

.interaction-timeline {
  --timeline-rail: 78%;
  position: relative;
  display: grid;
  gap: 0;
  padding: 8px 0;
}

.interaction-timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--timeline-rail);
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #9a6a3f, #dbc39b);
  transform: translateX(-50%);
}

.timeline-entry {
  position: relative;
  display: grid;
  grid-template-columns: var(--timeline-rail) minmax(0, 1fr);
  align-items: start;
  min-height: 112px;
}

.timeline-copy {
  grid-column: 1;
  padding: 0 34px 28px 0;
  text-align: right;
}

.timeline-entry-reaction .timeline-copy {
  grid-column: 2;
  padding-right: 0;
  padding-left: 34px;
  text-align: left;
}

.timeline-entry-reaction .timeline-copy .meta {
  justify-content: flex-start;
}

.timeline-connector {
  position: absolute;
  z-index: 0;
  top: 12px;
  left: var(--timeline-rail);
  width: calc(22% - 22px);
  height: 2px;
  background: #c6a979;
}

.timeline-copy time {
  display: block;
  color: #8b5a35;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.timeline-copy h3 {
  margin: 5px 0 6px;
  color: #132033;
  font-size: 1rem;
}

.timeline-copy p {
  color: #5d6b7f;
  white-space: pre-wrap;
}

.timeline-copy .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.timeline-dot {
  position: relative;
  z-index: 1;
  grid-column: 2;
  justify-self: start;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  margin-left: -9px;
  border: 4px solid white;
  border-radius: 50%;
  background: #8b4b2f;
  box-shadow: 0 0 0 3px #d0b17c, 0 5px 14px rgba(88, 45, 25, 0.25);
}

/* Timeline cards keep the chronological rail while giving every entry a readable surface. */
.timeline-cards {
  gap: 10px;
  padding-left: 52px;
}

.timeline-cards::before {
  left: 18px;
}

.timeline-cards .timeline-entry {
  display: block;
  min-height: 0;
  padding: 14px 16px;
  border: 1px solid rgba(34, 48, 79, 0.09);
  border-radius: 14px;
  background: #fffdf8;
  box-shadow: 0 5px 14px rgba(88, 45, 25, .05);
}

.timeline-cards .timeline-copy,
.timeline-cards .timeline-entry-reaction .timeline-copy {
  display: block;
  grid-column: auto;
  padding: 0;
  text-align: left;
}

.timeline-cards .timeline-copy .meta,
.timeline-cards .timeline-entry-reaction .timeline-copy .meta {
  justify-content: flex-start;
}

.timeline-cards .timeline-dot {
  position: absolute;
  left: -43px;
  top: 17px;
  margin: 0;
}

.timeline-cards .timeline-connector {
  left: -34px;
  width: 32px;
}

.timeline-cards .timeline-image {
  margin-left: 0;
}

.timeline-entry-muted .timeline-copy time {
  color: #8993a3;
}

.timeline-entry-muted .timeline-copy p {
  color: #8993a3;
  font-style: italic;
}

.timeline-entry-muted .timeline-dot {
  background: #aeb6c3;
  box-shadow: 0 0 0 3px #d2d7df, 0 5px 14px rgba(87, 99, 119, 0.18);
}

.timeline-image {
  display: block;
  width: min(220px, 100%);
  max-height: 180px;
  margin: 10px 0 0 auto;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid #d8dfeb;
  cursor: zoom-in;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100dvh;
  padding: 24px;
  overflow: hidden;
  background: rgba(5, 10, 20, .82);
  cursor: zoom-out;
}

.image-lightbox img {
  display: block;
  max-width: min(96vw, 1100px);
  max-height: calc(100dvh - 48px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 80px rgba(0,0,0,.4);
}

.reaction-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.reaction-status-grid h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.reaction-person {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #edf0f5;
}

.reaction-person.reacted {
  color: #24714b;
}

button.small {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.8rem;
}

.icon-button {
  min-width: 40px;
  min-height: 40px;
  padding: 8px 11px;
  font-size: 1.05rem;
  line-height: 1;
}

.muted-button {
  background: #eee5d7;
  color: #765b42;
}

.reaction-actions {
  display: inline-flex;
  gap: 6px;
}

.ignored-people {
  margin-top: 18px;
  border-top: 1px solid #eadfce;
  padding-top: 12px;
}

.ignored-people summary {
  cursor: pointer;
  color: #765b42;
  font-weight: 700;
}

.subevent-card {
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}

.subevent-card:hover,
.subevent-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(88, 45, 25, .11);
  outline: none;
}

.checkbox-label {
  display: flex !important;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px !important;
}

.checkbox-label input {
  width: auto;
  justify-self: start;
}

.image-upload {
  padding: 12px;
  border: 1px dashed #b9c6dd;
  border-radius: 12px;
  background: #f8faff;
}

.image-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.image-upload-actions > span {
  display: grid;
  gap: 5px;
  min-width: min(240px, 100%);
}

.image-upload-actions small {
  color: #425065;
  font-weight: 700;
}

.details {
  display: grid;
  gap: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid > div {
  background: #f7f9fd;
  border: 1px solid rgba(37, 52, 87, 0.08);
  border-radius: 14px;
  padding: 12px;
}

.detail-grid strong {
  display: block;
  margin-bottom: 4px;
}

.spaced {
  margin-top: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 16, 31, 0.48);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: start center;
  padding: 24px;
  z-index: 1000;
}

.modal-window {
  width: min(860px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(37, 52, 87, 0.12);
  border-radius: 24px;
  box-shadow: 0 30px 100px rgba(4, 11, 28, 0.22);
  padding: 20px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.4rem;
}

.modal-body {
  display: grid;
  gap: 16px;
}

.selected-images { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-height: 42px; }
.selected-image { padding: 7px 10px; border-radius: 9px; background: #f1e3cc; color: #6b3824; font-size: .85rem; }
.add-image-button { flex: 0 0 auto; }
.swipe-picker { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 4px 8px; border: 1px solid #cad4e4; border-radius: 12px; background: #fff; touch-action: pan-y; }
.swipe-picker strong { flex: 1; text-align: center; }

.small {
  font-size: 0.9rem;
}

@media (max-width: 960px) {
  .hero,
  .grid.two,
  .grid.three,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    display: flex;
    align-items: center;
    flex-direction: column;
    padding-top: 8px;
  }

  .brand-logo { width: 220px; height: 96px; }

  .nav {
    justify-content: flex-start;
    width: 100%;
    position: relative;
  }

  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .reaction-status-grid {
    grid-template-columns: 1fr;
  }

  .interaction-timeline {
    --timeline-rail: 12px;
    padding-left: 32px;
  }

  .interaction-timeline::before {
    left: var(--timeline-rail);
  }

  .timeline-entry {
    grid-template-columns: 1fr;
  }

  .timeline-copy {
    grid-column: 1;
    padding: 0 0 28px;
    text-align: left;
  }

  .timeline-copy .meta {
    justify-content: flex-start;
  }

  .timeline-dot {
    position: absolute;
    left: -32px;
    top: 0;
  }

  .timeline-entry-reaction .timeline-copy {
    grid-column: 1;
    padding-left: 0;
    text-align: left;
  }

  .timeline-entry-reaction .timeline-copy .meta {
    justify-content: flex-start;
  }

  .timeline-connector {
    left: 12px;
    width: 20px;
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-backdrop { padding: 8px; }
  .modal-window { width: 100%; max-height: calc(100dvh - 16px); padding: 14px; border-radius: 18px; }
  .modal-head { position: sticky; top: -14px; z-index: 1; padding: 4px 0 10px; background: rgba(255,255,255,.98); }
  .settings-popover { right: 0; left: auto; max-width: calc(100vw - 32px); }
}

@media (max-width: 760px) {
  .timeline-cards {
    padding-left: 32px;
  }

  .timeline-cards::before {
    left: 12px;
  }

  .timeline-cards .timeline-dot {
    left: -29px;
    top: 17px;
  }

  .event-interactions-timeline {
    display: grid;
    gap: 10px;
    padding: 0 0 0 32px;
  }

  .event-interactions-timeline::before {
    display: block;
  }

  .event-interactions-timeline .timeline-connector {
    display: none;
  }

  .event-interactions-timeline::before {
    left: 12px;
  }

  .event-interactions-timeline .timeline-entry {
    display: block;
    min-height: 0;
    padding: 13px 14px;
    border: 1px solid rgba(34, 48, 79, 0.09);
    border-radius: 14px;
    background: #fffdf8;
  }

  .event-interactions-timeline .timeline-copy,
  .event-interactions-timeline .timeline-entry-reaction .timeline-copy {
    display: block;
    padding: 0;
    text-align: left;
  }

  .event-interactions-timeline .timeline-copy .meta,
  .event-interactions-timeline .timeline-entry-reaction .timeline-copy .meta {
    justify-content: flex-start;
  }

  .event-interactions-timeline .timeline-dot {
    display: block;
    position: absolute;
    left: -29px;
    top: 17px;
    margin: 0;
  }

  .event-interactions-timeline .timeline-image {
    margin-left: 0;
  }
}
