:root {
  --paper: #f6f1e7;
  --paper-2: #efe6d6;
  --ink: #243026;
  --muted: #5d6b61;
  --line: #d9cdb6;
  --brick: #c45c26;
  --brick-dark: #9c4318;
  --forest: #3d5c4a;
  --forest-soft: #e4eee7;
  --gold: #e8c872;
  --white: #fffdf8;
  --shadow: 0 10px 30px rgba(36, 48, 38, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, #fff7e8 0%, transparent 55%),
    var(--paper);
  color: var(--ink);
  font-family: "Source Sans 3", system-ui, sans-serif;
}

body {
  padding: max(16px, env(safe-area-inset-top)) 16px 32px;
}

#app {
  width: min(430px, 100%);
  margin: 0 auto;
}

h1, h2, h3 { font-family: Fraunces, Georgia, serif; margin: 0; }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.topbar-title {
  flex: 1;
  min-width: 0;
}

.brand {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.7rem;
  font-weight: 650;
}

.sub {
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.45;
}

.back, .ghost, .primary, .danger, .chip {
  border: 0;
  cursor: pointer;
}

.back, .ghost {
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: var(--shadow);
}

.primary {
  background: var(--brick);
  color: white;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  width: 100%;
}

.primary:disabled { opacity: 0.55; }

.danger {
  background: transparent;
  color: #9b2c2c;
  padding: 8px;
}

.danger-solid {
  background: #9b2c2c;
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  width: 100%;
  cursor: pointer;
}

.card, .panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.stack[hidden] {
  display: none !important;
}

.list-row {
  display: flex;
  gap: 4px;
  align-items: center;
}

.list-row .list-btn,
.list-row .subject-btn {
  flex: 1;
  min-width: 0;
}

.icon-action {
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--forest);
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  font-weight: 600;
}

.icon-action-remove {
  color: #9b2c2c;
  font-size: 1.25rem;
}

.icon-action:hover,
.icon-action:focus-visible {
  background: var(--paper-2);
}

.icon-action[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 5px 8px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 12;
}

.icon-action:hover::after,
.icon-action:focus-visible::after {
  opacity: 1;
}

.list-row .icon-action[data-tip]::after,
.topbar .icon-action[data-tip]::after {
  left: auto;
  right: 0;
  transform: none;
}

.list-btn, .subject-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.list-btn:active, .subject-btn:active { transform: scale(0.99); }

.kicker {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.title { font-weight: 700; font-size: 1.05rem; }

.meta { color: var(--muted); font-size: 0.92rem; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--paper-2);
  color: var(--forest);
}

.badge.weekly { background: #f8ead0; color: var(--brick-dark); }

.form {
  display: grid;
  gap: 10px;
  padding: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92rem;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 12px;
  padding: 12px;
  color: var(--ink);
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row > * { flex: 1; }

.section-head {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 22px 0 10px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.collapse-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  text-align: left;
}

.collapse-toggle .chevron {
  display: inline-block;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 0.15s ease;
}

.collapse-toggle[aria-expanded="true"] .chevron {
  transform: rotate(90deg);
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.done-card {
  opacity: 0.72;
}

.stat {
  padding: 18px;
  text-align: center;
}

.stat .num {
  font-family: Fraunces, Georgia, serif;
  font-size: 3rem;
  line-height: 1;
}

.month-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.month-row:last-child { border-bottom: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 20;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
}

.muted-link {
  background: none;
  border: 0;
  color: var(--forest);
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.week-chip {
  background: var(--forest-soft);
  color: var(--forest);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.add-btn {
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--forest);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(36, 48, 38, 0.38);
}

.modal {
  position: relative;
  width: min(430px, 100%);
  max-height: min(92vh, 720px);
  overflow: auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -12px 40px rgba(36, 48, 38, 0.18);
  padding: 8px 8px 24px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 0;
}

.modal .form {
  padding-bottom: 8px;
}

.modal .warn {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
  padding: 0 16px 8px;
}

@media (min-width: 640px) {
  .modal-root { place-items: center; }
  .modal {
    border-radius: 24px;
    margin: 16px;
  }
}

/* Google Sign-In is the only way in; this is the whole login form. */
.google-btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  text-decoration: none;
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.google-btn:hover { background: var(--paper-2); }

.account {
  margin-top: 20px;
  font-size: 0.9rem;
}
