:root {
  color-scheme: light;
  --ink: #20242a;
  --muted: #5d6875;
  --line: #bfd7ee;
  --paper: #fffdf7;
  --paper-strong: #ffffff;
  --page: #eaf5ff;
  --blue: #2f7fc1;
  --blue-dark: #235d8c;
  --yellow: #f2c64f;
  --green: #5aa66a;
  --red: #d85d68;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--page);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: "Comic Sans MS", "Trebuchet MS", Arial, sans-serif;
  line-height: 1.45;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.34);
}

button,
input,
textarea {
  font: inherit;
}

.login-screen {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(520px, 100%);
  border: 4px solid var(--ink);
  border-radius: 8px;
  padding: clamp(24px, 5vw, 44px);
  background: var(--paper);
  box-shadow: 10px 10px 0 rgba(32, 36, 42, 0.16);
}

.app-shell {
  position: relative;
  z-index: 1;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 42px);
  background: rgba(255, 253, 247, 0.96);
  border-bottom: 4px solid var(--ink);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue-dark);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(42px, 6vw, 72px);
}

h2 {
  margin-bottom: 20px;
  font-size: clamp(30px, 4vw, 46px);
}

.code-line,
.small {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

button {
  min-height: 48px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 0 18px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}

button:hover,
button:focus-visible {
  transform: translate(-1px, -1px);
  outline: none;
}

#saveButton {
  background: var(--green);
  color: white;
}

#resetButton {
  background: white;
}

.layout {
  display: block;
  width: min(900px, calc(100% - 28px));
  margin: 22px auto 56px;
}

.page-toolbar {
  display: grid;
  grid-template-columns: 150px 1fr 150px;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
}

.page-toolbar.bottom {
  margin: 18px 0 0;
}

.page-toolbar span {
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  text-align: center;
  box-shadow: 3px 3px 0 rgba(32, 36, 42, 0.18);
}

.panel {
  display: none;
  min-height: min(920px, calc(100vh - 230px));
  margin-bottom: 0;
  border: 4px solid var(--ink);
  border-radius: 8px;
  padding: clamp(24px, 5vw, 48px);
  background: var(--paper);
  box-shadow: 7px 7px 0 rgba(32, 36, 42, 0.14);
}

.panel.active-page {
  display: block;
}

.cycle {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.cycle span {
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 14px;
  background: #fff3b5;
  font-weight: 800;
  text-align: center;
}

.grid {
  display: grid;
  gap: 18px;
}

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

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

label {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--blue-dark);
  font-size: 19px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 13px 14px;
  background: white;
  color: var(--ink);
  font-weight: 600;
}

textarea {
  min-height: 126px;
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 4px solid rgba(242, 198, 79, 0.65);
}

.dot-row {
  display: grid;
  grid-template-columns: repeat(14, minmax(42px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.dot-row button {
  min-width: 0;
  border-radius: 999px;
  padding: 0;
  background: white;
  aspect-ratio: 1;
  box-shadow: 2px 2px 0 var(--ink);
}

.dot-row button.active {
  background: var(--red);
  color: white;
}

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

.journal-day {
  display: grid;
  gap: 12px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 14px;
  background: white;
}

.journal-day h3 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.journal-day label {
  margin: 0;
}

.image-box {
  display: grid;
  min-height: 190px;
  place-items: center;
  overflow: hidden;
  border: 3px dashed var(--blue);
  border-radius: 8px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    #f8fcff;
  background-size: 18px 18px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.image-box img {
  width: 100%;
  height: 100%;
  max-height: 260px;
  object-fit: contain;
  background: white;
}

.image-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.image-upload {
  display: grid;
  min-height: 48px;
  place-items: center;
  margin: 0;
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}

.image-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-controls button {
  min-height: 48px;
  padding: 0 10px;
  background: white;
  font-size: 16px;
}

fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 20px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 16px;
  background: white;
}

legend {
  padding: 0 8px;
  color: var(--blue-dark);
  font-size: 19px;
  font-weight: 800;
}

.radio {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--ink);
}

.radio input {
  width: 22px;
  height: 22px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .app-header {
    display: block;
  }

  .actions {
    justify-content: flex-start;
    margin-top: 16px;
  }

  .layout {
    width: min(760px, calc(100% - 24px));
  }

  .page-toolbar {
    grid-template-columns: 124px 1fr 124px;
  }

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

  .dot-row {
    grid-template-columns: repeat(7, minmax(42px, 1fr));
  }
}

@media (max-width: 680px) {
  .two,
  .three,
  .journal,
  .cycle {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: white;
  }

  body::before,
  .actions,
  .page-toolbar {
    display: none;
  }

  .app-header,
  .layout {
    display: block;
    position: static;
  }

  .layout {
    width: auto;
    margin: 0;
  }

  .panel {
    display: block;
    min-height: auto;
    margin-bottom: 18px;
    break-inside: avoid;
    box-shadow: none;
  }
}
