.period-page {
  background:
    radial-gradient(circle at 8% 8%, rgba(248, 206, 96, 0.29) 0 150px, transparent 151px),
    radial-gradient(circle at 94% 90%, rgba(221, 164, 159, 0.23) 0 190px, transparent 191px),
    #f7f0e3;
}

.period-section {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  padding-top: 120px;
}

.period-heading {
  display: flex;
  max-width: 1180px;
  margin: 0 auto 28px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.period-heading h2 {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-size: clamp(38px, 5vw, 68px);
  line-height: 1.12;
}

.period-heading h2 em {
  color: var(--wine-dark);
  font-style: normal;
}

.period-privacy {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  border: 1.5px dashed rgba(75, 56, 42, 0.27);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.74);
}

.period-privacy > span {
  color: var(--wine);
  font-size: 25px;
}

.period-privacy div {
  display: grid;
  gap: 1px;
}

.period-privacy strong {
  font-size: 10px;
}

.period-privacy small {
  color: var(--muted);
  font-size: 8px;
}

.period-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(300px, 0.74fr);
  align-items: start;
  gap: 22px;
  max-width: 1180px;
  margin: 0 auto;
}

.period-main {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.period-summary,
.period-calendar-card,
.period-log-card,
.period-ai-card {
  border: 2px solid var(--ink);
  border-radius: 26px;
  background: rgba(255, 252, 245, 0.96);
  box-shadow: 6px 6px 0 rgba(75, 56, 42, 0.12);
}

.period-ai-invite {
  position: sticky;
  top: 120px;
  padding: 24px;
  border: 2px solid var(--ink);
  border-radius: 26px;
  background:
    radial-gradient(circle at 95% 5%, rgba(248, 206, 96, 0.55) 0 95px, transparent 96px),
    #fff7e7;
  box-shadow: 6px 6px 0 rgba(75, 56, 42, 0.12);
}

.period-ai-invite .period-ai-orb {
  margin-bottom: 18px;
}

.period-ai-invite h3 {
  margin: 10px 0 8px;
  font-family: var(--serif);
  font-size: 27px;
}

.period-ai-invite > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}

.period-ai-invite > a {
  display: inline-flex;
  min-height: 38px;
  margin-top: 9px;
  padding: 0 15px;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: var(--honey);
  box-shadow: 2px 2px 0 rgba(75, 56, 42, 0.18);
  font-size: 10px;
  font-weight: 800;
}

.period-summary {
  padding: 22px;
}

.period-summary-title,
.period-card-head,
.period-calendar-head,
.period-history-head,
.period-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.period-summary-title > div,
.period-card-head > div,
.period-ai-head > div {
  display: grid;
  gap: 2px;
}

.period-summary-title span,
.period-card-head span,
.period-ai-head span {
  color: var(--wine-dark);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.period-summary-title h3,
.period-card-head h3,
.period-ai-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
}

.period-summary-title img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.period-stats {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, minmax(90px, 0.75fr));
  gap: 9px;
  margin-top: 17px;
}

.period-stats > div {
  display: grid;
  min-height: 104px;
  padding: 13px;
  border: 1px solid rgba(75, 56, 42, 0.13);
  border-radius: 16px;
  background: #fbf4e7;
  align-content: center;
}

.period-stats > div.is-primary {
  color: #fffaf1;
  background: linear-gradient(135deg, #7c5040, #a06a50);
}

.period-stats span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
}

.period-stats .is-primary span,
.period-stats .is-primary small {
  color: #f4ddce;
}

.period-stats strong {
  margin-top: 3px;
  font-family: var(--serif);
  font-size: clamp(23px, 3vw, 34px);
  line-height: 1.1;
}

.period-stats .is-primary strong {
  font-size: clamp(17px, 2vw, 23px);
}

.period-stats small {
  color: var(--muted);
  font-size: 8px;
}

.period-insight {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  color: #6d5c4e;
  background: #f5e9d8;
  font-size: 10px;
  line-height: 1.65;
}

.period-calendar-card {
  padding: 22px;
}

.period-calendar-head > div {
  display: grid;
  text-align: center;
}

.period-calendar-head strong,
.period-calendar-head span {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 800;
}

.period-calendar-head small {
  color: var(--muted);
  font-size: 8px;
}

.period-calendar-head > button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: #fffaf1;
  cursor: pointer;
  font-size: 23px;
  place-items: center;
}

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

.period-weekdays {
  margin-top: 15px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  text-align: center;
}

.period-calendar {
  gap: 4px;
  margin-top: 6px;
}

.period-day {
  position: relative;
  display: grid;
  min-height: 43px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #5c4e43;
  background: transparent;
  font-size: 11px;
  place-items: center;
}

.period-day.is-empty {
  visibility: hidden;
}

.period-day.is-today {
  border-color: var(--ink);
  font-weight: 800;
}

.period-day.is-recorded {
  color: #fff;
  background: var(--wine-dark);
}

.period-day.is-predicted {
  border: 1.5px dashed var(--wine);
  background: #f8ded8;
}

.period-day.is-fertile:not(.is-recorded):not(.is-predicted) {
  background: #e4f0d9;
}

.period-day.is-period-start::after {
  position: absolute;
  bottom: 3px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.period-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 8px;
}

.period-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.period-legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.period-legend .is-recorded {
  background: var(--wine-dark);
}

.period-legend .is-predicted {
  border: 1px dashed var(--wine);
  background: #f8ded8;
}

.period-legend .is-fertile {
  background: #e4f0d9;
}

.period-log-card {
  padding: 22px;
}

.period-today-button {
  min-height: 32px;
  padding: 0 12px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: var(--honey);
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
}

#periodForm {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
  margin-top: 17px;
}

#periodForm label {
  display: grid;
  min-width: 0;
  gap: 5px;
}

#periodForm label > span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

#periodForm input,
#periodForm select,
#periodForm textarea {
  width: 100%;
  min-height: 41px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  color: var(--ink);
  background: #fffdf8;
  font-family: var(--sans);
  font-size: 16px;
}

#periodForm textarea {
  min-height: 62px;
  resize: vertical;
}

#periodForm input:focus,
#periodForm select:focus,
#periodForm textarea:focus {
  border-color: var(--wine-dark);
}

.period-note-field,
.period-form-actions {
  grid-column: 1 / -1;
}

.period-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.period-form-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 8px;
}

.period-form-actions button {
  min-height: 38px;
  padding: 0 16px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: var(--honey);
  box-shadow: 2px 2px 0 rgba(75, 56, 42, 0.18);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.period-history-head {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1.5px dashed rgba(75, 56, 42, 0.2);
}

.period-history-head strong {
  font-family: var(--serif);
  font-size: 15px;
}

.period-history-head button {
  padding: 0;
  border: 0;
  color: var(--wine-dark);
  background: transparent;
  cursor: pointer;
  font-size: 8px;
  font-weight: 800;
}

.period-history {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.period-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8f0e2;
}

.period-history-item > div {
  display: grid;
  gap: 2px;
}

.period-history-item strong {
  font-size: 11px;
}

.period-history-item span,
.period-history-item small {
  color: var(--muted);
  font-size: 8px;
  line-height: 1.5;
}

.period-history-item button {
  width: 27px;
  height: 27px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--wine-dark);
  background: #fffaf2;
  cursor: pointer;
  font-size: 16px;
}

.period-history-empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed rgba(75, 56, 42, 0.2);
  border-radius: 12px;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.period-ai-card {
  position: sticky;
  top: 120px;
  overflow: hidden;
  padding: 17px;
  color: #fffaf2;
  background:
    radial-gradient(circle at 95% 4%, rgba(248, 206, 96, 0.38) 0 100px, transparent 101px),
    linear-gradient(160deg, #76513f, #51372c);
  border-color: #3e2d24;
}

.period-ai-head {
  justify-content: flex-start;
}

.period-ai-head > i {
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-radius: 50%;
  background: #99dc86;
  box-shadow: 0 0 0 4px rgba(153, 220, 134, 0.12);
}

.period-ai-orb {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--ink);
  background: #f4cd6b;
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 800;
  place-items: center;
}

.period-ai-head span {
  color: #f2b9a3;
}

.period-ai-head h3 {
  color: #fff8ec;
  font-size: 18px;
}

.period-ai-mode {
  margin: 9px 0 0;
  color: #d8c5b8;
  font-size: 8px;
}

.period-ai-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: min(44vh, 390px);
  margin: 13px -4px 11px;
  padding: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.period-ai-message {
  max-width: 88%;
  padding: 9px 11px;
  border-radius: 13px 13px 13px 4px;
  color: #392b23;
  background: #fff8ec;
}

.period-ai-message.is-user {
  align-self: flex-end;
  color: #fff9ef;
  background: #a76e51;
  border-radius: 13px 13px 4px 13px;
}

.period-ai-message > span {
  display: block;
  margin-bottom: 3px;
  color: #9a765f;
  font-size: 7px;
  font-weight: 800;
}

.period-ai-message.is-user > span {
  color: #f0d9cb;
}

.period-ai-message p {
  margin: 0;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.period-ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.period-ai-suggestions button {
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(255, 245, 231, 0.24);
  border-radius: 999px;
  color: #f7eadf;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 8px;
}

.period-ai-form {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: 9px;
  padding: 5px;
  border-radius: 14px;
  background: #fffaf0;
}

.period-ai-form textarea {
  flex: 1;
  min-height: 34px;
  max-height: 92px;
  padding: 7px 8px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.35;
  resize: none;
}

.period-ai-form button {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: var(--wine-dark);
  cursor: pointer;
  font-size: 17px;
  place-items: center;
}

.period-ai-disclaimer {
  margin: 9px 0 0;
  color: #d8c5b8;
  font-size: 7px;
  line-height: 1.55;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .period-layout {
    grid-template-columns: 1fr;
  }

  .period-ai-card {
    position: static;
  }

  .period-ai-invite {
    position: static;
  }

  .period-ai-messages {
    height: 330px;
  }
}

@media (max-width: 640px) {
  .period-section {
    padding: 96px 12px 48px;
  }

  .period-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .period-heading h2 {
    font-size: 38px;
  }

  .period-privacy {
    width: 100%;
  }

  .period-layout,
  .period-main {
    gap: 14px;
  }

  .period-summary,
  .period-calendar-card,
  .period-log-card,
  .period-ai-card {
    padding: 16px;
    border-radius: 21px;
    box-shadow: 4px 4px 0 rgba(75, 56, 42, 0.1);
  }

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

  .period-stats > div {
    min-height: 88px;
  }

  .period-day {
    min-height: 39px;
  }

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

  #periodForm label:nth-child(3),
  #periodForm label:nth-child(4) {
    grid-column: span 1;
  }

  .period-form-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .period-form-actions button {
    width: 100%;
  }

  .period-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .period-today-button {
    width: 100%;
  }
}

.period-reminder-settings {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 13px;
  border: 1px dashed rgba(104, 70, 50, 0.24);
  border-radius: 15px;
  background: rgba(255, 250, 238, 0.82);
}

.period-reminder-settings > div {
  display: grid;
  gap: 2px;
}

.period-reminder-settings strong {
  color: var(--wine-dark);
  font-size: 12px;
}

.period-reminder-settings small,
.period-reminder-settings p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.55;
}

.period-reminder-settings label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
}

.period-reminder-settings select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(87, 59, 42, 0.18);
  border-radius: 8px;
  color: var(--ink);
  background: #fffaf0;
  font-size: 10px;
}

.period-reminder-settings > button {
  width: fit-content;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: var(--honey-light);
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
}

.period-reminder-settings > button.is-enabled {
  background: var(--honey);
}

.period-advice-card {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid rgba(87, 59, 42, 0.12);
  border-radius: 15px;
  background: #fffaf0;
}

.period-advice-card[hidden] {
  display: none;
}

.period-advice-card > strong {
  color: var(--wine-dark);
  font-size: 12px;
}

.period-advice-card ul {
  margin: 8px 0;
  padding-left: 17px;
  color: var(--ink);
  font-size: 10px;
  line-height: 1.65;
}

.period-advice-card small {
  color: var(--muted);
  font-size: 8px;
  line-height: 1.5;
}
