/* Studio theme: sage paper, spruce green, a touch of marigold, and a serif
   for names and headings. Fonts are loaded in the two HTML pages. */
:root {
  --paper: #ecf1ec;
  --surface: #fffefa;
  --ivory: #fffdf6;

  --ink: #1b2a26;
  --ink-soft: #52625c;
  --line: #d9e0d8;
  --line-strong: #82958b;
  --wash: #e2e9e2;

  --spruce: #1f5d4e;
  --spruce-deep: #143f35;
  --spruce-wash: #e0eee7;
  --spruce-tint: #c9e0d6;
  --spruce-line: #6fa391;

  --marigold: #e3a02f;
  --marigold-wash: #fcf0d6;

  --danger: #b03a2e;

  --font-head: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --radius: 16px;
  --radius-control: 10px;
  --shadow-card: 0 1px 2px rgba(27, 42, 38, 0.05), 0 10px 24px -18px rgba(27, 42, 38, 0.35);

  /* Height of 15 minutes in the week grid. */
  --row: 28px;
}

@media (pointer: coarse) {
  :root {
    --row: 34px;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-body);
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
  color: var(--spruce-deep);
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.3rem);
}

h2 {
  font-size: 1.3rem;
}

h3 {
  font-size: 1.1rem;
}

p {
  margin: 0;
}

a {
  color: var(--spruce);
}

[hidden] {
  display: none !important;
}

/* ---- Layout ---- */

.topbar {
  background: var(--surface);
  color: var(--ink);
}

/* A strip of piano keys under the header. */
.topbar::after {
  content: '';
  display: block;
  height: 20px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line-strong);
  background:
    linear-gradient(
        90deg,
        transparent 0 11px,
        var(--ink) 11px 21px,
        transparent 21px 27px,
        var(--ink) 27px 37px,
        transparent 37px 59px,
        var(--ink) 59px 69px,
        transparent 69px 75px,
        var(--ink) 75px 85px,
        transparent 85px 91px,
        var(--ink) 91px 101px,
        transparent 101px 112px
      )
      0 0 / 112px 11px repeat-x,
    linear-gradient(90deg, transparent 0 15px, var(--line-strong) 15px 16px) 0 0 / 16px 100% repeat-x,
    var(--ivory);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.2;
  color: var(--spruce-deep);
}

.wordmark small {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.6rem;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: var(--spruce-wash);
  color: var(--spruce-deep);
  font: 600 0.7rem/1.4 var(--font-body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  min-width: 0;
}

.topbar-right .who {
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1rem 4rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}

.muted {
  color: var(--ink-soft);
}

.small {
  font-size: 0.875rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.6rem 0.75rem;
  flex-wrap: wrap;
}

.row.spread {
  justify-content: space-between;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---- Controls ---- */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.925rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--spruce-deep);
  white-space: nowrap;
  transition:
    background-color 0.12s,
    border-color 0.12s;
}

.btn:hover {
  border-color: var(--spruce);
  background: var(--spruce-wash);
}

.btn.primary {
  background: var(--spruce);
  border-color: var(--spruce);
  color: var(--ivory);
  box-shadow: 0 2px 0 var(--spruce-deep);
}

.btn.primary:hover {
  background: var(--spruce-deep);
  border-color: var(--spruce-deep);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--ivory);
}

.btn.danger:hover {
  background: #8f2d23;
  border-color: #8f2d23;
}

.btn.small {
  min-height: 2rem;
  padding: 0.2rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

button.link {
  background: none;
  border: 0;
  padding: 0.15rem 0;
  color: var(--spruce);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--spruce-line);
  text-underline-offset: 3px;
  cursor: pointer;
}

button.link:hover {
  text-decoration-color: currentColor;
}

button.link.danger {
  color: var(--danger);
  text-decoration-color: rgba(176, 58, 46, 0.45);
}

:focus-visible {
  outline: 2px solid var(--spruce);
  outline-offset: 2px;
}

label.field {
  display: grid;
  gap: 0.3rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.field .hint,
fieldset .hint {
  font-weight: 400;
  color: var(--ink-soft);
}

input[type='text'],
input[type='email'],
input[type='tel'],
input[type='password'],
input[type='date'],
input[type='time'],
input[type='search'],
select,
textarea {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--ivory);
  font-size: 1rem;
  font-weight: 400;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline-offset: 0;
  border-color: var(--spruce);
}

textarea {
  min-height: 5rem;
  resize: vertical;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

legend {
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.checks label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  background: var(--ivory);
}

.checks label:has(input:checked) {
  border-color: var(--spruce);
  background: var(--spruce-wash);
  color: var(--spruce-deep);
}

.checks input {
  accent-color: var(--spruce);
  margin: 0;
}

.form-error {
  color: var(--danger);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  white-space: nowrap;
}

.badge.open {
  background: var(--marigold-wash);
  border-color: var(--marigold);
  color: #6b4405;
}

.badge.draft {
  border-style: dashed;
}

.badge.closed {
  background: var(--wash);
  border-color: var(--wash);
}

/* A segmented control. */
.tabs {
  display: inline-flex;
  gap: 2px;
  flex-wrap: wrap;
  padding: 3px;
  border-radius: 12px;
  background: var(--wash);
}

.tabs button {
  border: 0;
  background: none;
  padding: 0.4rem 0.9rem;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.925rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.tabs button:hover {
  color: var(--spruce-deep);
}

.tabs button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--spruce-deep);
  box-shadow: 0 1px 3px rgba(27, 42, 38, 0.18);
}

/* ---- Sign in ---- */

.signin {
  max-width: 27rem;
  margin: 8vh auto 0;
}

.signin .card {
  padding: 1.75rem;
}

/* ---- Family view ---- */

.family {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 900px) {
  .family {
    grid-template-columns: 20rem minmax(0, 1fr);
  }
}

.students {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.student {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  background: var(--ivory);
}

.student.active {
  border-color: var(--spruce);
  box-shadow: inset 4px 0 0 var(--spruce);
  background: var(--spruce-wash);
  padding-left: 1rem;
}

.student-main {
  display: grid;
  gap: 0.1rem;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.student-name {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--spruce-deep);
}

.student-slot {
  font-size: 0.9rem;
}

.student-slot.none {
  color: var(--ink-soft);
}

.student-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.35rem;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
}

.inline-form input {
  flex: 1;
  min-width: 0;
}

.notice {
  border-left: 4px solid var(--marigold);
  background: var(--marigold-wash);
  border-radius: 4px 10px 10px 4px;
  padding: 0.7rem 0.9rem;
}

.notice.banner {
  background: var(--spruce-deep);
  color: var(--ivory);
  border-left-color: var(--marigold);
}

.notice.banner .btn {
  background: transparent;
  color: var(--ivory);
  border-color: rgba(255, 253, 246, 0.55);
}

.notice.banner .btn:hover {
  background: rgba(255, 253, 246, 0.14);
  border-color: var(--ivory);
}

.notice.banner :focus-visible {
  outline-color: var(--marigold);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend i {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 4px;
  display: inline-block;
}

.legend .k-mine {
  background: var(--spruce);
}

.legend .k-taken {
  background: #d3dbd4;
}

.legend .k-open {
  background: var(--spruce-wash);
  border: 1px dashed var(--spruce-line);
}

/* ---- Week grid ---- */

.week {
  display: grid;
  grid-template-columns: 2.9rem repeat(var(--days), minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.week-head {
  padding: 0.6rem 0.2rem;
  text-align: center;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1rem;
  color: var(--spruce-deep);
  background: var(--ivory);
  border-bottom: 1px solid var(--line-strong);
  border-left: 1px solid var(--line);
}

.week-head.corner {
  border-left: 0;
}

/* Short labels for narrow columns. */
.week span.abbr {
  display: none;
}

@media (max-width: 640px) {
  .week span.full {
    display: none;
  }
  .week span.abbr {
    display: inline;
  }
}

.week-times,
.week-col {
  position: relative;
  height: calc(var(--rows) * var(--row));
}

.week-col {
  border-left: 1px solid var(--line);
}

.week-time {
  position: absolute;
  right: 0.35rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1;
  margin-top: 0.3rem;
  white-space: nowrap;
}

.week-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--line);
  pointer-events: none;
}

.lesson,
.slot {
  position: absolute;
  left: 3px;
  right: 3px;
  top: calc(var(--at) * var(--row) + 1px);
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.75rem;
  line-height: 1.25;
  text-align: left;
}

.lesson {
  height: calc(2 * var(--row) - 2px);
  padding: 0.25rem 0.45rem;
  border: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #dde4de;
  color: var(--ink-soft);
}

.lesson b {
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson.mine {
  background: var(--spruce);
  color: var(--ivory);
  box-shadow: inset 0 -3px 0 var(--marigold);
}

.lesson.full {
  background: var(--spruce-wash);
  color: var(--ink);
  box-shadow: inset 4px 0 0 var(--spruce);
  padding-left: 0.65rem;
}

button.lesson {
  cursor: pointer;
}

button.lesson.full:hover {
  background: var(--spruce-tint);
}

/* The lesson being moved: an outline behind the open start times. */
.lesson.moving {
  background: none;
  color: transparent;
  box-shadow: 0 0 0 2px var(--marigold);
  pointer-events: none;
}

.slot {
  height: calc(var(--row) - 2px);
  overflow: visible;
  padding: 0 0.3rem;
  border: 1px dashed var(--spruce-line);
  background: var(--spruce-wash);
  color: var(--spruce-deep);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

.slot:hover,
.slot:focus-visible {
  background: var(--spruce);
  border-color: var(--spruce);
  border-style: solid;
  color: var(--ivory);
  z-index: 2;
}

/* Shows the full half hour a start time would take. */
.slot:hover::after,
.slot:focus-visible::after {
  content: '';
  position: absolute;
  left: -1px;
  right: -1px;
  top: 100%;
  height: calc(var(--row) + 1px);
  background: rgba(31, 93, 78, 0.3);
  border-radius: 0 0 8px 8px;
  pointer-events: none;
}

/* ---- Teacher view ---- */

.teacher-schedule {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 1000px) {
  .teacher-schedule {
    grid-template-columns: minmax(0, 1fr) 17rem;
  }
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.plain-list > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.plain-list > li:first-child {
  border-top: 0;
}

.details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.4rem 1rem;
  margin: 0;
}

.details dt {
  color: var(--ink-soft);
  font-size: 0.875rem;
}

.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.family-card h3 {
  overflow-wrap: anywhere;
}

/* ---- Dialog and toast ---- */

dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(20, 63, 53, 0.35);
}

dialog::backdrop {
  background: rgba(20, 45, 39, 0.55);
}

.dialog-body {
  padding: 1.4rem;
  display: grid;
  gap: 1rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

#toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 1.25rem;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  pointer-events: none;
  z-index: 100;
  padding: 0 1rem;
}

.toast {
  background: var(--spruce-deep);
  color: var(--ivory);
  padding: 0.65rem 1.1rem;
  border-radius: 12px;
  border-bottom: 3px solid var(--marigold);
  font-size: 0.925rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(20, 63, 53, 0.3);
  max-width: 100%;
}

.toast.error {
  background: var(--danger);
  border-bottom-color: #7a241b;
  color: var(--ivory);
}

@media print {
  .no-print,
  #toasts {
    display: none !important;
  }
  body {
    background: #fff;
  }
  main {
    padding: 0;
    max-width: none;
  }
  .teacher-schedule {
    display: block;
  }
  .card,
  .week {
    box-shadow: none;
  }
  .lesson,
  .lesson.full {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
