:root {
  --green: #22A04B;
  --blue: #1E6FD9;
  --red: #E5484D;
  --bg: #F4F6F8;
  --card: #FFFFFF;
  --text: #111418;
  --muted: #555B63;
  --border: #D5DAE0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; cursor: pointer; border: 0; }
button:active { opacity: 0.8; transform: scale(0.97); }

[hidden] { display: none !important; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}

/* Home */
.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.add-button {
  width: 220px;
  aspect-ratio: 1;
  border-radius: 24px;
  background: var(--green);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.plus { font-size: 72px; font-weight: 300; line-height: 80px; }

.list-button {
  width: 220px;
  padding: 18px 0;
  border-radius: 16px;
  background: var(--blue);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.badge {
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 13px;
  background: #fff;
  color: var(--blue);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hint {
  max-width: 300px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.hint button {
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
}

.topbar h1 { font-size: 22px; margin: 0; }

.back {
  background: none;
  color: var(--blue);
  font-size: 18px;
  padding: 8px 8px 8px 0;
}

/* Form */
.form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 480px;
}

.form > label, .form .label { font-weight: 600; margin-top: 12px; }

/* Subject picker on the Add Assignment screen */
.subjects { display: flex; flex-wrap: wrap; gap: 8px; }

.subject-pick input { position: absolute; opacity: 0; pointer-events: none; }

.subject-pick span {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid var(--pick);
  background: var(--card);
  color: var(--pick);
  font-weight: 700;
  cursor: pointer;
}

.subject-pick input:checked + span { background: var(--pick); color: #fff; }
.subject-pick input:focus-visible + span { outline: 3px solid var(--text); outline-offset: 2px; }

.subject-pick.math { --pick: #D93036; }
.subject-pick.english { --pick: #1E6FD9; }
.subject-pick.history { --pick: #8F6500; }
.subject-pick.science { --pick: #157A3A; }

.subject-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 12px; }
.subject-head .label { margin-top: 0; }

.link { background: none; color: var(--blue); font-weight: 600; padding: 4px 0; }

/* The + button that makes a new subject */
.subject-add {
  min-width: 48px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px dashed var(--muted);
  background: var(--card);
  color: var(--muted);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
}

.form input:not([type="radio"]) {
  font: inherit;
  font-size: 18px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  width: 100%;
  min-height: 52px;
}

.save {
  margin-top: 24px;
  padding: 16px;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.save.small { margin-top: 16px; padding: 12px 20px; font-size: 16px; }

.error { color: var(--red); font-weight: 600; margin: 4px 0 0; }

/* Work list */
.items {
  list-style: none;
  margin: 0;
  padding: 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  position: relative;
  overflow: hidden;
  container-type: inline-size;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  border-left: 6px solid var(--blue);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.card-text { flex: 1; min-width: 0; position: relative; z-index: 1; }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  margin: 0 6px 6px 0;
  color: #fff;
}

/* Red belongs to Math, so overdue gets its own black badge */
.overdue-badge { background: var(--text); }

/* Faded symbols behind each subject card */
.deco {
  position: absolute;
  right: 110px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 0;
  font-size: 44px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

/* Math: red graph paper */
.card.math {
  border-left-color: #D93036;
  background-color: #FFD9D9;
  background-image:
    linear-gradient(rgba(217, 48, 54, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 48, 54, 0.14) 1px, transparent 1px);
  background-size: 16px 16px;
}
.math .tag:not(.overdue-badge), .math .done { background: #D93036; }
.math .card-cal { color: #B3242A; }
.math .deco { color: rgba(217, 48, 54, 0.22); font-family: "Times New Roman", serif; font-style: italic; }

/* English / writing: blue lined notebook paper */
.card.english {
  border-left-color: #1E6FD9;
  background-color: #D9E8FF;
  background-image:
    linear-gradient(90deg, transparent 34px, rgba(30, 111, 217, 0.45) 34px, rgba(30, 111, 217, 0.45) 36px, transparent 36px),
    repeating-linear-gradient(transparent 0 23px, rgba(30, 111, 217, 0.18) 23px 24px);
}
.english .card-text { padding-left: 26px; }
.english .tag:not(.overdue-badge), .english .done { background: #1E6FD9; }
.english .card-name { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 19px; }
.english .card-cal { color: #1659B3; }
.english .deco { color: rgba(30, 111, 217, 0.20); font-family: Georgia, serif; font-size: 60px; }

/* History / social studies: yellow parchment with map lines */
.card.history {
  border-left-color: #B07D00;
  background-color: #FFF0B3;
  background-image:
    radial-gradient(circle at 85% 50%, transparent 0 38px, rgba(176, 125, 0, 0.16) 38px 39px, transparent 39px 56px, rgba(176, 125, 0, 0.12) 56px 57px, transparent 57px),
    repeating-linear-gradient(135deg, transparent 0 18px, rgba(176, 125, 0, 0.08) 18px 19px);
}
.history .tag:not(.overdue-badge), .history .done { background: #8F6500; }
.history .card-name { font-family: Georgia, "Times New Roman", serif; font-variant: small-caps; letter-spacing: 0.02em; }
.history .card-cal { color: #7A5600; }
.history .deco { color: rgba(143, 101, 0, 0.22); font-family: Georgia, serif; letter-spacing: 0.06em; }

/* Science / STEM: green with a molecule dot pattern */
.card.science {
  border-left-color: #157A3A;
  background-color: #D3F2DC;
  background-image:
    radial-gradient(rgba(21, 122, 58, 0.20) 2px, transparent 2.5px),
    radial-gradient(rgba(21, 122, 58, 0.12) 1.5px, transparent 2px);
  background-size: 22px 22px, 22px 22px;
  background-position: 0 0, 11px 11px;
}
.science .tag:not(.overdue-badge), .science .done { background: #157A3A; }
.science .card-name { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 17px; }
.science .card-cal { color: #0F5E2C; }
.science .deco { color: rgba(21, 122, 58, 0.22); }

/* Subjects you make: colors come from --c, --bg and --rgb set in app.js */
.card.custom { border-left-color: var(--c); background-color: var(--bg); }
.custom .tag:not(.overdue-badge), .custom .done { background: var(--c); }
.custom .card-cal { color: var(--c); }
.custom .deco { opacity: 0.25; }

.pat-grid {
  background-image:
    linear-gradient(rgb(var(--rgb) / 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgb(var(--rgb) / 0.14) 1px, transparent 1px);
  background-size: 16px 16px;
}
.pat-lines { background-image: repeating-linear-gradient(transparent 0 23px, rgb(var(--rgb) / 0.20) 23px 24px); }
.pat-dots {
  background-image: radial-gradient(rgb(var(--rgb) / 0.22) 2px, transparent 2.5px);
  background-size: 18px 18px;
}
.pat-stripes { background-image: repeating-linear-gradient(135deg, transparent 0 14px, rgb(var(--rgb) / 0.10) 14px 24px); }

/* On a phone, shrink the faded symbols into the bottom corner */
@container (max-width: 520px) {
  .card .deco { top: auto; bottom: 4px; right: 14px; transform: none; font-size: 22px; }
}

.card-name {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

.card-time { font-size: 14px; color: #3E444B; margin: 0; }
.overdue .card-time { color: var(--text); font-weight: 600; }

.card-cal {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--blue);
  text-decoration: none;
}

.done {
  background: var(--green);
  color: #fff;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 14px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.empty {
  text-align: center;
  padding-top: 25vh;
}

.empty h2 { margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0; }

/* In-app alert when a reminder goes off */
.banner {
  position: fixed;
  left: 16px;
  right: 16px;
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 10;
  background: var(--text);
  color: #fff;
  padding: 14px 16px;
  border-radius: 14px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* New / edit subject sheet */
.sheet {
  width: min(520px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  border: 0;
  border-radius: 20px;
  padding: 8px 20px 20px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.45); }
.sheet h2 { margin: 12px 0 0; font-size: 22px; }
.sheet .items { padding: 0; }
.sheet .preview { margin-top: 12px; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.swatch input:focus-visible + span { outline: 3px solid var(--text); outline-offset: 2px; }

.swatch.icon span {
  width: 44px;
  height: 44px;
  font-size: 24px;
  border-radius: 12px;
  background: var(--card);
  border: 2px solid var(--border);
}
.swatch.icon input:checked + span { border-color: var(--text); background: #E9ECEF; }

.swatch.color span { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--border); }
.swatch.color input:checked + span { box-shadow: 0 0 0 3px var(--text); }

.swatch.pattern span {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  background-color: var(--bg);
  border: 2px solid var(--border);
}
.swatch.pattern input:checked + span { border-color: var(--text); }

.sheet-buttons { display: flex; gap: 8px; margin-top: 16px; align-items: stretch; }
.sheet-buttons .save { flex: 1; margin-top: 0; }
.secondary, .danger { padding: 14px 16px; border-radius: 14px; font-weight: 700; font-size: 16px; }
.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.danger { background: var(--card); color: var(--red); border: 1px solid var(--red); }
