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

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --secondary: #86868b;
  --border: rgba(0, 0, 0, 0.06);
  --hairline: rgba(0, 0, 0, 0.08);
  --accent: #007aff;
  --track-height: 672px;
  --time-axis-width: 4.5rem;
  --col-gap: 0.75rem;
  --column-scale: 0.9;
  --column-count: 3;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  --child1-name: #8b2e4a;
  --child2-name: #1a4d8c;
  --child3-name: #1a6b3a;
  --child1: #f5a3b8;
  --child2: #7eb8f0;
  --child3: #7ece9e;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.47;
}

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.header {
  margin-bottom: 1.5rem;
}

.title {
  margin: 0 0 1.25rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: rgba(118, 118, 128, 0.12);
  border-radius: 9px;
  gap: 2px;
}

.segmented__btn {
  padding: 0.4rem 0.95rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}

.segmented__btn:hover {
  color: var(--text);
}

.segmented__btn.is-active {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0.5px 0 rgba(0, 0, 0, 0.04);
}

.main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem 1.5rem;
}

.panel__heading {
  margin: 0 0 1rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel__heading.child1 { color: var(--child1-name); }
.panel__heading.child2 { color: var(--child2-name); }
.panel__heading.child3 { color: var(--child3-name); }

/* —— Shared vertical schedule —— */
.schedule {
  user-select: none;
}

.schedule-grid {
  display: grid;
  grid-template-columns: var(--time-axis-width) 1fr;
  column-gap: 0.625rem;
  align-items: end;
}

.schedule-grid--single {
  --column-count: 1;
}

.time-axis {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  height: var(--track-height);
  flex-shrink: 0;
}

.time-axis__label {
  position: absolute;
  right: 0;
  left: 0;
  transform: translateY(-50%);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding-right: 4px;
  pointer-events: none;
}

.schedule-body {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
}

.columns-area {
  position: relative;
  display: flex;
  gap: var(--col-gap);
  align-items: flex-end;
  width: 100%;
  overflow: hidden;
}

.schedule-column {
  flex: 0 0
    calc(
      (100% - (var(--column-count) - 1) * var(--col-gap)) / var(--column-count) *
        var(--column-scale)
    );
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.schedule-column .column {
  width: 100%;
  height: var(--track-height);
  flex-shrink: 0;
}

.hover-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.hover-guide {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 50;
}

.hover-guide__line {
  flex: 1;
  min-width: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.35);
}

.hover-guide__time {
  flex-shrink: 0;
  margin-left: 10px;
  padding: 3px 8px;
  font-size: calc(0.9375rem * 1.5);
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: var(--surface);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  line-height: 1.2;
}

.schedule-body.is-hovering .hover-guide {
  opacity: 1;
}

.hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--hairline);
  pointer-events: none;
}

.column {
  position: relative;
  height: 100%;
  background: rgba(120, 120, 128, 0.06);
  border-radius: 10px;
  overflow: hidden;
}

.column__label {
  display: block;
  width: 100%;
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  background: none;
  color: var(--text);
}

.column__label:hover {
  text-decoration: underline;
}

.column__label.child1 { color: var(--child1-name); }
.column__label.child2 { color: var(--child2-name); }
.column__label.child3 { color: var(--child3-name); }

.column__track {
  position: absolute;
  inset: 0;
}

.bar {
  position: absolute;
  left: 6px;
  right: 6px;
  min-height: 4px;
  border: none;
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s, box-shadow 0.15s;
  z-index: 1;
}

.bar:hover {
  filter: brightness(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  z-index: 4;
}

.bar.child1 {
  background: var(--child1);
  box-shadow: inset 0 0 0 1px rgba(139, 46, 74, 0.12);
}

.bar.child2 {
  background: var(--child2);
  box-shadow: inset 0 0 0 1px rgba(26, 77, 140, 0.12);
}

.bar.child3 {
  background: var(--child3);
  box-shadow: inset 0 0 0 1px rgba(26, 107, 58, 0.12);
}

.bar__label {
  position: absolute;
  top: 4px;
  left: 8px;
  right: 8px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(29, 29, 31, 0.82);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.bar.child1 .bar__label { color: var(--child1-name); }
.bar.child2 .bar__label { color: var(--child2-name); }
.bar.child3 .bar__label { color: var(--child3-name); }

.column__track--detail .bar {
  left: 8px;
  right: 8px;
  border-radius: 8px;
}

/* —— Login, topbar, calendar —— */
.login {
  max-width: 400px;
  margin: 4rem auto 0;
}

.login__desc {
  margin: 0 0 1.5rem;
  color: var(--secondary);
  font-size: 0.95rem;
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login__error {
  margin: 0;
  color: #d70015;
  font-size: 0.875rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.topbar__back {
  border: none;
  background: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--accent);
  padding: 0.25rem 0.5rem;
}

.topbar__spacer {
  width: 2rem;
}

.topbar__title {
  flex: 1;
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar__user {
  font-size: 0.8125rem;
  color: var(--secondary);
}

.btn {
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 0.9rem;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--ghost {
  background: rgba(118, 118, 128, 0.12);
  color: var(--text);
}

.btn--danger {
  background: #ff3b30;
  color: #fff;
}

.btn--block {
  width: 100%;
  padding: 0.75rem;
}

.btn--sm {
  font-size: 0.75rem;
  padding: 0.35rem 0.6rem;
}

.calendar-nav {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.calendar__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
  font-size: 0.75rem;
  color: var(--secondary);
  text-align: center;
}

.calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar__cell {
  min-height: 4.5rem;
}

.calendar__day {
  width: 100%;
  height: 100%;
  min-height: 4.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-family: inherit;
}

.calendar__day:hover {
  border-color: var(--accent);
}

.calendar__day.is-today {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.calendar__num {
  font-size: 0.9rem;
  font-weight: 600;
}

.calendar__dots {
  display: flex;
  gap: 3px;
  margin-top: auto;
  flex-wrap: wrap;
}

.calendar__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.calendar__dot.child1 { background: var(--child1); }
.calendar__dot.child2 { background: var(--child2); }
.calendar__dot.child3 { background: var(--child3); }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field__label {
  font-size: 0.8125rem;
  color: var(--secondary);
  font-weight: 500;
}

.field input,
.field select {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}

.dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 400px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog__form {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.dialog__title {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.day-schedule__names,
.day-schedule__actions {
  display: flex;
  gap: var(--col-gap);
  margin-left: calc(var(--time-axis-width) + 0.625rem);
}

.tracks-area {
  display: flex;
  gap: var(--col-gap);
}

.day-schedule__names {
  margin-bottom: 0.5rem;
}

.day-schedule__actions {
  margin-top: 0.5rem;
}

.name-slot,
.action-slot,
.tracks-area .schedule-column {
  flex: 0 0
    calc(
      (100% - (var(--column-count) - 1) * var(--col-gap)) / var(--column-count) *
        var(--column-scale)
    );
  min-width: 0;
}

.tracks-area {
  position: relative;
  height: var(--track-height);
}

.tracks-area .schedule-column .column {
  width: 100%;
  height: var(--track-height);
}

.action-slot .add-btn {
  width: 100%;
}

/* —— Detail event list —— */
.event-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.event-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

.event-item:last-child {
  border-bottom: none;
}

.event-item__time {
  flex-shrink: 0;
  width: 6.5rem;
  font-size: 0.8125rem;
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
}

.event-item__title {
  font-weight: 500;
  letter-spacing: -0.01em;
}

@media (max-width: 640px) {
  .app {
    padding: 1.25rem 1rem 2rem;
  }

  .title {
    font-size: 1.5rem;
  }

  .segmented {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
  }

  .segmented__btn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.45rem 0.5rem;
    font-size: 0.75rem;
  }

  .columns-area {
    gap: 0.4rem;
  }

  .column__label {
    font-size: 1.05rem;
    margin-bottom: 0.4rem;
  }

  .panel__heading {
    font-size: 1.5rem;
  }

  .bar__label {
    display: none;
  }

  :root {
    --time-axis-width: 3.75rem;
  }

  .time-axis__label {
    font-size: 0.8125rem;
  }

  .hover-guide__time {
    font-size: calc(0.8125rem * 1.5);
  }
}
